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 111

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

powered by: WebSVN 2.1.0

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