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

Subversion Repositories 8051

[/] [8051/] [tags/] [rel_2/] [bench/] [verilog/] [oc8051_tb.v] - Blame information for rev 74

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 74 simont
// Revision 1.6  2002/10/24 13:36:53  simont
48
// add instruction cache and DELAY parameters for external ram, rom
49
//
50 68 simont
// Revision 1.5  2002/10/17 19:00:50  simont
51
// add external rom
52
//
53 59 simont
// Revision 1.4  2002/09/30 17:33:58  simont
54
// prepared header
55 68 simont
//
56
//
57
 
58
// synopsys translate_off
59
`include "oc8051_timescale.v"
60
// synopsys translate_on
61
 
62
`include "oc8051_defines.v"
63
 
64
 
65
module oc8051_tb;
66
 
67
reg rst, clk;
68
reg [15:0] pc_in;
69
reg [7:0] p0_in, p1_in, p2_in;
70 59 simont
wire [31:0] idat_i;
71 68 simont
wire [15:0] ext_addr, iadr_o;
72
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;
73
wire [7:0] data_in, data_out, p0_out, p1_out, p2_out, p3_out, data_out_uart, data_out_xram, p3_in;
74
 
75
///
76
/// buffer for test vectors
77
///
78
//
79
// buffer
80
reg [23:0] buff [255:0];
81 59 simont
reg ea [1:0];
82 68 simont
 
83
integer num;
84
 
85
 
86
//
87
// oc8051 controller
88
//
89
oc8051_top oc8051_top_1(.rst(rst), .clk(clk), .int0(int0), .int1(int1),
90
         .dat_i(data_in), .dat_o(data_out),
91 59 simont
         .adr_o(ext_addr), .iadr_o(iadr_o), .istb_o(istb_o), .iack_i(iack_i),
92 68 simont
         .icyc_o(icyc_o), .we_o(write), .p0_in(p0_in),
93
         .ack_i(ack_i), .stb_o(stb_o), .cyc_o(cyc_o),
94
         .p1_in(p1_in), .p2_in(p2_in), .p3_in(p3_in), .p0_out(p0_out), .p1_out(p1_out),
95
         .p2_out(p2_out), .p3_out(p3_out), .idat_i(idat_i), .ea(ea[0]),
96
         .rxd(rxd), .txd(txd), .t0(t0), .t1(t1));
97
 
98
 
99
//
100
// external data ram
101
//
102
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));
103
 
104
 
105
defparam oc8051_xram1.DELAY = 2;
106
 
107
//
108
// external uart
109
//
110
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
111
                  .wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
112
                  .txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
113
 
114
//
115
// exteranl program rom
116
//
117
//    cache
118
//
119
//
120
wire istb_i, icyc_i, iack_o;
121
wire [15:0] iadr_i;
122
wire [31:0] idat_o;
123
 
124 74 simont
`ifdef OC8051_CACHE
125
 
126
 
127 68 simont
oc8051_icache oc8051_icache1(.rst(rst), .clk(clk),
128
// oc8051
129
        .adr_i(iadr_o), .dat_o(idat_i), .stb_i(istb_o), .ack_o(iack_i),
130
        .cyc_i(icyc_o),
131
// external rom
132
        .dat_i(idat_o), .stb_o(istb_i), .adr_o(iadr_i), .ack_i(iack_o),
133
        .cyc_o(icyc_i));
134
 
135
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_i), .data(idat_o),
136
             .stb_i(istb_i), .cyc_i(icyc_i), .ack_o(iack_o));
137
 
138
defparam oc8051_icache1.ADR_WIDTH = 6;  // cache address wihth
139 74 simont
defparam oc8051_icache1.LINE_WIDTH = 2; // line address width (2 => 4x32)
140
defparam oc8051_icache1.BL_NUM = 15; // number of blocks (2^BL_WIDTH-1); BL_WIDTH = ADR_WIDTH - LINE_WIDTH
141 68 simont
defparam oc8051_icache1.CACHE_RAM = 64; // cache ram x 32 (2^ADR_WIDTH)
142
 
143
 
144
//
145
//    no cache
146
//
147
`else
148
 
149 74 simont
oc8051_wb_iinterface oc8051_wb_iinterface(.rst(rst), .clk(clk),
150
// oc8051
151
        .adr_i(iadr_o), .dat_o(idat_i), .stb_i(istb_o), .ack_o(iack_i),
152
        .cyc_i(icyc_o),
153
// external rom
154
        .dat_i(idat_o), .stb_o(istb_i), .adr_o(iadr_i), .ack_i(iack_o),
155
        .cyc_o(icyc_i));
