Define a constant for a fix-point number?

E

Elektro

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?
 
E

Egbert Molenkamp

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top