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 mpmc10_pkg::*;
|
38 |
|
|
|
39 |
|
|
module mpmc10_strm_read_cache(rst, wclk, wr, wadr, wdat, inv,
|
40 |
|
|
rclk, rd, radr, rdat, hit
|
41 |
|
|
);
|
42 |
|
|
input rst;
|
43 |
|
|
input wclk;
|
44 |
|
|
input wr;
|
45 |
|
|
input [31:0] wadr;
|
46 |
|
|
input [127:0] wdat;
|
47 |
|
|
input inv;
|
48 |
|
|
input rclk;
|
49 |
|
|
input rd;
|
50 |
|
|
input [31:0] radr;
|
51 |
|
|
output [127:0] rdat;
|
52 |
|
|
output reg hit;
|
53 |
|
|
|
54 |
|
|
(* ram_style="distributed" *)
|
55 |
|
|
reg [18:0] tags [0:7];
|
56 |
|
|
(* ram_style="distributed" *)
|
57 |
|
|
reg [7:0] vbit;
|
58 |
|
|
reg [31:0] radrr;
|
59 |
|
|
reg [18:0] tago;
|
60 |
|
|
reg vbito;
|
61 |
|
|
|
62 |
|
|
xpm_memory_sdpram #(
|
63 |
|
|
.ADDR_WIDTH_A(9), // DECIMAL
|
64 |
|
|
.ADDR_WIDTH_B(9), // DECIMAL
|
65 |
|
|
.AUTO_SLEEP_TIME(0), // DECIMAL
|
66 |
|
|
.BYTE_WRITE_WIDTH_A(128), // DECIMAL
|
67 |
|
|
.CASCADE_HEIGHT(0), // DECIMAL
|
68 |
|
|
.CLOCKING_MODE("independent_clock"), // String
|
69 |
|
|
.ECC_MODE("no_ecc"), // String
|
70 |
|
|
.MEMORY_INIT_FILE("none"), // String
|
71 |
|
|
.MEMORY_INIT_PARAM("0"), // String
|
72 |
|
|
.MEMORY_OPTIMIZATION("true"), // String
|
73 |
|
|
.MEMORY_PRIMITIVE("block"), // String
|
74 |
|
|
.MEMORY_SIZE(512*128), // DECIMAL
|
75 |
|
|
.MESSAGE_CONTROL(0), // DECIMAL
|
76 |
|
|
.READ_DATA_WIDTH_B(128), // DECIMAL
|
77 |
|
|
.READ_LATENCY_B(1), // DECIMAL
|
78 |
|
|
.READ_RESET_VALUE_B("0"), // String
|
79 |
|
|
.RST_MODE_A("SYNC"), // String
|
80 |
|
|
.RST_MODE_B("SYNC"), // String
|
81 |
|
|
.SIM_ASSERT_CHK(0), // DECIMAL; 0=disable simulation messages, 1=enable simulation messages
|
82 |
|
|
.USE_EMBEDDED_CONSTRAINT(0), // DECIMAL
|
83 |
|
|
.USE_MEM_INIT(1), // DECIMAL
|
84 |
|
|
.WAKEUP_TIME("disable_sleep"), // String
|
85 |
|
|
.WRITE_DATA_WIDTH_A(128), // DECIMAL
|
86 |
|
|
.WRITE_MODE_B("no_change") // String
|
87 |
|
|
)
|
88 |
|
|
xpm_memory_sdpram_inst (
|
89 |
|
|
.dbiterrb(), // 1-bit output: Status signal to indicate double bit error occurrence
|
90 |
|
|
// on the data output of port B.
|
91 |
|
|
|
92 |
|
|
.doutb(rdat), // READ_DATA_WIDTH_B-bit output: Data output for port B read operations.
|
93 |
|
|
.sbiterrb(), // 1-bit output: Status signal to indicate single bit error occurrence
|
94 |
|
|
// on the data output of port B.
|
95 |
|
|
|
96 |
|
|
.addra(wadr[12:4]), // ADDR_WIDTH_A-bit input: Address for port A write operations.
|
97 |
|
|
.addrb(radr[12:4]), // ADDR_WIDTH_B-bit input: Address for port B read operations.
|
98 |
|
|
.clka(wclk), // 1-bit input: Clock signal for port A. Also clocks port B when
|
99 |
|
|
// parameter CLOCKING_MODE is "common_clock".
|
100 |
|
|
|
101 |
|
|
.clkb(rclk), // 1-bit input: Clock signal for port B when parameter CLOCKING_MODE is
|
102 |
|
|
// "independent_clock". Unused when parameter CLOCKING_MODE is
|
103 |
|
|
// "common_clock".
|
104 |
|
|
|
105 |
|
|
.dina(wdat), // WRITE_DATA_WIDTH_A-bit input: Data input for port A write operations.
|
106 |
|
|
.ena(wr), // 1-bit input: Memory enable signal for port A. Must be high on clock
|
107 |
|
|
// cycles when write operations are initiated. Pipelined internally.
|
108 |
|
|
|
109 |
|
|
.enb(rd), // 1-bit input: Memory enable signal for port B. Must be high on clock
|
110 |
|
|
// cycles when read operations are initiated. Pipelined internally.
|
111 |
|
|
|
112 |
|
|
.injectdbiterra(1'b0), // 1-bit input: Controls double bit error injection on input data when
|
113 |
|
|
// ECC enabled (Error injection capability is not available in
|
114 |
|
|
// "decode_only" mode).
|
115 |
|
|
|
116 |
|
|
.injectsbiterra(1'b0), // 1-bit input: Controls single bit error injection on input data when
|
117 |
|
|
// ECC enabled (Error injection capability is not available in
|
118 |
|
|
// "decode_only" mode).
|
119 |
|
|
|
120 |
|
|
.regceb(1'b1), // 1-bit input: Clock Enable for the last register stage on the output
|
121 |
|
|
// data path.
|
122 |
|
|
|
123 |
|
|
.rstb(rst), // 1-bit input: Reset signal for the final port B output register stage.
|
124 |
|
|
// Synchronously resets output port doutb to the value specified by
|
125 |
|
|
// parameter READ_RESET_VALUE_B.
|
126 |
|
|
|
127 |
|
|
.sleep(1'b0), // 1-bit input: sleep signal to enable the dynamic power saving feature.
|
128 |
|
|
.wea(wr) // WRITE_DATA_WIDTH_A/BYTE_WRITE_WIDTH_A-bit input: Write enable vector
|
129 |
|
|
// for port A input data port dina. 1 bit wide when word-wide writes are
|
130 |
|
|
// used. In byte-wide write configurations, each bit controls the
|
131 |
|
|
// writing one byte of dina to address addra. For example, to
|
132 |
|
|
// synchronously write only bits [15-8] of dina when WRITE_DATA_WIDTH_A
|
133 |
|
|
// is 32, wea would be 4'b0010.
|
134 |
|
|
|
135 |
|
|
);
|
136 |
|
|
|
137 |
|
|
always_ff @(posedge rclk)
|
138 |
|
|
radrr <= radr;
|
139 |
|
|
always_ff @(posedge wclk)
|
140 |
|
|
if (wr && wadr[9:4]==6'h3F)
|
141 |
|
|
tags[wadr[12:10]] <= wadr[31:13];
|
142 |
|
|
always_comb
|
143 |
|
|
tago <= tags[radrr[12:10]];
|
144 |
|
|
always_comb // @(posedge rclk)
|
145 |
|
|
vbito <= vbit[radrr[12:10]];
|
146 |
|
|
always_ff @(posedge wclk)
|
147 |
|
|
if (rst)
|
148 |
|
|
vbit <= 'b0;
|
149 |
|
|
else begin
|
150 |
|
|
if (wr && wadr[9:4]==6'h3F)
|
151 |
|
|
vbit[wadr[12:10]] <= 1'b1;
|
152 |
|
|
else if (inv)
|
153 |
|
|
vbit[wadr[12:10]] <= 1'b0;
|
154 |
|
|
end
|
155 |
|
|
always_comb
|
156 |
|
|
hit = (tago==radrr[31:13]) && (vbito==1'b1);
|
157 |
|
|
|
158 |
|
|
endmodule
|