OpenCores
URL https://opencores.org/ocsvn/ata/ata/trunk

Subversion Repositories ata

[/] [ata/] [trunk/] [bench/] [verilog/] [test_bench_top.v] - Blame information for rev 21

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Top Level Test Bench                                       ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/vga_lcd/   ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14
//// Copyright (C) 2001 Rudolf Usselmann                         ////
15
////                    rudi@asics.ws                            ////
16
////                                                             ////
17
//// This source file may be used and distributed without        ////
18
//// restriction provided that this copyright statement is not   ////
19
//// removed from the file and that any derivative work contains ////
20
//// the original copyright notice and the associated disclaimer.////
21
////                                                             ////
22
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
23
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
24
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
25
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
26
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
27
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
28
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
29
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
30
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
31
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
32
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
33
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
34
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
35
////                                                             ////
36
/////////////////////////////////////////////////////////////////////
37
 
38
//  CVS Log
39
//
40 21 rherveille
//  $Id: test_bench_top.v,v 1.2 2002-02-16 10:41:16 rherveille Exp $
41 16 rudi
//
42 21 rherveille
//  $Date: 2002-02-16 10:41:16 $
43
//  $Revision: 1.2 $
44
//  $Author: rherveille $
45 16 rudi
//  $Locker:  $
46
//  $State: Exp $
47
//
48
// Change History:
49
//               $Log: not supported by cvs2svn $
50 21 rherveille
//               Revision 1.1  2001/08/16 10:01:05  rudi
51 16 rudi
//
52 21 rherveille
//               - Added Test Bench
53
//               - Added Synthesis scripts for Design Compiler
54
//               - Fixed minor bug in atahost_top
55 16 rudi
//
56
//
57 21 rherveille
//
58
//
59 16 rudi
//                        
60
 
61
`timescale 1ns / 10ps
62
 
63
module test;
64
 
65
reg             clk;
66
reg             rst;
67
 
68
wire            int;
69
wire    [31:0]   wb_addr_i;
70
wire    [31:0]   wb_data_i;
71
wire    [31:0]   wb_data_o;
72
wire    [3:0]    wb_sel_i;
73
wire            wb_we_i;
74
wire            wb_stb_i;
75
wire            wb_cyc_i;
76
wire            wb_ack_o;
77
wire            wb_err_o;
78
 
79
wire            ata_rst_;
80
wire    [15:0]   ata_dout;
81
wire    [15:0]   ata_din;
82
wire    [15:0]   ata_data;
83
wire            ata_doe;
84
wire    [2:0]    ata_da;
85
wire            ata_cs0, ata_cs1;
86
wire            ata_dior, ata_diow;
87
wire            ata_iordy;
88
wire            ata_intrq;
89
reg             ata_intrq_r;
90
 
91
 
92
// Test Bench Variables
93
integer         wd_cnt;
94
integer         error_cnt;
95
integer         verbose;
96
 
97
// Misc Variables
98
 
99
/////////////////////////////////////////////////////////////////////
100
//
101
// Defines 
102
//
103
 
104
`define CTRL            32'h0000_0000
105
`define STAT            32'h0000_0004
106
`define PCTR            32'h0000_0008
107
`define ATA_DEV         32'h0000_0040
108
 
109
/////////////////////////////////////////////////////////////////////
110
//
111
// Simulation Initialization and Start up Section
112
//
113
 
114
initial
115
   begin
116
        $display("\n\n");
117
        $display("******************************************************");
118
        $display("* WISHBONE ATA 1 Controller Simulation started ...   *");
119
        $display("******************************************************");
120
        $display("\n");
121
`ifdef WAVES
122
        $shm_open("waves");
123
        $shm_probe("AS",test,"AS");
124
        $display("INFO: Signal dump enabled ...\n\n");
