杭州电子科技大学计算机组成实验:代码和解析
顶层模块:
module First_Experiment_Add(A,B,Ci,F,C);
input A,B,Ci;
output F,C;
xor XU1(F,A,B,Ci),
XU2(Q,A,B);
and AN1(W,Q,Ci),
AN2(E,A,B);
or OR1(C,W,E);
endmodule
测试模块:
module test;
// Inputs
reg A;
reg B;
reg Ci;
// Outputs
wire F;
wire C;
First_Experiment_Add uut (
.A(A),
.B(B),
.Ci(Ci),
.F(F),
.C(C)
);
initial begin
A = 0;
B = 0;
Ci = 0;
#100;
A = 1;
B = 0;
Ci = 0;
#100;
A = 1;
B = 1;
Ci = 0;
#100;
A = 1;
B = 1;
Ci = 1;
end
endmodule