⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fpalign.vhd

📁 一个32位元的浮点数加法器
💻 VHD
字号:
--modified 2007,03 v1
--modified 2007,04,09 v2
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
USE ieee.std_logic_unsigned.all;

ENTITY FPalign IS
   PORT( 
      A_in  : IN     std_logic_vector (28 DOWNTO 0); --23sig+5count
      B_in  : IN     std_logic_vector (28 DOWNTO 0);
      cin   : IN     std_logic;
      diff  : IN     std_logic_vector (8 DOWNTO 0);  --8exp+1
      A_out : OUT    std_logic_vector (28 DOWNTO 0);
      B_out : OUT    std_logic_vector (28 DOWNTO 0)
   );
END FPalign ;

ARCHITECTURE struct OF FPalign IS
   SIGNAL B_shift  : std_logic_vector(28 DOWNTO 0);
   SIGNAL diff_int : std_logic_vector(8 DOWNTO 0);
   SIGNAL shift_B  : std_logic_vector(5 DOWNTO 0);

BEGIN
   PROCESS(diff_int, B_shift)
   BEGIN
      IF (diff_int(8)='1') THEN
         IF (((NOT diff_int) + 1) > 28) THEN
             B_out <= (OTHERS => '0');
          ELSE
              B_out <= B_shift;
          END IF; 
      ELSE      
          IF (diff_int > 28) THEN
             B_out <= (OTHERS => '0');
          ELSE
              B_out <= B_shift;
          END IF;
       END IF;
   END PROCESS;

   PROCESS(diff_int)
   BEGIN
      IF (diff_int(8)='1') THEN
            shift_B <= (NOT diff_int(5 DOWNTO 0)) + 1;
      ELSE
            shift_B <= diff_int(5 DOWNTO 0) ;
      END IF;
   END PROCESS;

   PROCESS(cin,diff)
   BEGIN
      IF ((cin='1') AND (diff(8)='1')) THEN
         diff_int <= diff + 2;
      ELSE
         diff_int <= diff;
      END IF;
   END PROCESS;


   -- ModuleWare code(v1.1) for instance 'I0' of 'assignment'
   A_out <= A_in;

   -- ModuleWare code(v1.1) for instance 'I1' of 'rshift'
   I1combo : PROCESS (B_in, shift_B)
   VARIABLE stemp : std_logic_vector (5 DOWNTO 0);
   VARIABLE dtemp : std_logic_vector (28 DOWNTO 0);
   VARIABLE temp : std_logic_vector (28 DOWNTO 0);
   BEGIN
      temp := (OTHERS=> 'X');
      stemp := shift_B;
      temp := B_in;
      FOR i IN 5 DOWNTO 0 LOOP
         IF (i < 5) THEN
            IF (stemp(i) = '1' OR stemp(i) = 'H') THEN
               dtemp := (OTHERS => '0');
               dtemp(28 - 2**i DOWNTO 0) := temp(28 DOWNTO 2**i);
            ELSIF (stemp(i) = '0' OR stemp(i) = 'L') THEN
               dtemp := temp;
            ELSE
               dtemp := (OTHERS => 'X');
            END IF;
         ELSE
            IF (stemp(i) = '1' OR stemp(i) = 'H') THEN
               dtemp := (OTHERS => '0');
            ELSIF (stemp(i) = '0' OR stemp(i) = 'L') THEN
               dtemp := temp;
            ELSE
               dtemp := (OTHERS => 'X');
            END IF;
         END IF;
         temp := dtemp;
      END LOOP;
      B_shift <= dtemp;
   END PROCESS I1combo;

END struct;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -