-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbench.v
81 lines (67 loc) · 2.03 KB
/
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
77
78
79
80
81
// File: testbench.v
// This is a top level testbench for the
// vga_example design, which is part of
// the EE178 Lab #4 assignment.
// The `timescale directive specifies what the
// simulation time units are (1 ns here) and what
// the simulator time step should be (1 ps here).
`timescale 1 ns / 1 ps
module testbench;
// Declare wires to be driven by the outputs
// of the design, and regs to drive the inputs.
// The testbench will be in control of inputs
// to the design, and will check the outputs.
// Then, instantiate the design to be tested.
reg clk;
wire pclk_mirror;
wire vs, hs;
wire [3:0] r, g, b;
// Instantiate the vga_example module.
vga_example my_example (
.clk(clk),
.vs(vs),
.hs(hs),
.r(r),
.g(g),
.b(b),
.pclk_mirror(pclk_mirror)
);
// Instantiate the tiff_writer module.
tiff_writer my_writer (
.pclk_mirror(pclk_mirror),
.r({r,r}), // fabricate an 8-bit value
.g({g,g}), // fabricate an 8-bit value
.b({b,b}), // fabricate an 8-bit value
.go(vs),
.xdim(16'd1056),
.ydim(16'd628)
);
// Describe a process that generates a clock
// signal. The clock is 100 MHz.
always
begin
clk = 1'b0;
#5;
clk = 1'b1;
#5;
end
// Assign values to the input signals and
// check the output results. This template
// is meant to get you started, you can modify
// it as you see fit. If you simply run it as
// provided, you will need to visually inspect
// the output waveforms to see if they make
// sense...
initial
begin
$display("If simulation ends before the testbench");
$display("completes, use the menu option to run all.");
$display("Prepare to wait a long time...");
wait (vs == 1'b0);
@(negedge vs) $display("Info: negedge VS at %t",$time);
@(negedge vs) $display("Info: negedge VS at %t",$time);
// End the simulation.
$display("Simulation is over, check the waveforms.");
$stop;
end
endmodule