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

Subversion Repositories light8080

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

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
//---------------------------------------------------------------------------------------
40
// internal signals 
41
reg clock;                              // global clock 
42
reg reset;                              // global reset 
43
 
44
// UUT interfaces 
45
wire rxd, txd;
46
wire [7:0] p1dio, p2dio;
47
 
48
//---------------------------------------------------------------------------------------
49
// test bench implementation 
50
// global signals generation  
51
initial
52
begin
53
        clock = 0;
54
        reset = 1;
55
        #100 reset = 0;
56
end
57
 
58
// clock generator - 50MHz clock 
59
always
60
begin
61
        #10 clock = 0;
62
        #10 clock = 1;
63
end
64
 
65
// test bench dump variables 
66
initial
67
begin
68
        $display("");
69
        $display("  light8080 SOC simulation");
70
        $display("--------------------------------------");
71
        $dumpfile("test.vcd");
72
        $dumpvars(0, test);
73
        $display("");
74
end
75
 
76
// simulation end condition 
77
always @ (posedge clock)
78
begin
79
        if (dut.cpu_io && (dut.cpu_addr[7:0] == 8'hff))
80
        begin
81
                $display("");
82
                $display("Simulation ended by software");
83
                $finish;
84
        end
85
end
86
 
87
//------------------------------------------------------------------
88
// device under test 
89
l80soc dut
90
(
91
        .clock(clock),
92
        .reset(reset),
93
        .txd(txd),
94
        .rxd(rxd),
95
        .p1dio(p1dio),
96
        .p2dio(p2dio)
97
);
98
 
99
//------------------------------------------------------------------
100
// uart receive is not used in this test becnch 
101
assign rxd = 1'b1;
102
 
103
`ifdef CPU_TRACE
104
// display executed instructions 
105
reg [15:0] saddr;
106
reg scpu_rd;
107
always @ (posedge clock)
108
begin
109
        if (dut.cpu.uc_decode)
110
        begin
111
                $display("");
112
                $write("%x : %x", saddr, dut.cpu.data_in);
113
        end
114
        else if (scpu_rd)
115
                $write("%x", dut.cpu.data_in);
116
 
117
        // sampled address bus and read pulse 
118
        saddr <= dut.cpu.addr_out;
119
        scpu_rd <= dut.cpu.rd;
120
end
121
`else
122
// display characters transmitted to the uart 
123
initial
124
begin
125
        $display("Characters sent to the UART:");
126
end
127
 
128
// check uart write pulse 
129
always @ (posedge clock)
130
begin
131
        if (dut.txValid)
132
                $write("%c", dut.cpu_dout);
133
end
134
`endif
135
endmodule
136
//---------------------------------------------------------------------------------------
137
//                                              Th.. Th.. Th.. Thats all folks !!!
138
//---------------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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