I'm working on a digital video evaluation project and trying to implement the evaluation process on a FPGA using VHDL.
The problem is: the equations that our project uses to rate the videos are a bit complex, with a lot of multiplications (of positive and negative numbers with decimal units) and also a exponential.
I try to simulate the code but the Quartus II compiler doesn't accept to compile a variable of the REAL type. And of course I can't work with just INTEGERs.
So the question (for now) is: how to use real/float/double numbers in a VHDL code and synthetize it? I've done some research and found some stuff about a library called ieee_proposed, but I have not been able to use it.
numbers of type REAL are not synthesizable on real hardware. You have to use floating-point numbers instead. The IEEE 754 standard defines floating points numbers as sign-extended bit vectors with a mantissa (23 bits) and an exponent (8 bits) for the 32-bits case. You have to use these if you want a synthesizable design.
numbers of type REAL are not synthesizable on real hardware. You have to use floating-point numbers instead. The IEEE 754 standard defines floating points numbers as sign-extended bit vectors with a mantissa (23 bits) and an exponent (8 bits) for the 32-bits case. You have to use these if you want a synthesizable design.
You should first check if floating-point is required, or fixed-point is enough for your purposes. There are some real efforts in making VHDL and packages for synthesizable floating-point and fixed-point operations: take a look at the following link, it should contain appropriate information:
If you really have to use floating point, you will need to use the floating point cores provided by Altera or Xilinx. They have a long latency (the divider and square root are the of the order of 25+ clock cycles) but they are pipelined so can be clocked quick.
But do you really need floating point? fixed point is usually more than anyone needs. Fixed point is really just integer arithmatic.
You should first check if floating-point is required, or fixed-point is enough for your purposes. There are some real efforts in making VHDL and packages for synthesizable floating-point and fixed-point operations: take a look at the following link, it should contain appropriate information:
If you really have to use floating point, you will need to use the floating point cores provided by Altera or Xilinx. They have a long latency (the divider and square root are the of the order of 25+ clock cycles) but they are pipelined so can be clocked quick.
But do you really need floating point? fixed point is usually more than anyone needs. Fixed point is really just integer arithmatic.
Didn't really thought about that. I've said floating-point because of the common FLOAT type in C and other languages. More a matter of common use.
But I think that fixed point is enough. I have to do calculations like this one:
fixed point is WAY easier to implement, because its just integer arithmatic with a 2^n offset. have a read of the fixfloatlib in the link that kingslayer posted
A lot easier. Fixed point arithmetic can be implemented with ieee.fixed_pkg_c. In contrast to the ieee float package it's well synthesizable. The float package is more in an experimental state, demonstrating the concept. But it doesn't synthesize to pipelined logic, which is absolutely required for reasonable speed.
Thanks for all the answers. I'm still having some issues.
I have added the files of the fixed-point arithmetic to the project, like **broken link removed** says (I'm using the same version of Quartus) and added the lines
use ieee.fixed_float_types.all;
use ieee.fixed_pkg.all;
like the user guide **broken link removed** says, but it seems to not recognize the type, as the error message states:
Error (10482): VHDL error at Project.vhd(79): object "sfixed" is used but not declared
Thanks to everyone who helped. I've managed to use the fixed-point package from **broken link removed** which also has a math pack with a exponential function, what will also be very useful.
The problem is that you can't see clearly the numbers you are working with, because the package works with binary set (6.5 = 0011010000, for example). But well, I guess I will have to live with that, at least for now.