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

Subversion Repositories mpmc8

[/] [mpmc8/] [trunk/] [rtl/] [mpmc10/] [mpmc10_cache_test.sv] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2015-2022  Robert Finch, Waterloo
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch@finitron.ca
7
//       ||
8
//
9
// BSD 3-Clause License
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are met:
12
//
13
// 1. Redistributions of source code must retain the above copyright notice, this
14
//    list of conditions and the following disclaimer.
15
//
16
// 2. Redistributions in binary form must reproduce the above copyright notice,
17
//    this list of conditions and the following disclaimer in the documentation
18
//    and/or other materials provided with the distribution.
19
//
20
// 3. Neither the name of the copyright holder nor the names of its
21
//    contributors may be used to endorse or promote products derived from
22
//    this software without specific prior written permission.
23
//
24
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
//
35
// ============================================================================
36
//
37
import const_pkg::*;
38
import wishbone_pkg::*;
39
import mpmc10_pkg::*;
40
 
41
module mpmc10_cache_test();
42
 
43
reg rst;
44
reg clk;
45
reg wclk;
46
reg ch6clk;
47
typedef enum logic [5:0] {
48
        ST1 = 6'd1,
49
        ST2,ST3,ST4,ST5
50
} state_t;
51
state_t state;
52
 
53
initial begin
54
        clk = 1'b0;
55
        wclk = 1'b0;
56
        ch6clk = 1'b0;
57
        rst = 1'b0;
58
        #5 rst = 1'b1;
59
        #305 rst = 1'b0;
60
end
61
 
62
always #5 clk = ~clk;
63
always #5 wclk = ~wclk;
64
always #12 ch6clk = ~ch6clk;
65
 
66
reg [7:0] count, count2;
67
wb_write_request128_t ld, ch6i;
68
wb_read_response128_t ch6o;
69
 
70
mpmc10_cache_wb ucache1
71
(
72
        .rst(rst),
73
        .wclk(wclk),
74
        .inv(1'b0),
75
        .wchi('d0),
76
        .wcho(),
77
        .ld(ld),
78
        .ch0i('d0),
79
        .ch1i('d0),
80
        .ch2i('d0),
81
        .ch3i('d0),
82
        .ch4i('d0),
83
        .ch5i('d0),
84
        .ch6i(ch6i),
85
        .ch7i('d0),
86
        .ch0clk(1'b0),
87
        .ch1clk(1'b0),
88
        .ch2clk(1'b0),
89
        .ch3clk(1'b0),
90
        .ch4clk(1'b0),
91
        .ch5clk(1'b0),
92
        .ch6clk(ch6clk),
93
        .ch7clk(1'b0),
94
        .ch0wack(),
95
        .ch1wack(),
96
        .ch2wack(),
97
        .ch3wack(),
98
        .ch4wack(),
99
        .ch5wack(),
100
        .ch6wack(1'b0),
101
        .ch7wack(),
102
        .ch0o(),
103
        .ch1o(),
104
        .ch2o(),
105
        .ch3o(),
106
        .ch4o(),
107
        .ch5o(),
108
        .ch6o(ch6o),
109
        .ch7o()
110
);
111
 
112
always @(posedge ch6clk)
113
if (rst)
114
        state <= ST1;
115
else begin
116
        case(state)
117
        ST1:    state <= ST2;
118
        ST2:    state <= ST3;
119
        ST3:    state <= ST4;
120
        ST4:
121
                if (ch6o.ack)
122
                        state <= ST5;
123
        ST5:    state <= ST1;
124
        default:        state <= ST1;
125
        endcase
126
end
127
 
128
always @(posedge wclk)
129
if (rst) begin
130
        ld <= 'd0;
131
        count <= 'd0;
132
end
133
else begin
134
        case(state)
135
        ST1,ST2,ST3,ST4:
136
                begin
137
                        ld.cyc <= 1'b1;
138
                        ld.stb <= 1'b1;
139
                        ld.we <= 1'b0;
140
                        ld.adr <= 32'h300000 + {count,4'h0};
141
                        ld.dat <= {8{16'h7C00}};
142
                        ld.sel <= -1;
143
                        count <= count + 2'd1;
144
                end
145
        endcase
146
end
147
 
148
 
149
always @(posedge ch6clk)
150
if (rst) begin
151
        ch6i <= 'd0;
152
        count2 <= 'd0;
153
end
154
else
155
case(state)
156
ST3:
157
        begin
158
                ch6i.cyc <= 1'b1;
159
                ch6i.stb <= 1'b1;
160
                ch6i.we <= 1'b0;
161
                ch6i.sel <= -1;
162
                ch6i.adr <= 32'h300000 + {count2,4'h0};
163
        end
164
ST4:
165
        if (ch6o.ack) begin
166
                ch6i.cyc <= 1'b0;
167
                ch6i.stb <= 1'b0;
168
                count2 <= count2 + 2'd1;
169
        end
170
endcase
171
 
172
endmodule

powered by: WebSVN 2.1.0

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