Lots
Lots
This commit is contained in:
@@ -61,3 +61,48 @@ module ALU(
|
||||
.out(result));
|
||||
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
//module alu_tb();
|
||||
//reg [8:0] a;
|
||||
//reg [8:0] b;
|
||||
//reg [2:0] c;
|
||||
//wire [8:0] d;
|
||||
|
||||
//ALU alu0(
|
||||
//.operand0(a),
|
||||
//.operand1(b),
|
||||
//.opcode(c),
|
||||
//.result(d));
|
||||
|
||||
// initial begin
|
||||
// a = 9'b000000111;
|
||||
// b = 9'b000111000;
|
||||
// c = 3'b000;
|
||||
// #5
|
||||
// a = 9'b000011000;
|
||||
// b = 9'b000011000;
|
||||
// c = 3'b001;
|
||||
// #5
|
||||
// a = 9'b101010100;
|
||||
// b = 9'b010101011;
|
||||
// c = 3'b010;
|
||||
// #5
|
||||
// a = 9'b101010100;
|
||||
// b = 9'b010101000;
|
||||
// c = 3'b011;
|
||||
// #5
|
||||
// a = 9'b000110000;
|
||||
// b = 9'b000111000;
|
||||
// c = 3'b100;
|
||||
// #5
|
||||
// a = 9'b01011000;
|
||||
// c = 3'b101;
|
||||
// #5
|
||||
// a = 9'b00001010;
|
||||
// c = 3'b110;
|
||||
// #5
|
||||
// #5 $finish;
|
||||
|
||||
// end
|
||||
//endmodule
|
||||
|
||||
@@ -900,7 +900,7 @@ module register(input wire clk, reset,
|
||||
Dout = Din;
|
||||
end
|
||||
else begin
|
||||
Dout = 9'bZZZZZZZZZ;
|
||||
Dout = Dout;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -54,3 +54,82 @@ module RegFile(input wire clk, reset,
|
||||
.switch(op1_idx));
|
||||
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
module regFile_tb();
|
||||
reg [8:0] write_d;
|
||||
reg [1:0] w_idx, op0_idx, op1_idx;
|
||||
reg reset;
|
||||
wire [8:0] op0,op1;
|
||||
|
||||
reg clk;
|
||||
initial begin
|
||||
clk = 1'b0;
|
||||
end
|
||||
always begin
|
||||
#5 clk = ~clk; // Period to be determined
|
||||
end
|
||||
|
||||
RegFile regFile0(
|
||||
.clk(clk),
|
||||
.reset(reset),
|
||||
.write_index(w_idx),
|
||||
.op0_idx(op0_idx),
|
||||
.op1_idx(op1_idx),
|
||||
.write_data(write_d),
|
||||
.op0(op0),
|
||||
.op1(op1));
|
||||
|
||||
initial begin
|
||||
reset = 0;
|
||||
#5
|
||||
reset = 1;
|
||||
#5
|
||||
reset = 0;
|
||||
w_idx = 2'b00;
|
||||
op0_idx = 2'b00;
|
||||
op1_idx = 2'b00;
|
||||
write_d = 9'b000000011;
|
||||
#5
|
||||
w_idx = 2'b01;
|
||||
#5
|
||||
w_idx = 2'b10;
|
||||
#5
|
||||
w_idx = 2'b11;
|
||||
#5
|
||||
reset = 0;
|
||||
w_idx = 2'b00;
|
||||
op0_idx = 2'b00;
|
||||
op1_idx = 2'b00;
|
||||
write_d = 9'b001111000;
|
||||
#5
|
||||
reset = 0;
|
||||
w_idx = 2'b01;
|
||||
op0_idx = 2'b00;
|
||||
op1_idx = 2'b01;
|
||||
write_d = 9'b000001111;
|
||||
#5
|
||||
reset = 0;
|
||||
w_idx = 2'b10;
|
||||
op0_idx = 2'b00;
|
||||
op1_idx = 2'b10;
|
||||
write_d = 9'b111000001;
|
||||
#5
|
||||
reset = 0;
|
||||
w_idx = 2'b11;
|
||||
op0_idx = 2'b11;
|
||||
op1_idx = 2'b10;
|
||||
write_d = 9'b100110001;
|
||||
#5
|
||||
reset = 1;
|
||||
w_idx = 2'b00;
|
||||
#5
|
||||
w_idx = 2'b10;
|
||||
#5
|
||||
w_idx = 2'b01;
|
||||
#5
|
||||
w_idx = 2'b11;
|
||||
#5 $finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
Reference in New Issue
Block a user