2021-01-30 04:43:48 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// subwordwrite.sv
|
|
|
|
//
|
|
|
|
// Written: David_Harris@hmc.edu 9 January 2021
|
|
|
|
// Modified:
|
|
|
|
//
|
|
|
|
// Purpose: Masking and muxing for subword writes
|
|
|
|
//
|
2023-01-11 23:15:08 +00:00
|
|
|
// A component of the CORE-V-WALLY configurable RISC-V project.
|
2021-01-30 04:43:48 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// Copyright (C) 2021-23 Harvey Mudd College & Oklahoma State University
|
2021-01-30 04:43:48 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
|
2021-01-30 04:43:48 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// 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
|
2021-01-30 04:43:48 +00:00
|
|
|
//
|
2023-01-10 19:35:20 +00:00
|
|
|
// 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.
|
2022-01-07 12:58:40 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
2021-01-30 04:43:48 +00:00
|
|
|
|
|
|
|
`include "wally-config.vh"
|
|
|
|
|
|
|
|
module subwordwrite (
|
2022-03-11 00:50:03 +00:00
|
|
|
input logic [2:0] LSUFunct3M,
|
2022-08-23 15:34:39 +00:00
|
|
|
input logic [`LLEN-1:0] IMAFWriteDataM,
|
|
|
|
output logic [`LLEN-1:0] LittleEndianWriteDataM);
|
2022-03-10 21:48:31 +00:00
|
|
|
|
2022-04-17 22:33:25 +00:00
|
|
|
// Replicate data for subword writes
|
2022-08-23 15:34:39 +00:00
|
|
|
if (`LLEN == 128) begin:sww
|
|
|
|
always_comb
|
|
|
|
case(LSUFunct3M[2:0])
|
2022-08-23 17:23:08 +00:00
|
|
|
3'b000: LittleEndianWriteDataM = {16{IMAFWriteDataM[7:0]}}; // sb
|
|
|
|
3'b001: LittleEndianWriteDataM = {8{IMAFWriteDataM[15:0]}}; // sh
|
|
|
|
3'b010: LittleEndianWriteDataM = {4{IMAFWriteDataM[31:0]}}; // sw
|
|
|
|
3'b011: LittleEndianWriteDataM = {2{IMAFWriteDataM[63:0]}}; // sd
|
2022-08-23 15:34:39 +00:00
|
|
|
default: LittleEndianWriteDataM = IMAFWriteDataM; // sq
|
|
|
|
endcase
|
|
|
|
end else if (`LLEN == 64) begin:sww
|
2022-01-05 16:25:08 +00:00
|
|
|
always_comb
|
2022-03-11 00:50:03 +00:00
|
|
|
case(LSUFunct3M[1:0])
|
2022-08-23 15:34:39 +00:00
|
|
|
2'b00: LittleEndianWriteDataM = {8{IMAFWriteDataM[7:0]}}; // sb
|
|
|
|
2'b01: LittleEndianWriteDataM = {4{IMAFWriteDataM[15:0]}}; // sh
|
|
|
|
2'b10: LittleEndianWriteDataM = {2{IMAFWriteDataM[31:0]}}; // sw
|
|
|
|
2'b11: LittleEndianWriteDataM = IMAFWriteDataM; // sd
|
2022-01-05 16:25:08 +00:00
|
|
|
endcase
|
|
|
|
end else begin:sww // 32-bit
|
|
|
|
always_comb
|
2022-03-11 00:50:03 +00:00
|
|
|
case(LSUFunct3M[1:0])
|
2022-08-23 15:34:39 +00:00
|
|
|
2'b00: LittleEndianWriteDataM = {4{IMAFWriteDataM[7:0]}}; // sb
|
|
|
|
2'b01: LittleEndianWriteDataM = {2{IMAFWriteDataM[15:0]}}; // sh
|
|
|
|
2'b10: LittleEndianWriteDataM = IMAFWriteDataM; // sw
|
|
|
|
default: LittleEndianWriteDataM = IMAFWriteDataM; // shouldn't happen
|
2022-01-05 16:25:08 +00:00
|
|
|
endcase
|
|
|
|
end
|
2021-01-30 04:43:48 +00:00
|
|
|
endmodule
|