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 46

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

Line No. Rev Author Line
1 46 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
// $Log: not supported by cvs2svn $
47
//
48
 
49
// synopsys translate_off
50
`include "oc8051_timescale.v"
51
// synopsys translate_on
52
 
53
module oc8051_tb;
54
 
55
reg rst, clk, ea;
56
reg [15:0] pc_in;
57
reg [7:0] p0_in, p1_in, p2_in, op1, op2, op3;
58
wire [15:0] ext_addr, rom_addr;
59
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;
60
wire [7:0] data_in, data_out, p0_out, p1_out, p2_out, p3_out, data_out_uart, data_out_xram, p3_in;
61
 
62
///
63
/// buffer for test vectors
64
///
65
//
66
// buffer
67
reg [23:0] buff [255:0];
68
 
69
integer num;
70
 
71
 
72
oc8051_top oc8051_top_1(.rst(rst), .clk(clk), .int0(int0), .int1(int1),
73
         .dat_i(data_in), .dat_o(data_out),
74
         .adr_o(ext_addr), .rom_addr(rom_addr), .we_o(write), .p0_in(p0_in),
75
         .ack_i(ack_i), .stb_o(stb_o), .cyc_o(cyc_o),
76
         .p1_in(p1_in), .p2_in(p2_in), .p3_in(p3_in), .p0_out(p0_out), .p1_out(p1_out),
77
         .p2_out(p2_out), .p3_out(p3_out), .op1(op1), .op2(op2), .op3(op3), .ea(ea),
78
         .rxd(rxd), .txd(txd), .t0(t0), .t1(t1));
79
 
80
 
81
oc8051_xram oc8051_xram1 (.clk(clk), .wr(write_xram), .addr(ext_addr), .data_in(data_out), .data_out(data_out_xram), .ack(ack_xram), .stb(stb_o));
82
 
83
oc8051_uart_test oc8051_uart_test1(.clk(clk), .rst(rst), .addr(ext_addr[7:0]), .wr(write_uart),
84
                  .wr_bit(p3_out[0]), .data_in(data_out), .data_out(data_out_uart), .bit_out(bit_out), .rxd(txd),
85
                  .txd(rxd), .ow(p3_out[1]), .intr(int_uart), .stb(stb_o), .ack(ack_uart));
86
 
87
 
88
assign write_xram = p3_out[7] & write;
89
assign write_uart = !p3_out[7] & write;
90
assign data_in = p3_out[7] ? data_out_xram : data_out_uart;
91
assign ack_i = p3_out[7] ? ack_xram : ack_uart;
92
assign p3_in = {7'b000000, bit_out, int_uart};
93
assign t0 = p3_out[5];
94
assign t1 = p3_out[6];
95
 
96
assign int0 = p3_out[3];
97
assign int1 = p3_out[4];
98
 
99
 
100
initial begin
101
  clk= 1'b0;
102
  rst= 1'b1;
103
//  int0= 1'b1;
104
//  int1= 1'b1;
105
  pc_in = 16'h0000;
106
  p0_in = 8'h00;
107
  p1_in = 8'h00;
108
  p2_in = 8'h00;
109
  op1 = 8'h00;
110
  op2 = 8'h00;
111
  op3 = 8'h00;
112
  ea =1'b1;
113
#22
114
  rst = 1'b0;
115
//#2000000
116
#4444000
117
 
118
//#500000
119
  $display("time ",$time, "\n faulire: end of time\n \n");
120
  $finish;
121
end
122
 
123
/*initial begin
124
#222
125
  int= 1'b1;
126
  int_v= 8'h50;
127
#20
128
  int= 1'b0;
129
end*/
130
 
131
always clk = #5 ~clk;
132
 
133
 
134
 
135
initial
136
  $readmemh("../src/oc8051_test.vec", buff);
137
 
138
initial num= 0;
139
 
140
always @(p0_out or p1_out or p2_out)
141
begin
142
  if ({p0_out, p1_out, p2_out} != buff[num])
143
  begin
144
    $display("time ",$time, " faulire: mismatch on ports in step %d", num);
145
    $display(" p0_out %h", p0_out, " p1_out %h", p1_out, " p2_out %h", p2_out);
146
    $display(" testvecp %h", buff[num]);
147
    $display(" p_out   %h%h%h", p0_out, p1_out, p2_out);
148
#22
149
    $finish;
150
  end
151
  else begin
152
    $display("time ",$time, " step %d", num, ": pass");
153
    num =  num+1;
154
    if (buff[num]===24'hxxxxxx)
155
    begin
156
      $display("");
157
      $display(" Done!");
158
      $finish;
159
    end
160
  end
161
end
162
 
163
 
164
initial $dumpvars;
165
 
166
 
167
//initial $monitor("time ",$time," acc %h", data_out, " dptr %h", ext_addr, " write ", write, " p0_out %h", p0_out, " p1_out %h", p1_out);
168
 
169
//initial $monitor("time ",$time, " p0_out ", p0_out);
170
 
171
//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);
172
 
173
endmodule

powered by: WebSVN 2.1.0

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