Define a constant for a fix-point number?

E

Elektro

Guest
I want to define a fix-point constant for a signed 24 bit number as
S.I1.23, that is a signed binary number with a 1 bit integer part and
a 23 bit fraction part.

I found a way but is look a bit ugly.

constant b0 : std_logic_vector (23 downto 0) :=
conv_std_logic_vector(integer(-0.2763932 * (2**23)), 24);

This is the same as "define b0 as a fix-point number with the value
-0.2763932"

Is there another nicer way to define this constant?
 
You could define your own fixed point. But there are several sources with
fixed point packages.
A draft of an IEEE propsosal is:
http://vhdl.org/vhdlsynth/proposals/dave_p3.html

If you are already have defined your own package I would add general
functions that converts between real and fixed point.

Egbert Molenkamp

"Elektro" <skolpojken72@yahoo.se> wrote in message
news:51f32d27.0502070135.7bd21b1a@posting.google.com...
I want to define a fix-point constant for a signed 24 bit number as
S.I1.23, that is a signed binary number with a 1 bit integer part and
a 23 bit fraction part.

I found a way but is look a bit ugly.

constant b0 : std_logic_vector (23 downto 0) :=
conv_std_logic_vector(integer(-0.2763932 * (2**23)), 24);

This is the same as "define b0 as a fix-point number with the value
-0.2763932"

Is there another nicer way to define this constant?
 

Welcome to EDABoard.com

Sponsor

Back
Top