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

Reply

VHDL - Modelsim behavior

 
Thread Tools Search this Thread
Old 08-09-2004, 03:52 PM   #1
Default Modelsim behavior


My understanding of 1076-2002 is that the value "integer'high + 1" is out of
range for a variable of type integer. Modelsim PE 5.8b seems to implement
the integer type as a 2's complement 32 bit number so that (integer'high +
1) = integer'low. For most values of an integer variable D32,
integer'succ(D32) = D32 + 1. However, for at least one value,
integer'succ(D32) is out of range while D32+1 is integer'low.

Is Modelsim's behavior incorrect? How do other simulators behave?

Paul Butler

PS I claim that the following code should produce a fatal "out of range"
error. The code shows that, in Modelsim, adding two positive numbers can
produce a negative sum.

entity \Integer range demonstration\ is
end entity \Integer range demonstration\;

architecture \Test\ of \Integer range demonstration\ is
begin

\32 bit 2's complement\:
Process is
variable \Integer Variable\ : integer;
variable \Increment\, \Decrement\ : integer;
begin

\Integer Variable\ := integer'high;

\Increment\ := \Integer Variable\ + 1;

assert \Increment\ > \Integer Variable\
report "integer'high + 1 = " & integer'image(\Increment\);

\Integer Variable\ := integer'low;

\Decrement\ := \Integer Variable\ - 1;

assert \Decrement\ < \Integer Variable\
report "integer'low - 1 = " & integer'image(\Decrement\);

wait;

end process \32 bit 2's complement\;

end architecture \Test\;




Paul Butler
  Reply With Quote
Old 08-09-2004, 04:36 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: Modelsim behavior
On Mon, 9 Aug 2004 09:52:44 -0500, "Paul Butler" <>
wrote:

>My understanding of 1076-2002 is that the value "integer'high + 1" is out of
>range for a variable of type integer. Modelsim PE 5.8b seems to implement
>the integer type as a 2's complement 32 bit number so that (integer'high +
>1) = integer'low. For most values of an integer variable D32,
>integer'succ(D32) = D32 + 1. However, for at least one value,
>integer'succ(D32) is out of range while D32+1 is integer'low.
>
>Is Modelsim's behavior incorrect? How do other simulators behave?


Scirocco (Synopsys) detects the error if "-debug all" is
selected at the simulator invocation line.

I think it gets worse:

When I first saw this I thought: Ahah, the problem is with
implementation of "+". It does modulo-2^32 arithmetic,
erroneously yielding a result -(2^31), but that result
is in-range and so any range check on assignment to the
incremented variable will be OK. But then I tried
defining a subtype

integer range integer'low+1 to integer'high

which brings ModelSim's definition of integer into line
with the LRM's minimum, and outlaws the value -(2^31).
Then, if "target" is of the new subtype,

target := integer'high + 1;

should fail on two counts: the arithmetic overflows
the base type "integer", but even if that test
is ignored, the resulting value is out of range for
assignment to "target". Hmmm, nice theory.
ModelSim goes ahead and does the assignment anyhow.

There may well be something about this in ModelTech's
release notes, but I've no time to trawl through them
right now - sorry.
--
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 in Modelsim 6.0a boitsas Software 1 10-26-2009 05:36 AM
VERY WIRED BEHAVIOR OF NERO 7.7.5.1 tanyaru@hotmail.com DVD Video 4 04-06-2007 08:45 AM
simprim problems on modelsim saiyijinprince Hardware 2 04-05-2007 02:24 PM
Re: Odd PSU behavior? w_tom A+ Certification 19 09-15-2006 10:33 AM
You MUST Watch This Before You Vote - Esteemed Shrink Profiles Bush Barney Lyon DVD Video 13 11-02-2004 06:21 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