-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbench_top_cpu.v
170 lines (158 loc) · 3.21 KB
/
testbench_top_cpu.v
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
`timescale 1ns / 1ps
module testbench_top_cpu;
// Inputs
reg clk;
// Outputs
wire PCSrcD;
wire [31:0] PCPlus4F;
wire [31:0] PCBranch;
wire [31:0] PCBranchD;
wire [31:0] PC_;
wire [31:0] PCF;
wire [31:0] InstrD;
wire [31:0] PCPlus4D;
wire RegWriteD;
wire MemtoRegD;
wire MemWriteD;
wire [3:0] ALUControlD;
wire ALUSrcD;
wire ALUSrcNoExD;
wire RegDstD;
wire BranchED;
wire BranchNED;
wire Branch2RegD;
wire Branch2ValueD;
wire [31:0] RD1;
wire [31:0] RD2;
wire [31:0] RD1D;
wire [31:0] RD2D;
wire [31:0] SignImmD;
wire [31:0] NoSignImmD;
wire [31:0] SignImmLS2D;
wire RegWriteE;
wire MemtoRegE;
wire MemWriteE;
wire [3:0] ALUControlE;
wire ALUSrcE;
wire ALUSrcNoExE;
wire RegDstE;
wire [31:0] RD1E;
wire [31:0] RD2E;
wire [4:0] RsE;
wire [4:0] RtE;
wire [4:0] RdE;
wire [31:0] SignImmE;
wire [31:0] NoSignImmE;
wire [31:0] SrcAE;
wire [31:0] SrcBE;
wire [31:0] WriteDataE;
wire [4:0] WriteRegE;
wire [31:0] ALUOutE;
wire RegWriteM;
wire MemtoRegM;
wire MemWriteM;
wire [31:0] ALUOutM;
wire [31:0] WriteDataM;
wire [4:0] WriteRegM;
wire RegWriteW;
wire MemtoRegW;
wire [31:0] ReadDataW;
wire [31:0] ALUOutW;
wire [4:0] WriteRegW;
wire [31:0] ResultW;
wire StallF;
wire StallD;
wire ForwardAD;
wire ForwardBD;
wire ForwardADN1;
wire ForwardBDN1;
wire ForwardADN2;
wire ForwardBDN2;
wire FlushE;
wire [1:0] ForwardAE;
wire [1:0] ForwardBE;
// Instantiate the Unit Under Test (UUT)
top_cpu uut (
.clk(clk),
.PCSrcD(PCSrcD),
.PCPlus4F(PCPlus4F),
.PCBranch(PCBranch),
.PCBranchD(PCBranchD),
.PC_(PC_),
.PCF(PCF),
.InstrD(InstrD),
.PCPlus4D(PCPlus4D),
.RegWriteD(RegWriteD),
.MemtoRegD(MemtoRegD),
.MemWriteD(MemWriteD),
.ALUControlD(ALUControlD),
.ALUSrcD(ALUSrcD),
.ALUSrcNoExD(ALUSrcNoExD),
.RegDstD(RegDstD),
.BranchED(BranchED),
.BranchNED(BranchNED),
.Branch2RegD(Branch2RegD),
.Branch2ValueD(Branch2ValueD),
.RD1(RD1),
.RD2(RD2),
.RD1D(RD1D),
.RD2D(RD2D),
.SignImmD(SignImmD),
.NoSignImmD(NoSignImmD),
.SignImmLS2D(SignImmLS2D),
.RegWriteE(RegWriteE),
.MemtoRegE(MemtoRegE),
.MemWriteE(MemWriteE),
.ALUControlE(ALUControlE),
.ALUSrcE(ALUSrcE),
.ALUSrcNoExE(ALUSrcNoExE),
.RegDstE(RegDstE),
.RD1E(RD1E),
.RD2E(RD2E),
.RsE(RsE),
.RtE(RtE),
.RdE(RdE),
.SignImmE(SignImmE),
.NoSignImmE(NoSignImmE),
.SrcAE(SrcAE),
.SrcBE(SrcBE),
.WriteDataE(WriteDataE),
.WriteRegE(WriteRegE),
.ALUOutE(ALUOutE),
.RegWriteM(RegWriteM),
.MemtoRegM(MemtoRegM),
.MemWriteM(MemWriteM),
.ALUOutM(ALUOutM),
.WriteDataM(WriteDataM),
.WriteRegM(WriteRegM),
.RegWriteW(RegWriteW),
.MemtoRegW(MemtoRegW),
.ReadDataW(ReadDataW),
.ALUOutW(ALUOutW),
.WriteRegW(WriteRegW),
.ResultW(ResultW),
.StallF(StallF),
.StallD(StallD),
.ForwardAD(ForwardAD),
.ForwardBD(ForwardBD),
.ForwardADN1(ForwardADN1),
.ForwardBDN1(ForwardBDN1),
.ForwardADN2(ForwardADN2),
.ForwardBDN2(ForwardBDN2),
.FlushE(FlushE),
.ForwardAE(ForwardAE),
.ForwardBE(ForwardBE)
);
initial begin
// Initialize Inputs
clk = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here...
end
always
begin
#10;
clk=~clk;
end
endmodule