mul2.vhd

来自「用VHDL编写的计算器:能实现简单的加减乘除四则运算」· VHDL 代码 · 共 65 行

VHD
65
字号
------------------------------------------------------------------------------------ Company: -- Engineer: -- -- Create Date:    20:29:19 11/16/2006 -- Design Name: -- Module Name:    shiftl - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: ---- Dependencies: ---- Revision: -- Revision 0.01 - File Created-- Additional Comments: ------------------------------------------------------------------------------------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 mul2 is    Port ( num1 : in  STD_LOGIC_VECTOR (3 downto 0);           num2 : in  STD_LOGIC_VECTOR (8 downto 0);         --  start : in  STD_LOGIC;           clk : in  STD_LOGIC;           num : out  STD_LOGIC_VECTOR (11 downto 0));end mul2;architecture Behavioral of mul2 isbeginprocess(clk,num1,num2)variable acc:std_logic_vector(11 downto 0);variable q:std_logic_vector(11 downto 0);variable ma:std_logic_vector(11 downto 0);begin  if rising_edge(clk)then
  ma:="00000000"&num1;  acc:="000000000000";  for i in 0 to 8 loop
     for j in  0 to 11 loop
	  q(j):=num2(i)and ma(j);
	  end loop;
	  acc:=acc+q;
	  ma:=ma(10 downto 0)&ma(11);
	end loop;
	num<=acc;
	end if;
end process;  end Behavioral;

⌨️ 快捷键说明

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