📄 dattransf.vhd
字号:
------------------------------------------------------------------------------------ Company: uestc-- Engineer: hubiao-- -- Create Date: 20:06:34 07/17/2007 -- Design Name: 10bit two's complement to ieee 32 bit float digitals -- Module Name: dattransf - transf -- Project Name: 2c2f-- Target Devices: xc2v1500-6fg676c-- Tool versions: ise8.2i-- Description: 10 bit two's complement's point is in afront;32bit float digitals is ieee standards---- Dependencies: ---- Revision: -- Revision 0.01 - File Created-- Additional Comments: test pass successfully!!look up test.txt for more descriptions------------------------------------------------------------------------------------library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;entity dattransf is port(datin : in bit_vector(9 downto 0); clk:in std_logic; ad_rst:in std_logic; ad_buffer:out bit_vector(9 downto 0); datout: out bit_vector(31 downto 0));end dattransf;architecture transf of dattransf is begin P1:process (datin,clk) variable datbuf:bit_vector(9 downto 0); variable datfh:bit; --IEEE32位浮点数标准:1位符号&8位指数&23位尾数 variable datwsh:bit_vector(22 downto 0); variable datzsh:bit_vector(7 downto 0); begin if ad_rst='1' then if clk='0' and clk'event then if datin(9)='0' then --第一步将2的补码数转换成有符号的绝对 datbuf:=datin; ad_buffer<=datbuf; else datbuf(9):=datin(9); --负二进制补码取反码 datbuf(8):=not datin(8); datbuf(7):=not datin(7); datbuf(6):=not datin(6); datbuf(5):=not datin(5); datbuf(4):=not datin(4); datbuf(3):=not datin(3); datbuf(2):=not datin(2); datbuf(1):=not datin(1); datbuf(0):=not datin(0); if datbuf="1111111111" then datbuf:="1111111111"; else if datbuf(0)='0' then --反码加一得绝对值形式 datbuf(0):='1'; else datbuf(0):='0'; if datbuf(1)='0' then datbuf(1):='1'; else datbuf(1):='0'; if datbuf(2)='0' then datbuf(2):='1'; else datbuf(2):='0'; if datbuf(3)='0' then datbuf(3):='1'; else datbuf(3):='0'; if datbuf(4)='0' then datbuf(4):='1' ; else datbuf(4):='0'; if datbuf(5)='0' then datbuf(5):='1'; else datbuf(5):='0'; if datbuf(6)='0' then datbuf(6):='1'; else datbuf(6):='0'; if datbuf(7)='0' then datbuf(7):='1'; else datbuf(7):='0'; if datbuf(8)='0' then datbuf(8):='1'; else datbuf(8):='0'; end if; end if; end if; end if; end if; end if; end if; end if; end if; end if; ad_buffer<=datbuf; end if; if datbuf(8)='1' then -- datwsh:=datbuf(7 downto 0)&"000000000000000"; datzsh:="01111110"; -- -1+2^7-1 else if datbuf(7)='1' then datwsh:=datbuf(6 downto 0)&"0000000000000000"; datzsh:="01111101"; -- -2+2^7-1 else if datbuf(6)='1' then datwsh:=datbuf(5 downto 0)&"00000000000000000"; datzsh:="01111100"; -- -3+2^7-1 else if datbuf(5)='1' then datwsh:=datbuf(4 downto 0)&"000000000000000000"; datzsh:="01111011"; -- -4+2^7-1 else if datbuf(4)='1' then datwsh:=datbuf(3 downto 0)&"0000000000000000000"; datzsh:="01111010"; -- -5+2^7-1 else if datbuf(3)='1' then datwsh:=datbuf(2 downto 0)&"00000000000000000000"; datzsh:="01111001"; -- -6+2^7-1 else if datbuf(2)='1' then datwsh:=datbuf(1 downto 0)&"000000000000000000000"; datzsh:="01111000"; -- -7+2^7-1 else if datbuf(1)='1' then datwsh:=datbuf(0)&"0000000000000000000000"; datzsh:="01110111"; -- -8+2^7-1 else if datbuf(0)='1' then datwsh:="00000000000000000000000"; datzsh:="01110110"; -- -9+2^7-1 else datwsh:="00000000000000000000000"; datzsh:="00000000"; --定0,用IEEE32位标准表示浮点0 end if; end if; end if; end if; end if; end if; end if; end if; end if; datfh:=datbuf(9); datout<=datfh & datzsh & datwsh; --第三步将datout end if; else datfh:='0'; datzsh:="00000000"; datwsh:="00000000000000000000000"; datout<=datfh & datzsh & datwsh; end if; end process; end transf;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -