boothsmul.vhd

来自「Booths Multiplier using Behavioral Model」· VHDL 代码 · 共 43 行

VHD
43
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

Entity Boothsmul is
 generic (N : integer := 24; NN : integer := 48);
 port(a,b : in signed(N-1 downto 0); 
	en : in std_logic;
	c: out signed(NN-1 downto 0));
end Boothsmul;

Architecture beh of Boothsmul is
begin
 process(en)
 variable acc : signed(NN-1 downto 0):=(others=>'0');
 variable ltwolsb : signed(1 downto 0) := "00";
 --variable count:integer := 8;
 begin
   if en = '1' and en'event then
    acc(N-1 downto 0) := acc(N-1 downto 0) + b;
    
    for i in 0 to N-1 loop
--	 wait until clk = '1' and clk'event; 
      ltwolsb := acc(0) & ltwolsb(1);
      
      if ltwolsb(0) = '1' and ltwolsb(1) = '0' then
		acc(NN-1 downto N) := acc(NN-1 downto N) + a;
	  elsif ltwolsb(0) = '0' and ltwolsb(1) = '1' then
		acc(NN-1 downto N) := acc(NN-1 downto N) - a;
	  end if;
 
      acc := acc(NN-1) & acc(NN-1 downto 1);
 --     count := count - 1; 	
	 end loop;
   end if;
   c <= acc;
  end process; 
end beh;

 
 
 
  

⌨️ 快捷键说明

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