Professional Documents
Culture Documents
input [15:0] a;
input [15:0] b;
wire [15:0] alu_control;
always @(a,b,op)
begin
case(op)
ADD: result = a + b;
SUB: result = a - b;
SHL: result = a<<b;
SHR: result = a>>b;
AND: result = a & b;
OR: result = a | b;
XOR: result = a ^ b;
default:result = 0;
endcase
end
endmodule
module testbench;
parameter totaltime=300;
ALU M3(tresult,tA,tB,topcode);
initial #totaltime $finish;
initial
begin
tbA=9312;tB=9234;topcode=8;
#10 tA=tresult; tB=5872;topcode=9;
#20 tA=tresult;tB=7234;topcode=12;
#30 tA=tresult;tB=7121;topcode=11;
#45 tA=tresult;tB=1111;topcode=10;
#55 tA=tresult;tB=1111;topcode=8;
#60 tA=tresult;tB=3;topcode=13;
end
endmodule