2021-01-15 04:37:51 +00:00
|
|
|
///////////////////////////////////////////
|
|
|
|
// wallypipelinedhart.sv
|
|
|
|
//
|
|
|
|
// Written: David_Harris@hmc.edu 9 January 2021
|
|
|
|
// Modified:
|
|
|
|
//
|
|
|
|
// Purpose: Pipelined RISC-V Processor
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
2021-01-23 15:48:12 +00:00
|
|
|
`include "wally-config.vh"
|
2021-01-27 11:40:26 +00:00
|
|
|
/* verilator lint_on UNUSED */
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-10-23 18:03:28 +00:00
|
|
|
module wallypipelinedhart (
|
2021-06-24 18:05:22 +00:00
|
|
|
input logic clk, reset,
|
|
|
|
// Privileged
|
|
|
|
input logic TimerIntM, ExtIntM, SwIntM,
|
2021-12-31 06:40:21 +00:00
|
|
|
input logic [63:0] MTIME_CLINT,
|
2021-06-24 18:05:22 +00:00
|
|
|
// Bus Interface
|
|
|
|
input logic [`AHBW-1:0] HRDATA,
|
|
|
|
input logic HREADY, HRESP,
|
|
|
|
output logic HCLK, HRESETn,
|
|
|
|
output logic [31:0] HADDR,
|
|
|
|
output logic [`AHBW-1:0] HWDATA,
|
|
|
|
output logic HWRITE,
|
|
|
|
output logic [2:0] HSIZE,
|
|
|
|
output logic [2:0] HBURST,
|
|
|
|
output logic [3:0] HPROT,
|
|
|
|
output logic [1:0] HTRANS,
|
|
|
|
output logic HMASTLOCK,
|
|
|
|
// Delayed signals for subword write
|
|
|
|
output logic [2:0] HADDRD,
|
|
|
|
output logic [3:0] HSIZED,
|
|
|
|
output logic HWRITED
|
|
|
|
);
|
|
|
|
|
|
|
|
// logic [1:0] ForwardAE, ForwardBE;
|
|
|
|
logic StallF, StallD, StallE, StallM, StallW;
|
|
|
|
logic FlushF, FlushD, FlushE, FlushM, FlushW;
|
2021-09-27 18:57:46 +00:00
|
|
|
logic RetM;
|
|
|
|
(* mark_debug = "true" *) logic TrapM;
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-01-27 12:46:52 +00:00
|
|
|
// new signals that must connect through DP
|
2022-01-07 04:30:00 +00:00
|
|
|
logic MDUE, W64E;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic CSRReadM, CSRWriteM, PrivilegedM;
|
2021-07-13 17:46:20 +00:00
|
|
|
logic [1:0] AtomicE;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic [1:0] AtomicM;
|
2021-12-08 20:33:53 +00:00
|
|
|
logic [`XLEN-1:0] ForwardedSrcAE, ForwardedSrcBE; //, SrcAE, SrcBE;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic [`XLEN-1:0] SrcAM;
|
|
|
|
logic [2:0] Funct3E;
|
2021-04-04 01:28:24 +00:00
|
|
|
// logic [31:0] InstrF;
|
2021-11-29 16:06:53 +00:00
|
|
|
logic [31:0] InstrD, InstrW;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* mark_debug = "true" *) logic [31:0] InstrM;
|
2021-11-29 16:06:53 +00:00
|
|
|
logic [`XLEN-1:0] PCF, PCD, PCE, PCLinkE;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] PCM;
|
2022-01-07 04:30:00 +00:00
|
|
|
logic [`XLEN-1:0] CSRReadValW, MDUResultW;
|
2022-01-06 23:03:29 +00:00
|
|
|
logic [`XLEN-1:0] PrivilegedNextPCM;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* mark_debug = "true" *) logic [1:0] MemRWM;
|
|
|
|
(* mark_debug = "true" *) logic InstrValidM;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic InstrMisalignedFaultM;
|
|
|
|
logic IllegalBaseInstrFaultD, IllegalIEUInstrFaultD;
|
|
|
|
logic ITLBInstrPageFaultF, DTLBLoadPageFaultM, DTLBStorePageFaultM;
|
|
|
|
logic LoadMisalignedFaultM, LoadAccessFaultM;
|
|
|
|
logic StoreMisalignedFaultM, StoreAccessFaultM;
|
|
|
|
logic [`XLEN-1:0] InstrMisalignedAdrM;
|
2021-09-15 17:14:00 +00:00
|
|
|
logic InvalidateICacheM, FlushDCacheM;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic PCSrcE;
|
|
|
|
logic CSRWritePendingDEM;
|
|
|
|
logic DivBusyE;
|
2022-01-07 04:30:00 +00:00
|
|
|
logic LoadStallD, StoreStallD, MDUStallD, CSRRdStallD;
|
2021-10-23 17:29:52 +00:00
|
|
|
logic SquashSCW;
|
2021-06-24 22:39:18 +00:00
|
|
|
// floating point unit signals
|
2021-07-02 16:52:26 +00:00
|
|
|
logic [2:0] FRM_REGW;
|
2021-10-23 19:00:32 +00:00
|
|
|
logic [4:0] RdM, RdW;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic FStallD;
|
2021-12-18 13:36:32 +00:00
|
|
|
logic FWriteIntE;
|
2021-07-02 16:52:26 +00:00
|
|
|
logic [`XLEN-1:0] FWriteDataE;
|
|
|
|
logic [`XLEN-1:0] FIntResM;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic FDivBusyE;
|
|
|
|
logic IllegalFPUInstrD, IllegalFPUInstrE;
|
2021-07-13 17:20:30 +00:00
|
|
|
logic FRegWriteM;
|
2021-07-02 16:52:26 +00:00
|
|
|
logic FPUStallD;
|
|
|
|
logic [4:0] SetFflagsM;
|
2021-01-30 04:43:48 +00:00
|
|
|
|
2021-03-04 08:11:34 +00:00
|
|
|
// memory management unit signals
|
2021-10-23 17:12:33 +00:00
|
|
|
logic ITLBWriteF;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic ITLBFlushF, DTLBFlushM;
|
2021-10-23 17:12:33 +00:00
|
|
|
logic ITLBMissF;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic [`XLEN-1:0] SATP_REGW;
|
2021-07-04 17:20:29 +00:00
|
|
|
logic STATUS_MXR, STATUS_SUM, STATUS_MPRV;
|
|
|
|
logic [1:0] STATUS_MPP;
|
2021-06-24 18:05:22 +00:00
|
|
|
logic [1:0] PrivilegeModeW;
|
2021-07-17 19:04:39 +00:00
|
|
|
logic [`XLEN-1:0] PTE;
|
2021-07-17 06:31:23 +00:00
|
|
|
logic [1:0] PageType;
|
2021-03-04 08:11:34 +00:00
|
|
|
|
2021-04-22 19:34:02 +00:00
|
|
|
// PMA checker signals
|
2021-06-21 05:17:08 +00:00
|
|
|
var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW [`PMP_ENTRIES-1:0];
|
2021-07-04 15:39:59 +00:00
|
|
|
var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0];
|
2021-04-22 19:34:02 +00:00
|
|
|
|
2021-03-30 19:25:07 +00:00
|
|
|
// IMem stalls
|
2022-01-07 04:30:00 +00:00
|
|
|
logic IFUStallF;
|
2021-07-15 15:16:16 +00:00
|
|
|
logic LSUStall;
|
2021-07-04 18:49:38 +00:00
|
|
|
|
2021-06-25 20:07:41 +00:00
|
|
|
|
2021-03-18 18:35:46 +00:00
|
|
|
|
2021-07-09 20:16:38 +00:00
|
|
|
// cpu lsu interface
|
2021-06-24 18:05:22 +00:00
|
|
|
logic [2:0] Funct3M;
|
2021-12-15 20:10:45 +00:00
|
|
|
logic [`XLEN-1:0] IEUAdrE;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] WriteDataM;
|
2021-12-19 20:00:30 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] IEUAdrM;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] ReadDataM;
|
2021-07-22 19:51:14 +00:00
|
|
|
logic [`XLEN-1:0] ReadDataW;
|
2021-12-29 04:27:12 +00:00
|
|
|
logic CommittedM;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
|
|
|
// AHB ifu interface
|
2022-01-07 04:30:00 +00:00
|
|
|
logic [`PA_BITS-1:0] IFUBusAdr;
|
|
|
|
logic [`XLEN-1:0] IFUBusHRDATA;
|
|
|
|
logic IFUBusRead;
|
|
|
|
logic IFUBusAck;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
|
|
|
// AHB LSU interface
|
2022-01-07 04:30:00 +00:00
|
|
|
logic [`PA_BITS-1:0] LSUBusAdr;
|
|
|
|
logic LSUBusRead;
|
|
|
|
logic LSUBusWrite;
|
|
|
|
logic LSUBusAck;
|
|
|
|
logic [`XLEN-1:0] LSUBusHRDATA;
|
|
|
|
logic [`XLEN-1:0] LSUBusHWDATA;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
2021-06-24 18:05:22 +00:00
|
|
|
logic BPPredWrongE;
|
|
|
|
logic BPPredDirWrongM;
|
|
|
|
logic BTBPredPCWrongM;
|
|
|
|
logic RASPredPCWrongM;
|
|
|
|
logic BPPredClassNonCFIWrongM;
|
|
|
|
logic [4:0] InstrClassM;
|
2021-07-06 18:43:53 +00:00
|
|
|
logic InstrAccessFaultF;
|
2022-01-07 04:30:00 +00:00
|
|
|
logic [2:0] LSUBusSize;
|
2021-07-06 18:43:53 +00:00
|
|
|
|
2021-07-14 20:00:33 +00:00
|
|
|
logic ExceptionM;
|
|
|
|
logic PendingInterruptM;
|
2021-07-20 03:12:20 +00:00
|
|
|
logic DCacheMiss;
|
|
|
|
logic DCacheAccess;
|
2021-08-23 20:43:43 +00:00
|
|
|
logic BreakpointFaultM, EcallFaultM;
|
2021-07-01 22:59:55 +00:00
|
|
|
|
2021-06-24 18:05:22 +00:00
|
|
|
|
2021-10-27 20:45:37 +00:00
|
|
|
ifu ifu(
|
2021-11-17 20:39:05 +00:00
|
|
|
.clk, .reset,
|
|
|
|
.StallF, .StallD, .StallE, .StallM, .StallW,
|
|
|
|
.FlushF, .FlushD, .FlushE, .FlushM, .FlushW,
|
|
|
|
|
2021-11-21 04:35:47 +00:00
|
|
|
.ExceptionM, .PendingInterruptM,
|
2021-11-17 20:39:05 +00:00
|
|
|
// Fetch
|
2022-01-07 04:30:00 +00:00
|
|
|
.IFUBusHRDATA, .IFUBusAck, .PCF, .IFUBusAdr,
|
|
|
|
.IFUBusRead, .IFUStallF,
|
2021-11-17 20:39:05 +00:00
|
|
|
|
|
|
|
// Execute
|
2021-12-15 20:10:45 +00:00
|
|
|
.PCLinkE, .PCSrcE, .IEUAdrE, .PCE,
|
2021-10-27 20:45:37 +00:00
|
|
|
.BPPredWrongE,
|
2021-11-17 20:39:05 +00:00
|
|
|
|
|
|
|
// Mem
|
|
|
|
.RetM, .TrapM, .PrivilegedNextPCM, .InvalidateICacheM,
|
|
|
|
.InstrD, .InstrM, . PCM, .InstrClassM, .BPPredDirWrongM,
|
|
|
|
.BTBPredPCWrongM, .RASPredPCWrongM, .BPPredClassNonCFIWrongM,
|
|
|
|
|
|
|
|
// Writeback
|
|
|
|
|
|
|
|
// output logic
|
|
|
|
// Faults
|
|
|
|
.IllegalBaseInstrFaultD, .ITLBInstrPageFaultF,
|
|
|
|
.IllegalIEUInstrFaultD, .InstrMisalignedFaultM,
|
|
|
|
.InstrMisalignedAdrM,
|
|
|
|
|
|
|
|
// mmu management
|
2021-10-27 20:45:37 +00:00
|
|
|
.PrivilegeModeW, .PTE, .PageType, .SATP_REGW,
|
2021-11-17 20:39:05 +00:00
|
|
|
.STATUS_MXR, .STATUS_SUM, .STATUS_MPRV,
|
|
|
|
.STATUS_MPP, .ITLBWriteF, .ITLBFlushF,
|
2021-12-28 18:11:45 +00:00
|
|
|
.ITLBMissF,
|
2021-11-17 20:39:05 +00:00
|
|
|
|
|
|
|
// pmp/pma (inside mmu) signals. *** temporarily from AHB bus but eventually replace with internal versions pre H
|
|
|
|
.PMPCFG_ARRAY_REGW, .PMPADDR_ARRAY_REGW,
|
2021-10-27 20:45:37 +00:00
|
|
|
.InstrAccessFaultF
|
2021-11-17 20:39:05 +00:00
|
|
|
|
2021-10-27 20:45:37 +00:00
|
|
|
|
|
|
|
); // instruction fetch unit: PC, branch prediction, instruction cache
|
|
|
|
|
2021-11-17 21:24:28 +00:00
|
|
|
ieu ieu(
|
2021-11-25 07:22:04 +00:00
|
|
|
.clk, .reset,
|
|
|
|
|
|
|
|
// Decode Stage interface
|
|
|
|
.InstrD, .IllegalIEUInstrFaultD,
|
|
|
|
.IllegalBaseInstrFaultD,
|
|
|
|
|
|
|
|
// Execute Stage interface
|
|
|
|
.PCE, .PCLinkE, .FWriteIntE, .IllegalFPUInstrE,
|
2022-01-07 04:30:00 +00:00
|
|
|
.FWriteDataE, .IEUAdrE, .MDUE, .W64E,
|
2021-11-25 07:22:04 +00:00
|
|
|
.Funct3E, .ForwardedSrcAE, .ForwardedSrcBE, // *** these are the src outputs before the mux choosing between them and PCE to put in srcA/B
|
|
|
|
|
|
|
|
// Memory stage interface
|
|
|
|
.SquashSCW, // from LSU
|
|
|
|
.MemRWM, // read/write control goes to LSU
|
|
|
|
.AtomicE, // atomic control goes to LSU
|
|
|
|
.AtomicM, // atomic control goes to LSU
|
2021-12-15 20:10:45 +00:00
|
|
|
.WriteDataM, // Write data to LSU
|
2021-11-25 07:22:04 +00:00
|
|
|
.Funct3M, // size and signedness to LSU
|
|
|
|
.SrcAM, // to privilege and fpu
|
|
|
|
.RdM, .FIntResM, .InvalidateICacheM, .FlushDCacheM,
|
|
|
|
|
|
|
|
// Writeback stage
|
2022-01-07 04:30:00 +00:00
|
|
|
.CSRReadValW, .ReadDataM, .MDUResultW,
|
2021-12-18 13:36:32 +00:00
|
|
|
.RdW, .ReadDataW,
|
2021-11-25 07:22:04 +00:00
|
|
|
.InstrValidM,
|
|
|
|
|
|
|
|
// hazards
|
|
|
|
.StallD, .StallE, .StallM, .StallW,
|
|
|
|
.FlushD, .FlushE, .FlushM, .FlushW,
|
2022-01-07 04:30:00 +00:00
|
|
|
.FPUStallD, .LoadStallD, .MDUStallD, .CSRRdStallD,
|
2021-11-25 07:22:04 +00:00
|
|
|
.PCSrcE,
|
|
|
|
.CSRReadM, .CSRWriteM, .PrivilegedM,
|
|
|
|
.CSRWritePendingDEM, .StoreStallD
|
2021-11-17 21:24:28 +00:00
|
|
|
|
|
|
|
); // integer execution unit: integer register file, datapath and controller
|
2021-05-21 02:17:59 +00:00
|
|
|
|
2021-11-25 06:09:39 +00:00
|
|
|
lsu lsu(
|
2021-11-25 07:22:04 +00:00
|
|
|
.clk, .reset, .StallM, .FlushM, .StallW,
|
|
|
|
.FlushW,
|
|
|
|
// CPU interface
|
|
|
|
.MemRWM, .Funct3M, .Funct7M(InstrM[31:25]),
|
|
|
|
.AtomicM, .ExceptionM, .PendingInterruptM,
|
2021-12-29 04:27:12 +00:00
|
|
|
.CommittedM, .DCacheMiss, .DCacheAccess,
|
2021-11-25 07:22:04 +00:00
|
|
|
.SquashSCW,
|
|
|
|
//.DataMisalignedM(DataMisalignedM),
|
2021-12-19 20:00:30 +00:00
|
|
|
.IEUAdrE, .IEUAdrM, .WriteDataM,
|
2021-11-25 07:22:04 +00:00
|
|
|
.ReadDataM, .FlushDCacheM,
|
|
|
|
// connected to ahb (all stay the same)
|
2022-01-07 04:30:00 +00:00
|
|
|
.LSUBusAdr, .LSUBusRead, .LSUBusWrite, .LSUBusAck,
|
|
|
|
.LSUBusHRDATA, .LSUBusHWDATA, .LSUBusSize,
|
2021-11-25 07:22:04 +00:00
|
|
|
|
|
|
|
// connect to csr or privilege and stay the same.
|
|
|
|
.PrivilegeModeW, // connects to csr
|
|
|
|
.PMPCFG_ARRAY_REGW, // connects to csr
|
|
|
|
.PMPADDR_ARRAY_REGW, // connects to csr
|
|
|
|
// hptw keep i/o
|
|
|
|
.SATP_REGW, // from csr
|
|
|
|
.STATUS_MXR, // from csr
|
|
|
|
.STATUS_SUM, // from csr
|
|
|
|
.STATUS_MPRV, // from csr
|
|
|
|
.STATUS_MPP, // from csr
|
|
|
|
|
|
|
|
.DTLBFlushM, // connects to privilege
|
|
|
|
.DTLBLoadPageFaultM, // connects to privilege
|
|
|
|
.DTLBStorePageFaultM, // connects to privilege
|
|
|
|
.LoadMisalignedFaultM, // connects to privilege
|
|
|
|
.LoadAccessFaultM, // connects to privilege
|
|
|
|
.StoreMisalignedFaultM, // connects to privilege
|
|
|
|
.StoreAccessFaultM, // connects to privilege
|
2021-07-03 20:51:25 +00:00
|
|
|
|
2021-11-25 07:22:04 +00:00
|
|
|
.PCF, .ITLBMissF, .PTE, .PageType, .ITLBWriteF,
|
|
|
|
.LSUStall); // change to LSUStall
|
2021-07-09 20:16:38 +00:00
|
|
|
|
2021-06-23 21:43:22 +00:00
|
|
|
|
2021-12-20 00:53:41 +00:00
|
|
|
// *** Ross: please make EBU conditional when only supporting internal memories
|
2021-06-23 21:43:22 +00:00
|
|
|
|
2021-07-09 20:16:38 +00:00
|
|
|
ahblite ebu(// IFU connections
|
2021-11-25 06:48:01 +00:00
|
|
|
.clk, .reset,
|
|
|
|
.UnsignedLoadM(1'b0), .AtomicMaskedM(2'b00),
|
2022-01-07 04:30:00 +00:00
|
|
|
.IFUBusAdr,
|
|
|
|
.IFUBusRead, .IFUBusHRDATA, .IFUBusAck,
|
2021-11-25 06:48:01 +00:00
|
|
|
// Signals from Data Cache
|
2022-01-07 04:30:00 +00:00
|
|
|
.LSUBusAdr, .LSUBusRead, .LSUBusWrite, .LSUBusHWDATA,
|
|
|
|
.LSUBusHRDATA,
|
|
|
|
.LSUBusSize,
|
|
|
|
.LSUBusAck,
|
2021-11-25 06:48:01 +00:00
|
|
|
|
|
|
|
.HRDATA, .HREADY, .HRESP, .HCLK, .HRESETn,
|
|
|
|
.HADDR, .HWDATA, .HWRITE, .HSIZE, .HBURST,
|
|
|
|
.HPROT, .HTRANS, .HMASTLOCK, .HADDRD, .HSIZED,
|
|
|
|
.HWRITED);
|
2021-06-23 21:43:22 +00:00
|
|
|
|
2021-06-24 18:05:22 +00:00
|
|
|
|
2021-12-20 00:53:41 +00:00
|
|
|
hazard hzu(
|
2021-11-25 06:48:01 +00:00
|
|
|
.BPPredWrongE, .CSRWritePendingDEM, .RetM, .TrapM,
|
2022-01-07 04:30:00 +00:00
|
|
|
.LoadStallD, .StoreStallD, .MDUStallD, .CSRRdStallD,
|
|
|
|
.LSUStall, .IFUStallF,
|
2021-11-25 06:48:01 +00:00
|
|
|
.FPUStallD, .FStallD,
|
|
|
|
.DivBusyE, .FDivBusyE,
|
|
|
|
.EcallFaultM, .BreakpointFaultM,
|
|
|
|
.InvalidateICacheM,
|
|
|
|
// Stall & flush outputs
|
|
|
|
.StallF, .StallD, .StallE, .StallM, .StallW,
|
|
|
|
.FlushF, .FlushD, .FlushE, .FlushM, .FlushW
|
|
|
|
); // global stall and flush control
|
2021-01-27 11:40:26 +00:00
|
|
|
|
2022-01-05 16:41:17 +00:00
|
|
|
if (`ZICSR_SUPPORTED) begin:priv
|
|
|
|
privileged priv(
|
|
|
|
.clk, .reset,
|
|
|
|
.FlushD, .FlushE, .FlushM, .FlushW,
|
|
|
|
.StallD, .StallE, .StallM, .StallW,
|
|
|
|
.CSRReadM, .CSRWriteM, .SrcAM, .PCM,
|
|
|
|
.InstrM, .CSRReadValW, .PrivilegedNextPCM,
|
|
|
|
.RetM, .TrapM,
|
|
|
|
.ITLBFlushF, .DTLBFlushM,
|
|
|
|
.InstrValidM, .CommittedM,
|
|
|
|
.FRegWriteM, .LoadStallD,
|
|
|
|
.BPPredDirWrongM, .BTBPredPCWrongM,
|
|
|
|
.RASPredPCWrongM, .BPPredClassNonCFIWrongM,
|
|
|
|
.InstrClassM, .DCacheMiss, .DCacheAccess, .PrivilegedM,
|
|
|
|
.ITLBInstrPageFaultF, .DTLBLoadPageFaultM, .DTLBStorePageFaultM,
|
|
|
|
.InstrMisalignedFaultM, .IllegalIEUInstrFaultD, .IllegalFPUInstrD,
|
|
|
|
.LoadMisalignedFaultM, .StoreMisalignedFaultM,
|
|
|
|
.TimerIntM, .ExtIntM, .SwIntM,
|
|
|
|
.MTIME_CLINT,
|
|
|
|
.InstrMisalignedAdrM, .IEUAdrM,
|
|
|
|
.SetFflagsM,
|
|
|
|
// Trap signals from pmp/pma in mmu
|
|
|
|
// *** do these need to be split up into one for dmem and one for ifu?
|
|
|
|
// instead, could we only care about the instr and F pins that come from ifu and only care about the load/store and m pins that come from dmem?
|
|
|
|
.InstrAccessFaultF, .LoadAccessFaultM, .StoreAccessFaultM,
|
|
|
|
.ExceptionM, .PendingInterruptM, .IllegalFPUInstrE,
|
|
|
|
.PrivilegeModeW, .SATP_REGW,
|
|
|
|
.STATUS_MXR, .STATUS_SUM, .STATUS_MPRV, .STATUS_MPP,
|
|
|
|
.PMPCFG_ARRAY_REGW, .PMPADDR_ARRAY_REGW,
|
|
|
|
.FRM_REGW,.BreakpointFaultM, .EcallFaultM
|
|
|
|
);
|
|
|
|
end else begin
|
|
|
|
assign CSRReadValW = 0;
|
|
|
|
assign PrivilegedNextPCM = 0;
|
|
|
|
assign RetM = 0;
|
|
|
|
assign TrapM = 0;
|
|
|
|
assign ITLBFlushF = 0;
|
|
|
|
assign DTLBFlushM = 0;
|
|
|
|
end
|
|
|
|
if (`M_SUPPORTED) begin:mdu
|
|
|
|
muldiv mdu(
|
|
|
|
.clk, .reset,
|
|
|
|
.ForwardedSrcAE, .ForwardedSrcBE,
|
2022-01-07 04:30:00 +00:00
|
|
|
.Funct3E, .Funct3M, .MDUE, .W64E,
|
|
|
|
.MDUResultW, .DivBusyE,
|
2022-01-05 16:41:17 +00:00
|
|
|
.StallM, .StallW, .FlushM, .FlushW
|
|
|
|
);
|
|
|
|
end else begin // no M instructions supported
|
2022-01-07 04:30:00 +00:00
|
|
|
assign MDUResultW = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign DivBusyE = 0;
|
|
|
|
end
|
|
|
|
|
|
|
|
if (`F_SUPPORTED) begin:fpu
|
|
|
|
fpu fpu(
|
|
|
|
.clk, .reset,
|
|
|
|
.FRM_REGW, // Rounding mode from CSR
|
|
|
|
.InstrD, // instruction from IFU
|
|
|
|
.ReadDataW,// Read data from memory
|
|
|
|
.ForwardedSrcAE, // Integer input being processed (from IEU)
|
|
|
|
.StallE, .StallM, .StallW, // stall signals from HZU
|
|
|
|
.FlushE, .FlushM, .FlushW, // flush signals from HZU
|
|
|
|
.RdM, .RdW, // which FP register to write to (from IEU)
|
|
|
|
.FRegWriteM, // FP register write enable
|
|
|
|
.FStallD, // Stall the decode stage
|
|
|
|
.FWriteIntE, // integer register write enable
|
|
|
|
.FWriteDataE, // Data to be written to memory
|
|
|
|
.FIntResM, // data to be written to integer register
|
|
|
|
.FDivBusyE, // Is the divide/sqrt unit busy (stall execute stage)
|
|
|
|
.IllegalFPUInstrD, // Is the instruction an illegal fpu instruction
|
|
|
|
.SetFflagsM // FPU flags (to privileged unit)
|
|
|
|
); // floating point unit
|
|
|
|
end else begin // no F_SUPPORTED or D_SUPPORTED; tie outputs low
|
|
|
|
assign FStallD = 0;
|
|
|
|
assign FWriteIntE = 0;
|
|
|
|
assign FWriteDataE = 0;
|
|
|
|
assign FIntResM = 0;
|
|
|
|
assign FDivBusyE = 0;
|
|
|
|
assign IllegalFPUInstrD = 1;
|
|
|
|
assign SetFflagsM = 0;
|
|
|
|
end
|
2021-01-15 04:37:51 +00:00
|
|
|
endmodule
|