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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [io_ports/] [io_ports_tb.v] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
// SPDX-FileCopyrightText: 2020 Efabless Corporation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// SPDX-License-Identifier: Apache-2.0
15
 
16
`default_nettype none
17
 
18
`timescale 1 ns / 1 ps
19
 
20
`include "uprj_netlists.v"
21
`include "caravel_netlists.v"
22
`include "spiflash.v"
23
 
24
module io_ports_tb;
25
        reg clock;
26
        reg RSTB;
27
        reg CSB;
28
        reg power1, power2;
29
        reg power3, power4;
30
 
31
        wire gpio;
32
        wire [37:0] mprj_io;
33
        wire [7:0] mprj_io_0;
34
 
35
        assign mprj_io_0 = mprj_io[7:0];
36
        // assign mprj_io_0 = {mprj_io[8:4],mprj_io[2:0]};
37
 
38
        assign mprj_io[3] = (CSB == 1'b1) ? 1'b1 : 1'bz;
39
        // assign mprj_io[3] = 1'b1;
40
 
41
        // External clock is used by default.  Make this artificially fast for the
42
        // simulation.  Normally this would be a slow clock and the digital PLL
43
        // would be the fast clock.
44
 
45
        always #12.5 clock <= (clock === 1'b0);
46
 
47
        initial begin
48
                clock = 0;
49
        end
50
 
51
        initial begin
52 22 dinesha
                `ifdef WFDUMP
53
                    $dumpfile("io_ports.vcd");
54
                    $dumpvars(0, io_ports_tb);
55
                `endif
56 2 dinesha
 
57
                // Repeat cycles of 1000 clock edges as needed to complete testbench
58
                repeat (25) begin
59
                        repeat (1000) @(posedge clock);
60
                        // $display("+1000 cycles");
61
                end
62
                $display("%c[1;31m",27);
63
                `ifdef GL
64
                        $display ("Monitor: Timeout, Test Mega-Project IO Ports (GL) Failed");
65
                `else
66
                        $display ("Monitor: Timeout, Test Mega-Project IO Ports (RTL) Failed");
67
                `endif
68
                $display("%c[0m",27);
69
                $finish;
70
        end
71
 
72
        initial begin
73
            // Observe Output pins [7:0]
74
            wait(mprj_io_0 == 8'h01);
75
            wait(mprj_io_0 == 8'h02);
76
            wait(mprj_io_0 == 8'h03);
77
            wait(mprj_io_0 == 8'h04);
78
            wait(mprj_io_0 == 8'h05);
79
            wait(mprj_io_0 == 8'h06);
80
            wait(mprj_io_0 == 8'h07);
81
            wait(mprj_io_0 == 8'h08);
82
            wait(mprj_io_0 == 8'h09);
83
            wait(mprj_io_0 == 8'h0A);
84
            wait(mprj_io_0 == 8'hFF);
85
            wait(mprj_io_0 == 8'h00);
86
 
87
                `ifdef GL
88
                $display("Monitor: Test 1 Mega-Project IO (GL) Passed");
89
                `else
90
                    $display("Monitor: Test 1 Mega-Project IO (RTL) Passed");
91
                `endif
92
            $finish;
93
        end
94
 
95
        initial begin
96
                RSTB <= 1'b0;
97
                CSB  <= 1'b1;           // Force CSB high
98
                #2000;
99
                RSTB <= 1'b1;           // Release reset
100
                #170000;
101
                CSB = 1'b0;             // CSB can be released
102
        end
103
 
104
        initial begin           // Power-up sequence
105
                power1 <= 1'b0;
106
                power2 <= 1'b0;
107
                power3 <= 1'b0;
108
                power4 <= 1'b0;
109
                #100;
110
                power1 <= 1'b1;
111
                #100;
112
                power2 <= 1'b1;
113
                #100;
114
                power3 <= 1'b1;
115
                #100;
116
                power4 <= 1'b1;
117
        end
118
 
119
        always @(mprj_io) begin
120
                #1 $display("MPRJ-IO state = %b ", mprj_io[7:0]);
121
        end
122
 
123
        wire flash_csb;
124
        wire flash_clk;
125
        wire flash_io0;
126
        wire flash_io1;
127
 
128
        wire VDD3V3 = power1;
129
        wire VDD1V8 = power2;
130
        wire USER_VDD3V3 = power3;
131
        wire USER_VDD1V8 = power4;
132
        wire VSS = 1'b0;
133
 
134
        caravel uut (
135
                .vddio    (VDD3V3),
136
                .vssio    (VSS),
137
                .vdda     (VDD3V3),
138
                .vssa     (VSS),
139
                .vccd     (VDD1V8),
140
                .vssd     (VSS),
141
                .vdda1    (USER_VDD3V3),
142
                .vdda2    (USER_VDD3V3),
143
                .vssa1    (VSS),
144
                .vssa2    (VSS),
145
                .vccd1    (USER_VDD1V8),
146
                .vccd2    (USER_VDD1V8),
147
                .vssd1    (VSS),
148
                .vssd2    (VSS),
149
                .clock    (clock),
150
                .gpio     (gpio),
151
                .mprj_io  (mprj_io),
152
                .flash_csb(flash_csb),
153
                .flash_clk(flash_clk),
154
                .flash_io0(flash_io0),
155
                .flash_io1(flash_io1),
156
                .resetb   (RSTB)
157
        );
158
 
159
        spiflash #(
160
                .FILENAME("io_ports.hex")
161
        ) spiflash (
162
                .csb(flash_csb),
163
                .clk(flash_clk),
164
                .io0(flash_io0),
165
                .io1(flash_io1),
166
                .io2(),                 // not used
167
                .io3()                  // not used
168
        );
169
 
170
endmodule
171
`default_nettype wire

powered by: WebSVN 2.1.0

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