www.pudn.com > project_2.zip > real_show.vhd, change:2015-12-07,size:2395b


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity real_show is
    port(clk, en: in std_logic; cin: std_logic_vector(511 downto 0); cout1, cout2, cout3, cout4, cout5, cout6, cout7, cout8, cout9, cout10, cout11, cout12, cout13, cout14, cout15, cout16: out real);
end real_show;

architecture Behavioral of real_show is

type real_group is array(15 downto 0) of real;
signal tmp: real_group;

begin
    p1: process(en)
    variable v: std_logic_vector(31 downto 0);
    variable index, inte: integer;
    variable value: std_logic_vector(23 downto 0);
    variable deci: real;
    begin
        if(en' event and en='1')then
            for i in 0 to 15 loop
                v:=cin(511-i*32 downto 480-i*32);
                value(23):='1';
                value(22 downto 0):=v(22 downto 0);
                deci:=0.0;
                if(v(30 downto 23)>="01111111")then
                    index:=conv_integer(v(30 downto 23)-"01111111");
                    inte:=conv_integer(value(23 downto 23-index));
                    for j in 23-index-1 downto 0 loop
                        if(value(j)='1')then
                            deci:=real(1.0/2.0**(23-index-j))+deci;
                         end if;
                    end loop;
                    if(v(31)='0')then
                        tmp(15-i)<=real(inte)+deci;
                    else
                        tmp(15-i)<=-real(inte)-deci;
                    end if;
                elsif(v(30 downto 23)<"01111111")then
                    index:=conv_integer("01111111"-v(30 downto 23));
                    for j in 23 downto 0 loop
                        if(value(j)='1')then
                            deci:=1.0/2.0**(index+23-j)+deci;
                        end if;
                    end loop;
                    if(v(31)='0')then
                        tmp(15-i)<=deci;
                    else
                        tmp(15-i)<=-deci;
                    end if;
                end if;   
            end loop;
        end if;
    end process p1;
    cout1<=tmp(15);
    cout2<=tmp(14);
    cout3<=tmp(13);
    cout4<=tmp(12);
    cout5<=tmp(11);
    cout6<=tmp(10);
    cout7<=tmp(9);
    cout8<=tmp(8);
    cout9<=tmp(7);
    cout10<=tmp(6);
    cout11<=tmp(5);
    cout12<=tmp(4);
    cout13<=tmp(3);
    cout14<=tmp(2);
    cout15<=tmp(1);
    cout16<=tmp(0);
end Behavioral;