![]() |
|
|
|||||||
![]() |
VHDL - Enumerated Type in assertion ? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hello everybody,
last time I have done some simulations with self-test features, there was a problem of reporting a value of one signal. It was an array of ennumerated types: Something like this: --------- type enum_t is (S1, S2, S3, S4, S5, S6, S7); type enum_a is array (1 to 5) of enum_t; constant enum_c : enum_a := (S1, S2, S3, S4, S5); signal enum_s : natural range of 1 to 5; .... enum_s <= 3; assert(FALSE) report "Value is:"&to_string(enum_c(enum_s)) severity note; --------- Function to_string was from std_developers_kit. But this does not work (Modelsim). The enummerated vatues have to be somehow converted to string... Does anybody have a better approach ? Thanks, Marek Ponca Marek Ponca |
|
|
|
|
#2 |
|
Posts: n/a
|
On Mon, 10 Jan 2005 11:00:41 +0100, Marek Ponca <>
wrote: >Function to_string was from std_developers_kit. > > >But this does not work (Modelsim). The enummerated vatues have to be >somehow >converted to string... Does this FAQ entry help? http://www.vhdl.org/comp.lang.vhdl/F...#scalar_string Regards, Allan Allan Herriman |
|
|
|
#3 |
|
Posts: n/a
|
On Mon, 10 Jan 2005 11:00:41 +0100,
Marek Ponca <> wrote: >Something like this: >--------- >type enum_t is (S1, S2, S3, S4, S5, S6, S7); >type enum_a is array (1 to 5) of enum_t; > >constant enum_c : enum_a := (S1, S2, S3, S4, S5); > >signal enum_s : natural range of 1 to 5; >... >enum_s <= 3; > >assert(FALSE) > report "Value is:"&to_string(enum_c(enum_s)) > severity note; >--------- > > The enummerated vatues have to be > somehow converted to string... report "Value is: " & enum_t'image(enum_c(enum(s))) severity note; In VHDL-93 there is a built-in "to_string()" function for *any* scalar type T, called T'image(). There is a much less useful function T'value() which does the reverse - it converts a string to its data value. Unfortunately, there's no way to protect T'value() against errors. If the input string is in any way wrong, i.e. it doesn't exactly match one of the possible results of T'image, then it bombs the simulation with an error. Consequently, T'value() is too fragile for any practical use IMHO. Hey, that's one for VHDL-200x that I hadn't thought of - T'value() with an error trap. By the way... are you *sure* you want a signal of subtype "natural range 1 to 5", rather than a signal of subtype "enum_t range S1 to S5" ? -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK Tel: +44 (0)1425 471223 mail: Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. Jonathan Bromley |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error: expected constructor, destructor or type conversion before '(' token | suse | Software | 0 | 03-09-2009 03:25 AM |
| Eclipse - Axis2 - Java Webservices Error | amanjsingh | Software | 1 | 10-09-2007 09:03 AM |
| Need help on Modelsim VHDL syntax? ASAP:) | kaji | General Help Related Topics | 0 | 03-14-2007 10:43 PM |
| Need help on a Modelsim VHDL Syntax? ASAP:) | kaji | Software | 0 | 03-14-2007 10:43 PM |
| Need Help on a Modelsim VHDL Syntax....ASAP:) | kaji | Hardware | 0 | 03-14-2007 10:41 PM |