Is there a common conversion function to convert a integer type object to a real type in VHDL? This is for a testbench so synthesizability is a non-issue.
Instead of if x >= 0 then x else ~x , use Int. abs x . To convert x to real, use Real. fromInt x .
Conversion functions convert a value from one datatype to another. Generally, the form of the function names follows the convention datatype TO datatype. The fırst datatype is the input dataty; the last datatype is the output.
Description. The atoi() function converts a character string to an integer value. The input string is a sequence of characters that can be interpreted as a numeric value of the specified return type.
You can convert integer to real as follows:
signal i: integer;
signal R: Real;
...
R <= Real(i);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With