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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
//
// uLab GPMC interface verification test bench
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (c) 2014 Timothy Pearson
// Raptor Engineering
// http://www.raptorengineeringinc.com
//
//////////////////////////////////////////////////////////////////////////////////
module verification;
// Inputs
reg clk;
reg gpmc_advn;
reg gpmc_oen;
reg gpmc_wen;
reg [15:0] gpmc_address;
reg usermem_wen;
reg userproc_done;
reg userlogic_clock;
reg userlogic_serial_rxd;
reg host_serial_rxd;
reg [3:0] four_bit_leds;
reg [7:0] eight_bit_leds;
reg sixteen_bit_io_wen;
reg [3:0] sseg_mux;
reg [7:0] sseg_data;
// Outputs
wire usermem_wait;
wire userproc_start;
wire userlogic_reset;
wire userlogic_serial_txd;
wire host_serial_txd;
wire [3:0] four_bit_switches;
wire [7:0] eight_bit_switches;
wire sixteen_bit_io_mode;
wire userdevice_reset;
// Bidirs
wire [7:0] gpmc_data;
wire [7:0] usermem_data;
wire [15:0] usermem_address;
wire [15:0] sixteen_bit_io;
// Instantiate the Unit Under Test (UUT)
main uut (
.clk(clk),
.gpmc_advn(gpmc_advn),
.gpmc_oen(gpmc_oen),
.gpmc_wen(gpmc_wen),
.gpmc_data(gpmc_data),
.gpmc_address(gpmc_address),
.usermem_wen(usermem_wen),
.usermem_wait(usermem_wait),
.usermem_data(usermem_data),
.usermem_address(usermem_address),
.userproc_start(userproc_start),
.userproc_done(userproc_done),
.userlogic_reset(userlogic_reset),
.userlogic_clock(userlogic_clock),
.userlogic_serial_txd(userlogic_serial_txd),
.userlogic_serial_rxd(userlogic_serial_rxd),
.host_serial_txd(host_serial_txd),
.host_serial_rxd(host_serial_rxd),
.four_bit_leds(four_bit_leds),
.eight_bit_leds(eight_bit_leds),
.four_bit_switches(four_bit_switches),
.eight_bit_switches(eight_bit_switches),
.sixteen_bit_io(sixteen_bit_io),
.sixteen_bit_io_wen(sixteen_bit_io_wen),
.sixteen_bit_io_mode(sixteen_bit_io_mode),
.sseg_mux(sseg_mux),
.sseg_data(sseg_data),
.userdevice_reset(userdevice_reset)
);
reg gpmc_data_driven = 0;
reg [7:0] gpmc_data_out;
assign gpmc_data = (gpmc_data_driven) ? gpmc_data_out : 8'bz;
// Generate 100MHz clock
always begin
#5;
clk = !clk;
end
// Terminate test bench after specified time has elapsed
initial begin
#10000;
$finish;
end
// Test logic analyzer triggering and data acquisition
initial begin
// Initialize Inputs
clk = 0;
gpmc_advn = 0;
gpmc_oen = 0;
gpmc_wen = 0;
gpmc_address = 0;
usermem_wen = 0;
userproc_done = 0;
userlogic_clock = 0;
userlogic_serial_rxd = 0;
host_serial_rxd = 0;
four_bit_leds = 0;
eight_bit_leds = 0;
sixteen_bit_io_wen = 0;
sseg_mux = 0;
sseg_data = 0;
// Wait 100 ns for global reset to finish
#100;
// Send user logic reset signal to GPMC interface
gpmc_address = 16'h000c;
gpmc_data_out = 8'h01;
gpmc_data_driven = 1'b1;
gpmc_advn = 1'b0;
gpmc_wen = 1'b0;
#1000
gpmc_address = 16'h000c;
gpmc_data_out = 8'h00;
gpmc_data_driven = 1'b1;
gpmc_advn = 1'b0;
gpmc_wen = 1'b0;
#100
gpmc_data_driven = 1'b0;
gpmc_advn = 1'b1;
gpmc_wen = 1'b1;
end
endmodule
|