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

Subversion Repositories wb_z80

[/] [wb_z80/] [trunk/] [rtl/] [z80_testbed.v] - Blame information for rev 26

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

Line No. Rev Author Line
1 22 bporcella
///////////////////////////////////////////////////////////////////////////////////////////////////
2
////                                                                                           ////
3
////  file name:   z80_testbed.v                                                               ////
4
////  description: testbed for Wishbone z80                                                    ////
5
////  project:     wb_z80                                                                      ////
6
////                                                                                           ////
7
////                                                                                           ////
8
////  Author: B.J. Porcella                                                                    ////
9
////          bporcella@sbcglobal.net                                                          ////
10
////                                                                                           ////
11
////                                                                                           ////
12
////                                                                                           ////
13
///////////////////////////////////////////////////////////////////////////////////////////////////
14
////                                                                                           ////
15
//// Copyright (C) 2000-2002 B.J. Porcella                                                     ////
16
////                         Real Time Solutions                                               ////
17
////                                                                                           ////
18
////                                                                                           ////
19
//// This source file may be used and distributed without                                      ////
20
//// restriction provided that this copyright statement is not                                 ////
21
//// removed from the file and that any derivative work contains                               ////
22
//// the original copyright notice and the associated disclaimer.                              ////
23
////                                                                                           ////
24
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY                                   ////
25
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED                                 ////
26
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS                                 ////
27
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR                                    ////
28
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,                                       ////
29
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES                                  ////
30
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE                                 ////
31
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR                                      ////
32
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF                                ////
33
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT                                ////
34
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT                                ////
35
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE                                       ////
36
//// POSSIBILITY OF SUCH DAMAGE.                                                               ////
37
////                                                                                           ////
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
//  CVS Log
40
//
41 26 bporcella
//  $Id: z80_testbed.v,v 1.3 2004-05-21 02:51:25 bporcella Exp $
42 22 bporcella
//
43 26 bporcella
//  $Date: 2004-05-21 02:51:25 $
44
//  $Revision: 1.3 $
45 22 bporcella
//  $Author: bporcella $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//      $Log: not supported by cvs2svn $
51 26 bporcella
//      Revision 1.2  2004/05/18 22:31:21  bporcella
52
//      instruction test getting to final stages
53
//
54 25 bporcella
//      Revision 1.1  2004/05/13 14:57:35  bporcella
55
//      testbed files
56
//
57 22 bporcella
//      Revision 1.1.1.1  2004/04/13 23:47:42  bporcella
58
//      import first files
59
//
60
//
61
//
62
//-------1---------2---------3--------Module Name and Port List------7---------8---------9--------0
63
 
64
 
65
`timescale 1ns/10ps
66
`define  COMPILE_BIST   // need this for this file to work
67
 
68
// testbench - do not synthesize.  this just sequences the bist signals
69
module z80_testbed();
70
 
71
reg      rst, bist_req, clk;
72
wire     bist_ack;
73
wire     bist_err;
74
 
75
 
76
 
77
//-------   CAUTION  TEST RESULTS DEPEND ON INITIAL CONDITIONS -------
78
//  bist will not pass if some of these imputs are not as specified.
79
//
80
z80_core_top i_z80_core_top(
81
    .wb_dat_o(wb_dat),
82
    .wb_stb_o(wb_stb),
83
    .wb_cyc_o(wb_cyc),
84
    .wb_we_o(wb_we),
85
    .wb_adr_o(wb_adr),
86
    .wb_tga_o(wb_tga),
87
    .wb_ack_i(ack),
88
    .wb_clk_i(clk),
89 26 bporcella
    .wb_dat_i(io_i),
90 22 bporcella
    .wb_rst_i(rst),
91
    .bist_ack_o(bist_ack),
92
    .bist_err_o(bist_err),
93
    .bist_req_i(bist_req),
94
    .int_req_i(1'b0)        // initial test inst test only 
95
    );
96
 
97
 
98
reg   ack;
99
wire [1:0]  wb_tga;
100
wire [15:0] wb_adr;
101
wire        wb_stb, wb_cyc, wb_we;
102
wire [7:0]  wb_dat;
103 26 bporcella
wire [7:0]    io_i;
104
reg [7:0]   out_state;
105
 
106 22 bporcella
parameter   TAG_IO    = 2'b01,   // need to review general wb usage to undrstand how best to 
107
            TAG_INT   = 2'b10;   // document this.
108
 
109 26 bporcella
parameter   MY_IO_ADR = 8'h10 ;
110
// ----------------- a pretty simple I/O device   -------
111
//  output simply displays the data written   --  
112
//  input cycles through 
113
//  various interesting data  patterens as used by the instruction test
114
//  namely   7f 55 80 0  ff  aa
115 22 bporcella
 
116 26 bporcella
 
117
assign io_i = (wb_adr[7:0] == MY_IO_ADR) & wb_stb & wb_cyc & (wb_tga == TAG_IO) & !wb_we ?
118
                  out_state : 8'hz;
119
wire a2me = (wb_adr[7:0] == MY_IO_ADR) & wb_stb & wb_cyc & (wb_tga == TAG_IO);
120
 
121 22 bporcella
always @(posedge clk or posedge rst)
122
begin
123
    if (rst )              ack <= 1'b0;
124 26 bporcella
    else if (a2me & !ack)
125 22 bporcella
    begin
126
                           ack <= 1'b1;
127 26 bporcella
                           if (wb_we)    $write("%s",wb_dat);
128 22 bporcella
    end
129 26 bporcella
    else                   ack <= 1'b0;
130 22 bporcella
end
131
 
132 26 bporcella
always @(posedge clk or posedge rst)
133
begin
134
    if (rst)              out_state <=  8'h7f;
135
    else if (a2me & !wb_we & ack)
136
        case (out_state)
137
            8'h7f:         out_state <=  8'h55 ;
138
            8'h55:         out_state <=  8'h80 ;
139
            8'h80:         out_state <=  8'h00 ;
140
            8'h00:         out_state <=  8'hff ;
141
            8'hff:         out_state <=  8'haa ;
142
            8'haa:         out_state <=  8'h7f ;
143
            default:       out_state <=  8'h7f ;
144
        endcase
145
end
146 22 bporcella
 
147 26 bporcella
 
148
 
149 22 bporcella
initial
150
begin
151
    clk = 0;
152
    //  timeout if u hang up  -- always a good idea.
153 25 bporcella
    #500000     $finish;
154 22 bporcella
    $display("simulation timeout");
155
end
156
 
157
always   #5 clk = ~clk;
158
 
159
// The bist sequencer  --- pertty trivial
160
initial
161
begin
162
    rst = 1'b0;
163
    bist_req = 1'b0;
164
    @( posedge clk)  rst = 1'b1;
165
    @( posedge clk)  rst = 1'b0;
166
    @( posedge clk)  bist_req = 1'b1;
167
    @( bist_ack ) ;
168
    @( posedge clk)
169
        if ( bist_err ) $display("bist error");
170
        else            $display( "bist ok"    );
171
    $finish;
172
end
173
 
174
 
175
initial
176
begin
177
    $dumpfile("dump.vcd");
178
    $dumpvars;
179
end
180
 
181
endmodule

powered by: WebSVN 2.1.0

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