| 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 |
|
|
// $Id: z80_testbed.v,v 1.1 2004-05-13 14:57:35 bporcella Exp $
|
| 42 |
|
|
//
|
| 43 |
|
|
// $Date: 2004-05-13 14:57:35 $
|
| 44 |
|
|
// $Revision: 1.1 $
|
| 45 |
|
|
// $Author: bporcella $
|
| 46 |
|
|
// $Locker: $
|
| 47 |
|
|
// $State: Exp $
|
| 48 |
|
|
//
|
| 49 |
|
|
// Change History:
|
| 50 |
|
|
// $Log: not supported by cvs2svn $
|
| 51 |
|
|
// Revision 1.1.1.1 2004/04/13 23:47:42 bporcella
|
| 52 |
|
|
// import first files
|
| 53 |
|
|
//
|
| 54 |
|
|
//
|
| 55 |
|
|
//
|
| 56 |
|
|
//-------1---------2---------3--------Module Name and Port List------7---------8---------9--------0
|
| 57 |
|
|
|
| 58 |
|
|
|
| 59 |
|
|
`timescale 1ns/10ps
|
| 60 |
|
|
`define COMPILE_BIST // need this for this file to work
|
| 61 |
|
|
|
| 62 |
|
|
// testbench - do not synthesize. this just sequences the bist signals
|
| 63 |
|
|
module z80_testbed();
|
| 64 |
|
|
|
| 65 |
|
|
reg rst, bist_req, clk;
|
| 66 |
|
|
wire bist_ack;
|
| 67 |
|
|
wire bist_err;
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
|
| 71 |
|
|
//------- CAUTION TEST RESULTS DEPEND ON INITIAL CONDITIONS -------
|
| 72 |
|
|
// bist will not pass if some of these imputs are not as specified.
|
| 73 |
|
|
//
|
| 74 |
|
|
z80_core_top i_z80_core_top(
|
| 75 |
|
|
.wb_dat_o(wb_dat),
|
| 76 |
|
|
.wb_stb_o(wb_stb),
|
| 77 |
|
|
.wb_cyc_o(wb_cyc),
|
| 78 |
|
|
.wb_we_o(wb_we),
|
| 79 |
|
|
.wb_adr_o(wb_adr),
|
| 80 |
|
|
.wb_tga_o(wb_tga),
|
| 81 |
|
|
.wb_ack_i(ack),
|
| 82 |
|
|
.wb_clk_i(clk),
|
| 83 |
|
|
.wb_dat_i(8'b0),
|
| 84 |
|
|
.wb_rst_i(rst),
|
| 85 |
|
|
.bist_ack_o(bist_ack),
|
| 86 |
|
|
.bist_err_o(bist_err),
|
| 87 |
|
|
.bist_req_i(bist_req),
|
| 88 |
|
|
.int_req_i(1'b0) // initial test inst test only
|
| 89 |
|
|
);
|
| 90 |
|
|
|
| 91 |
|
|
|
| 92 |
|
|
reg ack;
|
| 93 |
|
|
wire [1:0] wb_tga;
|
| 94 |
|
|
wire [15:0] wb_adr;
|
| 95 |
|
|
wire wb_stb, wb_cyc, wb_we;
|
| 96 |
|
|
wire [7:0] wb_dat;
|
| 97 |
|
|
parameter TAG_IO = 2'b01, // need to review general wb usage to undrstand how best to
|
| 98 |
|
|
TAG_INT = 2'b10; // document this.
|
| 99 |
|
|
|
| 100 |
|
|
// a pretty simple output device
|
| 101 |
|
|
|
| 102 |
|
|
wire wr2me = (wb_adr[7:0] == 8'h10) & wb_stb & wb_cyc & (wb_tga == TAG_IO) & wb_we;
|
| 103 |
|
|
always @(posedge clk or posedge rst)
|
| 104 |
|
|
begin
|
| 105 |
|
|
if (rst ) ack <= 1'b0;
|
| 106 |
|
|
else if (wr2me & !ack)
|
| 107 |
|
|
begin
|
| 108 |
|
|
ack <= 1'b1;
|
| 109 |
|
|
$write("%s",wb_dat);
|
| 110 |
|
|
end
|
| 111 |
|
|
else ack <= 1'b0;
|
| 112 |
|
|
|
| 113 |
|
|
end
|
| 114 |
|
|
|
| 115 |
|
|
|
| 116 |
|
|
initial
|
| 117 |
|
|
begin
|
| 118 |
|
|
clk = 0;
|
| 119 |
|
|
// timeout if u hang up -- always a good idea.
|
| 120 |
|
|
#50000 $finish;
|
| 121 |
|
|
$display("simulation timeout");
|
| 122 |
|
|
end
|
| 123 |
|
|
|
| 124 |
|
|
always #5 clk = ~clk;
|
| 125 |
|
|
|
| 126 |
|
|
// The bist sequencer --- pertty trivial
|
| 127 |
|
|
initial
|
| 128 |
|
|
begin
|
| 129 |
|
|
rst = 1'b0;
|
| 130 |
|
|
bist_req = 1'b0;
|
| 131 |
|
|
@( posedge clk) rst = 1'b1;
|
| 132 |
|
|
@( posedge clk) rst = 1'b0;
|
| 133 |
|
|
@( posedge clk) bist_req = 1'b1;
|
| 134 |
|
|
@( bist_ack ) ;
|
| 135 |
|
|
@( posedge clk)
|
| 136 |
|
|
if ( bist_err ) $display("bist error");
|
| 137 |
|
|
else $display( "bist ok" );
|
| 138 |
|
|
$finish;
|
| 139 |
|
|
end
|
| 140 |
|
|
|
| 141 |
|
|
|
| 142 |
|
|
initial
|
| 143 |
|
|
begin
|
| 144 |
|
|
$dumpfile("dump.vcd");
|
| 145 |
|
|
$dumpvars;
|
| 146 |
|
|
end
|
| 147 |
|
|
|
| 148 |
|
|
endmodule
|