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 120

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 120 simont
// Revision 1.10  2003/04/03 19:20:55  simont
48
// Remove instruction cache and wb_interface
49
//
50 111 simont
// Revision 1.9  2003/04/02 15:08:59  simont
51
// rename signals
52
//
53 103 simont
// Revision 1.8  2003/01/13 14:35:25  simont
54
// remove wb_bus_mon
55
//
56 84 simont
// Revision 1.7  2002/10/28 16:43:12  simont
57
// add module oc8051_wb_iinterface
58
//
59 74 simont
// Revision 1.6  2002/10/24 13:36:53  simont
60
// add instruction cache and DELAY parameters for external ram, rom
61
//
62 68 simont
// Revision 1.5  2002/10/17 19:00:50  simont
63
// add external rom
64
//
65 59 simont
// Revision 1.4  2002/09/30 17:33:58  simont
66
// prepared header
67 68 simont
//
68
//
69
 
70
// synopsys translate_off
71
`include "oc8051_timescale.v"
72
// synopsys translate_on
73
 
74
`include "oc8051_defines.v"
75
 
76
 
77
module oc8051_tb;
78
 
79 103 simont
reg  rst, clk;
80
reg  [7:0] p0_in, p1_in, p2_in;
81 59 simont
wire [31:0] idat_i;
82 68 simont
wire [15:0] ext_addr, iadr_o;
83 84 simont
wire write, write_xram, write_uart, txd, rxd, int_uart, int0, int1, t0, t1, bit_out, stb_o, ack_i;
84
wire ack_xram, ack_uart, cyc_o, iack_i, istb_o, icyc_o, t2, t2ex;
85 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;
86 103 simont
wire wbi_err_i, wbd_err_i;
87 68 simont
 
88 84 simont
 
89 68 simont
///
90
/// buffer for test vectors
91
///
92
//
93
// buffer
94 103 simont
reg [23:0] buff [0:255];
95
reg ea [0:1];
96 68 simont
 
97
integer num;
98
 
99 103 simont
assign wbd_err_i = 1'b0;
100
assign wbi_err_i = 1'b0;
101 68 simont
 
102
//
103
// oc8051 controller
104
//
105 103 simont
oc8051_top oc8051_top_1(.wb_rst_i(rst), .wb_clk_i(clk),
106
         .int0_i(int0), .int1_i(int1),
107 68 simont
 
108 103 simont
         .wbd_dat_i(data_in), .wbd_we_o(write), .wbd_dat_o(data_out),
109
         .wbd_adr_o(ext_addr), .wbd_err_i(wbd_err_i),
110
         .wbd_ack_i(ack_i), .wbd_stb_o(stb_o), .wbd_cyc_o(cyc_o),
111 68 simont
 
112 103 simont
         .wbi_adr_o(iadr_o), .wbi_stb_o(istb_o), .wbi_ack_i(iack_i),
113
         .wbi_cyc_o(icyc_o), .wbi_dat_i(idat_i), .wbi_err_i(wbi_err_i),
114
 
115 120 simont
  `ifdef OC8051_PORTS
116 103 simont
 
117 120 simont
   `ifdef OC8051_PORT0
118
         .p0_i(p0_in),
119
         .p0_o(p0_out),
120
   `endif
121
 
122
   `ifdef OC8051_PORT1
123
         .p1_i(p1_in),
124
         .p1_o(p1_out),
125
   `endif
126
 
127
   `ifdef OC8051_PORT2
128
         .p2_i(p2_in),
129
         .p2_o(p2_out),
130
   `endif
131
 
132
   `ifdef OC8051_PORT3
133
         .p3_i(p3_in),
134
         .p3_o(p3_out),
135
   `endif
136
  `endif
137
 
138
 
139
   `ifdef OC8051_UART
140 103 simont
         .rxd_i(rxd), .txd_o(txd),
141 120 simont
   `endif
142 103 simont
 
143 120 simont
   `ifdef OC8051_TC01
144
         .t0_i(t0), .t1_i(t1),
145
   `endif
146 103 simont
 
147 120 simont
   `ifdef OC8051_TC2
148
         .t2_i(t2), .t2ex_i(t2ex),
149
   `endif
150
 
151
         .ea_in(ea[0]));
152
 
153
 
154 68 simont
//
155
// external data ram
156
//
157
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));
158
 
159
 
160
defparam oc8051_xram1.DELAY = 2;
161
 
162
//
163
// external uart
164
//
165
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
166
                  .wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
167
                  .txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
168
 
169
//
170
// exteranl program rom
171
//
172
 
173 111 simont
oc8051_xrom oc8051_xrom1(.rst(rst), .clk(clk), .addr(iadr_o), .data(idat_i),
174
             .stb_i(istb_o), .cyc_i(icyc_o), .ack_o(iack_i));
175 74 simont
 
176
 
177 68 simont
//
178
//
179
//
180 59 simont
 
181 68 simont
defparam oc8051_xrom1.DELAY = 5;
182 59 simont
 
183 74 simont
//
184
// test wb interface
185
//
186 84 simont
 
187 74 simont
reg [31:0] log_file;
188 59 simont
 
189 74 simont
initial
190
begin
191
  log_file = $fopen("log_file");
192
  $fdisplay(log_file, "file open");
193
end
194 68 simont
 
195 74 simont
 
196 68 simont
assign write_xram = p3_out[7] & write;
197
assign write_uart = !p3_out[7] & write;
198
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
199
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
200 84 simont
assign p3_in = {6'h0, bit_out, int_uart};
201 68 simont
assign t0 = p3_out[5];
202
assign t1 = p3_out[6];
203
 
204
assign int0 = p3_out[3];
205
assign int1 = p3_out[4];
206 84 simont
assign t2 = p3_out[5];
207
assign t2ex = p3_out[2];
208 68 simont
 
209
initial begin
210
  rst= 1'b1;
211
  p0_in = 8'h00;
212
  p1_in = 8'h00;
213
  p2_in = 8'h00;
214 103 simont
#220
215 68 simont
  rst = 1'b0;
216
 
217 111 simont
#40000000
218 74 simont
  $fclose(log_file);
219 68 simont
  $display("time ",$time, "\n faulire: end of time\n \n");
220
  $finish;
221
end
222
 
223
 
224 103 simont
initial
225
begin
226
  clk = 0;
227 111 simont
  forever #30 clk <= ~clk;
228 103 simont
end
229 68 simont
 
230
 
231
 
232
initial
233 103 simont
  $readmemh("../../../bench/vec/oc8051_test.vec", buff);
234 68 simont
 
235
initial
236
  $readmemb("../oc8051_ea.in", ea);
237
 
238
 
239
initial num= 0;
240
 
241
always @(p0_out or p1_out or p2_out)
242
begin
243
  if ({p0_out, p1_out, p2_out} != buff[num])
244
  begin
245
    $display("time ",$time, " faulire: mismatch on ports in step %d", num);
246
    $display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
247
    $display(" testvecp %h", buff[num]);
248
    $display(" p_out   %h%h%h", p0_out, p1_out, p2_out);
249
#22
250 74 simont
    $fclose(log_file);
251 68 simont
    $finish;
252
  end
253
  else begin
254
    $display("time ",$time, " step %d", num, ": pass");
255
    num =  num+1;
256
    if (buff[num]===24'hxxxxxx)
257
    begin
258
      $display("");
259
      $display(" Done!");
260 74 simont
      $fclose(log_file);
261 68 simont
      $finish;
262
    end
263
  end
264
end
265
 
266
 
267
initial $dumpvars;
268
 
269
 
270
endmodule

powered by: WebSVN 2.1.0

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