Converting int to float and vice-versa in HDL

floating pointhdl

I am trying to write an HDL code for converting floating point numbers in IEEE-754 format to integers and vice-versa. For eg.

    for floatToInt operation:
    input = 8.9 (in IEEE-754 format)
    output = 9  (an integer number)

    for intToFloat operation:
    input = 10 (an integer number)
    output = 10.00 (in IEEE-754 format)

In my code, I also need to take care of all the exceptions that might be generated while doing this. Please explain or point me to a good article which exhaustively explains the general procedure/algorithm to do so. I would be very obliged. Thanks in advance.

Best Answer

How about just casting them:

entity x is
end entity x;
architecture STR of x is
    signal i: integer;
    signal r: real;
begin
    i <= integer(r);
    r <= real(i);
end architecture STR;