2021-01-15 04:37:51 +00:00
|
|
|
///////////////////////////////////////////
|
2022-01-20 16:02:08 +00:00
|
|
|
// wallypipelinedcore.sv
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// 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:
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// The above copyright notice and this permission notice shall be included in all copies or
|
|
|
|
// substantial portions of the Software.
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
2022-01-07 12:58:40 +00:00
|
|
|
// 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-15 04:37:51 +00:00
|
|
|
|
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
|
|
|
|
2022-01-20 16:02:08 +00:00
|
|
|
module wallypipelinedcore (
|
2022-03-25 00:08:10 +00:00
|
|
|
input logic clk, reset,
|
2021-06-24 18:05:22 +00:00
|
|
|
// Privileged
|
2022-05-11 15:08:33 +00:00
|
|
|
input logic MTimerInt, MExtInt, SExtInt, MSwInt,
|
2022-03-25 00:08:10 +00:00
|
|
|
input logic [63:0] MTIME_CLINT,
|
2021-06-24 18:05:22 +00:00
|
|
|
// Bus Interface
|
|
|
|
input logic [`AHBW-1:0] HRDATA,
|
2022-03-25 00:08:10 +00:00
|
|
|
input logic HREADY, HRESP,
|
|
|
|
output logic HCLK, HRESETn,
|
2022-08-25 20:11:36 +00:00
|
|
|
output logic [`PA_BITS-1:0] HADDR,
|
2021-06-24 18:05:22 +00:00
|
|
|
output logic [`AHBW-1:0] HWDATA,
|
2022-07-05 15:51:35 +00:00
|
|
|
output logic [`XLEN/8-1:0] HWSTRB,
|
2022-03-25 00:08:10 +00:00
|
|
|
output logic HWRITE,
|
|
|
|
output logic [2:0] HSIZE,
|
|
|
|
output logic [2:0] HBURST,
|
|
|
|
output logic [3:0] HPROT,
|
|
|
|
output logic [1:0] HTRANS,
|
2022-08-25 22:34:14 +00:00
|
|
|
output logic HMASTLOCK
|
2021-06-24 18:05:22 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// logic [1:0] ForwardAE, ForwardBE;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic StallF, StallD, StallE, StallM, StallW;
|
2022-12-11 22:28:11 +00:00
|
|
|
logic FlushD, FlushE, FlushM, FlushW;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic RetM;
|
2021-09-27 18:57:46 +00:00
|
|
|
(* 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-03-25 00:08:10 +00:00
|
|
|
logic MDUE, W64E;
|
|
|
|
logic CSRReadM, CSRWriteM, PrivilegedM;
|
|
|
|
logic [1:0] AtomicM;
|
|
|
|
logic [`XLEN-1:0] ForwardedSrcAE, ForwardedSrcBE; //, SrcAE, SrcBE;
|
2022-04-02 21:39:45 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] SrcAM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic [2:0] Funct3E;
|
2022-05-12 15:26:08 +00:00
|
|
|
logic [31:0] InstrD;
|
2022-03-25 00:08:10 +00:00
|
|
|
(* mark_debug = "true" *) logic [31:0] InstrM;
|
|
|
|
logic [`XLEN-1:0] PCF, PCD, PCE, PCLinkE;
|
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] PCM;
|
|
|
|
logic [`XLEN-1:0] CSRReadValW, MDUResultW;
|
2022-12-20 23:55:45 +00:00
|
|
|
logic [`XLEN-1:0] UnalignedPCNextF, PCNext2F;
|
2022-03-25 00:08:10 +00:00
|
|
|
(* mark_debug = "true" *) logic [1:0] MemRWM;
|
|
|
|
(* mark_debug = "true" *) logic InstrValidM;
|
|
|
|
logic InstrMisalignedFaultM;
|
|
|
|
logic IllegalBaseInstrFaultD, IllegalIEUInstrFaultD;
|
|
|
|
logic InstrPageFaultF, LoadPageFaultM, StoreAmoPageFaultM;
|
|
|
|
logic LoadMisalignedFaultM, LoadAccessFaultM;
|
|
|
|
logic StoreAmoMisalignedFaultM, StoreAmoAccessFaultM;
|
2021-09-15 17:14:00 +00:00
|
|
|
logic InvalidateICacheM, FlushDCacheM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic PCSrcE;
|
2022-12-15 15:53:35 +00:00
|
|
|
logic CSRWriteFenceM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic DivBusyE;
|
|
|
|
logic LoadStallD, StoreStallD, MDUStallD, CSRRdStallD;
|
|
|
|
logic SquashSCW;
|
2021-06-24 22:39:18 +00:00
|
|
|
// floating point unit signals
|
2022-03-25 00:08:10 +00:00
|
|
|
logic [2:0] FRM_REGW;
|
2022-12-23 18:47:18 +00:00
|
|
|
logic [4:0] RdE, RdM, RdW;
|
2022-12-19 15:28:45 +00:00
|
|
|
logic FPUStallD;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic FWriteIntE;
|
2022-06-28 21:33:31 +00:00
|
|
|
logic [`FLEN-1:0] FWriteDataM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic [`XLEN-1:0] FIntResM;
|
2022-08-23 19:17:19 +00:00
|
|
|
logic [`XLEN-1:0] FCvtIntResW;
|
|
|
|
logic FCvtIntW;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic FDivBusyE;
|
2022-08-23 19:17:19 +00:00
|
|
|
logic IllegalFPUInstrM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic FRegWriteM;
|
2022-12-02 19:55:23 +00:00
|
|
|
logic FCvtIntStallD;
|
2022-06-28 21:33:31 +00:00
|
|
|
logic FpLoadStoreM;
|
2022-06-13 22:47:51 +00:00
|
|
|
logic [1:0] FResSelW;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic [4:0] SetFflagsM;
|
2022-12-15 01:03:13 +00:00
|
|
|
logic [`XLEN-1:0] FPIntDivResultW;
|
2021-01-30 04:43:48 +00:00
|
|
|
|
2021-03-04 08:11:34 +00:00
|
|
|
// memory management unit signals
|
2022-03-25 00:08:10 +00:00
|
|
|
logic ITLBWriteF;
|
|
|
|
logic ITLBMissF;
|
|
|
|
logic [`XLEN-1:0] SATP_REGW;
|
2021-07-04 17:20:29 +00:00
|
|
|
logic STATUS_MXR, STATUS_SUM, STATUS_MPRV;
|
2022-05-03 11:56:31 +00:00
|
|
|
logic [1:0] STATUS_MPP, STATUS_FS;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic [1:0] PrivilegeModeW;
|
|
|
|
logic [`XLEN-1:0] PTE;
|
|
|
|
logic [1:0] PageType;
|
2022-12-23 21:10:37 +00:00
|
|
|
logic sfencevmaM, WFIStallM;
|
2022-05-08 06:46:35 +00:00
|
|
|
logic SelHPTW;
|
2022-07-05 15:51:35 +00:00
|
|
|
|
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-12-23 21:10:37 +00:00
|
|
|
logic IFUStallF;
|
|
|
|
logic LSUStallM;
|
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
|
2022-03-25 00:11:41 +00:00
|
|
|
logic [2:0] Funct3M;
|
|
|
|
logic [`XLEN-1:0] IEUAdrE;
|
2022-08-22 20:47:56 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] WriteDataM;
|
2022-03-25 00:11:41 +00:00
|
|
|
(* mark_debug = "true" *) logic [`XLEN-1:0] IEUAdrM;
|
2022-06-20 22:53:13 +00:00
|
|
|
logic [`LLEN-1:0] ReadDataW;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic CommittedM;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
|
|
|
// AHB ifu interface
|
2022-09-18 01:30:01 +00:00
|
|
|
logic [`PA_BITS-1:0] IFUHADDR;
|
|
|
|
logic [2:0] IFUHBURST;
|
|
|
|
logic [1:0] IFUHTRANS;
|
|
|
|
logic [2:0] IFUHSIZE;
|
|
|
|
logic IFUHWRITE;
|
|
|
|
logic IFUHREADY;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
|
|
|
// AHB LSU interface
|
2022-09-18 01:30:01 +00:00
|
|
|
logic [`PA_BITS-1:0] LSUHADDR;
|
|
|
|
logic [`XLEN-1:0] LSUHWDATA;
|
|
|
|
logic [`XLEN/8-1:0] LSUHWSTRB;
|
|
|
|
logic LSUHWRITE;
|
|
|
|
logic LSUHREADY;
|
2021-07-09 20:16:38 +00:00
|
|
|
|
2022-03-25 00:08:10 +00:00
|
|
|
logic BPPredWrongE;
|
2023-01-05 19:36:51 +00:00
|
|
|
logic DirPredictionWrongM;
|
2022-03-25 00:08:10 +00:00
|
|
|
logic BTBPredPCWrongM;
|
|
|
|
logic RASPredPCWrongM;
|
|
|
|
logic BPPredClassNonCFIWrongM;
|
|
|
|
logic [4:0] InstrClassM;
|
2022-11-29 22:28:14 +00:00
|
|
|
logic InstrAccessFaultF, HPTWInstrAccessFaultM;
|
2022-08-25 16:52:08 +00:00
|
|
|
logic [2:0] LSUHSIZE;
|
|
|
|
logic [2:0] LSUHBURST;
|
|
|
|
logic [1:0] LSUHTRANS;
|
2021-07-06 18:43:53 +00:00
|
|
|
|
2022-03-25 00:08:10 +00:00
|
|
|
logic DCacheMiss;
|
|
|
|
logic DCacheAccess;
|
|
|
|
logic ICacheMiss;
|
|
|
|
logic ICacheAccess;
|
|
|
|
logic BreakpointFaultM, EcallFaultM;
|
2022-02-17 05:37:36 +00:00
|
|
|
logic InstrDAPageFaultF;
|
2022-05-08 06:46:35 +00:00
|
|
|
logic BigEndianM;
|
2022-08-23 21:14:41 +00:00
|
|
|
logic FCvtIntE;
|
2022-09-28 22:39:51 +00:00
|
|
|
logic CommittedF;
|
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,
|
2023-01-05 20:04:09 +00:00
|
|
|
.StallF, .StallD, .StallE, .StallM, .StallW,
|
2022-12-11 22:28:11 +00:00
|
|
|
.FlushD, .FlushE, .FlushM, .FlushW,
|
2021-11-17 20:39:05 +00:00
|
|
|
// Fetch
|
2022-12-20 23:55:45 +00:00
|
|
|
.HRDATA, .PCF, .IFUHADDR, .PCNext2F,
|
2022-12-23 21:10:37 +00:00
|
|
|
.IFUStallF, .IFUHBURST, .IFUHTRANS, .IFUHSIZE,
|
2022-08-29 18:01:24 +00:00
|
|
|
.IFUHREADY, .IFUHWRITE,
|
2022-01-10 04:56:56 +00:00
|
|
|
.ICacheAccess, .ICacheMiss,
|
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
|
2022-12-20 23:55:45 +00:00
|
|
|
.RetM, .TrapM, .CommittedF, .UnalignedPCNextF, .InvalidateICacheM, .CSRWriteFenceM,
|
2023-01-05 19:36:51 +00:00
|
|
|
.InstrD, .InstrM, .PCM, .InstrClassM, .DirPredictionWrongM,
|
2021-11-17 20:39:05 +00:00
|
|
|
.BTBPredPCWrongM, .RASPredPCWrongM, .BPPredClassNonCFIWrongM,
|
|
|
|
|
|
|
|
// Writeback
|
|
|
|
|
|
|
|
// output logic
|
|
|
|
// Faults
|
2022-01-27 23:11:27 +00:00
|
|
|
.IllegalBaseInstrFaultD, .InstrPageFaultF,
|
2021-11-17 20:39:05 +00:00
|
|
|
.IllegalIEUInstrFaultD, .InstrMisalignedFaultM,
|
|
|
|
|
|
|
|
// 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,
|
2022-06-02 14:18:55 +00:00
|
|
|
.STATUS_MPP, .ITLBWriteF, .sfencevmaM,
|
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,
|
2022-02-17 05:37:36 +00:00
|
|
|
.InstrAccessFaultF,
|
|
|
|
.InstrDAPageFaultF
|
2022-03-25 00:08:10 +00:00
|
|
|
|
|
|
|
); // instruction fetch unit: PC, branch prediction, instruction cache
|
2021-10-27 20:45:37 +00:00
|
|
|
|
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
|
2022-08-23 21:14:41 +00:00
|
|
|
.PCE, .PCLinkE, .FWriteIntE, .FCvtIntE,
|
2022-08-22 20:47:56 +00:00
|
|
|
.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
|
|
|
|
.AtomicM, // atomic control goes to LSU
|
2022-08-22 20:47:56 +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
|
2022-12-23 18:47:18 +00:00
|
|
|
.RdE, .RdM, .FIntResM, .InvalidateICacheM, .FlushDCacheM,
|
2021-11-25 07:22:04 +00:00
|
|
|
|
|
|
|
// Writeback stage
|
2022-12-15 01:03:13 +00:00
|
|
|
.CSRReadValW, .MDUResultW, .FPIntDivResultW,
|
2022-06-20 22:53:13 +00:00
|
|
|
.RdW, .ReadDataW(ReadDataW[`XLEN-1:0]),
|
2021-11-25 07:22:04 +00:00
|
|
|
.InstrValidM,
|
2022-06-13 22:47:51 +00:00
|
|
|
.FCvtIntResW,
|
2022-08-23 19:17:19 +00:00
|
|
|
.FCvtIntW,
|
2021-11-25 07:22:04 +00:00
|
|
|
|
|
|
|
// hazards
|
|
|
|
.StallD, .StallE, .StallM, .StallW,
|
|
|
|
.FlushD, .FlushE, .FlushM, .FlushW,
|
2022-12-02 19:55:23 +00:00
|
|
|
.FCvtIntStallD, .LoadStallD, .MDUStallD, .CSRRdStallD,
|
2021-11-25 07:22:04 +00:00
|
|
|
.PCSrcE,
|
|
|
|
.CSRReadM, .CSRWriteM, .PrivilegedM,
|
2022-12-15 15:53:35 +00:00
|
|
|
.CSRWriteFenceM, .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,
|
2022-12-23 03:43:25 +00:00
|
|
|
.FlushW,
|
2022-03-25 00:11:41 +00:00
|
|
|
// CPU interface
|
|
|
|
.MemRWM, .Funct3M, .Funct7M(InstrM[31:25]),
|
2022-11-07 21:03:43 +00:00
|
|
|
.AtomicM,
|
2022-03-25 00:11:41 +00:00
|
|
|
.CommittedM, .DCacheMiss, .DCacheAccess,
|
|
|
|
.SquashSCW,
|
2022-06-28 21:33:31 +00:00
|
|
|
.FpLoadStoreM,
|
2022-08-22 20:29:54 +00:00
|
|
|
.FWriteDataM,
|
2022-03-25 00:11:41 +00:00
|
|
|
//.DataMisalignedM(DataMisalignedM),
|
2022-08-22 20:47:56 +00:00
|
|
|
.IEUAdrE, .IEUAdrM, .WriteDataM,
|
2022-06-20 22:53:13 +00:00
|
|
|
.ReadDataW, .FlushDCacheM,
|
2022-03-25 00:11:41 +00:00
|
|
|
// connected to ahb (all stay the same)
|
2022-08-31 14:50:39 +00:00
|
|
|
.LSUHADDR,
|
|
|
|
.HRDATA, .LSUHWDATA, .LSUHWSTRB, .LSUHSIZE, .LSUHBURST, .LSUHTRANS,
|
2022-08-29 18:01:24 +00:00
|
|
|
.LSUHWRITE, .LSUHREADY,
|
2021-11-25 07:22:04 +00:00
|
|
|
|
2022-03-25 00:08:10 +00:00
|
|
|
// connect to csr or privilege and stay the same.
|
2022-05-08 06:46:35 +00:00
|
|
|
.PrivilegeModeW, .BigEndianM, // connects to csr
|
2022-03-25 00:08:10 +00:00
|
|
|
.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
|
2021-11-25 07:22:04 +00:00
|
|
|
|
2022-06-02 14:18:55 +00:00
|
|
|
.sfencevmaM, // connects to privilege
|
2022-03-25 00:08:10 +00:00
|
|
|
.LoadPageFaultM, // connects to privilege
|
|
|
|
.StoreAmoPageFaultM, // connects to privilege
|
|
|
|
.LoadMisalignedFaultM, // connects to privilege
|
|
|
|
.LoadAccessFaultM, // connects to privilege
|
2022-11-29 22:28:14 +00:00
|
|
|
.HPTWInstrAccessFaultM, // connects to privilege
|
2022-03-25 00:08:10 +00:00
|
|
|
.StoreAmoMisalignedFaultM, // connects to privilege
|
|
|
|
.StoreAmoAccessFaultM, // connects to privilege
|
2022-02-17 05:37:36 +00:00
|
|
|
.InstrDAPageFaultF,
|
2021-07-03 20:51:25 +00:00
|
|
|
|
2022-05-08 06:46:35 +00:00
|
|
|
.PCF, .ITLBMissF, .PTE, .PageType, .ITLBWriteF, .SelHPTW,
|
2022-12-23 21:10:37 +00:00
|
|
|
.LSUStallM); // change to LSUStallM
|
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
|
|
|
|
2022-08-25 16:02:46 +00:00
|
|
|
if(`BUS) begin : ebu
|
2022-09-26 19:37:18 +00:00
|
|
|
ebu ebu(// IFU connections
|
2022-08-29 22:04:53 +00:00
|
|
|
.clk, .reset,
|
2022-08-31 14:50:39 +00:00
|
|
|
// IFU interface
|
2022-08-29 22:04:53 +00:00
|
|
|
.IFUHADDR,
|
|
|
|
.IFUHBURST,
|
|
|
|
.IFUHTRANS,
|
|
|
|
.IFUHREADY,
|
2022-09-18 01:30:01 +00:00
|
|
|
.IFUHSIZE,
|
2022-08-31 14:50:39 +00:00
|
|
|
// LSU interface
|
2022-08-29 22:04:53 +00:00
|
|
|
.LSUHADDR,
|
|
|
|
.LSUHWDATA,
|
2022-08-29 22:11:27 +00:00
|
|
|
.LSUHWSTRB,
|
2022-08-29 22:04:53 +00:00
|
|
|
.LSUHSIZE,
|
|
|
|
.LSUHBURST,
|
|
|
|
.LSUHTRANS,
|
|
|
|
.LSUHWRITE,
|
|
|
|
.LSUHREADY,
|
2022-08-31 14:50:39 +00:00
|
|
|
// BUS interface
|
2022-08-29 22:04:53 +00:00
|
|
|
.HREADY, .HRESP, .HCLK, .HRESETn,
|
|
|
|
.HADDR, .HWDATA, .HWSTRB, .HWRITE, .HSIZE, .HBURST,
|
|
|
|
.HPROT, .HTRANS, .HMASTLOCK);
|
|
|
|
|
2022-08-25 14:24:13 +00:00
|
|
|
end
|
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(
|
2022-12-15 15:53:35 +00:00
|
|
|
.BPPredWrongE, .CSRWriteFenceM, .RetM, .TrapM,
|
2022-01-07 04:30:00 +00:00
|
|
|
.LoadStallD, .StoreStallD, .MDUStallD, .CSRRdStallD,
|
2022-12-23 21:10:37 +00:00
|
|
|
.LSUStallM, .IFUStallF,
|
2022-12-19 15:28:45 +00:00
|
|
|
.FCvtIntStallD, .FPUStallD,
|
2022-03-25 00:08:10 +00:00
|
|
|
.DivBusyE, .FDivBusyE,
|
|
|
|
.EcallFaultM, .BreakpointFaultM,
|
2022-12-23 21:10:37 +00:00
|
|
|
.WFIStallM,
|
2021-11-25 06:48:01 +00:00
|
|
|
// Stall & flush outputs
|
2022-03-25 00:08:10 +00:00
|
|
|
.StallF, .StallD, .StallE, .StallM, .StallW,
|
2022-12-11 22:28:11 +00:00
|
|
|
.FlushD, .FlushE, .FlushM, .FlushW
|
2022-03-25 00:08:10 +00:00
|
|
|
); // 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,
|
2022-12-20 23:55:45 +00:00
|
|
|
.CSRReadM, .CSRWriteM, .SrcAM, .PCM, .PCNext2F,
|
|
|
|
.InstrM, .CSRReadValW, .UnalignedPCNextF,
|
2022-01-05 16:41:17 +00:00
|
|
|
.RetM, .TrapM,
|
2022-06-02 14:18:55 +00:00
|
|
|
.sfencevmaM,
|
2022-09-28 22:39:51 +00:00
|
|
|
.InstrValidM, .CommittedM, .CommittedF,
|
2022-01-05 16:41:17 +00:00
|
|
|
.FRegWriteM, .LoadStallD,
|
2023-01-05 19:36:51 +00:00
|
|
|
.DirPredictionWrongM, .BTBPredPCWrongM,
|
2022-01-05 16:41:17 +00:00
|
|
|
.RASPredPCWrongM, .BPPredClassNonCFIWrongM,
|
2022-01-10 04:56:56 +00:00
|
|
|
.InstrClassM, .DCacheMiss, .DCacheAccess, .ICacheMiss, .ICacheAccess, .PrivilegedM,
|
2022-01-27 23:11:27 +00:00
|
|
|
.InstrPageFaultF, .LoadPageFaultM, .StoreAmoPageFaultM,
|
2022-08-23 19:17:19 +00:00
|
|
|
.InstrMisalignedFaultM, .IllegalIEUInstrFaultD,
|
2022-01-27 23:11:27 +00:00
|
|
|
.LoadMisalignedFaultM, .StoreAmoMisalignedFaultM,
|
2022-05-11 15:08:33 +00:00
|
|
|
.MTimerInt, .MExtInt, .SExtInt, .MSwInt,
|
2022-01-05 16:41:17 +00:00
|
|
|
.MTIME_CLINT,
|
2022-04-22 22:45:23 +00:00
|
|
|
.IEUAdrM,
|
2022-01-05 16:41:17 +00:00
|
|
|
.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?
|
2022-11-29 22:28:14 +00:00
|
|
|
.InstrAccessFaultF, .HPTWInstrAccessFaultM, .LoadAccessFaultM, .StoreAmoAccessFaultM, .SelHPTW,
|
2022-08-23 19:17:19 +00:00
|
|
|
.IllegalFPUInstrM,
|
2022-01-05 16:41:17 +00:00
|
|
|
.PrivilegeModeW, .SATP_REGW,
|
2022-05-03 11:56:31 +00:00
|
|
|
.STATUS_MXR, .STATUS_SUM, .STATUS_MPRV, .STATUS_MPP, .STATUS_FS,
|
2022-01-05 16:41:17 +00:00
|
|
|
.PMPCFG_ARRAY_REGW, .PMPADDR_ARRAY_REGW,
|
2022-12-23 21:10:37 +00:00
|
|
|
.FRM_REGW,.BreakpointFaultM, .EcallFaultM, .WFIStallM, .BigEndianM
|
2022-01-05 16:41:17 +00:00
|
|
|
);
|
|
|
|
end else begin
|
|
|
|
assign CSRReadValW = 0;
|
2022-12-20 23:55:45 +00:00
|
|
|
assign UnalignedPCNextF = PCNext2F;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign RetM = 0;
|
|
|
|
assign TrapM = 0;
|
2022-12-23 21:10:37 +00:00
|
|
|
assign WFIStallM = 0;
|
2022-06-02 14:18:55 +00:00
|
|
|
assign sfencevmaM = 0;
|
2022-05-08 06:46:35 +00:00
|
|
|
assign BigEndianM = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
end
|
|
|
|
if (`M_SUPPORTED) begin:mdu
|
2022-12-28 03:57:10 +00:00
|
|
|
mdu mdu(
|
2022-01-05 16:41:17 +00:00
|
|
|
.clk, .reset,
|
|
|
|
.ForwardedSrcAE, .ForwardedSrcBE,
|
2022-01-07 04:30:00 +00:00
|
|
|
.Funct3E, .Funct3M, .MDUE, .W64E,
|
2022-05-12 14:49:58 +00:00
|
|
|
.MDUResultW, .DivBusyE,
|
2022-12-15 19:00:54 +00:00
|
|
|
.StallM, .StallW, .FlushE, .FlushM, .FlushW
|
2022-01-05 16:41:17 +00:00
|
|
|
);
|
|
|
|
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
|
2022-06-20 22:53:13 +00:00
|
|
|
.ReadDataW(ReadDataW[`FLEN-1:0]),// Read data from memory
|
2022-01-05 16:41:17 +00:00
|
|
|
.ForwardedSrcAE, // Integer input being processed (from IEU)
|
|
|
|
.StallE, .StallM, .StallW, // stall signals from HZU
|
2022-12-15 18:56:18 +00:00
|
|
|
//.TrapM,
|
2022-01-05 16:41:17 +00:00
|
|
|
.FlushE, .FlushM, .FlushW, // flush signals from HZU
|
2022-12-23 18:47:18 +00:00
|
|
|
.RdE, .RdM, .RdW, // which FP register to write to (from IEU)
|
2022-05-03 11:56:31 +00:00
|
|
|
.STATUS_FS, // is floating-point enabled?
|
2022-01-05 16:41:17 +00:00
|
|
|
.FRegWriteM, // FP register write enable
|
2022-06-28 21:33:31 +00:00
|
|
|
.FpLoadStoreM,
|
2022-09-29 23:08:27 +00:00
|
|
|
.ForwardedSrcBE, // Integer input for intdiv
|
|
|
|
.Funct3E, .Funct3M, .MDUE, .W64E, // Integer flags and functions
|
2022-12-19 15:28:45 +00:00
|
|
|
.FPUStallD, // Stall the decode stage
|
2022-08-23 21:14:41 +00:00
|
|
|
.FWriteIntE, .FCvtIntE, // integer register write enable, conversion operation
|
2022-06-28 21:33:31 +00:00
|
|
|
.FWriteDataM, // Data to be written to memory
|
2022-01-05 16:41:17 +00:00
|
|
|
.FIntResM, // data to be written to integer register
|
2022-06-13 22:47:51 +00:00
|
|
|
.FCvtIntResW, // fp -> int conversion result to be stored in int register
|
2022-08-23 19:17:19 +00:00
|
|
|
.FCvtIntW, // fpu result selection
|
2022-01-05 16:41:17 +00:00
|
|
|
.FDivBusyE, // Is the divide/sqrt unit busy (stall execute stage)
|
2022-08-23 19:17:19 +00:00
|
|
|
.IllegalFPUInstrM, // Is the instruction an illegal fpu instruction
|
2022-12-15 01:03:13 +00:00
|
|
|
.SetFflagsM, // FPU flags (to privileged unit)
|
|
|
|
.FPIntDivResultW
|
2022-01-05 16:41:17 +00:00
|
|
|
); // floating point unit
|
|
|
|
end else begin // no F_SUPPORTED or D_SUPPORTED; tie outputs low
|
2022-12-19 15:28:45 +00:00
|
|
|
assign FPUStallD = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign FWriteIntE = 0;
|
2022-08-23 21:14:41 +00:00
|
|
|
assign FCvtIntE = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign FIntResM = 0;
|
2022-08-23 19:17:19 +00:00
|
|
|
assign FCvtIntW = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign FDivBusyE = 0;
|
2022-08-23 19:17:19 +00:00
|
|
|
assign IllegalFPUInstrM = 1;
|
2022-01-05 16:41:17 +00:00
|
|
|
assign SetFflagsM = 0;
|
2022-10-10 14:12:37 +00:00
|
|
|
assign FpLoadStoreM = 0;
|
2022-01-05 16:41:17 +00:00
|
|
|
end
|
2021-01-15 04:37:51 +00:00
|
|
|
endmodule
|