-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu_tb.v
47 lines (36 loc) · 1.02 KB
/
cpu_tb.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
`include "multicycle.v"
`include "ram.v"
`include "rom.v"
`timescale 1ns/1ps
module cpu_tb();
//internal nets
reg clk, rst;
wire MemRead, MemWrite;
wire [31:0] instr, dReadData, PC, dAddress, dWriteData, WriteBackData;
//instruction mem instatiation
INSTRUCTION_MEMORY instrMem (.clk(clk), .addr(PC/*32->9 bits*/), .dout(instr));
//mylticycle instatiation
multicycle mc(.clk(clk), .rst(rst), .instr(instr), .dReadData(dReadData), .MemRead(MemRead),
.MemWrite(MemWrite), .PC(PC), .dAddress(dAddress), .dWriteData(dWriteData),
.WriteBackData(WriteBackData));
//data mem instatiation
DATA_MEMORY dataMem(.clk(clk), .we(MemWrite), .addr(dAddress/*32->9 bits*/), .din(dWriteData),
.dout(dReadData));
//ATTENTION: Missing input for control signal MemRead
//Reset generator
initial
begin : ResetGenerator
rst = 1'b1;
#5 rst = 1'b0;
end
//Clock generator
initial
clk = 1'b1;
always
begin
#10 clk = ~clk;
end
//Simulation stopper
initial
#2300 $stop;
endmodule