Question: The answer is: module Q1 (output reg[7:0] y, input [7:0] A, B, input [2:0] Sel); always @(A, B, Sel) begin y=0; case (Sel) 3'b000: y=8'b0;
The answer is:
module Q1 (output reg[7:0] y, input [7:0] A, B, input [2:0] Sel);
always @(A, B, Sel) begin
y=0;
case (Sel)
3'b000: y=8'b0;
3'b001: y=A&B;
3'b010: y=A|B;
3'b011: y=A^B;
3'b100: y=A+B;
3'b101: y=A-B;
3'b110: y=~A;
3'b111: y=8'hFF;
endcase
end
endmodule
module Q();
wire [7:0]y;
reg [7:0] A,B;
reg [7:0] Sel;
Q1 MO (y, A, B, Sel);
initial#180 $finish;
initial fork
#5 begin A=8'hAA; B=8'h55; end
#10 begin Sel=3'b000; A=8'hAA; B=8'h55; end
#20 begin Sel=3'b001; A=8'hAA; B=8'hAA; end
#30 begin Sel=3'b001; A=8'h55; B=8'h55; end
#40 begin Sel=3'b010; A=8'h55; B=8'h55; end
#50 begin Sel=3'b010; A=8'hAA; B=8'hAA; end
#60 begin Sel=3'b011; A=8'h55; B=8'h55; end
#70 begin Sel=3'b011; A=8'hAA; B=8'h55; end
#80 begin Sel=3'b100; A=8'h55; B=8'h00; end
#90 begin Sel=3'b100; A=8'hAA; B=8'h55; end
#110 begin Sel=3'b101; A=8'hAA; B=8'h55; end
#120 begin Sel=3'b101; A=8'h55; B=8'hAA; end
#130 begin Sel=3'b110; A=8'hFF; end
#140 begin Sel=3'b110; A=8'd0; end
#150 begin Sel=3'b110; A=8'hFF; end
#160 begin Sel=3'b111; end
join
endmodule
But I can not understand what it is doing after module Q()......
Can anyone explain to me? Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
