tom@srl.mew.mei.co.jp (Tom Borgstrom) (02/26/91)
I have been using <Company>'s VHDL tool to simulate a behavioral-level model of parts of a 32-bit microprocessor that require 32-bit unsigned integers. This is what I tried to do: type long is range 0 to 4294967295; The VHDL tool flagged this as an error, complaining about an integer overflow. My questions are: 1) Do other VHDL analyzers/simulators have less restrictive bounds on the range constraint of integer types? 2) Is there a better way of doing behavioral models with > 32-bit integers? -tom == Thomas H. Borgstrom tom@mew.mei.co.jp Semiconductor Research Lab telephone: +81 6-908-1431 Matsushita Electric Works facsimile: +81 6-906-7251 1048 Kadoma, Osaka 571 Japan
jab0396@cec2.wustl.edu (John A. Breen) (02/28/91)
In article <TOM.91Feb26105730@venus.srl.mew.mei.co.jp> tom@srl.mew.mei.co.jp (Tom Borgstrom) writes: >I have been using <Company>'s VHDL tool to simulate a behavioral-level >model of parts of a 32-bit microprocessor that require 32-bit unsigned >integers. This is what I tried to do: > >type long is range 0 to 4294967295; > >The VHDL tool flagged this as an error, complaining about an integer overflow. > >My questions are: > >1) Do other VHDL analyzers/simulators have less restrictive bounds on the > range constraint of integer types? > >2) Is there a better way of doing behavioral models with > 32-bit integers? Since I haven't seen anyone else respond, I'll take a stab at it: The LRM only guarantees that an integer is in the range -2147483647 to +2147483647. While a vendor can implement a larger range (or distinguish between signed and unsigned ranges to save a bit), code using this would not be portable. I would suggest representing your 32-bit numbers as an array of n-bit integers, and doing the extended math yourself (overloading operators makes this look nice, too). For example, if you're only doing adds and subtracts, you could use an array of integers of length 2; when you add the first halves, take the result mod 2**16, and add the overflow to the second half sum. If you need to multiply them, then you'll need a larger array to avoid overflow. I implemented a pseudorandom number generator with a 48-bit seed this way, using an array of four integers (each representing 12 bits). It's not particularly fast, but it's portable. ----- John A. Breen | johnb@hobbes.mdc.com McDonnell Douglas Missile Systems Co. | jab0396@cec1.wustl.edu (forwarded ^) Tel: (314)234-4341