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

Subversion Repositories 8051

[/] [8051/] [trunk/] [bench/] [verilog/] [oc8051_tb.v] - Blame information for rev 84

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

powered by: WebSVN 2.1.0

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