Electrical – Use floating values in VHDL code

fixed-pointfpgavhdl

Assume I want to have a continous sine signal as input to my VHDL code. The values will be of type float since it will take on non-integer values for example: 10.5 mA.

How do I manage these numbers in my VHDL code?

I have tried to use: type Voltage_Level is range -5.5 to +5.5; as an example but it did not work since i couldn't import signed vector into Voltage_level since Voltage_level must be represented as a signal.

I would appreciate if someone could help with these kind of issues? What is the most easiest way to deal with this?

The basic problem is when I input non-integer values, say 10.5 and try to use the same value as input the FPGA outputs a rounded integer, in this case 10. So it seems that I can use VHDL only when i deal with integers and bit vectors, which is very limiting use scenario. Especially for people like me that work a lot with various kinds of signals.

Best Answer

Try using fixed point notation instead. Float point is bit tedious in VHDL. Since your range is not wide, you can use Fixed point representation. To see more about the fixed point visit : http://vhdlguru.blogspot.in/2010/03/fixed-point-operations-in-vhdl-tutorial.html