alu电路[最新]
- 格式:pdf
- 大小:296.60 KB
- 文档页数:4
EDA技术与应用
实验报告
实验名称: ALU的设计
一、 实验目的 1、学习包集和元件例化语句的使用。 2、学习AUL电路的设计。 二、 实验内容 1、用VHDL代码描述逻辑单元、算术单元、选择器单元,要求输入两组二进制数据,每组二进制数据的位数为8位。 2、利用元件例化语句将设计的三个单元进行连接组合。 3、建立一个包含所有原件的包集。 4、仿真并利用实验箱验证所设计电路的正确性,将结果用数码管进行显示。 三、 实验原理 1、AUL的原理图:
逻辑单a(7..0) b(7..0)
y(7..0)
2、 AUL的功能表
四、 实验代码 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity alu is port(a,b:in std_logic_vector(7 downto 0); sel:buffer std_logic_vector(3 downto 0); cin,clk:in std_logic; y:out std_logic_vector(7 downto 0)); end alu; architecture dataflow of alu is signal arith,logic:std_logic_vector(7 downto 0); begin variable s:std_logic_vector(3 downto 0); begin if(clk'event and clk='1')then if s="1111"then s:="0000"; else s:=s+1; end if; end if; sel<=s; end process; with sel (2 downto 0) select arith<= a when "000", a+1 when "001", a-1 when "010", b when "011", b+1 when "100", b-1 when "101", a+b when "110", a+b+cin when others; with sel (2 downto 0) select logic<= not a when "000", not b when "001", a and b when "010", a or b when "011", a nand b when "100", a nor b when "101", a xor b when "110", not(a xor b) when others; with sel(3) select y<=arith when '0', logic when others; end dataflow; 五、 电路仿真结果
六、管脚配制