156 59 simont
 
157 74 simont
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_i), .data(idat_o),
158
             .stb_i(istb_i), .cyc_i(icyc_i), .ack_o(iack_o));
159
 
160
 
161 68 simont
`endif
162
//
163
//
164
//
165 59 simont
 
166 68 simont
defparam oc8051_xrom1.DELAY = 5;
167 59 simont
 
168 74 simont
//
169
// test wb interface
170
//
171
reg [31:0] log_file;
172 59 simont
 
173 74 simont
initial
174
begin
175
  log_file = $fopen("log_file");
176
  $fdisplay(log_file, "file open");
177
end
178 68 simont
 
179 74 simont
// cache/cpu to instruction rom
180
//
181
 
182
WB_BUS_MON wb_bus_mon1(.CLK_I(clk), .RST_I(rst), .ACK_I(iack_o), .ADDR_O({16'h0000, iadr_i}), .CYC_O(icyc_i),
183
     .DAT_I(idat_o), .DAT_O(32'd0), .ERR_I(1'b0), .RTY_I(1'b0), .SEL_O(4'b0000), .STB_O(istb_i),
184
     .WE_O(1'b0), .TAG_I(4'h0), .TAG_O(4'h0), .CAB_O(1'b0), .log_file_desc(log_file));
185
 
186
 
187
// cpu to data ram
188
//
189
 
190
WB_BUS_MON wb_bus_mon3(.CLK_I(clk), .RST_I(rst), .ACK_I(ack_i), .ADDR_O({16'h0000, ext_addr}), .CYC_O(cyc_o),
191
     .DAT_I({24'h000000, data_in}), .DAT_O({24'h000000, data_out}), .ERR_I(1'b0), .RTY_I(1'b0), .SEL_O(4'b0000), .STB_O(stb_o),
192
     .WE_O(write), .TAG_I(4'h0), .TAG_O(4'h0), .CAB_O(1'b0), .log_file_desc(log_file));
193
//
194
//
195
//
196
//
197
 
198
 
199
 
200 68 simont
assign write_xram = p3_out[7] & write;
201
assign write_uart = !p3_out[7] & write;
202
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
203
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
204
assign p3_in = {7'b000000, bit_out, int_uart};
205
assign t0 = p3_out[5];
206
assign t1 = p3_out[6];
207
 
208
assign int0 = p3_out[3];
209
assign int1 = p3_out[4];
210
 
211
 
212
initial begin
213
  clk= 1'b0;
214
  rst= 1'b1;
215
  pc_in = 16'h0000;
216
  p0_in = 8'h00;
217
  p1_in = 8'h00;
218
  p2_in = 8'h00;
219
#22
220
  rst = 1'b0;
221
//#444000
222
 
223
#7000000
224 74 simont
  $fclose(log_file);
225 68 simont
  $display("time ",$time, "\n faulire: end of time\n \n");
226
  $finish;
227
end
228
 
229
 
230
always clk = #5 ~clk;
231
 
232
 
233
 
234
initial
235
  $readmemh("../../../asm/vec/oc8051_test.vec", buff);
236
 
237
initial
238
  $readmemb("../oc8051_ea.in", ea);
239
 
240
 
241
initial num= 0;
242
 
243
always @(p0_out or p1_out or p2_out)
244
begin
245
  if ({p0_out, p1_out, p2_out} != buff[num])
246
  begin
247
    $display("time ",$time, " faulire: mismatch on ports in step %d", num);
248
    $display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
249
    $display(" testvecp %h", buff[num]);
250
    $display(" p_out   %h%h%h", p0_out, p1_out, p2_out);
251
#22
252 74 simont
    $fclose(log_file);
253 68 simont
    $finish;
254
  end
255
  else begin
256
    $display("time ",$time, " step %d", num, ": pass");
257
    num =  num+1;
258
    if (buff[num]===24'hxxxxxx)
259
    begin
260
      $display("");
261
      $display(" Done!");
262 74 simont
      $fclose(log_file);
263 68 simont
      $finish;
264
    end
265
  end
266
end
267
 
268
 
269
initial $dumpvars;
270
 
271
 
272
//initial $monitor("time ",$time," acc %h", data_out, " dptr %h", ext_addr, " write ", write, " p0_out %h", p0_out, " p1_out %h", p1_out);
273
 
274
//initial $monitor("time ",$time, " p0_out ", p0_out);
275
 
276
//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);
277
 
278
endmodule

powered by: WebSVN 2.1.0

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