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 37

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

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

powered by: WebSVN 2.1.0

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