cvw/src/cache/subcachelineread.sv

55 lines
2.4 KiB
Systemverilog
Raw Normal View History

///////////////////////////////////////////
2023-04-14 04:01:57 +00:00
// subcachelineread.sv
//
2023-01-20 19:13:05 +00:00
// Written: Ross Thompson ross1728@gmail.com
// Created: 4 February 2022
// Modified: 20 January 2023
//
2023-04-14 04:01:57 +00:00
// Purpose: Muxes the cache line down to the word size. Also include possible save/restore registers/muxes.
//
2023-01-20 19:13:05 +00:00
// Documentation: RISC-V System on Chip Design Chapter 7
2023-01-11 23:15:08 +00:00
// A component of the CORE-V-WALLY configurable RISC-V project.
//
// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University
//
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
//
// Licensed under the Solderpad Hardware License v 2.1 (the “License”); you may not use this file
// except in compliance with the License, or, at your option, the Apache License version 2.0. You
// may obtain a copy of the License at
//
// https://solderpad.org/licenses/SHL-2.1/
//
// Unless required by applicable law or agreed to in writing, any work distributed under the
// License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
////////////////////////////////////////////////////////////////////////////////////////////////
2023-01-20 19:13:05 +00:00
module subcachelineread #(parameter LINELEN, WORDLEN,
2023-01-28 19:00:05 +00:00
parameter MUXINTERVAL )( // The number of bits between mux. Set to 16 for I$ to support compressed. Set to `LLEN for D$
2023-01-20 19:13:05 +00:00
input logic [$clog2(LINELEN/8) - $clog2(MUXINTERVAL/8) - 1 : 0] PAdr, // Physical address
2023-03-24 20:15:38 +00:00
input logic [LINELEN-1:0] ReadDataLine,// Read data of the whole cacheline
output logic [WORDLEN-1:0] ReadDataWord // read data of selected word.
2023-01-15 03:43:29 +00:00
);
localparam WORDSPERLINE = LINELEN/MUXINTERVAL;
localparam PADLEN = WORDLEN-MUXINTERVAL;
2023-01-15 03:43:29 +00:00
// pad is for icache. Muxing extends over the cacheline boundary.
logic [LINELEN+(WORDLEN-MUXINTERVAL)-1:0] ReadDataLinePad;
logic [WORDLEN-1:0] ReadDataLineSets [(LINELEN/MUXINTERVAL)-1:0];
if (PADLEN > 0) assign ReadDataLinePad = {{PADLEN{1'b0}}, ReadDataLine};
else assign ReadDataLinePad = ReadDataLine;
genvar index;
for (index = 0; index < WORDSPERLINE; index++) begin:readdatalinesetsmux
2023-03-24 20:15:38 +00:00
assign ReadDataLineSets[index] = ReadDataLinePad[(index*MUXINTERVAL)+WORDLEN-1 : (index*MUXINTERVAL)];
end
2023-01-15 03:43:29 +00:00
// variable input mux
assign ReadDataWord = ReadDataLineSets[PAdr];
endmodule