-
Notifications
You must be signed in to change notification settings - Fork 0
/
IF_testbench.v
77 lines (62 loc) · 1.84 KB
/
IF_testbench.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
`include "TwotoOnemux.v"
`include "Program_Counter.v"
`include "InstructionMemory.v"
`include "TwoByteAdder.v"
module IMFixture;
//General
reg clk, rst;
wire [15:0] PC_Out;
//Multiplexer
reg [15:0] IF_Mux_A;
reg [15:0] IF_Mux_B;
reg [15:0] IF_Mux_Sel;
wire [15:0] IF_Mux_Out;
TwotoOnemux my_mux( .a(PC_Out), .b(IF_Mux_B), .s(IF_Mux_Sel), .out(IF_Mux_Out) );
//Program Counter
PC my_pc(.in(IF_Mux_Out), .out(PC_Out), .clk(clk), .rst(rst));
//Instruction Memory
wire [15:0] IM_Out;
IM im1(.data_in(PC_Out), .data_out(IM_Out), .clk(clk), .rst(rst));
//IF Adder
wire [15:0] TwoByteAdderOut;
TwoByteAdder add1(.A(PC_Out), .R(TwoByteAdderOut));
initial
begin
$display("Time\ TwoByteAdderOut \IF_Mux_B \IF_Mux_Sel IF_Mux_Out PC_Out IM_Out \clk \rst");
$display("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
$monitor("%0d\t%b\t%b\t%b\t%b\t%b\t%b\t%b\t%b", $time, TwoByteAdderOut, IF_Mux_B, IF_Mux_Sel, IF_Mux_Out, PC_Out, IM_Out, clk, rst);
end
initial
begin
rst = 0;
#10
rst = 1;
IF_Mux_B = 0; IF_Mux_Sel= 1'b1; //1 will select top mux input on Datapath Diagram
#10;
IF_Mux_B = 1; IF_Mux_Sel= 1'b1;
#10;
IF_Mux_B = 2; IF_Mux_Sel= 1'b1;
#10;
IF_Mux_B = 3; IF_Mux_Sel= 1'b1;
#10;
IF_Mux_B = 4; IF_Mux_Sel= 1'b1;
#10;
IF_Mux_B = 5; IF_Mux_Sel= 1'b1;
#10;
IF_Mux_B = 6; IF_Mux_Sel= 1'b1;
#20;
IF_Mux_B = 7; IF_Mux_Sel= 1'b1;
#20;
end
// Setup the clock to toggle every 10 time units
initial
begin
clk = 1'b0;
forever #5 clk = ~clk;
end
// Finish the simulation at time 200
initial
begin
#100 $finish;
end
endmodule