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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_12/] [bench/] [verilog/] [oc8051_tb.v] - Blame information for rev 68

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

Line No. Rev Author Line
1 68 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 top level test bench                                   ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   top level test bench.                                      ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46 59 simont
// $Log: not supported by cvs2svn $
47 68 simont
// Revision 1.5  2002/10/17 19:00:50  simont
48
// add external rom
49
//
50 59 simont
// Revision 1.4  2002/09/30 17:33:58  simont
51
// prepared header
52 68 simont
//
53
//
54
 
55
// synopsys translate_off
56
`include "oc8051_timescale.v"
57
// synopsys translate_on
58
 
59
`include "oc8051_defines.v"
60
 
61
 
62
module oc8051_tb;
63
 
64
reg rst, clk;
65
reg [15:0] pc_in;
66
reg [7:0] p0_in, p1_in, p2_in;
67 59 simont
wire [31:0] idat_i;
68 68 simont
wire [15:0] ext_addr, iadr_o;
69
wire  write, write_xram, write_uart, txd, rxd, int_uart, int0, int1, t0, t1, bit_out, stb_o, ack_i, ack_xram, ack_uart, cyc_o, iack_i, istb_o, icyc_o;
70
wire [7:0] data_in, data_out, p0_out, p1_out, p2_out, p3_out, data_out_uart, data_out_xram, p3_in;
71
 
72
///
73
/// buffer for test vectors
74
///
75
//
76
// buffer
77
reg [23:0] buff [255:0];
78 59 simont
reg ea [1:0];
79 68 simont
 
80
integer num;
81
 
82
 
83
//
84
// oc8051 controller
85
//
86
oc8051_top oc8051_top_1(.rst(rst), .clk(clk), .int0(int0), .int1(int1),
87
         .dat_i(data_in), .dat_o(data_out),
88 59 simont
         .adr_o(ext_addr), .iadr_o(iadr_o), .istb_o(istb_o), .iack_i(iack_i),
89 68 simont
         .icyc_o(icyc_o), .we_o(write), .p0_in(p0_in),
90
         .ack_i(ack_i), .stb_o(stb_o), .cyc_o(cyc_o),
91
         .p1_in(p1_in), .p2_in(p2_in), .p3_in(p3_in), .p0_out(p0_out), .p1_out(p1_out),
92
         .p2_out(p2_out), .p3_out(p3_out), .idat_i(idat_i), .ea(ea[0]),
93
         .rxd(rxd), .txd(txd), .t0(t0), .t1(t1));
94
 
95
 
96
//
97
// external data ram
98
//
99
oc8051_xram oc8051_xram1 (.clk(clk), .rst(rst), .wr(write_xram), .addr(ext_addr), .data_in(data_out), .data_out(data_out_xram), .ack(ack_xram), .stb(stb_o));
100
 
101
 
102
defparam oc8051_xram1.DELAY = 2;
103
 
104
//
105
// external uart
106
//
107
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
108
                  .wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
109
                  .txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
110
 
111
//
112
// exteranl program rom
113
//
114
//    cache
115
//
116
//
117
 
118
`ifdef OC8051_CACHE
119
 
120
wire istb_i, icyc_i, iack_o;
121
wire [15:0] iadr_i;
122
wire [31:0] idat_o;
123
 
124
oc8051_icache oc8051_icache1(.rst(rst), .clk(clk),
125
// oc8051
126
        .adr_i(iadr_o), .dat_o(idat_i), .stb_i(istb_o), .ack_o(iack_i),
127
        .cyc_i(icyc_o),
128
// external rom
129
        .dat_i(idat_o), .stb_o(istb_i), .adr_o(iadr_i), .ack_i(iack_o),
130
        .cyc_o(icyc_i));
131
 
132
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_i), .data(idat_o),
133
             .stb_i(istb_i), .cyc_i(icyc_i), .ack_o(iack_o));
134
 
135
defparam oc8051_icache1.ADR_WIDTH = 6;  // cache address wihth
136
defparam oc8051_icache1.LINE_WIDTH = 3; // line address width (2 => 4x32)
137
defparam oc8051_icache1.BL_NUM = 7; // number of blocks (2^BL_WIDTH-1); BL_WIDTH = ADR_WIDTH - LINE_WIDTH
138
defparam oc8051_icache1.CACHE_RAM = 64; // cache ram x 32 (2^ADR_WIDTH)
139
 
140
 
141
//
142
//    no cache
143
//
144
`else
145
 
146
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_o), .data(idat_i),
147 59 simont
             .stb_i(istb_o), .cyc_i(icyc_o), .ack_o(iack_i));
148
 
149 68 simont
`endif
150
//
151
//
152
//
153 59 simont
 
154 68 simont
defparam oc8051_xrom1.DELAY = 5;
155 59 simont
 
156
 
157 68 simont
 
158
assign write_xram = p3_out[7] & write;
159
assign write_uart = !p3_out[7] & write;
160
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
161
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
162
assign p3_in = {7'b000000, bit_out, int_uart};
163
assign t0 = p3_out[5];
164
assign t1 = p3_out[6];
165
 
166
assign int0 = p3_out[3];
167
assign int1 = p3_out[4];
168
 
169
 
170
initial begin
171
  clk= 1'b0;
172
  rst= 1'b1;
173
  pc_in = 16'h0000;
174
  p0_in = 8'h00;
175
  p1_in = 8'h00;
176
  p2_in = 8'h00;
177
#22
178
  rst = 1'b0;
179
//#444000
180
 
181
#7000000
182
  $display("time ",$time, "\n faulire: end of time\n \n");
183
  $finish;
184
end
185
 
186
 
187
always clk = #5 ~clk;
188
 
189
 
190
 
191
initial
192
  $readmemh("../../../asm/vec/oc8051_test.vec", buff);
193
 
194
initial
195
  $readmemb("../oc8051_ea.in", ea);
196
 
197
 
198
initial num= 0;
199
 
200
always @(p0_out or p1_out or p2_out)
201
begin
202
  if ({p0_out, p1_out, p2_out} != buff[num])
203
  begin
204
    $display("time ",$time, " faulire: mismatch on ports in step %d", num);
205
    $display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
206
    $display(" testvecp %h", buff[num]);
207
    $display(" p_out   %h%h%h", p0_out, p1_out, p2_out);
208
#22
209
    $finish;
210
  end
211
  else begin
212
    $display("time ",$time, " step %d", num, ": pass");
213
    num =  num+1;
214
    if (buff[num]===24'hxxxxxx)
215
    begin
216
      $display("");
217
      $display(" Done!");
218
      $finish;
219
    end
220
  end
221
end
222
 
223
 
224
initial $dumpvars;
225
 
226
 
227
//initial $monitor("time ",$time," acc %h", data_out, " dptr %h", ext_addr, " write ", write, " p0_out %h", p0_out, " p1_out %h", p1_out);
228
 
229
//initial $monitor("time ",$time, " p0_out ", p0_out);
230
 
231
//initial $monitor("time ",$time," write ", write, " p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out, " p3_out %h", p3_out);
232
 
233
endmodule

powered by: WebSVN 2.1.0

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