【计算机组成原理】使用Quartus完成十六位运算器ALU的设计

设计16位ALU运算器

要求

设计具有下列功能的16位ALU

功能选择输入func[3…0]操作
0000c←a and b
0001c←a or b
0010c←a xor b
0011c←not a
0100c←a+b
0101c←a-b
其它c←a
  • 编写VHDL代码

编写VHDL代码

-- 十六位运算器的设计

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

entity two_sixteenAU is
	port(a, b: in std_logic_vector(15 downto 0);
			func: in std_logic_vector(3 downto 0);
			c_linxuan: out std_logic_vector(15 downto 0));
end two_sixteenAU;

architecture behave of two_sixteenAU is
	begin
		process(a, b, func)
			begin 
				case func is
					when "0000" => c_linxuan <= a and b;
					when "0001" => c_linxuan <= a or b;
					when "0010" => c_linxuan <= a xor b;
					when "0011" => c_linxuan <= not a;
					when "0100" => c_linxuan <= a + b;
					when "0101" => c_linxuan <= a - b;
					when others => c_linxuan <= a;
				end case;
		end process;
end behave;

  • 0
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值