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

Subversion Repositories yifive

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

powered by: WebSVN 2.1.0

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