1 |
2 |
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 mpmc8_pkg::*;
|
38 |
|
|
|
39 |
|
|
module mpmc8_read_cache(rst, wclk, wr, wadr, wdat, inv,
|
40 |
|
|
rclk0, radr0, rdat0, hit0,
|
41 |
|
|
rclk1, radr1, rdat1, hit1,
|
42 |
|
|
rclk2, radr2, rdat2, hit2,
|
43 |
|
|
rclk3, radr3, rdat3, hit3,
|
44 |
|
|
rclk4, radr4, rdat4, hit4,
|
45 |
|
|
rclk5, radr5, rdat5, hit5,
|
46 |
|
|
rclk6, radr6, rdat6, hit6,
|
47 |
|
|
rclk7, radr7, rdat7, hit7
|
48 |
|
|
);
|
49 |
|
|
input rst;
|
50 |
|
|
input wclk;
|
51 |
|
|
input wr;
|
52 |
|
|
input [31:0] wadr;
|
53 |
|
|
input [127:0] wdat;
|
54 |
|
|
input inv;
|
55 |
|
|
input rclk0;
|
56 |
|
|
input [31:0] radr0;
|
57 |
|
|
output reg [127:0] rdat0;
|
58 |
|
|
output reg hit0;
|
59 |
|
|
input rclk1;
|
60 |
|
|
input [31:0] radr1;
|
61 |
|
|
output reg [127:0] rdat1;
|
62 |
|
|
output reg hit1;
|
63 |
|
|
input rclk2;
|
64 |
|
|
input [31:0] radr2;
|
65 |
|
|
output reg [127:0] rdat2;
|
66 |
|
|
output reg hit2;
|
67 |
|
|
input rclk3;
|
68 |
|
|
input [31:0] radr3;
|
69 |
|
|
output reg [127:0] rdat3;
|
70 |
|
|
output reg hit3;
|
71 |
|
|
input rclk4;
|
72 |
|
|
input [31:0] radr4;
|
73 |
|
|
output reg [127:0] rdat4;
|
74 |
|
|
output reg hit4;
|
75 |
|
|
input rclk5;
|
76 |
|
|
input [31:0] radr5;
|
77 |
|
|
output reg [127:0] rdat5;
|
78 |
|
|
output reg hit5;
|
79 |
|
|
input rclk6;
|
80 |
|
|
input [31:0] radr6;
|
81 |
|
|
output reg [127:0] rdat6;
|
82 |
|
|
output reg hit6;
|
83 |
|
|
input rclk7;
|
84 |
|
|
input [31:0] radr7;
|
85 |
|
|
output reg [127:0] rdat7;
|
86 |
|
|
output reg hit7;
|
87 |
|
|
|
88 |
|
|
(* ram_style="block" *)
|
89 |
|
|
reg [127:0] lines [0:1023];
|
90 |
|
|
(* ram_style="block" *)
|
91 |
|
|
reg [27:0] tags [0:1023];
|
92 |
|
|
(* ram_style="distributed" *)
|
93 |
|
|
reg [1023:0] vbit;
|
94 |
|
|
reg [31:0] radrr0;
|
95 |
|
|
reg [31:0] radrr1;
|
96 |
|
|
reg [31:0] radrr2;
|
97 |
|
|
reg [31:0] radrr3;
|
98 |
|
|
reg [31:0] radrr4;
|
99 |
|
|
reg [31:0] radrr5;
|
100 |
|
|
reg [31:0] radrr6;
|
101 |
|
|
reg [31:0] radrr7;
|
102 |
|
|
reg [27:0] tago0;
|
103 |
|
|
reg [27:0] tago1;
|
104 |
|
|
reg [27:0] tago2;
|
105 |
|
|
reg [27:0] tago3;
|
106 |
|
|
reg [27:0] tago4;
|
107 |
|
|
reg [27:0] tago5;
|
108 |
|
|
reg [27:0] tago6;
|
109 |
|
|
reg [27:0] tago7;
|
110 |
|
|
reg vbito0;
|
111 |
|
|
reg vbito1;
|
112 |
|
|
reg vbito2;
|
113 |
|
|
reg vbito3;
|
114 |
|
|
reg vbito4;
|
115 |
|
|
reg vbito5;
|
116 |
|
|
reg vbito6;
|
117 |
|
|
reg vbito7;
|
118 |
|
|
|
119 |
|
|
always_ff @(posedge rclk0)
|
120 |
|
|
radrr0 <= radr0;
|
121 |
|
|
always_ff @(posedge rclk1)
|
122 |
|
|
radrr1 <= radr1;
|
123 |
|
|
always_ff @(posedge rclk2)
|
124 |
|
|
radrr2 <= radr2;
|
125 |
|
|
always_ff @(posedge rclk3)
|
126 |
|
|
radrr3 <= radr3;
|
127 |
|
|
always_ff @(posedge rclk4)
|
128 |
|
|
radrr4 <= radr4;
|
129 |
|
|
always_ff @(posedge rclk5)
|
130 |
|
|
radrr5 <= radr5;
|
131 |
|
|
always_ff @(posedge rclk6)
|
132 |
|
|
radrr6 <= radr6;
|
133 |
|
|
always_ff @(posedge rclk7)
|
134 |
|
|
radrr7 <= radr7;
|
135 |
|
|
always_ff @(posedge wclk)
|
136 |
|
|
if (wr) lines[wadr[13:4]] <= wdat;
|
137 |
|
|
always_ff @(posedge rclk0)
|
138 |
|
|
rdat0 <= lines[radrr0[13:4]];
|
139 |
|
|
always_ff @(posedge rclk1)
|
140 |
|
|
rdat1 <= lines[radrr1[13:4]];
|
141 |
|
|
always_ff @(posedge rclk2)
|
142 |
|
|
rdat2 <= lines[radrr2[13:4]];
|
143 |
|
|
always_ff @(posedge rclk3)
|
144 |
|
|
rdat3 <= lines[radrr3[13:4]];
|
145 |
|
|
always_ff @(posedge rclk4)
|
146 |
|
|
rdat4 <= lines[radrr4[13:4]];
|
147 |
|
|
always_ff @(posedge rclk5)
|
148 |
|
|
rdat5 <= lines[radrr5[13:4]];
|
149 |
|
|
always_ff @(posedge rclk6)
|
150 |
|
|
rdat6 <= lines[radrr6[13:4]];
|
151 |
|
|
always_ff @(posedge rclk7)
|
152 |
|
|
rdat7 <= lines[radrr7[13:4]];
|
153 |
|
|
always_ff @(posedge rclk0)
|
154 |
|
|
tago0 <= tags[radrr0[13:4]];
|
155 |
|
|
always_ff @(posedge rclk1)
|
156 |
|
|
tago1 <= tags[radrr1[13:4]];
|
157 |
|
|
always_ff @(posedge rclk2)
|
158 |
|
|
tago2 <= tags[radrr2[13:4]];
|
159 |
|
|
always_ff @(posedge rclk3)
|
160 |
|
|
tago3 <= tags[radrr3[13:4]];
|
161 |
|
|
always_ff @(posedge rclk4)
|
162 |
|
|
tago4 <= tags[radrr4[13:4]];
|
163 |
|
|
always_ff @(posedge rclk5)
|
164 |
|
|
tago5 <= tags[radrr5[13:4]];
|
165 |
|
|
always_ff @(posedge rclk6)
|
166 |
|
|
tago6 <= tags[radrr6[13:4]];
|
167 |
|
|
always_ff @(posedge rclk7)
|
168 |
|
|
tago7 <= tags[radrr7[13:4]];
|
169 |
|
|
always_ff @(posedge rclk0)
|
170 |
|
|
vbito0 <= vbit[radrr0[13:4]];
|
171 |
|
|
always_ff @(posedge rclk1)
|
172 |
|
|
vbito1 <= vbit[radrr1[13:4]];
|
173 |
|
|
always_ff @(posedge rclk2)
|
174 |
|
|
vbito2 <= vbit[radrr2[13:4]];
|
175 |
|
|
always_ff @(posedge rclk3)
|
176 |
|
|
vbito3 <= vbit[radrr3[13:4]];
|
177 |
|
|
always_ff @(posedge rclk4)
|
178 |
|
|
vbito4 <= vbit[radrr4[13:4]];
|
179 |
|
|
always_ff @(posedge rclk5)
|
180 |
|
|
vbito5 <= vbit[radrr5[13:4]];
|
181 |
|
|
always_ff @(posedge rclk6)
|
182 |
|
|
vbito6 <= vbit[radrr6[13:4]];
|
183 |
|
|
always_ff @(posedge rclk7)
|
184 |
|
|
vbito7 <= vbit[radrr7[13:4]];
|
185 |
|
|
always_ff @(posedge wclk)
|
186 |
|
|
if (wr) tags[wadr[13:4]] <= wadr[31:4];
|
187 |
|
|
always_ff @(posedge wclk)
|
188 |
|
|
if (rst)
|
189 |
|
|
vbit <= 256'b0;
|
190 |
|
|
else begin
|
191 |
|
|
if (wr)
|
192 |
|
|
vbit[wadr[13:4]] <= 1'b1;
|
193 |
|
|
else if (inv)
|
194 |
|
|
vbit[wadr[13:4]] <= 1'b0;
|
195 |
|
|
end
|
196 |
|
|
always_comb
|
197 |
|
|
hit0 = (tago0==radrr0[31:4]) && (vbito0==1'b1);
|
198 |
|
|
always_comb
|
199 |
|
|
hit1 = (tago1==radrr1[31:4]) && (vbito1==1'b1);
|
200 |
|
|
always_comb
|
201 |
|
|
hit2 = (tago2==radrr2[31:4]) && (vbito2==1'b1);
|
202 |
|
|
always_comb
|
203 |
|
|
hit3 = (tago3==radrr3[31:4]) && (vbito3==1'b1);
|
204 |
|
|
always_comb
|
205 |
|
|
hit4 = (tago4==radrr4[31:4]) && (vbito4==1'b1);
|
206 |
|
|
always_comb
|
207 |
|
|
hit5 = (tago5==radrr5[31:4]) && (vbito5==1'b1);
|
208 |
|
|
always_comb
|
209 |
|
|
hit6 = (tago6==radrr6[31:4]) && (vbito6==1'b1);
|
210 |
|
|
always_comb
|
211 |
|
|
hit7 = (tago7==radrr7[31:4]) && (vbito7==1'b1);
|
212 |
|
|
|
213 |
|
|
endmodule
|