Adjusted indentation of testbench code
This commit is contained in:
@@ -10,8 +10,7 @@
|
|||||||
* Need to allow for signed numbers
|
* Need to allow for signed numbers
|
||||||
* Remove subtraction from ALU
|
* Remove subtraction from ALU
|
||||||
* Have arithmetic shift left and right
|
* Have arithmetic shift left and right
|
||||||
* <strike>Uncomment all testbenches</strike>
|
* <strike>Uncomment all testbenches</strike> (We can have multiple testbenches active at once)
|
||||||
* We can have multiple testbenches active at once
|
|
||||||
* Bitwise operations do not need a 1-bit implementation, modify 9-bit and keep it only
|
* Bitwise operations do not need a 1-bit implementation, modify 9-bit and keep it only
|
||||||
* Comparator needed
|
* Comparator needed
|
||||||
* Make subtraction more efficient
|
* Make subtraction more efficient
|
||||||
|
|||||||
@@ -62,18 +62,18 @@ module ALU(
|
|||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
testbench
|
//testbench
|
||||||
module alu_tb();
|
module alu_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
reg [8:0] b;
|
reg [8:0] b;
|
||||||
reg [2:0] c;
|
reg [2:0] c;
|
||||||
wire [8:0] d;
|
wire [8:0] d;
|
||||||
|
|
||||||
ALU alu0(
|
ALU alu0(
|
||||||
.operand0(a),
|
.operand0(a),
|
||||||
.operand1(b),
|
.operand1(b),
|
||||||
.opcode(c),
|
.opcode(c),
|
||||||
.result(d));
|
.result(d));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 9'b000000111;
|
a = 9'b000000111;
|
||||||
@@ -102,7 +102,7 @@ ALU alu0(
|
|||||||
a = 9'b00001010;
|
a = 9'b00001010;
|
||||||
c = 3'b110;
|
c = 3'b110;
|
||||||
#5
|
#5
|
||||||
#5 $finish;
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module add1bit_tb();
|
module add1bit_tb();
|
||||||
reg v;
|
reg v;
|
||||||
reg w;
|
reg w;
|
||||||
reg x;
|
reg x;
|
||||||
wire y;
|
wire y;
|
||||||
wire z;
|
wire z;
|
||||||
|
|
||||||
add_1bit add0(
|
add_1bit tb0(
|
||||||
.A(v),
|
.A(v),
|
||||||
.B(w),
|
.B(w),
|
||||||
.Cin(x),
|
.Cin(x),
|
||||||
@@ -47,6 +47,9 @@ add_1bit add0(
|
|||||||
v = 1;
|
v = 1;
|
||||||
w = 1;
|
w = 1;
|
||||||
x = 1;
|
x = 1;
|
||||||
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
@@ -133,13 +136,12 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module add9bit_tb();
|
module add9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a,b;
|
||||||
reg [8:0] b;
|
reg cin;
|
||||||
reg cin;
|
wire [8:0] s;
|
||||||
wire [8:0] s;
|
wire cout;
|
||||||
wire cout;
|
|
||||||
|
|
||||||
add_9bit add0(
|
add_9bit tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.Cin(cin),
|
.Cin(cin),
|
||||||
@@ -181,14 +183,13 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module and1bit_tb();
|
module and1bit_tb();
|
||||||
reg a;
|
reg a,b;
|
||||||
reg b;
|
wire c;
|
||||||
wire c;
|
|
||||||
|
|
||||||
and_1bit and0(
|
and_1bit and0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c));
|
.C(c));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 0;
|
a = 0;
|
||||||
@@ -202,7 +203,8 @@ and_1bit and0(
|
|||||||
#5
|
#5
|
||||||
a = 1;
|
a = 1;
|
||||||
b = 1;
|
b = 1;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -261,14 +263,13 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module and9bit_tb();
|
module and9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a,b;
|
||||||
reg [8:0] b;
|
wire [8:0] c;
|
||||||
wire [8:0] c;
|
|
||||||
|
|
||||||
and_9bit and0(
|
and_9bit and0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c));
|
.C(c));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 9'b000000000;
|
a = 9'b000000000;
|
||||||
@@ -288,7 +289,8 @@ and_9bit and0(
|
|||||||
#5
|
#5
|
||||||
a = 9'b000100001;
|
a = 9'b000100001;
|
||||||
b = 9'b000100001;
|
b = 9'b000100001;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -303,13 +305,13 @@ module gen_clock();
|
|||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
testbench
|
//testbench
|
||||||
module gen_clock_tb();
|
module gen_clock_tb();
|
||||||
|
reg clk;
|
||||||
reg clk;
|
|
||||||
gen
|
gen
|
||||||
|
|
||||||
module mux_2_1(input wire switch,
|
module mux_2_1 tb0(
|
||||||
|
input wire switch,
|
||||||
input wire [8:0] A,B,
|
input wire [8:0] A,B,
|
||||||
output reg [8:0] out);
|
output reg [8:0] out);
|
||||||
|
|
||||||
@@ -320,21 +322,19 @@ module mux_2_1(input wire switch,
|
|||||||
default : out = 9'bxxxxxxxxx;
|
default : out = 9'bxxxxxxxxx;
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module mux_2_1_tb();
|
module mux_2_1_tb();
|
||||||
reg s;
|
reg s;
|
||||||
reg [8:0] a;
|
reg [8:0] a,b;
|
||||||
reg [8:0] b;
|
wire [8:0] c;
|
||||||
wire [8:0] c;
|
|
||||||
|
|
||||||
mux_2_1 mux0(
|
mux_2_1 tb0(
|
||||||
.switch(s),
|
.switch(s),
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.out(c));
|
.out(c));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
s = 0;
|
s = 0;
|
||||||
@@ -360,7 +360,8 @@ mux_2_1 mux0(
|
|||||||
s = 1;
|
s = 1;
|
||||||
a = 9'b000010001;
|
a = 9'b000010001;
|
||||||
b = 9'b000010111;
|
b = 9'b000010111;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -383,20 +384,17 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module mux_4_1_tb();
|
module mux_4_1_tb();
|
||||||
reg [1:0] s;
|
reg [1:0] s;
|
||||||
reg [8:0] a;
|
reg [8:0] a,b,c,d;
|
||||||
reg [8:0] b;
|
wire [8:0] e;
|
||||||
reg [8:0] c;
|
|
||||||
reg [8:0] d;
|
|
||||||
wire [8:0] e;
|
|
||||||
|
|
||||||
mux_4_1 mux1(
|
mux_4_1 tb0(
|
||||||
.switch(s),
|
.switch(s),
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c),
|
.C(c),
|
||||||
.D(d),
|
.D(d),
|
||||||
.out(e));
|
.out(e));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
s = 2'b00;
|
s = 2'b00;
|
||||||
@@ -422,7 +420,8 @@ mux_4_1 mux1(
|
|||||||
b = 9'b000111100;
|
b = 9'b000111100;
|
||||||
c = 9'b001001001;
|
c = 9'b001001001;
|
||||||
d = 9'b100000000;
|
d = 9'b100000000;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -445,33 +444,25 @@ module mux_8_1(
|
|||||||
default : out = 9'bxxxxxxxxx;
|
default : out = 9'bxxxxxxxxx;
|
||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module mux_8_1_tb();
|
module mux_8_1_tb();
|
||||||
reg [2:0] s;
|
reg [2:0] s;
|
||||||
reg [8:0] a;
|
reg [8:0] a,b,c,d,e,f,g,h;
|
||||||
reg [8:0] b;
|
wire [8:0] out;
|
||||||
reg [8:0] c;
|
|
||||||
reg [8:0] d;
|
|
||||||
reg [8:0] e;
|
|
||||||
reg [8:0] f;
|
|
||||||
reg [8:0] g;
|
|
||||||
reg [8:0] h;
|
|
||||||
wire [8:0] out;
|
|
||||||
|
|
||||||
mux_8_1 mux1(
|
mux_8_1 tb0(
|
||||||
.switch(s),
|
.switch(s),
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c),
|
.C(c),
|
||||||
.D(d),
|
.D(d),
|
||||||
.E(e),
|
.E(e),
|
||||||
.F(f),
|
.F(f),
|
||||||
.G(g),
|
.G(g),
|
||||||
.H(h),
|
.H(h),
|
||||||
.out(out));
|
.out(out));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
s = 3'b000;
|
s = 3'b000;
|
||||||
@@ -497,7 +488,8 @@ mux_8_1 mux1(
|
|||||||
s = 3'b110;
|
s = 3'b110;
|
||||||
#5
|
#5
|
||||||
s = 3'b111;
|
s = 3'b111;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -543,14 +535,14 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module nor_1bit_tb();
|
module nor_1bit_tb();
|
||||||
reg a;
|
reg a;
|
||||||
reg b;
|
reg b;
|
||||||
wire c;
|
wire c;
|
||||||
|
|
||||||
nor_1bit nor0(
|
nor_1bit nor0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c));
|
.C(c));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 0;
|
a = 0;
|
||||||
@@ -564,7 +556,8 @@ nor_1bit nor0(
|
|||||||
#5
|
#5
|
||||||
a = 1;
|
a = 1;
|
||||||
b = 1;
|
b = 1;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -623,14 +616,14 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module nor_9bit_tb();
|
module nor_9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
reg [8:0] b;
|
reg [8:0] b;
|
||||||
wire [8:0] c;
|
wire [8:0] c;
|
||||||
|
|
||||||
nor_9bit nor0(
|
nor_9bit nor0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b),
|
.B(b),
|
||||||
.C(c));
|
.C(c));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 9'b000000000;
|
a = 9'b000000000;
|
||||||
@@ -650,7 +643,8 @@ nor_9bit nor0(
|
|||||||
#5
|
#5
|
||||||
a = 9'b000100001;
|
a = 9'b000100001;
|
||||||
b = 9'b000100001;
|
b = 9'b000100001;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -666,18 +660,19 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module not_1bit_tb();
|
module not_1bit_tb();
|
||||||
reg a;
|
reg a;
|
||||||
wire b;
|
wire b;
|
||||||
|
|
||||||
not_1bit not0(
|
not_1bit not0(
|
||||||
.A(a),
|
.A(a),
|
||||||
.B(b));
|
.B(b));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
a = 0;
|
a = 0;
|
||||||
#5
|
#5
|
||||||
a = 1;
|
a = 1;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
@@ -726,8 +721,8 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module not_9bit_tb();
|
module not_9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
wire [8:0] b;
|
wire [8:0] b;
|
||||||
|
|
||||||
not_9bit not0(
|
not_9bit not0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -747,10 +742,10 @@ wire [8:0] b;
|
|||||||
a = 9'b111111111;
|
a = 9'b111111111;
|
||||||
#5
|
#5
|
||||||
a = 9'b100000001;
|
a = 9'b100000001;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module or_1bit(
|
module or_1bit(
|
||||||
@@ -764,9 +759,9 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module or_1bit_tb();
|
module or_1bit_tb();
|
||||||
reg a;
|
reg a;
|
||||||
reg b;
|
reg b;
|
||||||
wire c;
|
wire c;
|
||||||
|
|
||||||
or_1bit or0(
|
or_1bit or0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -785,10 +780,10 @@ wire c;
|
|||||||
#5
|
#5
|
||||||
a = 1;
|
a = 1;
|
||||||
b = 1;
|
b = 1;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module or_9bit(
|
module or_9bit(
|
||||||
@@ -845,9 +840,9 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module or_9bit_tb();
|
module or_9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
reg [8:0] b;
|
reg [8:0] b;
|
||||||
wire [8:0] c;
|
wire [8:0] c;
|
||||||
|
|
||||||
or_9bit tb0(
|
or_9bit tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -881,13 +876,14 @@ wire [8:0] c;
|
|||||||
#5
|
#5
|
||||||
a = 9'b000000000;
|
a = 9'b000000000;
|
||||||
b = 9'b000010000;
|
b = 9'b000010000;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module register(input wire clk, reset,
|
module register(
|
||||||
|
input wire clk, reset,
|
||||||
input wire [1:0] En,
|
input wire [1:0] En,
|
||||||
input wire [8:0] Din,
|
input wire [8:0] Din,
|
||||||
output reg [8:0] Dout);
|
output reg [8:0] Dout);
|
||||||
@@ -903,15 +899,14 @@ module register(input wire clk, reset,
|
|||||||
Dout = Dout;
|
Dout = Dout;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module register_tb();
|
module register_tb();
|
||||||
reg clk,reset;
|
reg clk,reset;
|
||||||
reg [1:0] En;
|
reg [1:0] En;
|
||||||
reg [8:0] Din;
|
reg [8:0] Din;
|
||||||
wire [8:0] Dout;
|
wire [8:0] Dout;
|
||||||
|
|
||||||
register tb0(
|
register tb0(
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
@@ -957,10 +952,10 @@ wire [8:0] Dout;
|
|||||||
clk = 1;
|
clk = 1;
|
||||||
#5
|
#5
|
||||||
clk = 0;
|
clk = 0;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module shift_logical_left(
|
module shift_logical_left(
|
||||||
@@ -973,8 +968,8 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module shift_logical_left_tb();
|
module shift_logical_left_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
wire [8:0] b;
|
wire [8:0] b;
|
||||||
|
|
||||||
shift_logical_left tb0(
|
shift_logical_left tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -994,10 +989,10 @@ wire [8:0] b;
|
|||||||
a = 9'b111111111;
|
a = 9'b111111111;
|
||||||
#5
|
#5
|
||||||
a = 9'b100000001;
|
a = 9'b100000001;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module shift_logical_right(
|
module shift_logical_right(
|
||||||
@@ -1010,8 +1005,8 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module shift_logical_right_tb();
|
module shift_logical_right_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
wire [8:0] b;
|
wire [8:0] b;
|
||||||
|
|
||||||
shift_logical_right tb0(
|
shift_logical_right tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -1031,10 +1026,10 @@ wire [8:0] b;
|
|||||||
a = 9'b111111111;
|
a = 9'b111111111;
|
||||||
#5
|
#5
|
||||||
a = 9'b100000001;
|
a = 9'b100000001;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module sub_9bit(
|
module sub_9bit(
|
||||||
@@ -1058,9 +1053,9 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module sub_9bit_tb();
|
module sub_9bit_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
reg [8:0] b;
|
reg [8:0] b;
|
||||||
wire [8:0] c;
|
wire [8:0] c;
|
||||||
|
|
||||||
sub_9bit tb0(
|
sub_9bit tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -1098,7 +1093,6 @@ wire [8:0] c;
|
|||||||
$finish;
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module twos_compliment_9bit(
|
module twos_compliment_9bit(
|
||||||
@@ -1121,8 +1115,8 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module twos_compliment_tb();
|
module twos_compliment_tb();
|
||||||
reg [8:0] a;
|
reg [8:0] a;
|
||||||
wire [8:0] b;
|
wire [8:0] b;
|
||||||
|
|
||||||
twos_compliment_9bit tb0(
|
twos_compliment_9bit tb0(
|
||||||
.A(a),
|
.A(a),
|
||||||
@@ -1146,5 +1140,4 @@ wire [8:0] b;
|
|||||||
$finish;
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
@@ -32,12 +32,10 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module fetchUnit_tb();
|
module fetchUnit_tb();
|
||||||
reg [8:0] addr_in;
|
reg [8:0] addr_in;
|
||||||
reg opidx;
|
reg opidx,reset,clk;
|
||||||
reg reset;
|
wire [8:0] addr_out;
|
||||||
wire [8:0] addr_out;
|
|
||||||
|
|
||||||
reg clk;
|
|
||||||
initial begin
|
initial begin
|
||||||
clk = 1'b0;
|
clk = 1'b0;
|
||||||
end
|
end
|
||||||
@@ -45,12 +43,12 @@ wire [8:0] addr_out;
|
|||||||
#5 clk = ~clk; // Period to be determined
|
#5 clk = ~clk; // Period to be determined
|
||||||
end
|
end
|
||||||
|
|
||||||
FetchUnit fetchUnit0(
|
FetchUnit tb0(
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.op_idx(opidx),
|
.op_idx(opidx),
|
||||||
.AddrIn(addr_in),
|
.AddrIn(addr_in),
|
||||||
.AddrOut(addr_out));
|
.AddrOut(addr_out));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -57,12 +57,11 @@ endmodule
|
|||||||
|
|
||||||
//testbench
|
//testbench
|
||||||
module regFile_tb();
|
module regFile_tb();
|
||||||
reg [8:0] write_d;
|
reg [8:0] write_d;
|
||||||
reg [1:0] w_idx, op0_idx, op1_idx;
|
reg [1:0] w_idx, op0_idx, op1_idx;
|
||||||
reg reset;
|
reg reset,clk;
|
||||||
wire [8:0] op0,op1;
|
wire [8:0] op0,op1;
|
||||||
|
|
||||||
reg clk;
|
|
||||||
initial begin
|
initial begin
|
||||||
clk = 1'b0;
|
clk = 1'b0;
|
||||||
end
|
end
|
||||||
@@ -70,15 +69,15 @@ wire [8:0] op0,op1;
|
|||||||
#5 clk = ~clk; // Period to be determined
|
#5 clk = ~clk; // Period to be determined
|
||||||
end
|
end
|
||||||
|
|
||||||
RegFile regFile0(
|
RegFile regFile0(
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.write_index(w_idx),
|
.write_index(w_idx),
|
||||||
.op0_idx(op0_idx),
|
.op0_idx(op0_idx),
|
||||||
.op1_idx(op1_idx),
|
.op1_idx(op1_idx),
|
||||||
.write_data(write_d),
|
.write_data(write_d),
|
||||||
.op0(op0),
|
.op0(op0),
|
||||||
.op1(op1));
|
.op1(op1));
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
reset = 0;
|
reset = 0;
|
||||||
@@ -129,7 +128,8 @@ RegFile regFile0(
|
|||||||
w_idx = 2'b01;
|
w_idx = 2'b01;
|
||||||
#5
|
#5
|
||||||
w_idx = 2'b11;
|
w_idx = 2'b11;
|
||||||
#5 $finish;
|
#5
|
||||||
|
$finish;
|
||||||
|
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
Reference in New Issue
Block a user