Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Enumerated Type in assertion ?

 
Thread Tools Search this Thread
Old 01-10-2005, 10:00 AM   #1
Default Enumerated Type in assertion ?


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
  Reply With Quote
Old 01-10-2005, 10:29 AM   #2
Allan Herriman
 
Posts: n/a
Default Re: Enumerated Type in assertion ?
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
  Reply With Quote
Old 01-10-2005, 10:32 AM   #3
Jonathan Bromley
 
Posts: n/a
Default Re: Enumerated Type in assertion ?
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46