0 évaluation0% ont trouvé ce document utile (0 vote)
20 vues3 pages
This document contains code for an ALU module and test bench in Verilog. The ALU module defines inputs and outputs and uses a case statement to perform different operations on inputs a and b based on the value of the select signal sel. The test bench initializes input values for a, b and sel over multiple timesteps and tests the ALU module.
This document contains code for an ALU module and test bench in Verilog. The ALU module defines inputs and outputs and uses a case statement to perform different operations on inputs a and b based on the value of the select signal sel. The test bench initializes input values for a, b and sel over multiple timesteps and tests the ALU module.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOCX, PDF, TXT ou lisez en ligne sur Scribd
This document contains code for an ALU module and test bench in Verilog. The ALU module defines inputs and outputs and uses a case statement to perform different operations on inputs a and b based on the value of the select signal sel. The test bench initializes input values for a, b and sel over multiple timesteps and tests the ALU module.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOCX, PDF, TXT ou lisez en ligne sur Scribd
// Inputs reg [7:0] a; reg [7:0] b; reg [3:0] sel; // Outputs wire [7:0] z; // Instantiate the Unit Under Test (UUT) add00 uut ( .a(a), .b(b), .sel(sel), .z(z) ); initial begin // Initialize Inputs a = 8'b00000001; b = 8'b00001000; sel = 4'b0000; #10 a = 8'b01000101; b = 8'b00000110; sel = 4'b0001; #10 a = 8'b00000001; b = 8'b11000001; sel = 4'b0010; #10 a = 8'b10001001; b = 8'b00000111; sel = 4'b0011; #10 a = 8'b01010101; b = 8'b10010001; sel = 4'b0100; #10 a = 8'b01001001; b = 8'b10101010; sel = 4'b0101; #10 a = 8'b10101001; b = 8'b00000000; sel = 4'b0110; #10 a = 8'b10001010; b = 8'b00000000; sel = 4'b0111; #10 a = 8'b10101101; b = 8'b10011100; sel = 4'b1000; #10 a = 8'b00010001; b = 8'b01010001; sel = 4'b1001; #10 a = 8'b00100001; b = 8'b10100110; sel = 4'b1010; #10 a = 8'b11101001; b = 8'b00000000; sel = 4'b1011; #10 a = 8'b00111101; b = 8'b00000000; sel = 4'b1100;
#10 a = 8'b01001001; b = 8'b00000000; sel = 4'b1101;
#10 a = 8'b10100001; b = 8'b00000000; sel = 4'b1110; #10 $stop; end endmodule