-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdecoder_tb.v
More file actions
85 lines (72 loc) · 2.26 KB
/
decoder_tb.v
File metadata and controls
85 lines (72 loc) · 2.26 KB
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
79
80
81
82
83
84
85
`include "decoder.v"
// `include "sprf1024x32m4b1_wem.v"
module decoder_tb();
reg clk;
reg [31:0] instruction_i;
wire [20:0] alu_op_o;
wire rs1_sel_o, rs2_sel_o;
wire [2:0] imm_type_o;
wire beq, blt, branchBType_o, branchJAL_o, branchJALR_o;
wire [2:0] dmem_type_o;
wire [3:0] wb_src_o;
wire wb_en_o;
wire instr_illegal_o;
integer count;
// periodic time
initial begin
clk<=0;
count<=0;
forever begin
#1; clk<=~clk;
end
end
always @(posedge clk ) begin
if(count == 0) begin
instruction_i <= 32'h00400093; // addi x1, x0, 4
end
if(count == 1) begin
instruction_i <= 32'hfe628ee3; // beq x5, x6, _start
end
if(count == 2) begin
instruction_i <= 32'hfe629ee3; // beq x5, x6, _start
end
if(count == 3) begin
instruction_i <= 32'hfe62cee3; // blt x5, x6, _start
end
if(count == 4) begin
instruction_i <= 32'hfe62eee3; // bltu x5, x6, _start
end
if(count == 5) begin
instruction_i <= 32'hfe62dee3; // bge x5, x6, _start
end
if(count == 6) begin
instruction_i <= 32'hfe62fee3; // bgeu x5, x6, _start
end
if(count == 20)
$finish(0);
count = count +1;
$display("data is %h", u_decoder.alu_calculation );
end
// =========================================================================
// ============================ testing =============================
// =========================================================================
decoder u_decoder(
.instruction_i(instruction_i),
.alu_op_o(alu_op_o),
.rs1_sel_o(rs1_sel_o),
.rs2_sel_o(rs2_sel_o),
.imm_type_o(imm_type_o),
.branchBType_o(branchBType_o),
.branchJAL_o(branchJAL_o),
.branchJALR_o(branchJALR_o),
.dmem_type_o(dmem_type_o),
.wb_src_o(wb_src_o),
.wb_en_o(wb_en_o),
.instr_illegal_o(instr_illegal_o)
);
// generate waveforms
initial begin
$dumpfile("decoder_tb.vcd");
$dumpvars(0, decoder_tb);
end
endmodule