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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [wb_port/] [wb_port_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 wb_port_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
        wire [15:0] checkbits;
35
 
36
        assign checkbits = mprj_io[31:16];
37
 
38
        assign mprj_io[3] = (CSB == 1'b1) ? 1'b1 : 1'bz;
39
 
40
        // External clock is used by default.  Make this artificially fast for the
41
        // simulation.  Normally this would be a slow clock and the digital PLL
42
        // would be the fast clock.
43
 
44
        always #12.5 clock <= (clock === 1'b0);
45
 
46
        initial begin
47
                clock = 0;
48
        end
49
 
50
        initial begin
51
                $dumpfile("wb_port.vcd");
52
                $dumpvars(0, wb_port_tb);
53
 
54
                // Repeat cycles of 1000 clock edges as needed to complete testbench
55
                repeat (30) begin
56
                        repeat (1000) @(posedge clock);
57
                        // $display("+1000 cycles");
58
                end
59
                $display("%c[1;31m",27);
60
                `ifdef GL
61
                        $display ("Monitor: Timeout, Test Mega-Project WB Port (GL) Failed");
62
                `else
63
                        $display ("Monitor: Timeout, Test Mega-Project WB Port (RTL) Failed");
64
                `endif
65
                $display("%c[0m",27);
66
                $finish;
67
        end
68
 
69
        initial begin
70
           wait(checkbits == 16'h AB60);
71
                $display("Monitor: MPRJ-Logic WB Started");
72
                wait(checkbits == 16'h AB61);
73
                `ifdef GL
74
                $display("Monitor: Mega-Project WB (GL) Passed");
75
                `else
76
                    $display("Monitor: Mega-Project WB (RTL) Passed");
77
                `endif
78
            $finish;
79
        end
80
 
81
        initial begin
82
                RSTB <= 1'b0;
83
                CSB  <= 1'b1;           // Force CSB high
84
                #2000;
85
                RSTB <= 1'b1;           // Release reset
86
                #170000;
87
                CSB = 1'b0;             // CSB can be released
88
        end
89
 
90
        initial begin           // Power-up sequence
91
                power1 <= 1'b0;
92
                power2 <= 1'b0;
93
                power3 <= 1'b0;
94
                power4 <= 1'b0;
95
                #100;
96
                power1 <= 1'b1;
97
                #100;
98
                power2 <= 1'b1;
99
                #100;
100
                power3 <= 1'b1;
101
                #100;
102
                power4 <= 1'b1;
103
        end
104
 
105
        always @(mprj_io) begin
106
                #1 $display("MPRJ-IO state = %b ", mprj_io[7:0]);
107
        end
108
 
109
        wire flash_csb;
110
        wire flash_clk;
111
        wire flash_io0;
112
        wire flash_io1;
113
 
114
        wire VDD3V3 = power1;
115
        wire VDD1V8 = power2;
116
        wire USER_VDD3V3 = power3;
117
        wire USER_VDD1V8 = power4;
118
        wire VSS = 1'b0;
119
 
120
        caravel uut (
121
                .vddio    (VDD3V3),
122
                .vssio    (VSS),
123
                .vdda     (VDD3V3),
124
                .vssa     (VSS),
125
                .vccd     (VDD1V8),
126
                .vssd     (VSS),
127
                .vdda1    (USER_VDD3V3),
128
                .vdda2    (USER_VDD3V3),
129
                .vssa1    (VSS),
130
                .vssa2    (VSS),
131
                .vccd1    (USER_VDD1V8),
132
                .vccd2    (USER_VDD1V8),
133
                .vssd1    (VSS),
134
                .vssd2    (VSS),
135
                .clock    (clock),
136
                .gpio     (gpio),
137
        .mprj_io  (mprj_io),
138
                .flash_csb(flash_csb),
139
                .flash_clk(flash_clk),
140
                .flash_io0(flash_io0),
141
                .flash_io1(flash_io1),
142
                .resetb   (RSTB)
143
        );
144
 
145
        spiflash #(
146
                .FILENAME("wb_port.hex")
147
        ) spiflash (
148
                .csb(flash_csb),
149
                .clk(flash_clk),
150
                .io0(flash_io0),
151
                .io1(flash_io1),
152
                .io2(),                 // not used
153
                .io3()                  // not used
154
        );
155
 
156
endmodule
157
`default_nettype wire

powered by: WebSVN 2.1.0

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