2021-06-23 05:41:00 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// lsu.sv
|
|
|
|
//
|
|
|
|
// Written: David_Harris@hmc.edu 9 January 2021
|
|
|
|
// Modified:
|
|
|
|
//
|
|
|
|
// Purpose: Load/Store Unit
|
|
|
|
// Top level of the memory-stage hart logic
|
|
|
|
// Contains data cache, DTLB, subword read/write datapath, interface to external bus
|
|
|
|
//
|
|
|
|
// A component of the Wally configurable RISC-V project.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
|
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
|
|
|
// *** Ross Thompson amo misalignment check?
|
2021-07-06 15:41:36 +00:00
|
|
|
module lsu
|
|
|
|
(
|
|
|
|
input logic clk, reset,
|
|
|
|
input logic StallM, FlushM, StallW, FlushW,
|
|
|
|
output logic DCacheStall,
|
|
|
|
// Memory Stage
|
|
|
|
|
|
|
|
// connected to cpu (controls)
|
|
|
|
input logic [1:0] MemRWM,
|
|
|
|
input logic [2:0] Funct3M,
|
|
|
|
input logic [1:0] AtomicM,
|
|
|
|
output logic CommittedM,
|
|
|
|
output logic SquashSCW,
|
|
|
|
output logic DataMisalignedM,
|
|
|
|
|
|
|
|
// address and write data
|
|
|
|
input logic [`XLEN-1:0] MemAdrM,
|
|
|
|
input logic [`XLEN-1:0] WriteDataM,
|
|
|
|
output logic [`XLEN-1:0] ReadDataW,
|
|
|
|
|
|
|
|
// cpu privilege
|
|
|
|
input logic [1:0] PrivilegeModeW,
|
|
|
|
input logic DTLBFlushM,
|
|
|
|
// faults
|
|
|
|
input logic NonBusTrapM,
|
|
|
|
output logic DTLBLoadPageFaultM, DTLBStorePageFaultM,
|
|
|
|
output logic LoadMisalignedFaultM, LoadAccessFaultM,
|
|
|
|
// cpu hazard unit (trap)
|
|
|
|
output logic StoreMisalignedFaultM, StoreAccessFaultM,
|
|
|
|
|
|
|
|
// connect to ahb
|
|
|
|
input logic CommitM, // should this be generated in the abh interface?
|
|
|
|
output logic [`PA_BITS-1:0] MemPAdrM, // to ahb
|
|
|
|
output logic MemReadM, MemWriteM,
|
|
|
|
output logic [1:0] AtomicMaskedM,
|
|
|
|
input logic MemAckW, // from ahb
|
|
|
|
input logic [`XLEN-1:0] HRDATAW, // from ahb
|
|
|
|
output logic [2:0] SizeFromLSU,
|
|
|
|
output logic StallWfromLSU,
|
|
|
|
|
|
|
|
|
|
|
|
// mmu management
|
|
|
|
|
|
|
|
// page table walker
|
|
|
|
input logic [`XLEN-1:0] SATP_REGW, // from csr
|
|
|
|
input logic STATUS_MXR, STATUS_SUM, STATUS_MPRV,
|
|
|
|
input logic [1:0] STATUS_MPP,
|
|
|
|
|
|
|
|
input logic [`XLEN-1:0] PCF,
|
|
|
|
input logic ITLBMissF,
|
|
|
|
output logic [`XLEN-1:0] PageTableEntryF,
|
|
|
|
output logic [1:0] PageTypeF,
|
|
|
|
output logic ITLBWriteF,
|
|
|
|
output logic WalkerInstrPageFaultF,
|
|
|
|
output logic WalkerLoadPageFaultM,
|
|
|
|
output logic WalkerStorePageFaultM,
|
|
|
|
|
|
|
|
output logic DTLBHitM, // not connected
|
|
|
|
|
|
|
|
// PMA/PMP (inside mmu) signals
|
|
|
|
input logic [31:0] HADDR, // *** replace all of these H inputs with physical adress once pma checkers have been edited to use paddr as well.
|
|
|
|
input logic [2:0] HSIZE, HBURST,
|
|
|
|
input logic HWRITE,
|
|
|
|
input var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
|
|
|
|
input var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW[`PMP_ENTRIES-1:0], // *** this one especially has a large note attached to it in pmpchecker.
|
|
|
|
|
|
|
|
output logic DSquashBusAccessM
|
|
|
|
// output logic [5:0] DHSELRegionsM
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
logic SquashSCM;
|
|
|
|
logic DTLBPageFaultM;
|
|
|
|
logic MemAccessM;
|
|
|
|
|
|
|
|
logic preCommittedM;
|
|
|
|
|
|
|
|
typedef enum {STATE_READY,
|
|
|
|
STATE_FETCH,
|
|
|
|
STATE_FETCH_AMO_1,
|
|
|
|
STATE_FETCH_AMO_2,
|
|
|
|
STATE_STALLED,
|
|
|
|
STATE_PTW_READY,
|
|
|
|
STATE_PTW_FETCH,
|
|
|
|
STATE_PTW_DONE} statetype;
|
2021-06-30 21:25:03 +00:00
|
|
|
statetype CurrState, NextState;
|
2021-07-06 15:41:36 +00:00
|
|
|
|
2021-06-23 05:41:00 +00:00
|
|
|
|
2021-07-06 15:41:36 +00:00
|
|
|
logic PMPInstrAccessFaultF, PMAInstrAccessFaultF; // *** these are just so that the mmu has somewhere to put these outputs since they aren't used in dmem
|
2021-06-23 05:41:00 +00:00
|
|
|
// *** if you're allowed to parameterize outputs/ inputs existence, these are an easy delete.
|
2021-06-23 21:43:22 +00:00
|
|
|
|
2021-07-06 15:41:36 +00:00
|
|
|
logic DTLBMissM;
|
|
|
|
logic [`XLEN-1:0] PageTableEntryM;
|
|
|
|
logic [1:0] PageTypeM;
|
|
|
|
logic DTLBWriteM;
|
2021-07-08 23:03:52 +00:00
|
|
|
logic [`XLEN-1:0] HPTWReadPTE;
|
2021-07-06 15:41:36 +00:00
|
|
|
logic MMUReady;
|
|
|
|
logic HPTWStall;
|
2021-07-08 23:03:52 +00:00
|
|
|
logic [`XLEN-1:0] HPTWPAdr;
|
|
|
|
logic HPTWTranslate;
|
2021-07-06 15:41:36 +00:00
|
|
|
logic HPTWRead;
|
2021-07-08 23:03:52 +00:00
|
|
|
logic [1:0] MemRWMtoDCache;
|
|
|
|
logic [2:0] SizetoDCache;
|
|
|
|
logic [1:0] AtomicMtoDCache;
|
|
|
|
logic [`XLEN-1:0] MemAdrMtoDCache;
|
|
|
|
logic [`XLEN-1:0] WriteDataMtoDCache;
|
|
|
|
logic [`XLEN-1:0] ReadDataWfromDCache;
|
|
|
|
logic StallWtoDCache;
|
|
|
|
logic CommittedMfromDCache;
|
|
|
|
logic SquashSCWfromDCache;
|
|
|
|
logic DataMisalignedMfromDCache;
|
2021-07-06 15:41:36 +00:00
|
|
|
logic HPTWReady;
|
|
|
|
logic LSUStall;
|
|
|
|
logic DisableTranslation; // used to stop intermediate PTE physical addresses being saved to TLB.
|
2021-07-04 18:49:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-06-23 21:43:22 +00:00
|
|
|
// for time being until we have a dcache the AHB Lite read bus HRDATAW will be connected to the
|
|
|
|
// CPU's read data input ReadDataW.
|
2021-07-08 23:03:52 +00:00
|
|
|
assign ReadDataWfromDCache = HRDATAW;
|
2021-07-04 18:49:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
pagetablewalker pagetablewalker(
|
|
|
|
.clk(clk),
|
|
|
|
.reset(reset),
|
|
|
|
.SATP_REGW(SATP_REGW),
|
|
|
|
.PCF(PCF),
|
|
|
|
.MemAdrM(MemAdrM),
|
|
|
|
.ITLBMissF(ITLBMissF),
|
|
|
|
.DTLBMissM(DTLBMissM),
|
|
|
|
.MemRWM(MemRWM),
|
|
|
|
.PageTableEntryF(PageTableEntryF),
|
|
|
|
.PageTableEntryM(PageTableEntryM),
|
|
|
|
.PageTypeF(PageTypeF),
|
|
|
|
.PageTypeM(PageTypeM),
|
|
|
|
.ITLBWriteF(ITLBWriteF),
|
|
|
|
.DTLBWriteM(DTLBWriteM),
|
2021-07-08 23:03:52 +00:00
|
|
|
.HPTWReadPTE(HPTWReadPTE),
|
2021-07-04 18:49:38 +00:00
|
|
|
.MMUReady(HPTWReady),
|
|
|
|
.HPTWStall(HPTWStall),
|
2021-07-08 23:03:52 +00:00
|
|
|
.HPTWPAdr(HPTWPAdr),
|
|
|
|
.HPTWTranslate(HPTWTranslate),
|
2021-07-04 18:49:38 +00:00
|
|
|
.HPTWRead(HPTWRead),
|
|
|
|
.WalkerInstrPageFaultF(WalkerInstrPageFaultF),
|
|
|
|
.WalkerLoadPageFaultM(WalkerLoadPageFaultM),
|
|
|
|
.WalkerStorePageFaultM(WalkerStorePageFaultM));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// arbiter between IEU and pagetablewalker
|
|
|
|
lsuArb arbiter(.clk(clk),
|
|
|
|
.reset(reset),
|
|
|
|
// HPTW connection
|
2021-07-08 23:03:52 +00:00
|
|
|
.HPTWTranslate(HPTWTranslate),
|
2021-07-04 18:49:38 +00:00
|
|
|
.HPTWRead(HPTWRead),
|
2021-07-08 23:03:52 +00:00
|
|
|
.HPTWPAdr(HPTWPAdr),
|
|
|
|
.HPTWReadPTE(HPTWReadPTE),
|
2021-07-04 18:49:38 +00:00
|
|
|
.HPTWStall(HPTWStall),
|
|
|
|
// CPU connection
|
|
|
|
.MemRWM(MemRWM),
|
|
|
|
.Funct3M(Funct3M),
|
|
|
|
.AtomicM(AtomicM),
|
|
|
|
.MemAdrM(MemAdrM),
|
|
|
|
.WriteDataM(WriteDataM), // *** Need to remove this.
|
|
|
|
.StallW(StallW),
|
|
|
|
.ReadDataW(ReadDataW),
|
|
|
|
.CommittedM(CommittedM),
|
|
|
|
.SquashSCW(SquashSCW),
|
|
|
|
.DataMisalignedM(DataMisalignedM),
|
|
|
|
.DCacheStall(DCacheStall),
|
|
|
|
// LSU
|
|
|
|
.DisableTranslation(DisableTranslation),
|
2021-07-08 23:03:52 +00:00
|
|
|
.MemRWMtoDCache(MemRWMtoDCache),
|
|
|
|
.SizetoDCache(SizetoDCache),
|
|
|
|
.AtomicMtoDCache(AtomicMtoDCache),
|
|
|
|
.MemAdrMtoDCache(MemAdrMtoDCache),
|
|
|
|
.WriteDataMtoDCache(WriteDataMtoDCache), // *** ??????????????
|
|
|
|
.StallWtoDCache(StallWtoDCache),
|
|
|
|
.CommittedMfromDCache(CommittedMfromDCache),
|
|
|
|
.SquashSCWfromDCache(SquashSCWfromDCache),
|
|
|
|
.DataMisalignedMfromDCache(DataMisalignedMfromDCache),
|
|
|
|
.ReadDataWfromDCache(ReadDataWfromDCache),
|
2021-07-04 18:49:38 +00:00
|
|
|
.DataStall(LSUStall));
|
|
|
|
|
|
|
|
|
2021-07-06 15:41:36 +00:00
|
|
|
|
2021-07-04 22:05:22 +00:00
|
|
|
mmu #(.TLB_ENTRIES(`DTLB_ENTRIES), .IMMU(0))
|
2021-07-08 23:03:52 +00:00
|
|
|
dmmu(.VirtualAddress(MemAdrMtoDCache),
|
|
|
|
.Size(SizetoDCache[1:0]),
|
2021-07-06 07:25:11 +00:00
|
|
|
.PTE(PageTableEntryM),
|
2021-06-24 18:05:22 +00:00
|
|
|
.PageTypeWriteVal(PageTypeM),
|
|
|
|
.TLBWrite(DTLBWriteM),
|
|
|
|
.TLBFlush(DTLBFlushM),
|
|
|
|
.PhysicalAddress(MemPAdrM),
|
|
|
|
.TLBMiss(DTLBMissM),
|
|
|
|
.TLBHit(DTLBHitM),
|
|
|
|
.TLBPageFault(DTLBPageFaultM),
|
2021-07-02 18:56:49 +00:00
|
|
|
.ExecuteAccessF(1'b0),
|
2021-06-24 23:59:29 +00:00
|
|
|
.AtomicAccessM(AtomicMaskedM[1]),
|
2021-07-08 23:03:52 +00:00
|
|
|
.WriteAccessM(MemRWMtoDCache[0]),
|
|
|
|
.ReadAccessM(MemRWMtoDCache[1]),
|
2021-06-24 18:05:22 +00:00
|
|
|
.SquashBusAccess(DSquashBusAccessM),
|
2021-07-04 18:49:38 +00:00
|
|
|
.DisableTranslation(DisableTranslation),
|
2021-07-06 18:43:53 +00:00
|
|
|
.InstrAccessFaultF(),
|
2021-07-06 15:41:36 +00:00
|
|
|
// .SelRegions(DHSELRegionsM),
|
2021-06-24 18:05:22 +00:00
|
|
|
.*); // *** the pma/pmp instruction acess faults don't really matter here. is it possible to parameterize which outputs exist?
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Specify which type of page fault is occurring
|
2021-07-08 23:03:52 +00:00
|
|
|
assign DTLBLoadPageFaultM = DTLBPageFaultM & MemRWMtoDCache[1];
|
|
|
|
assign DTLBStorePageFaultM = DTLBPageFaultM & MemRWMtoDCache[0];
|
2021-06-23 05:41:00 +00:00
|
|
|
|
2021-06-24 18:05:22 +00:00
|
|
|
// Determine if an Unaligned access is taking place
|
|
|
|
always_comb
|
2021-07-08 23:03:52 +00:00
|
|
|
case(SizetoDCache[1:0])
|
|
|
|
2'b00: DataMisalignedMfromDCache = 0; // lb, sb, lbu
|
|
|
|
2'b01: DataMisalignedMfromDCache = MemAdrMtoDCache[0]; // lh, sh, lhu
|
|
|
|
2'b10: DataMisalignedMfromDCache = MemAdrMtoDCache[1] | MemAdrMtoDCache[0]; // lw, sw, flw, fsw, lwu
|
|
|
|
2'b11: DataMisalignedMfromDCache = |MemAdrMtoDCache[2:0]; // ld, sd, fld, fsd
|
2021-06-24 18:05:22 +00:00
|
|
|
endcase
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Squash unaligned data accesses and failed store conditionals
|
|
|
|
// *** this is also the place to squash if the cache is hit
|
2021-07-08 23:03:52 +00:00
|
|
|
// Changed DataMisalignedMfromDCache to a larger combination of trap sources
|
2021-06-23 05:41:00 +00:00
|
|
|
// NonBusTrapM is anything that the bus doesn't contribute to producing
|
|
|
|
// By contrast, using TrapM results in circular logic errors
|
2021-07-08 23:03:52 +00:00
|
|
|
assign MemReadM = MemRWMtoDCache[1] & ~NonBusTrapM & ~DTLBMissM & CurrState != STATE_STALLED;
|
|
|
|
assign MemWriteM = MemRWMtoDCache[0] & ~NonBusTrapM & ~DTLBMissM & ~SquashSCM & CurrState != STATE_STALLED;
|
|
|
|
assign AtomicMaskedM = CurrState != STATE_STALLED ? AtomicMtoDCache : 2'b00 ;
|
2021-06-25 16:00:42 +00:00
|
|
|
assign MemAccessM = MemReadM | MemWriteM;
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Determine if M stage committed
|
|
|
|
// Reset whenever unstalled. Set when access successfully occurs
|
2021-07-08 23:03:52 +00:00
|
|
|
flopr #(1) committedMreg(clk,reset,(CommittedMfromDCache | CommitM) & StallM,preCommittedM);
|
|
|
|
assign CommittedMfromDCache = preCommittedM | CommitM;
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Determine if address is valid
|
2021-07-08 23:03:52 +00:00
|
|
|
assign LoadMisalignedFaultM = DataMisalignedMfromDCache & MemRWMtoDCache[1];
|
|
|
|
assign StoreMisalignedFaultM = DataMisalignedMfromDCache & MemRWMtoDCache[0];
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Handle atomic load reserved / store conditional
|
|
|
|
generate
|
|
|
|
if (`A_SUPPORTED) begin // atomic instructions supported
|
|
|
|
logic [`PA_BITS-1:2] ReservationPAdrW;
|
2021-07-06 15:41:36 +00:00
|
|
|
logic ReservationValidM, ReservationValidW;
|
|
|
|
logic lrM, scM, WriteAdrMatchM;
|
2021-06-23 05:41:00 +00:00
|
|
|
|
2021-07-08 23:03:52 +00:00
|
|
|
assign lrM = MemReadM && AtomicMtoDCache[0];
|
|
|
|
assign scM = MemRWMtoDCache[0] && AtomicMtoDCache[0];
|
|
|
|
assign WriteAdrMatchM = MemRWMtoDCache[0] && (MemPAdrM[`PA_BITS-1:2] == ReservationPAdrW) && ReservationValidW;
|
2021-06-23 05:41:00 +00:00
|
|
|
assign SquashSCM = scM && ~WriteAdrMatchM;
|
|
|
|
always_comb begin // ReservationValidM (next value of valid reservation)
|
|
|
|
if (lrM) ReservationValidM = 1; // set valid on load reserve
|
|
|
|
else if (scM || WriteAdrMatchM) ReservationValidM = 0; // clear valid on store to same address or any sc
|
|
|
|
else ReservationValidM = ReservationValidW; // otherwise don't change valid
|
|
|
|
end
|
|
|
|
flopenrc #(`PA_BITS-2) resadrreg(clk, reset, FlushW, lrM, MemPAdrM[`PA_BITS-1:2], ReservationPAdrW); // could drop clear on this one but not valid
|
|
|
|
flopenrc #(1) resvldreg(clk, reset, FlushW, lrM, ReservationValidM, ReservationValidW);
|
2021-07-08 23:03:52 +00:00
|
|
|
flopenrc #(1) squashreg(clk, reset, FlushW, ~StallWtoDCache, SquashSCM, SquashSCWfromDCache);
|
2021-06-23 05:41:00 +00:00
|
|
|
end else begin // Atomic operations not supported
|
|
|
|
assign SquashSCM = 0;
|
2021-07-08 23:03:52 +00:00
|
|
|
assign SquashSCWfromDCache = 0;
|
2021-06-23 05:41:00 +00:00
|
|
|
end
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
// Data stall
|
2021-07-04 18:49:38 +00:00
|
|
|
//assign LSUStall = (NextState == STATE_FETCH) || (NextState == STATE_FETCH_AMO_1) || (NextState == STATE_FETCH_AMO_2);
|
2021-06-25 20:07:41 +00:00
|
|
|
assign HPTWReady = (CurrState == STATE_READY);
|
|
|
|
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
// Ross Thompson April 22, 2021
|
|
|
|
// for now we need to handle the issue where the data memory interface repeately
|
|
|
|
// requests data from memory rather than issuing a single request.
|
|
|
|
|
|
|
|
|
2021-06-30 21:25:03 +00:00
|
|
|
flopenl #(.TYPE(statetype)) stateReg(.clk(clk),
|
|
|
|
.load(reset),
|
|
|
|
.en(1'b1),
|
|
|
|
.d(NextState),
|
|
|
|
.val(STATE_READY),
|
|
|
|
.q(CurrState));
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
always_comb begin
|
|
|
|
case (CurrState)
|
2021-06-25 19:49:27 +00:00
|
|
|
STATE_READY:
|
2021-06-30 21:25:03 +00:00
|
|
|
if (DTLBMissM) begin
|
2021-07-01 17:49:09 +00:00
|
|
|
NextState = STATE_PTW_READY;
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-06-30 21:25:03 +00:00
|
|
|
end else if (AtomicMaskedM[1]) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_FETCH_AMO_1; // *** should be some misalign check
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-08 23:03:52 +00:00
|
|
|
end else if((MemReadM & AtomicMtoDCache[0]) | (MemWriteM & AtomicMtoDCache[0])) begin
|
2021-06-25 20:42:07 +00:00
|
|
|
NextState = STATE_FETCH_AMO_2;
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-08 23:03:52 +00:00
|
|
|
end else if (MemAccessM & ~DataMisalignedMfromDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_FETCH;
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-06-25 19:49:27 +00:00
|
|
|
end else begin
|
|
|
|
NextState = STATE_READY;
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b0;
|
2021-06-25 19:49:27 +00:00
|
|
|
end
|
2021-06-25 20:07:41 +00:00
|
|
|
STATE_FETCH_AMO_1: begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-06-25 19:49:27 +00:00
|
|
|
if (MemAckW) begin
|
|
|
|
NextState = STATE_FETCH_AMO_2;
|
|
|
|
end else begin
|
|
|
|
NextState = STATE_FETCH_AMO_1;
|
|
|
|
end
|
2021-06-25 20:07:41 +00:00
|
|
|
end
|
2021-06-25 19:49:27 +00:00
|
|
|
STATE_FETCH_AMO_2: begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-08 23:03:52 +00:00
|
|
|
if (MemAckW & ~StallWtoDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_FETCH_AMO_2;
|
2021-07-08 23:03:52 +00:00
|
|
|
end else if (MemAckW & StallWtoDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_STALLED;
|
|
|
|
end else begin
|
|
|
|
NextState = STATE_FETCH_AMO_2;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
STATE_FETCH: begin
|
2021-07-06 15:41:36 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-08 23:03:52 +00:00
|
|
|
if (MemAckW & ~StallWtoDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_READY;
|
2021-07-08 23:03:52 +00:00
|
|
|
end else if (MemAckW & StallWtoDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_STALLED;
|
|
|
|
end else begin
|
|
|
|
NextState = STATE_FETCH;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
STATE_STALLED: begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b0;
|
2021-07-08 23:03:52 +00:00
|
|
|
if (~StallWtoDCache) begin
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_READY;
|
|
|
|
end else begin
|
|
|
|
NextState = STATE_STALLED;
|
|
|
|
end
|
|
|
|
end
|
2021-07-01 17:49:09 +00:00
|
|
|
STATE_PTW_READY: begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b0;
|
2021-06-30 21:25:03 +00:00
|
|
|
if (DTLBWriteM) begin
|
2021-07-01 21:55:16 +00:00
|
|
|
NextState = STATE_READY;
|
2021-07-06 15:41:36 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-08 23:03:52 +00:00
|
|
|
end else if (MemReadM & ~DataMisalignedMfromDCache) begin
|
2021-07-01 17:49:09 +00:00
|
|
|
NextState = STATE_PTW_FETCH;
|
2021-06-30 21:25:03 +00:00
|
|
|
end else begin
|
2021-07-01 17:49:09 +00:00
|
|
|
NextState = STATE_PTW_READY;
|
2021-06-30 21:25:03 +00:00
|
|
|
end
|
|
|
|
end
|
2021-07-01 17:49:09 +00:00
|
|
|
STATE_PTW_FETCH : begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b1;
|
2021-07-01 17:49:09 +00:00
|
|
|
if (MemAckW & ~DTLBWriteM) begin
|
|
|
|
NextState = STATE_PTW_READY;
|
|
|
|
end else if (MemAckW & DTLBWriteM) begin
|
2021-07-01 21:55:16 +00:00
|
|
|
NextState = STATE_READY;
|
2021-07-01 17:49:09 +00:00
|
|
|
end else begin
|
|
|
|
NextState = STATE_PTW_FETCH;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
STATE_PTW_DONE: begin
|
|
|
|
NextState = STATE_READY;
|
|
|
|
end
|
2021-06-25 19:49:27 +00:00
|
|
|
default: begin
|
2021-07-04 18:49:38 +00:00
|
|
|
LSUStall = 1'b0;
|
2021-06-25 19:49:27 +00:00
|
|
|
NextState = STATE_READY;
|
|
|
|
end
|
2021-06-24 23:59:29 +00:00
|
|
|
endcase
|
2021-06-28 22:26:11 +00:00
|
|
|
end // always_comb
|
|
|
|
|
|
|
|
// *** for now just pass through size
|
2021-07-08 23:03:52 +00:00
|
|
|
assign SizeFromLSU = SizetoDCache;
|
|
|
|
assign StallWfromLSU = StallWtoDCache;
|
2021-06-28 22:26:11 +00:00
|
|
|
|
2021-06-23 05:41:00 +00:00
|
|
|
|
|
|
|
endmodule
|
|
|
|
|