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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [la_test2/] [la_test2_tb.v] - Blame information for rev 2

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 la_test2_tb;
25
        reg clock;
26
        reg RSTB;
27
        reg CSB;
28
 
29
        reg power1, power2;
30
 
31
        wire gpio;
32
        wire [37:0] mprj_io;
33
        wire [15:0] checkbits;
34
 
35
        assign checkbits = mprj_io[31:16];
36
        assign mprj_io[3] = (CSB == 1'b1) ? 1'b1 : 1'bz;
37
 
38
        always #12.5 clock <= (clock === 1'b0);
39
 
40
        initial begin
41
                clock = 0;
42
        end
43
 
44
        initial begin
45
                $dumpfile("la_test2.vcd");
46
                $dumpvars(0, la_test2_tb);
47
 
48
                // Repeat cycles of 1000 clock edges as needed to complete testbench
49
                repeat (30) begin
50
                        repeat (1000) @(posedge clock);
51
                        // $display("+1000 cycles");
52
                end
53
                $display("%c[1;31m",27);
54
                `ifdef GL
55
                        $display ("Monitor: Timeout, Test Mega-Project IO (GL) Failed");
56
                `else
57
                        $display ("Monitor: Timeout, Test Mega-Project IO (RTL) Failed");
58
                `endif
59
                $display("%c[0m",27);
60
                $finish;
61
        end
62
 
63
        initial begin
64
                wait(checkbits == 16'h AB60);
65
                $display("Monitor: Test 2 MPRJ-Logic Analyzer Started");
66
                wait(checkbits == 16'h AB61);
67
                $display("Monitor: Test 2 MPRJ-Logic Analyzer Passed");
68
                $finish;
69
        end
70
 
71
        initial begin
72
                RSTB <= 1'b0;
73
                CSB  <= 1'b1;           // Force CSB high
74
                #2000;
75
                RSTB <= 1'b1;           // Release reset
76
                #170000;
77
                CSB = 1'b0;             // CSB can be released
78
        end
79
 
80
        initial begin           // Power-up sequence
81
                power1 <= 1'b0;
82
                power2 <= 1'b0;
83
                #200;
84
                power1 <= 1'b1;
85
                #200;
86
                power2 <= 1'b1;
87
        end
88
 
89
        wire flash_csb;
90
        wire flash_clk;
91
        wire flash_io0;
92
        wire flash_io1;
93
 
94
        wire VDD1V8;
95
        wire VDD3V3;
96
        wire VSS;
97
 
98
        assign VDD3V3 = power1;
99
        assign VDD1V8 = power2;
100
        assign VSS = 1'b0;
101
 
102
        caravel uut (
103
                .vddio    (VDD3V3),
104
                .vssio    (VSS),
105
                .vdda     (VDD3V3),
106
                .vssa     (VSS),
107
                .vccd     (VDD1V8),
108
                .vssd     (VSS),
109
                .vdda1    (VDD3V3),
110
                .vdda2    (VDD3V3),
111
                .vssa1    (VSS),
112
                .vssa2    (VSS),
113
                .vccd1    (VDD1V8),
114
                .vccd2    (VDD1V8),
115
                .vssd1    (VSS),
116
                .vssd2    (VSS),
117
                .clock    (clock),
118
                .gpio     (gpio),
119
                .mprj_io  (mprj_io),
120
                .flash_csb(flash_csb),
121
                .flash_clk(flash_clk),
122
                .flash_io0(flash_io0),
123
                .flash_io1(flash_io1),
124
                .resetb   (RSTB)
125
        );
126
 
127
        spiflash #(
128
                .FILENAME("la_test2.hex")
129
        ) spiflash (
130
                .csb(flash_csb),
131
                .clk(flash_clk),
132
                .io0(flash_io0),
133
                .io1(flash_io1),
134
                .io2(),
135
                .io3()
136
        );
137
 
138
endmodule
139
`default_nettype wire

powered by: WebSVN 2.1.0

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