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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [rtl/] [verilog/] [t6532_tb.v] - Blame information for rev 217

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

Line No. Rev Author Line
1 203 creep
////////////////////////////////////////////////////////////////////////////
2
////                                                                    ////
3
//// T6532 IP Core                                                      ////
4
////                                                                    ////
5
//// This file is part of the T2600 project                             ////
6
//// http://www.opencores.org/cores/t2600/                              ////
7
////                                                                    ////
8
//// Description                                                        ////
9
//// 6532 testbench                                                     ////
10
////                                                                    ////
11
//// Author(s):                                                         ////
12
//// - Gabriel Oshiro Zardo, gabrieloshiro@gmail.com                    ////
13
//// - Samuel Nascimento Pagliarini (creep), snpagliarini@gmail.com     ////
14
////                                                                    ////
15
////////////////////////////////////////////////////////////////////////////
16
////                                                                    ////
17
//// Copyright (C) 2001 Authors and OPENCORES.ORG                       ////
18
////                                                                    ////
19
//// This source file may be used and distributed without               ////
20
//// restriction provided that this copyright statement is not          ////
21
//// removed from the file and that any derivative work contains        ////
22
//// the original copyright notice and the associated disclaimer.       ////
23
////                                                                    ////
24
//// This source file is free software; you can redistribute it         ////
25
//// and/or modify it under the terms of the GNU Lesser General         ////
26
//// Public License as published by the Free Software Foundation;       ////
27
//// either version 2.1 of the License, or (at your option) any         ////
28
//// later version.                                                     ////
29
////                                                                    ////
30
//// This source is distributed in the hope that it will be             ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied         ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ////
33
//// PURPOSE. See the GNU Lesser General Public License for more        ////
34
//// details.                                                           ////
35
////                                                                    ////
36
//// You should have received a copy of the GNU Lesser General          ////
37
//// Public License along with this source; if not, download it         ////
38
//// from http://www.opencores.org/lgpl.shtml                           ////
39
////                                                                    ////
40
////////////////////////////////////////////////////////////////////////////
41
 
42
`include "timescale.v"
43
 
44
module t6532_tb();
45
        // mem_rw signals
46
        localparam MEM_READ = 1'b0;
47
        localparam MEM_WRITE = 1'b1;
48
 
49
        parameter [3:0] DATA_SIZE = 4'd8;
50
        parameter [3:0] ADDR_SIZE = 4'd10; // this is the *local* addr_size
51
 
52
        localparam [3:0] DATA_SIZE_ = DATA_SIZE - 4'd1;
53
        localparam [3:0] ADDR_SIZE_ = ADDR_SIZE - 4'd1;
54
 
55
        reg clk; // regs are inputs
56
        reg reset_n;
57
        reg [15:0] io_lines;
58
        reg enable;
59
        reg mem_rw;
60
        reg [ADDR_SIZE_:0] address;
61
 
62
        reg [DATA_SIZE_:0] data_drv;
63
        tri [DATA_SIZE_:0] data = data_drv;
64
 
65
        t6532 #(DATA_SIZE, ADDR_SIZE) t6532(
66
                .clk            (clk),
67
                .reset_n        (reset_n),
68
                .io_lines       (io_lines),
69
                .enable         (enable),
70
                .mem_rw         (mem_rw),
71
                .address        (address),
72
                .data           (data)
73
        );
74
 
75
        always #10 clk = ~clk;
76
 
77
        always @(*) begin
78
                if (mem_rw == MEM_READ) begin
79
                        data_drv = 8'hZ;
80
                end
81
        end
82
 
83
        initial begin
84
                clk = 1'b0;
85
                reset_n = 1'b0;
86 204 creep
                io_lines = 16'd0;
87 203 creep
                enable = 1'b0;
88
                mem_rw = MEM_READ;
89
                address = 0;
90
 
91
                @(negedge clk) // will wait for next negative edge of the clock (t=20)
92
                reset_n=1'b1;
93
 
94 204 creep
                @(negedge clk) // testing the port_b. all switches must change!
95
                io_lines = 16'h00FF;
96
 
97
                @(negedge clk) // testing the port_b. all switches must change!
98
                io_lines = 16'h00FF;
99
 
100
                @(negedge clk) // testing the port_a. all switches must change since ddra = 0. (0 == input)
101
                io_lines = 16'hFF00;
102
 
103
                @(negedge clk) // setting ddra = FF. (output)
104
                enable = 1'b1;
105
                io_lines = 16'hFF00;
106
                address = 10'h281;
107
                mem_rw = MEM_WRITE;
108
                data_drv = 8'hFF;
109
 
110
                @(negedge clk) // testing port_a again. no switching this time!
111
                enable = 1'b0;
112
                io_lines = 16'h0000;
113
                address = 0;
114
                mem_rw = MEM_READ;
115
 
116
                @(negedge clk) // writing at the memory
117
                enable = 1'b1;
118
                address = 10'd255;
119
                mem_rw = MEM_WRITE;
120
                data_drv = 8'h11;
121
 
122
                @(negedge clk) // reading memory (output)
123
                enable = 1'b1;
124
                address = 10'd255;
125
                mem_rw = MEM_READ;
126
 
127
                @(negedge clk) // using the timer to count 100*1 cycle.
128
                enable = 1'b1;
129
                address = 10'h294;
130
                mem_rw = MEM_WRITE;
131
                data_drv = 8'd100;
132
 
133
                @(negedge clk);
134
                mem_rw = MEM_READ;
135
                enable = 1'b0;
136
                #2040;
137
 
138
                @(negedge clk) // using the timer to count 10*8 cycles.
139
                enable = 1'b1;
140
                address = 10'h295;
141
                mem_rw = MEM_WRITE;
142
                data_drv = 8'd10;
143
 
144
                @(negedge clk);
145
                mem_rw = MEM_READ;
146
                enable = 1'b0;
147
                #1640;
148
 
149
 
150
 
151 203 creep
                $finish; // to shut down the simulation
152
        end //initial
153
 
154
endmodule

powered by: WebSVN 2.1.0

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