cvw/pipelined/src/lsu/atomic.sv

59 lines
2.5 KiB
Systemverilog
Raw Normal View History

2022-01-31 16:28:12 +00:00
///////////////////////////////////////////
// atomic.sv
//
// Written: Ross Thompson ross1728@gmail.com January 31, 2022
// Modified:
//
// Purpose: atomic data path.
//
// A component of the Wally configurable RISC-V project.
//
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
//
// MIT LICENSE
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.
////////////////////////////////////////////////////////////////////////////////////////////////
`include "wally-config.vh"
module atomic (
input logic clk,
2022-05-12 14:49:58 +00:00
input logic reset, StallW,
2022-01-31 16:28:12 +00:00
input logic [`XLEN-1:0] ReadDataM,
input logic [`XLEN-1:0] IMWriteDataM,
2022-09-13 16:47:39 +00:00
input logic [`PA_BITS-1:0] PAdrM,
2022-01-31 16:28:12 +00:00
input logic [6:0] LSUFunct7M,
input logic [2:0] LSUFunct3M,
input logic [1:0] LSUAtomicM,
input logic [1:0] PreLSURWM,
input logic IgnoreRequest,
output logic [`XLEN-1:0] IMAWriteDataM,
2022-01-31 16:28:12 +00:00
output logic SquashSCW,
output logic [1:0] LSURWM);
2022-03-04 00:07:31 +00:00
logic [`XLEN-1:0] AMOResult;
2022-01-31 16:28:12 +00:00
logic MemReadM;
amoalu amoalu(.srca(ReadDataM), .srcb(IMWriteDataM), .funct(LSUFunct7M), .width(LSUFunct3M[1:0]),
2022-03-04 00:07:31 +00:00
.result(AMOResult));
mux2 #(`XLEN) wdmux(IMWriteDataM, AMOResult, LSUAtomicM[1], IMAWriteDataM);
2022-03-11 00:56:37 +00:00
assign MemReadM = PreLSURWM[1] & ~IgnoreRequest;
2022-09-13 16:47:39 +00:00
lrsc lrsc(.clk, .reset, .StallW, .MemReadM, .PreLSURWM, .LSUAtomicM, .PAdrM,
2022-03-04 00:07:31 +00:00
.SquashSCW, .LSURWM);
2022-01-31 16:28:12 +00:00
endmodule