125
`endif
126
        wd_cnt = 0;
127
        error_cnt = 0;
128
        clk = 0;
129
        rst = 0;
130
        verbose = 1;
131
        ata_intrq_r=0;
132
 
133
        repeat(10)      @(posedge clk);
134
        rst = 1;
135
        repeat(10)      @(posedge clk);
136
 
137
        // HERE IS WHERE THE TEST CASES GO ...
138
 
139
if(1)   // Full Regression Run
140
   begin
141
        io_test1;
142
        io_test2;
143
        int_test;
144
        rst_test;
145
 
146
   end
147
else
148
   begin
149
 
150
        //
151
        // TEST DEVELOPMENT AREA
152
        //
153
$display("\n\n");
154
$display("*****************************************************");
155
$display("*** DEVELOPMENT Test                              ***");
156
$display("*****************************************************\n");
157
 
158
 
159
 
160
 
161
show_errors;
162
$display("*****************************************************");
163
$display("*** Test DONE ...                                 ***");
164
$display("*****************************************************\n\n");
165
 
166
   end
167
        repeat(100)     @(posedge clk);
168
        $finish;
169
   end
170
 
171
/////////////////////////////////////////////////////////////////////
172
//
173
// System Clock (100Mhz)
174
//
175
 
176
always #5       clk = ~clk;
177
 
178
/////////////////////////////////////////////////////////////////////
179
//
180
// Watchdog Counter
181
// Terminate simulation if nothing happens ...
182
//
183
 
184
always @(wb_cyc_i or wb_ack_o)
185
        wd_cnt <= #5 0;
186
 
187
always @(posedge clk)
188
        wd_cnt <= #1 wd_cnt + 1;
189
 
190
always @(wd_cnt)
191
        if(wd_cnt>5000)
192
           begin
193
                $display("\n\n*************************************\n");
194
                $display("ERROR: Watch Dog Counter Expired\n");
195
                $display("*************************************\n\n\n");
196
                $finish;
197
           end
198
 
199
/////////////////////////////////////////////////////////////////////
200
//
201
// DUT & Models
202
//
203
 
204
// Create an external Tri-State Bus to the ATA Device
205
assign ata_din  = ata_data;
206
assign ata_data = ata_doe ? ata_dout : 16'hzzzz;
207
 
208
// DUT: ATA Host
209
atahost_top u0( //-- WISHBONE SYSCON signals
210
                .wb_clk_i(              clk             ),
211 21 rherveille
                .arst_i(                rst             ),
212 16 rudi
                .wb_rst_i(              ~rst            ),
213
 
214
                //-- WISHBONE SLAVE signals
215
                .wb_cyc_i(              wb_cyc_i        ),
216
                .wb_stb_i(              wb_stb_i        ),
217
                .wb_ack_o(              wb_ack_o        ),
218
                .wb_err_o(              wb_err_o        ),
219
                .wb_adr_i(              wb_addr_i[6:2]  ),
220
                .wb_dat_i(              wb_data_i       ),
221
                .wb_dat_o(              wb_data_o       ),
222
                .wb_sel_i(              wb_sel_i        ),
223
                .wb_we_i(               wb_we_i         ),
224
                .wb_inta_o(             int             ),
225
 
226
                //-- ATA signals
227 21 rherveille
                .resetn_pad_o(  ata_rst_        ),
228
                .dd_pad_i(              ata_din         ),
229
                .dd_pad_o(              ata_dout        ),
230
                .dd_padoe_o(            ata_doe         ),
231
                .da_pad_o(              ata_da          ),
232
                .cs0n_pad_o(    ata_cs0         ),
233
                .cs1n_pad_o(    ata_cs1         ),
234
                .diorn_pad_o(   ata_dior_       ),
235
                .diown_pad_o(   ata_diow_       ),
236
                .iordy_pad_i(   ata_iordy       ),
237
                .intrq_pad_i(   ata_intrq_r     )
238 16 rudi
                );
239
 
240
// ATA Device Model
241
ata_device a0(  .ata_rst_(      ata_rst_        ),
242
                .ata_data(      ata_data        ),
243
                .ata_da(        ata_da          ),
244
                .ata_cs0(       ata_cs0         ),
245
                .ata_cs1(       ata_cs1         ),
246
                .ata_dior_(     ata_dior_       ),
247
                .ata_diow_(     ata_diow_       ),
248
                .ata_iordy(     ata_iordy       ),
249
                .ata_intrq(     ata_intrq       ) );
250
 
251
// WISHBONE Master Model
252
wb_mast m0(     .clk(           clk             ),
253
                .rst(           rst             ),
254
                .adr(           wb_addr_i       ),
255
                .din(           wb_data_o       ),
256
                .dout(          wb_data_i       ),
257
                .cyc(           wb_cyc_i        ),
258
                .stb(           wb_stb_i        ),
259
                .sel(           wb_sel_i        ),
260
                .we(            wb_we_i         ),
261
                .ack(           wb_ack_o        ),
262
                .err(           wb_err_o        ),
263
                .rty(           1'b0            ) );
264
 
265
// External Tests
266
`include "tests.v"
267
 
268
endmodule
269
 
270 21 rherveille
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.