Adjusted indentation of testbench code
This commit is contained in:
@@ -10,8 +10,7 @@
|
||||
* Need to allow for signed numbers
|
||||
* Remove subtraction from ALU
|
||||
* Have arithmetic shift left and right
|
||||
* <strike>Uncomment all testbenches</strike>
|
||||
* We can have multiple testbenches active at once
|
||||
* <strike>Uncomment all testbenches</strike> (We can have multiple testbenches active at once)
|
||||
* Bitwise operations do not need a 1-bit implementation, modify 9-bit and keep it only
|
||||
* Comparator needed
|
||||
* Make subtraction more efficient
|
||||
|
||||
@@ -62,7 +62,7 @@ module ALU(
|
||||
|
||||
endmodule
|
||||
|
||||
testbench
|
||||
//testbench
|
||||
module alu_tb();
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
@@ -102,7 +102,7 @@ ALU alu0(
|
||||
a = 9'b00001010;
|
||||
c = 3'b110;
|
||||
#5
|
||||
#5 $finish;
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
|
||||
@@ -20,7 +20,7 @@ reg x;
|
||||
wire y;
|
||||
wire z;
|
||||
|
||||
add_1bit add0(
|
||||
add_1bit tb0(
|
||||
.A(v),
|
||||
.B(w),
|
||||
.Cin(x),
|
||||
@@ -47,6 +47,9 @@ add_1bit add0(
|
||||
v = 1;
|
||||
w = 1;
|
||||
x = 1;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
|
||||
@@ -133,13 +136,12 @@ endmodule
|
||||
|
||||
//testbench
|
||||
module add9bit_tb();
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
reg [8:0] a,b;
|
||||
reg cin;
|
||||
wire [8:0] s;
|
||||
wire cout;
|
||||
|
||||
add_9bit add0(
|
||||
add_9bit tb0(
|
||||
.A(a),
|
||||
.B(b),
|
||||
.Cin(cin),
|
||||
@@ -181,8 +183,7 @@ endmodule
|
||||
|
||||
//testbench
|
||||
module and1bit_tb();
|
||||
reg a;
|
||||
reg b;
|
||||
reg a,b;
|
||||
wire c;
|
||||
|
||||
and_1bit and0(
|
||||
@@ -202,7 +203,8 @@ and_1bit and0(
|
||||
#5
|
||||
a = 1;
|
||||
b = 1;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -261,8 +263,7 @@ endmodule
|
||||
|
||||
//testbench
|
||||
module and9bit_tb();
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
reg [8:0] a,b;
|
||||
wire [8:0] c;
|
||||
|
||||
and_9bit and0(
|
||||
@@ -288,7 +289,8 @@ and_9bit and0(
|
||||
#5
|
||||
a = 9'b000100001;
|
||||
b = 9'b000100001;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -303,13 +305,13 @@ module gen_clock();
|
||||
end
|
||||
endmodule
|
||||
|
||||
testbench
|
||||
//testbench
|
||||
module gen_clock_tb();
|
||||
|
||||
reg clk;
|
||||
gen
|
||||
|
||||
module mux_2_1(input wire switch,
|
||||
module mux_2_1 tb0(
|
||||
input wire switch,
|
||||
input wire [8:0] A,B,
|
||||
output reg [8:0] out);
|
||||
|
||||
@@ -320,17 +322,15 @@ module mux_2_1(input wire switch,
|
||||
default : out = 9'bxxxxxxxxx;
|
||||
endcase
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
module mux_2_1_tb();
|
||||
reg s;
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
reg [8:0] a,b;
|
||||
wire [8:0] c;
|
||||
|
||||
mux_2_1 mux0(
|
||||
mux_2_1 tb0(
|
||||
.switch(s),
|
||||
.A(a),
|
||||
.B(b),
|
||||
@@ -360,7 +360,8 @@ mux_2_1 mux0(
|
||||
s = 1;
|
||||
a = 9'b000010001;
|
||||
b = 9'b000010111;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -384,13 +385,10 @@ endmodule
|
||||
//testbench
|
||||
module mux_4_1_tb();
|
||||
reg [1:0] s;
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
reg [8:0] c;
|
||||
reg [8:0] d;
|
||||
reg [8:0] a,b,c,d;
|
||||
wire [8:0] e;
|
||||
|
||||
mux_4_1 mux1(
|
||||
mux_4_1 tb0(
|
||||
.switch(s),
|
||||
.A(a),
|
||||
.B(b),
|
||||
@@ -422,7 +420,8 @@ mux_4_1 mux1(
|
||||
b = 9'b000111100;
|
||||
c = 9'b001001001;
|
||||
d = 9'b100000000;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -445,23 +444,15 @@ module mux_8_1(
|
||||
default : out = 9'bxxxxxxxxx;
|
||||
endcase
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
module mux_8_1_tb();
|
||||
reg [2:0] s;
|
||||
reg [8:0] a;
|
||||
reg [8:0] b;
|
||||
reg [8:0] c;
|
||||
reg [8:0] d;
|
||||
reg [8:0] e;
|
||||
reg [8:0] f;
|
||||
reg [8:0] g;
|
||||
reg [8:0] h;
|
||||
reg [8:0] a,b,c,d,e,f,g,h;
|
||||
wire [8:0] out;
|
||||
|
||||
mux_8_1 mux1(
|
||||
mux_8_1 tb0(
|
||||
.switch(s),
|
||||
.A(a),
|
||||
.B(b),
|
||||
@@ -497,7 +488,8 @@ mux_8_1 mux1(
|
||||
s = 3'b110;
|
||||
#5
|
||||
s = 3'b111;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -564,7 +556,8 @@ nor_1bit nor0(
|
||||
#5
|
||||
a = 1;
|
||||
b = 1;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -650,7 +643,8 @@ nor_9bit nor0(
|
||||
#5
|
||||
a = 9'b000100001;
|
||||
b = 9'b000100001;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -677,7 +671,8 @@ not_1bit not0(
|
||||
a = 0;
|
||||
#5
|
||||
a = 1;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
@@ -747,10 +742,10 @@ wire [8:0] b;
|
||||
a = 9'b111111111;
|
||||
#5
|
||||
a = 9'b100000001;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module or_1bit(
|
||||
@@ -785,10 +780,10 @@ wire c;
|
||||
#5
|
||||
a = 1;
|
||||
b = 1;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module or_9bit(
|
||||
@@ -881,13 +876,14 @@ wire [8:0] c;
|
||||
#5
|
||||
a = 9'b000000000;
|
||||
b = 9'b000010000;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module register(input wire clk, reset,
|
||||
module register(
|
||||
input wire clk, reset,
|
||||
input wire [1:0] En,
|
||||
input wire [8:0] Din,
|
||||
output reg [8:0] Dout);
|
||||
@@ -903,7 +899,6 @@ module register(input wire clk, reset,
|
||||
Dout = Dout;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
@@ -957,10 +952,10 @@ wire [8:0] Dout;
|
||||
clk = 1;
|
||||
#5
|
||||
clk = 0;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module shift_logical_left(
|
||||
@@ -994,10 +989,10 @@ wire [8:0] b;
|
||||
a = 9'b111111111;
|
||||
#5
|
||||
a = 9'b100000001;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module shift_logical_right(
|
||||
@@ -1031,10 +1026,10 @@ wire [8:0] b;
|
||||
a = 9'b111111111;
|
||||
#5
|
||||
a = 9'b100000001;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module sub_9bit(
|
||||
@@ -1098,7 +1093,6 @@ wire [8:0] c;
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
module twos_compliment_9bit(
|
||||
@@ -1146,5 +1140,4 @@ wire [8:0] b;
|
||||
$finish;
|
||||
|
||||
end
|
||||
|
||||
endmodule
|
||||
@@ -33,11 +33,9 @@ endmodule
|
||||
//testbench
|
||||
module fetchUnit_tb();
|
||||
reg [8:0] addr_in;
|
||||
reg opidx;
|
||||
reg reset;
|
||||
reg opidx,reset,clk;
|
||||
wire [8:0] addr_out;
|
||||
|
||||
reg clk;
|
||||
initial begin
|
||||
clk = 1'b0;
|
||||
end
|
||||
@@ -45,7 +43,7 @@ wire [8:0] addr_out;
|
||||
#5 clk = ~clk; // Period to be determined
|
||||
end
|
||||
|
||||
FetchUnit fetchUnit0(
|
||||
FetchUnit tb0(
|
||||
.clk(clk),
|
||||
.reset(reset),
|
||||
.op_idx(opidx),
|
||||
|
||||
@@ -59,10 +59,9 @@ endmodule
|
||||
module regFile_tb();
|
||||
reg [8:0] write_d;
|
||||
reg [1:0] w_idx, op0_idx, op1_idx;
|
||||
reg reset;
|
||||
reg reset,clk;
|
||||
wire [8:0] op0,op1;
|
||||
|
||||
reg clk;
|
||||
initial begin
|
||||
clk = 1'b0;
|
||||
end
|
||||
@@ -129,7 +128,8 @@ RegFile regFile0(
|
||||
w_idx = 2'b01;
|
||||
#5
|
||||
w_idx = 2'b11;
|
||||
#5 $finish;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
Reference in New Issue
Block a user