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-01-25 20:57:36 +00:00
|
|
|
module wallypipelinedhart (
|
2021-02-02 04:44:41 +00:00
|
|
|
input logic clk, reset,
|
2021-01-23 15:48:12 +00:00
|
|
|
output logic [`XLEN-1:0] PCF,
|
2021-02-09 16:02:17 +00:00
|
|
|
// input logic [31:0] InstrF,
|
2021-01-30 04:43:48 +00:00
|
|
|
// Privileged
|
2021-02-02 04:44:41 +00:00
|
|
|
input logic TimerIntM, ExtIntM, SwIntM,
|
|
|
|
input logic InstrAccessFaultF,
|
|
|
|
input logic DataAccessFaultM,
|
2021-01-29 06:07:17 +00:00
|
|
|
// Bus Interface
|
2021-02-24 12:25:03 +00:00
|
|
|
input logic [15:0] rd2, // bogus, delete when real multicycle fetch works
|
2021-01-29 06:07:17 +00:00
|
|
|
input logic [`AHBW-1:0] HRDATA,
|
|
|
|
input logic HREADY, HRESP,
|
2021-01-30 05:56:12 +00:00
|
|
|
output logic HCLK, HRESETn,
|
2021-01-29 06:07:17 +00:00
|
|
|
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,
|
2021-02-08 04:21:55 +00:00
|
|
|
output logic HMASTLOCK,
|
|
|
|
// Delayed signals for subword write
|
|
|
|
output logic [2:0] HADDRD,
|
|
|
|
output logic [3:0] HSIZED,
|
|
|
|
output logic HWRITED
|
2021-01-29 06:07:17 +00:00
|
|
|
);
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-02-08 04:21:55 +00:00
|
|
|
// logic [1:0] ForwardAE, ForwardBE;
|
|
|
|
logic StallF, StallD, StallE, StallM, StallW;
|
2021-03-04 19:35:46 +00:00
|
|
|
logic FlushF, FlushD, FlushE, FlushM, FlushW;
|
2021-01-19 01:16:53 +00:00
|
|
|
logic RetM, TrapM;
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-01-27 12:46:52 +00:00
|
|
|
// new signals that must connect through DP
|
2021-02-16 03:27:35 +00:00
|
|
|
logic MulDivE, W64E;
|
2021-03-11 05:11:31 +00:00
|
|
|
logic CSRReadM, CSRWriteM, PrivilegedM;
|
|
|
|
logic [1:0] AtomicM;
|
2021-02-16 03:27:35 +00:00
|
|
|
logic [`XLEN-1:0] SrcAE, SrcBE;
|
2021-01-27 12:46:52 +00:00
|
|
|
logic [`XLEN-1:0] SrcAM;
|
2021-02-16 03:27:35 +00:00
|
|
|
logic [2:0] Funct3E;
|
2021-01-30 06:57:51 +00:00
|
|
|
// logic [31:0] InstrF;
|
2021-01-28 03:49:47 +00:00
|
|
|
logic [31:0] InstrD, InstrM;
|
2021-02-27 02:12:27 +00:00
|
|
|
logic [`XLEN-1:0] PCE, PCM, PCLinkE, PCLinkW;
|
2021-01-28 03:49:47 +00:00
|
|
|
logic [`XLEN-1:0] PCTargetE;
|
2021-02-16 03:27:35 +00:00
|
|
|
logic [`XLEN-1:0] CSRReadValW, MulDivResultW;
|
2021-01-27 12:46:52 +00:00
|
|
|
logic [`XLEN-1:0] PrivilegedNextPCM;
|
2021-01-29 20:37:51 +00:00
|
|
|
logic [1:0] MemRWM;
|
2021-01-27 12:46:52 +00:00
|
|
|
logic InstrValidW;
|
2021-01-28 03:49:47 +00:00
|
|
|
logic InstrMisalignedFaultM;
|
2021-01-29 20:37:51 +00:00
|
|
|
logic DataMisalignedM;
|
2021-01-28 03:49:47 +00:00
|
|
|
logic IllegalBaseInstrFaultD, IllegalIEUInstrFaultD;
|
2021-01-27 12:46:52 +00:00
|
|
|
logic LoadMisalignedFaultM, LoadAccessFaultM;
|
|
|
|
logic StoreMisalignedFaultM, StoreAccessFaultM;
|
|
|
|
logic [`XLEN-1:0] InstrMisalignedAdrM;
|
|
|
|
|
2021-01-27 11:40:26 +00:00
|
|
|
logic PCSrcE;
|
|
|
|
logic CSRWritePendingDEM;
|
2021-02-26 22:00:07 +00:00
|
|
|
logic LoadStallD, MulDivStallD, CSRRdStallD;
|
2021-01-15 04:37:51 +00:00
|
|
|
logic [4:0] SetFflagsM;
|
|
|
|
logic [2:0] FRM_REGW;
|
|
|
|
logic FloatRegWriteW;
|
2021-03-01 05:09:45 +00:00
|
|
|
logic SquashSCW;
|
2021-01-30 04:43:48 +00:00
|
|
|
|
2021-03-04 08:11:34 +00:00
|
|
|
// memory management unit signals
|
2021-03-05 06:22:53 +00:00
|
|
|
logic ITLBWriteF, DTLBWriteM;
|
2021-03-04 08:11:34 +00:00
|
|
|
logic ITLBMissF, ITLBHitF;
|
2021-03-04 08:30:06 +00:00
|
|
|
logic DTLBMissM, DTLBHitM;
|
2021-03-05 06:22:53 +00:00
|
|
|
logic [`XLEN-1:0] SATP_REGW;
|
|
|
|
|
|
|
|
logic [`XLEN-1:0] PageTableEntryF, PageTableEntryM;
|
2021-03-04 08:11:34 +00:00
|
|
|
|
2021-02-02 18:02:31 +00:00
|
|
|
// bus interface to dmem
|
2021-02-08 04:21:55 +00:00
|
|
|
logic MemReadM, MemWriteM;
|
|
|
|
logic [2:0] Funct3M;
|
2021-02-02 20:09:24 +00:00
|
|
|
logic [`XLEN-1:0] MemAdrM, MemPAdrM, WriteDataM;
|
2021-02-08 04:21:55 +00:00
|
|
|
logic [`XLEN-1:0] ReadDataW;
|
2021-02-02 20:09:24 +00:00
|
|
|
logic [`XLEN-1:0] InstrPAdrF;
|
2021-02-24 12:25:03 +00:00
|
|
|
logic [`XLEN-1:0] InstrRData;
|
2021-02-08 04:21:55 +00:00
|
|
|
logic InstrReadF;
|
2021-01-30 06:43:49 +00:00
|
|
|
logic DataStall, InstrStall;
|
2021-02-02 20:09:24 +00:00
|
|
|
logic InstrAckD, MemAckW;
|
2021-02-18 04:19:17 +00:00
|
|
|
logic BPPredWrongE;
|
|
|
|
|
2021-01-19 01:16:53 +00:00
|
|
|
|
2021-02-24 12:25:03 +00:00
|
|
|
ifu ifu(.InstrInF(InstrRData), .*); // instruction fetch unit: PC, branch prediction, instruction cache
|
2021-01-28 03:49:47 +00:00
|
|
|
|
2021-02-20 02:09:07 +00:00
|
|
|
ieu ieu(.*); // integer execution unit: integer register file, datapath and controller
|
2021-02-08 04:21:55 +00:00
|
|
|
dmem dmem(.*); // data cache unit
|
2021-01-28 06:03:12 +00:00
|
|
|
|
2021-02-08 04:21:55 +00:00
|
|
|
ahblite ebu(
|
|
|
|
//.InstrReadF(1'b0),
|
2021-02-24 12:25:03 +00:00
|
|
|
//.InstrRData(InstrF), // hook up InstrF later
|
2021-02-08 04:21:55 +00:00
|
|
|
.MemSizeM(Funct3M[1:0]), .UnsignedLoadM(Funct3M[2]),
|
2021-03-11 05:11:31 +00:00
|
|
|
.Funct7M(InstrM[31:25]),
|
2021-01-29 06:07:17 +00:00
|
|
|
.*);
|
2021-02-09 16:02:17 +00:00
|
|
|
|
2021-03-05 06:22:53 +00:00
|
|
|
// walker walker(.*); *** // can send addresses to ahblite, send out pagetablestall
|
|
|
|
// *** can connect to hazard unit
|
2021-02-08 04:21:55 +00:00
|
|
|
// changing from this to the line above breaks the program. auipc at 104 fails; seems to be flushed.
|
|
|
|
// Would need to insertinstruction as InstrD, not InstrF
|
2021-02-09 16:02:17 +00:00
|
|
|
/*ahblite ebu(
|
|
|
|
.InstrReadF(1'b0),
|
2021-02-08 04:21:55 +00:00
|
|
|
.InstrRData(), // hook up InstrF later
|
|
|
|
.MemSizeM(Funct3M[1:0]), .UnsignedLoadM(Funct3M[2]),
|
2021-02-09 16:02:17 +00:00
|
|
|
.*); */
|
2021-01-29 06:07:17 +00:00
|
|
|
|
2021-02-16 03:27:35 +00:00
|
|
|
|
|
|
|
muldiv mdu(.*); // multiply and divide unit
|
|
|
|
/* fpu fpu(.*); // floating point unit
|
2021-01-29 06:07:17 +00:00
|
|
|
*/
|
2021-01-27 11:40:26 +00:00
|
|
|
hazard hzu(.*); // global stall and flush control
|
|
|
|
|
|
|
|
// Priveleged block operates in M and W stages, handling CSRs and exceptions
|
2021-01-27 12:46:52 +00:00
|
|
|
privileged priv(.*);
|
2021-01-27 11:40:26 +00:00
|
|
|
|
2021-01-15 04:37:51 +00:00
|
|
|
// add FPU here, with SetFflagsM, FRM_REGW
|
|
|
|
// presently stub out SetFlagsM and FloatRegWriteW
|
|
|
|
assign SetFflagsM = 0;
|
2021-01-28 03:49:47 +00:00
|
|
|
assign FloatRegWriteW = 0;
|
2021-01-19 01:16:53 +00:00
|
|
|
|
2021-01-15 04:37:51 +00:00
|
|
|
endmodule
|