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

Subversion Repositories light8080

[/] [light8080/] [trunk/] [verilog/] [bench/] [tb_l80soc.v] - Blame information for rev 74

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

Line No. Rev Author Line
1 65 motilito
//---------------------------------------------------------------------------------------
2
//      Project:        light8080 SOC           WiCores Solutions 
3
// 
4
//      Filename:       tb_l80soc.v                     (February 04, 2012)
5
// 
6
//      Author(s):      Moti Litochevski 
7
// 
8
//      Description:
9
//              This file implements the light8080 SOC test bench. 
10
//
11
//---------------------------------------------------------------------------------------
12
//
13
//      To Do: 
14
//      - 
15
// 
16
//---------------------------------------------------------------------------------------
17
// 
18
//      Copyright (C) 2012 Moti Litochevski 
19
// 
20
//      This source file may be used and distributed without restriction provided that this 
21
//      copyright statement is not removed from the file and that any derivative work 
22
//      contains the original copyright notice and the associated disclaimer.
23
//
24
//      THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 
25
//      INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND 
26
//      FITNESS FOR A PARTICULAR PURPOSE. 
27
// 
28
//---------------------------------------------------------------------------------------
29
 
30
`timescale 1ns / 1ns
31
 
32
module test;
33
//---------------------------------------------------------------------------------------
34
// test bench global defines 
35
// the following define selects between CPU instruction trace and uart transmitted bytes 
36
//`define CPU_TRACE             1
37
 
38
//---------------------------------------------------------------------------------------
39
// internal signals 
40
reg clock;                              // global clock 
41
reg reset;                              // global reset 
42
 
43
// UUT interfaces 
44
wire rxd, txd;
45
wire [7:0] p1dio, p2dio;
46 66 motilito
wire [3:0] extint;
47
reg sp1dio0;
48 65 motilito
 
49
//---------------------------------------------------------------------------------------
50
// test bench implementation 
51
// global signals generation  
52
initial
53
begin
54
        clock = 0;
55
        reset = 1;
56
        #100 reset = 0;
57
end
58
 
59
// clock generator - 50MHz clock 
60
always
61
begin
62
        #10 clock = 0;
63
        #10 clock = 1;
64
end
65
 
66
// test bench dump variables 
67
initial
68
begin
69
        $display("");
70
        $display("  light8080 SOC simulation");
71
        $display("--------------------------------------");
72
        $dumpfile("test.vcd");
73
        $dumpvars(0, test);
74
        $display("");
75
end
76
 
77
// simulation end condition 
78
always @ (posedge clock)
79
begin
80
        if (dut.cpu_io && (dut.cpu_addr[7:0] == 8'hff))
81
        begin
82
                $display("");
83
                $display("Simulation ended by software");
84
                $finish;
85
        end
86
end
87
 
88
//------------------------------------------------------------------
89
// device under test 
90
l80soc dut
91
(
92
        .clock(clock),
93
        .reset(reset),
94
        .txd(txd),
95
        .rxd(rxd),
96
        .p1dio(p1dio),
97 66 motilito
        .p2dio(p2dio),
98
        .extint(extint)
99 65 motilito
);
100
 
101
//------------------------------------------------------------------
102
// uart receive is not used in this test becnch 
103
assign rxd = 1'b1;
104
 
105 66 motilito
// external interrupt 0 is connected to the p1dio[0] rising edge 
106
assign extint[3:1] = 3'b0;
107
assign extint[0] = ((sp1dio0 == 1'b0) && (p1dio[0] == 1'b1)) ? 1'b1 : 1'b0;
108
 
109
// p1dio[0] rising edge detection 
110
always @ (posedge reset or posedge clock)
111
begin
112
        if (reset)
113
                sp1dio0 <= 1'b0;
114
        else if (p1dio[0] == 1'b1)
115
                sp1dio0 <= 1'b1;
116
        else
117
                sp1dio0 <= 1'b0;
118
end
119
 
120
//------------------------------------------------------------------
121
// test bench output log selection - either simple CPU trace or UART 
122
// transmit port log 
123 65 motilito
`ifdef CPU_TRACE
124
// display executed instructions 
125
reg [15:0] saddr;
126
reg scpu_rd;
127
always @ (posedge clock)
128
begin
129
        if (dut.cpu.uc_decode)
130
        begin
131
                $display("");
132
                $write("%x : %x", saddr, dut.cpu.data_in);
133
        end
134
        else if (scpu_rd)
135
                $write("%x", dut.cpu.data_in);
136
 
137
        // sampled address bus and read pulse 
138
        saddr <= dut.cpu.addr_out;
139
        scpu_rd <= dut.cpu.rd;
140
end
141
`else
142
// display characters transmitted to the uart 
143
initial
144
begin
145
        $display("Characters sent to the UART:");
146
end
147
 
148
// check uart write pulse 
149
always @ (posedge clock)
150
begin
151
        if (dut.txValid)
152
                $write("%c", dut.cpu_dout);
153
end
154
`endif
155
endmodule
156
//---------------------------------------------------------------------------------------
157
//                                              Th.. Th.. Th.. Thats all folks !!!
158
//---------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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