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

powered by: WebSVN 2.1.0

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