资料简介
南通大学信息科学技术学院
《计算机组成实验》
实验报告
实验名称 运算器的设计与实现
班级 物联网工程 192
学生姓名 谢焘 学号 1930110689
指导教师 成耀
日 期 2021 年 6 月 1 日
实验 运算器的设计与实现
一、实验目的
1.熟悉 Vivado 软件的使用方法。
2.熟悉运算器的功能。
3.掌握自顶而下的硬件模块设计方法。
4.掌握电路仿真测试方法,掌握仿真激励文件的编写,掌握仿真输出的分析方法。
二、实验任务
设计一个运算器,具有基本的加、减、与、非、异或等功能。
三、设计步骤
(1)实验电路原理及信号说明
运算器的逻辑结构如图所示:
信号名 功能 位宽 类型
X 操作数 32 输入
Y 操作数 32 输入
Aluc 操作码 4 输入
R 运算结果 32 输出
Z 零标志 1 输出
其中 Aluc 操作码对应功能如下:
Aluc 功能描述 Aluc 功能描述
0000 Add 加 0100 Xor 异或
0001 Sub 减 0101 左移
0010 And 与 0111 右移
0011 Or 或 1101 算术左移
0100 Xor 异或 1111 算术右移
0110 Lui 设置高位
具体设计如下:
本实验采用运算部件并行多路选择实现,运用了 32 位加/减法器,32 位移位器,32 位 6 选 1 选
择器。
(2)实验电路设计
顶层文件:
module ALU(X,Y,Aluc,R,Z);
input[31:0]X,Y;
input[3:0]Aluc;
output[31:0]R;
output Z;
wire[31:0]d_as,d_and,d_or,d_xor,d_lui,d_sh,d;
ADDSUB_32 as32(X,Y,Aluc[0],d_as);
assign d_and=X&Y;
assign d_or=X|Y;
assign d_xor=X^Y;
assign d_lui={Y[15:0],16'h0};
SHIFTER shift(Y,X[10:6],Aluc[3],Aluc[1],d_sh);
MUX6X32 select(d_and,d_or,d_xor,d_lui,d_sh,d_as,Aluc[3:0],R);
assign Z=~|R;
endmodule
32 位加法/减法计算器:
module ADDSUB_32(X,Y,Sub,S);
input [31:0]X,Y;
wire Cout;
input Sub;
output [31:0]S;
CLA_32 adder0(X,Y^{32{Sub}},Sub,S,Cout);
endmodule
32 位 CLA 运算器 8x4 位:
module CLA_32(X,Y,Cin,S,Cout);
input[31:0]X,Y;
input Cin;
output[31:0]S;
output Cout;
wire Cout0,Cout1,Cout2,Cout3,Cout4,Cout5,Cout6;
CLA_4 add0(X[3:0],Y[3:0],Cin,S[3:0],Cout0);
CLA_4 add1(X[7:4],Y[7:4],Cout0,S[7:4],Cout1);
CLA_4 add2(X[11:8],Y[11:8],Cout1,S[11:8],Cout2);
CLA_4 add3(X[15:12],Y[15:12],Cout2,S[15:12],Cout3);
CLA_4 add4(X[19:16],Y[19:16],Cout3,S[19:16],Cout4);
CLA_4 add5(X[23:20],Y[23:20],Cout4,S[23:20],Cout5);
CLA_4 add6(X[27:24],Y[27:24],Cout5,S[27:24],Cout6);
CLA_4 add7(X[31:28],Y[31:28],Cout6,S[31:28],Cout);
Endmodule
4 位 CLA 运算器:
module CLA_4(X,Y,Cin,S,Cout);
input [3:0]X,Y;
output Cout;
input Cin;
output [3:0]S;
and i0(Y_3,X[3],Y[3]);
or i1(X_3,X[3],Y[3]);
and i2(Y_2,X[2],Y[2]);
or i3(X_2,X[2],Y[2]);
and i4(Y_1,X[1],Y[1]);
or i5(X_1,X[1],Y[1]);
and i6(Y_0,X[0],Y[0]);
or i7(X_0,X[0],Y[0]);
not i01(Y_31,Y_3);
nand i02(Y_32,X_3,Y_2);
nand i03(Y_33,X_3,X_2,Y_1);
nand i04(Y_34,X_3,X_2,X_1,Y_0);
nand i05(Y_35,X_3,X_2,X_1,X_0,Cin);
nand i00(Cout,Y_31,Y_32,Y_33,Y_34,Y_35);//Cout 的输出门级电路实现
not i_2(Y__3,Y_3);
and i21(Y_21,Y__3,X_3);
not i22(Y_22,Y_2);
nand i23(Y_23,X_2,Y_1);
nand i24(Y_24,X_2,X_1,Y_0);
nand i25(Y_25,X_2,X_1,X_0,Cin);
nand i26(Y_26,Y_22,Y_23,Y_24,Y_25)... 查看更多