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 2

Go to most recent revision | 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
                $dumpfile("io_ports.vcd");
53
                $dumpvars(0, io_ports_tb);
54
 
55
                // Repeat cycles of 1000 clock edges as needed to complete testbench
56
                repeat (25) begin
57
                        repeat (1000) @(posedge clock);
58
                        // $display("+1000 cycles");
59
                end
60
                $display("%c[1;31m",27);
61
                `ifdef GL
62
                        $display ("Monitor: Timeout, Test Mega-Project IO Ports (GL) Failed");
63
                `else
64
                        $display ("Monitor: Timeout, Test Mega-Project IO Ports (RTL) Failed");
65
                `endif
66
                $display("%c[0m",27);
67
                $finish;
68
        end
69
 
70
        initial begin
71
            // Observe Output pins [7:0]
72
            wait(mprj_io_0 == 8'h01);
73
            wait(mprj_io_0 == 8'h02);
74
            wait(mprj_io_0 == 8'h03);
75
            wait(mprj_io_0 == 8'h04);
76
            wait(mprj_io_0 == 8'h05);
77
            wait(mprj_io_0 == 8'h06);
78
            wait(mprj_io_0 == 8'h07);
79
            wait(mprj_io_0 == 8'h08);
80
            wait(mprj_io_0 == 8'h09);
81
            wait(mprj_io_0 == 8'h0A);
82
            wait(mprj_io_0 == 8'hFF);
83
            wait(mprj_io_0 == 8'h00);
84
 
85
                `ifdef GL
86
                $display("Monitor: Test 1 Mega-Project IO (GL) Passed");
87
                `else
88
                    $display("Monitor: Test 1 Mega-Project IO (RTL) Passed");
89
                `endif
90
            $finish;
91
        end
92
 
93
        initial begin
94
                RSTB <= 1'b0;
95
                CSB  <= 1'b1;           // Force CSB high
96
                #2000;
97
                RSTB <= 1'b1;           // Release reset
98
                #170000;
99
                CSB = 1'b0;             // CSB can be released
100
        end
101
 
102
        initial begin           // Power-up sequence
103
                power1 <= 1'b0;
104
                power2 <= 1'b0;
105
                power3 <= 1'b0;
106
                power4 <= 1'b0;
107
                #100;
108
                power1 <= 1'b1;
109
                #100;
110
                power2 <= 1'b1;
111
                #100;
112
                power3 <= 1'b1;
113
                #100;
114
                power4 <= 1'b1;
115
        end
116
 
117
        always @(mprj_io) begin
118
                #1 $display("MPRJ-IO state = %b ", mprj_io[7:0]);
119
        end
120
 
121
        wire flash_csb;
122
        wire flash_clk;
123
        wire flash_io0;
124
        wire flash_io1;
125
 
126
        wire VDD3V3 = power1;
127
        wire VDD1V8 = power2;
128
        wire USER_VDD3V3 = power3;
129
        wire USER_VDD1V8 = power4;
130
        wire VSS = 1'b0;
131
 
132
        caravel uut (
133
                .vddio    (VDD3V3),
134
                .vssio    (VSS),
135
                .vdda     (VDD3V3),
136
                .vssa     (VSS),
137
                .vccd     (VDD1V8),
138
                .vssd     (VSS),
139
                .vdda1    (USER_VDD3V3),
140
                .vdda2    (USER_VDD3V3),
141
                .vssa1    (VSS),
142
                .vssa2    (VSS),
143
                .vccd1    (USER_VDD1V8),
144
                .vccd2    (USER_VDD1V8),
145
                .vssd1    (VSS),
146
                .vssd2    (VSS),
147
                .clock    (clock),
148
                .gpio     (gpio),
149
                .mprj_io  (mprj_io),
150
                .flash_csb(flash_csb),
151
                .flash_clk(flash_clk),
152
                .flash_io0(flash_io0),
153
                .flash_io1(flash_io1),
154
                .resetb   (RSTB)
155
        );
156
 
157
        spiflash #(
158
                .FILENAME("io_ports.hex")
159
        ) spiflash (
160
                .csb(flash_csb),
161
                .clk(flash_clk),
162
                .io0(flash_io0),
163
                .io1(flash_io1),
164
                .io2(),                 // not used
165
                .io3()                  // not used
166
        );
167
 
168
endmodule
169
`default_nettype wire

powered by: WebSVN 2.1.0

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