-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpc_tb.v
72 lines (55 loc) · 1.16 KB
/
pc_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
62
63
64
65
66
67
68
69
70
71
`timescale 1ns / 1ps
module pc_tb;
// Testbench signals
reg clk;
reg Cp;
reg clr;
reg Ep;
wire [3:0] bus;
// Instantiate the PC module
pc uut (
.bus(bus),
.clk(clk),
.Cp(Cp),
.clr(clr),
.Ep(Ep)
);
// Clock generation
always begin
#5 clk = ~clk; // Toggle clock every 5ns
end
// Test sequence
initial begin
// Initialize signals
clk = 0;
Cp = 0;
clr = 0;
Ep = 0;
// Apply reset (clear the flip-flops)
clr = 1;
#10;
clr = 0;
// Test different values for Cp and Ep
Cp = 1;
Ep = 1;
#20; // Wait for some time
Cp = 0;
Ep = 0;
#20;
Cp = 1;
Ep = 1;
#20;
Cp = 0;
Ep = 1;
#20;
Cp = 1;
Ep = 0;
#20;
// End of simulation
$stop;
end
initial begin
$dumpfile("waveform.vcd"); // Specifies the output file
$dumpvars(0, pc_tb); // Dumps all signals in pc_tb
end
endmodule