File size: 2,089 Bytes
78c261f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | module control_unit_tb();
reg [1:0] instr_type;
reg [4:0] opcode;
wire reg_b;
wire reg_wr;
wire ext_op;
wire [1:0] alu_src;
wire [2:0] alu_op;
wire mem_read;
wire mem_write;
wire wb_src;
control_unit control_unit(
.instr_type(instr_type),
.opcode(opcode),
.reg_b(reg_b),
.reg_wr(reg_wr),
.ext_op(ext_op),
.alu_src(alu_src),
.alu_op(alu_op),
.mem_read(mem_read),
.mem_write(mem_write),
.wb_src(wb_src)
);
initial begin
instr_type = 2'b00;
opcode = 5'b00000; // AND
#10;
instr_type = 2'b00;
opcode = 5'b00001; // ADD
#10;
instr_type = 2'b00;
opcode = 5'b00010; // SUB
#10;
instr_type = 2'b00;
opcode = 5'b00011; // CMP
#10;
instr_type = 2'b01;
opcode = 5'b00000;// ANDI
#10;
instr_type = 2'b01;
opcode = 5'b00001; // ADDI
#10;
instr_type = 2'b01;
opcode = 5'b00010; // LW
#10;
instr_type = 2'b01;
opcode = 5'b00011; // SW
#10;
instr_type = 2'b01;
opcode = 5'b00100; // BEQ
#10;
instr_type = 2'b10;
opcode = 5'b00000; // J
#10;
instr_type = 2'b10;
opcode = 5'b00001; // JAL
#10;
instr_type = 2'b11;
opcode = 5'b00000; // SLL
#10;
instr_type = 2'b11;
opcode = 5'b00001; // SLR
#10;
instr_type = 2'b11;
opcode = 5'b00010; // SLLV
#10;
instr_type = 2'b11;
opcode = 5'b00011; // SLRV
#10;
#30 $finish;
end
initial begin
// monitor
$monitor("instr_type = %b, opcode = %b, reg_b = %b, reg_wr = %b, ext_op = %b, alu_src = %b, alu_op = %b, mem_read = %b, mem_write = %b, wb_src = %b\n", instr_type, opcode, reg_b, reg_wr, ext_op, alu_src, alu_op, mem_read, mem_write, wb_src);
end
endmodule |