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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [mprj_stimulus/] [mprj_stimulus_tb.v] - Blame information for rev 23

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