计算机组成原理实验第二个,VHDL语言,ISE设计环境设计一个16位的ALU。
资源下载:
链接:https://pan.baidu.com/s/1cyhJ2ZynUMMFnYi2YOIMmA
提取码:0upp
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity alu is
Port ( clk : in STD_LOGIC;--时钟
rst : in STD_LOGIC;--复位
In_A : in STD_LOGIC_VECTOR (15 downto 0);--操作数A
In_B : in STD_LOGIC_VECTOR (15 downto 0);--操作数B
Out_Y : out STD_LOGIC_VECTOR (15 downto 0);--输出
OP : in STD_LOGIC_VECTOR(3 downto 0);--操作码
Flags :out STD_LOGIC_VECTOR(3 DOWNTO 0));--标志位为OF/CF/ZF/SF
end alu;
architecture Behavioral of alu is
signal State:STD_LOGIC_VECTOR (1 downto 0):= "00";--记录当前的状态,来判断该进行什么操作
signal int_A, int_B, int_Y : INTEGER RANGE 0 TO 65535:=0;
signal temp_A, temp_B, temp_Y : STD_LOGIC_VECTOR (15 downto 0);--定义临时操作数
signal Flag_OF : STD_LOGIC;--溢出标志
signal Flag_CF : STD_LOGIC;--进位标志
signal Flag_ZF : STD_LOGIC;--0标志位
signal Flag_SF : STD_LOGIC;--正负标志
signal M: STD_LOGIC:='0';--扩展:对于带符号运算ADC/SBB
begin
process(rst,clk)
begin
if (rst='1') then
State <= "00";
Flag_OF <= '0';
Flag_CF <= '0';
Flag_ZF <= '0';
Flag_SF <= '0';
M <='0';
else
if (State = "00") then

本文详细介绍了一种使用VHDL语言在ISE设计环境中实现16位算术逻辑单元(ALU)的方法,包括完整的源代码和仿真测试过程,涵盖了加、减、逻辑运算等基本功能。
6463

被折叠的 条评论
为什么被折叠?



