Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Floating point number in verilog.

918 views
Skip to first unread message

Thomas A. Coonan

unread,
May 20, 1998, 3:00:00 AM5/20/98
to

What I've seen when dealing with A/Ds and D/As and such is that you
declare a variable of type real (say, for your behavioral model or
testbench). It is then represented as a 64-bit floating point number.
I'll guess that this 64-bit value is an IEEE floating point format,
but I may be wrong..

You often need to pass "reals" back and forth between modules. For
example, an A/D would have a Vin input that is supposed to represent
the analog voltage, say, between -2.500 and 2.500V. Unfortuneatly,
Verilog doesn't allow reals to be ports. The common trick is to then
define wires and ports that are 64-bit buses (e.g. input [63:0] vin).
There are Verilog functions $bitstoreal and $realtobits that will
convert back and forth (this is from memory..). This way, you can
glue together mixed signal systems. This is usually when someone will
chime in with something about the Analog extentions to Verilog...

I have examples of this sort of thing, if that's what you are
interested in.

tom coonan
Scientific Atlanta
>Can anyone here tell me how to specified a floating point number in
>verilog?
>Such as for a 32bit number A=6.0247e-23 ====> A=32'd ???
>
>Thanks in advance.
>
>


Mantat Lam

unread,
May 21, 1998, 3:00:00 AM5/21/98
to

Steven Sharp

unread,
May 23, 1998, 3:00:00 AM5/23/98
to

The IEEE Verilog standard specifies that the conversions with $bitstoreal
and $realtobits will conform to the IEEE floating point representation.
The specification of these functions indicates that reals are expected to
be 64-bit or double precision quantities. You can use these functions for
passing real values through nets. You can also use them for "converting"
between real numbers and their IEEE bit representations for convenience
when designing with IEEE floating point hardware.

On a practical level, any simulator is going to use the floating point
representation of the machine that it runs on. Anything else would take
extra work for the person writing the simulator and for the simulator
executing the floating point operations. Most computers use IEEE floating
point these days.


Ganapathy Subbaraman

unread,
May 26, 1998, 3:00:00 AM5/26/98
to u84...@ee.nthu.edu.tw

Mantat Lam wrote:

U will need to declare A has Real data type and then assign value
appropriately.

For Ex: real A;
initial begin
A = 6e-23; //scientific
notation; U maynot be able to declare it as 6.0247e-23
A = 6.0247; //Legal declaration
end

Get the idea !!!! -SUBBU


0 new messages