-
Notifications
You must be signed in to change notification settings - Fork 2
/
I_FETCH_tb.v
62 lines (50 loc) · 1.33 KB
/
I_FETCH_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////
// Company: California State University San Bernardino
// Engineer: Bogdan Kravtsov
//
// Create Date: 13:58:06 10/03/2016
// Module Name: I_FETCH_tb
// Project Name: MIPS
// Description: Testing MIPS FETCH stage implementation in verilog.
//
// Dependencies: I_FETCH.v
//
////////////////////////////////////////////////////////////////////////////////
module I_FETCH_tb;
// Delclare inputs.
reg clk;
reg PCSrc;
reg [31:0] EX_MEM_NPC;
// Declare outputs.
wire [31:0] IF_ID_IR;
wire [31:0] IF_ID_NPC;
// Declare the clock cycle counter.
reg [4:0] clk_cycle;
// Instantiate the FETCH stage module.
I_FETCH fetch(.clk(clk), .PCSrc(PCSrc), .EX_MEM_NPC(EX_MEM_NPC),
.IF_ID_IR(IF_ID_IR), .IF_ID_NPC(IF_ID_NPC));
initial begin
// Initialize inputs.
clk = 0;
PCSrc = 0;
EX_MEM_NPC = 0;
// Initialize clock cycle counter.
clk_cycle = 0;
// Terminate.
#220 $finish;
end
// Clock.
initial begin
forever begin
#10 clk = ~clk;
end
end
// Increment the cycle counter and display data at the end of each cycle.
always @ (posedge clk)
begin
$display("Cylce Number = %0d\tIF_ID_IR = %h\tIF_ID_NPC = %0d",
clk_cycle, IF_ID_IR, IF_ID_NPC);
#10 clk_cycle = clk_cycle + 1;
end
endmodule