mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	csr comments
This commit is contained in:
		
							parent
							
								
									543d9d379b
								
							
						
					
					
						commit
						25d8566694
					
				@ -32,17 +32,31 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
module csr #(parameter
 | 
					module csr #(parameter
 | 
				
			||||||
    MIP = 12'h344,
 | 
					    MIP = 12'h344,
 | 
				
			||||||
    SIP = 12'h144
 | 
					    SIP = 12'h144) (
 | 
				
			||||||
  ) (
 | 
					 | 
				
			||||||
  input  logic             clk, reset,
 | 
					  input  logic             clk, reset,
 | 
				
			||||||
  input  logic             FlushM, FlushW,
 | 
					  input  logic             FlushM, FlushW,
 | 
				
			||||||
  input  logic             StallE, StallM, StallW,
 | 
					  input  logic             StallE, StallM, StallW,
 | 
				
			||||||
  input  logic [31:0]      InstrM, 
 | 
					  input  logic [31:0]      InstrM,                    // current instruction
 | 
				
			||||||
  input  logic [`XLEN-1:0] PCM, SrcAM, IEUAdrM, PCNext2F,
 | 
					  input  logic [`XLEN-1:0] PCM, PCNext2F,             // program counter, next PC going to trap/return logic
 | 
				
			||||||
  input  logic             CSRReadM, CSRWriteM, TrapM, mretM, sretM, wfiM, IntPendingM, InterruptM,
 | 
					  input  logic [`XLEN-1:0] SrcAM, IEUAdrM,            // SrcA and memory address from IEU
 | 
				
			||||||
  input  logic             MTimerInt, MExtInt, SExtInt, MSwInt,
 | 
					  input  logic             CSRReadM, CSRWriteM,       // read or write CSR
 | 
				
			||||||
  input  logic [63:0]      MTIME_CLINT, 
 | 
					  input  logic             TrapM,                     // trap is occurring
 | 
				
			||||||
  input  logic             InstrValidM, FRegWriteM, LoadStallD,
 | 
					  input  logic             mretM, sretM, wfiM,        // return or WFI instruction
 | 
				
			||||||
 | 
					  input  logic             IntPendingM,               // at least one interrupt is pending and could occur if enabled
 | 
				
			||||||
 | 
					  input  logic             InterruptM,                // interrupt is occurring
 | 
				
			||||||
 | 
					  input  logic             MTimerInt,                 // timer interrupt
 | 
				
			||||||
 | 
					  input  logic             MExtInt, SExtInt,          // external interrupt (from PLIC) 
 | 
				
			||||||
 | 
					  input  logic             MSwInt,                    // software interrupt
 | 
				
			||||||
 | 
					  input  logic [63:0]      MTIME_CLINT,               // TIME value from CLINT
 | 
				
			||||||
 | 
					  input  logic             InstrValidM,               // current instruction is valid
 | 
				
			||||||
 | 
					  input  logic             FRegWriteM,                // writes to floating point registers change STATUS.FS
 | 
				
			||||||
 | 
					  input  logic [4:0]       SetFflagsM,                // Set floating point flag bits in FCSR
 | 
				
			||||||
 | 
					  input  logic [1:0]       NextPrivilegeModeM,        // STATUS bits updated based on next privilege mode
 | 
				
			||||||
 | 
					  input  logic [1:0]       PrivilegeModeW,            // current privilege mode
 | 
				
			||||||
 | 
					  input  logic [`LOG_XLEN-1:0] CauseM,                // Trap cause
 | 
				
			||||||
 | 
					  input  logic             SelHPTW,                   // hardware page table walker active, so base endianness on supervisor mode
 | 
				
			||||||
 | 
					  // inputs for performance counters
 | 
				
			||||||
 | 
					  input  logic             LoadStallD,
 | 
				
			||||||
  input  logic             DirPredictionWrongM,
 | 
					  input  logic             DirPredictionWrongM,
 | 
				
			||||||
  input  logic             BTBPredPCWrongM,
 | 
					  input  logic             BTBPredPCWrongM,
 | 
				
			||||||
  input  logic             RASPredPCWrongM,
 | 
					  input  logic             RASPredPCWrongM,
 | 
				
			||||||
@ -52,66 +66,61 @@ module csr #(parameter
 | 
				
			|||||||
  input  logic             DCacheAccess,
 | 
					  input  logic             DCacheAccess,
 | 
				
			||||||
  input  logic             ICacheMiss,
 | 
					  input  logic             ICacheMiss,
 | 
				
			||||||
  input  logic             ICacheAccess,
 | 
					  input  logic             ICacheAccess,
 | 
				
			||||||
  input  logic [1:0]       NextPrivilegeModeM, PrivilegeModeW,
 | 
					  // outputs from CSRs
 | 
				
			||||||
  input  logic [`LOG_XLEN-1:0] CauseM, 
 | 
					 | 
				
			||||||
  input  logic             SelHPTW,
 | 
					 | 
				
			||||||
  output logic [1:0]       STATUS_MPP,
 | 
					  output logic [1:0]       STATUS_MPP,
 | 
				
			||||||
  output logic             STATUS_SPP, STATUS_TSR, STATUS_TVM,
 | 
					  output logic             STATUS_SPP, STATUS_TSR, STATUS_TVM,
 | 
				
			||||||
  output logic [`XLEN-1:0]      MEDELEG_REGW, 
 | 
					  output logic [`XLEN-1:0] MEDELEG_REGW, 
 | 
				
			||||||
  output logic [`XLEN-1:0] SATP_REGW,
 | 
					  output logic [`XLEN-1:0] SATP_REGW,
 | 
				
			||||||
  output logic [11:0]      MIP_REGW, MIE_REGW, MIDELEG_REGW,
 | 
					  output logic [11:0]      MIP_REGW, MIE_REGW, MIDELEG_REGW,
 | 
				
			||||||
  output logic             STATUS_MIE, STATUS_SIE,
 | 
					  output logic             STATUS_MIE, STATUS_SIE,
 | 
				
			||||||
  output logic             STATUS_MXR, STATUS_SUM, STATUS_MPRV, STATUS_TW,
 | 
					  output logic             STATUS_MXR, STATUS_SUM, STATUS_MPRV, STATUS_TW,
 | 
				
			||||||
  output logic [1:0]       STATUS_FS,
 | 
					  output logic [1:0]       STATUS_FS,
 | 
				
			||||||
  output var logic [7:0]      PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
					  output var logic [7:0]   PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
				
			||||||
  output var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
					  output var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  input  logic [4:0]       SetFflagsM,
 | 
					 | 
				
			||||||
  output logic [2:0]       FRM_REGW, 
 | 
					  output logic [2:0]       FRM_REGW, 
 | 
				
			||||||
  output logic [`XLEN-1:0] CSRReadValW, UnalignedPCNextF,
 | 
					  //
 | 
				
			||||||
  output logic             IllegalCSRAccessM, BigEndianM
 | 
					  output logic [`XLEN-1:0] CSRReadValW,               // value read from CSR
 | 
				
			||||||
 | 
					  output logic [`XLEN-1:0] UnalignedPCNextF,          // Next PC, accounting for traps and returns
 | 
				
			||||||
 | 
					  output logic             IllegalCSRAccessM,         // Illegal CSR access: CSR doesn't exist or is inaccessible at this privilege level
 | 
				
			||||||
 | 
					  output logic             BigEndianM                 // memory access is big-endian based on privilege mode and STATUS register endian fields
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  localparam NOP = 32'h13;
 | 
					 | 
				
			||||||
  logic [`XLEN-1:0] CSRMReadValM, CSRSReadValM, CSRUReadValM, CSRCReadValM;
 | 
					  logic [`XLEN-1:0] CSRMReadValM, CSRSReadValM, CSRUReadValM, CSRCReadValM;
 | 
				
			||||||
(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRReadValM;  
 | 
					(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRReadValM;  
 | 
				
			||||||
(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRSrcM;
 | 
					(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRSrcM;
 | 
				
			||||||
  logic [`XLEN-1:0] CSRRWM, CSRRSM, CSRRCM;  
 | 
					  logic [`XLEN-1:0] CSRRWM, CSRRSM, CSRRCM;  
 | 
				
			||||||
(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRWriteValM;
 | 
					(* mark_debug = "true" *)  logic [`XLEN-1:0] CSRWriteValM;
 | 
				
			||||||
 
 | 
					 | 
				
			||||||
(* mark_debug = "true" *)  logic [`XLEN-1:0] MSTATUS_REGW, SSTATUS_REGW, MSTATUSH_REGW;
 | 
					(* mark_debug = "true" *)  logic [`XLEN-1:0] MSTATUS_REGW, SSTATUS_REGW, MSTATUSH_REGW;
 | 
				
			||||||
  logic [`XLEN-1:0] STVEC_REGW, MTVEC_REGW;
 | 
					  logic [`XLEN-1:0] STVEC_REGW, MTVEC_REGW;
 | 
				
			||||||
  logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW;
 | 
					  logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW;
 | 
				
			||||||
 | 
					  logic [31:0]      MCOUNTINHIBIT_REGW, MCOUNTEREN_REGW, SCOUNTEREN_REGW;
 | 
				
			||||||
  logic [31:0]     MCOUNTINHIBIT_REGW, MCOUNTEREN_REGW, SCOUNTEREN_REGW;
 | 
					  logic             WriteMSTATUSM, WriteMSTATUSHM, WriteSSTATUSM;
 | 
				
			||||||
  logic            WriteMSTATUSM, WriteMSTATUSHM, WriteSSTATUSM;
 | 
					  logic             CSRMWriteM, CSRSWriteM, CSRUWriteM;
 | 
				
			||||||
  logic            CSRMWriteM, CSRSWriteM, CSRUWriteM;
 | 
					  logic             WriteFRMM, WriteFFLAGSM;
 | 
				
			||||||
  logic            WriteFRMM, WriteFFLAGSM;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  logic [`XLEN-1:0] UnalignedNextEPCM, NextEPCM, NextCauseM, NextMtvalM;
 | 
					  logic [`XLEN-1:0] UnalignedNextEPCM, NextEPCM, NextCauseM, NextMtvalM;
 | 
				
			||||||
 | 
					  logic [11:0]      CSRAdrM;
 | 
				
			||||||
  logic [11:0] CSRAdrM;
 | 
					  logic             IllegalCSRCAccessM, IllegalCSRMAccessM, IllegalCSRSAccessM, IllegalCSRUAccessM;
 | 
				
			||||||
  logic        IllegalCSRCAccessM, IllegalCSRMAccessM, IllegalCSRSAccessM, IllegalCSRUAccessM, InsufficientCSRPrivilegeM;
 | 
					  logic             InsufficientCSRPrivilegeM;
 | 
				
			||||||
  logic IllegalCSRMWriteReadonlyM;
 | 
					  logic             IllegalCSRMWriteReadonlyM;
 | 
				
			||||||
  logic [`XLEN-1:0] CSRReadVal2M;
 | 
					  logic [`XLEN-1:0] CSRReadVal2M;
 | 
				
			||||||
  logic [11:0] MIP_REGW_writeable;
 | 
					  logic [11:0]      MIP_REGW_writeable;
 | 
				
			||||||
  logic [`XLEN-1:0] TVecM, TrapVectorM, NextFaultMtvalM;
 | 
					  logic [`XLEN-1:0] TVecM, TrapVectorM, NextFaultMtvalM;
 | 
				
			||||||
  logic MTrapM, STrapM;
 | 
					  logic             MTrapM, STrapM;
 | 
				
			||||||
 | 
					 | 
				
			||||||
  logic [`XLEN-1:0] EPC;
 | 
					  logic [`XLEN-1:0] EPC;
 | 
				
			||||||
  logic 			RetM;
 | 
					  logic 			      RetM;
 | 
				
			||||||
  logic       SelMtvecM;
 | 
					  logic             SelMtvecM;
 | 
				
			||||||
  logic [`XLEN-1:0] TVecAlignedM;
 | 
					  logic [`XLEN-1:0] TVecAlignedM;
 | 
				
			||||||
  
 | 
					  logic             InstrValidNotFlushedM;
 | 
				
			||||||
  logic InstrValidNotFlushedM;
 | 
					
 | 
				
			||||||
 | 
					  // only valid unflushed instructions can access CSRs
 | 
				
			||||||
  assign InstrValidNotFlushedM = InstrValidM & ~StallW & ~FlushW;
 | 
					  assign InstrValidNotFlushedM = InstrValidM & ~StallW & ~FlushW;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ///////////////////////////////////////////
 | 
					  ///////////////////////////////////////////
 | 
				
			||||||
  // MTVAL
 | 
					  // MTVAL: gets value from PC, Instruction, or load/store address
 | 
				
			||||||
  ///////////////////////////////////////////
 | 
					  ///////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  always_comb
 | 
					  always_comb
 | 
				
			||||||
    if (InterruptM) NextFaultMtvalM = 0;
 | 
					    if (InterruptM)           NextFaultMtvalM = 0;
 | 
				
			||||||
    else case (CauseM)
 | 
					    else case (CauseM)
 | 
				
			||||||
      12, 1, 3:               NextFaultMtvalM = PCM;  // Instruction page/access faults, breakpoint
 | 
					      12, 1, 3:               NextFaultMtvalM = PCM;  // Instruction page/access faults, breakpoint
 | 
				
			||||||
      2:                      NextFaultMtvalM = {{(`XLEN-32){1'b0}}, InstrM}; // Illegal instruction fault
 | 
					      2:                      NextFaultMtvalM = {{(`XLEN-32){1'b0}}, InstrM}; // Illegal instruction fault
 | 
				
			||||||
 | 
				
			|||||||
@ -39,27 +39,27 @@ module csrc #(parameter
 | 
				
			|||||||
  TIME  = 12'hC01,
 | 
					  TIME  = 12'hC01,
 | 
				
			||||||
  TIMEH = 12'hC81
 | 
					  TIMEH = 12'hC81
 | 
				
			||||||
) (
 | 
					) (
 | 
				
			||||||
    input logic 	     clk, reset,
 | 
					  input logic 	     clk, reset,
 | 
				
			||||||
    input logic 	     StallE, StallM, 
 | 
					  input logic 	     StallE, StallM, 
 | 
				
			||||||
    input logic        FlushM, 
 | 
					  input logic        FlushM, 
 | 
				
			||||||
    input logic 	     InstrValidNotFlushedM, LoadStallD, CSRMWriteM,
 | 
					  input logic 	     InstrValidNotFlushedM, LoadStallD, CSRMWriteM,
 | 
				
			||||||
    input logic 	     DirPredictionWrongM,
 | 
					  input logic 	     DirPredictionWrongM,
 | 
				
			||||||
    input logic 	     BTBPredPCWrongM,
 | 
					  input logic 	     BTBPredPCWrongM,
 | 
				
			||||||
    input logic 	     RASPredPCWrongM,
 | 
					  input logic 	     RASPredPCWrongM,
 | 
				
			||||||
    input logic 	     PredictionInstrClassWrongM,
 | 
					  input logic 	     PredictionInstrClassWrongM,
 | 
				
			||||||
    input logic [4:0] 	     InstrClassM,
 | 
					  input logic [4:0] 	     InstrClassM,
 | 
				
			||||||
    input logic 	     DCacheMiss,
 | 
					  input logic 	     DCacheMiss,
 | 
				
			||||||
    input logic 	     DCacheAccess,
 | 
					  input logic 	     DCacheAccess,
 | 
				
			||||||
    input logic 	     ICacheMiss,
 | 
					  input logic 	     ICacheMiss,
 | 
				
			||||||
    input logic 	     ICacheAccess,
 | 
					  input logic 	     ICacheAccess,
 | 
				
			||||||
    input logic [11:0] 	     CSRAdrM,
 | 
					  input logic [11:0] 	     CSRAdrM,
 | 
				
			||||||
    input logic [1:0] 	     PrivilegeModeW,
 | 
					  input logic [1:0] 	     PrivilegeModeW,
 | 
				
			||||||
    input logic [`XLEN-1:0]  CSRWriteValM,
 | 
					  input logic [`XLEN-1:0]  CSRWriteValM,
 | 
				
			||||||
    input logic [31:0] 	     MCOUNTINHIBIT_REGW, MCOUNTEREN_REGW, SCOUNTEREN_REGW,
 | 
					  input logic [31:0] 	     MCOUNTINHIBIT_REGW, MCOUNTEREN_REGW, SCOUNTEREN_REGW,
 | 
				
			||||||
    input logic [63:0] 	     MTIME_CLINT, 
 | 
					  input logic [63:0] 	     MTIME_CLINT, 
 | 
				
			||||||
    output logic [`XLEN-1:0] CSRCReadValM,
 | 
					  output logic [`XLEN-1:0] CSRCReadValM,
 | 
				
			||||||
    output logic 	     IllegalCSRCAccessM
 | 
					  output logic 	     IllegalCSRCAccessM
 | 
				
			||||||
  );
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (`ZICOUNTERS_SUPPORTED) begin:counters
 | 
					  if (`ZICOUNTERS_SUPPORTED) begin:counters
 | 
				
			||||||
    logic [4:0]  CounterNumM;
 | 
					    logic [4:0]  CounterNumM;
 | 
				
			||||||
 | 
				
			|||||||
@ -30,20 +30,20 @@
 | 
				
			|||||||
`include "wally-config.vh"
 | 
					`include "wally-config.vh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module csri #(parameter 
 | 
					module csri #(parameter 
 | 
				
			||||||
    MIE = 12'h304,
 | 
					  MIE = 12'h304,
 | 
				
			||||||
    MIP = 12'h344,
 | 
					  MIP = 12'h344,
 | 
				
			||||||
    SIE = 12'h104,
 | 
					  SIE = 12'h104,
 | 
				
			||||||
    SIP = 12'h144
 | 
					  SIP = 12'h144
 | 
				
			||||||
  ) (
 | 
					) (
 | 
				
			||||||
    input logic 			clk, reset, 
 | 
					  input logic 			clk, reset, 
 | 
				
			||||||
    input logic 			InstrValidNotFlushedM,
 | 
					  input logic 			InstrValidNotFlushedM,
 | 
				
			||||||
    input logic 			CSRMWriteM, CSRSWriteM,
 | 
					  input logic 			CSRMWriteM, CSRSWriteM,
 | 
				
			||||||
    input logic [`XLEN-1:0] CSRWriteValM,
 | 
					  input logic [`XLEN-1:0] CSRWriteValM,
 | 
				
			||||||
    input logic [11:0] 		CSRAdrM,
 | 
					  input logic [11:0] 		CSRAdrM,
 | 
				
			||||||
    (* mark_debug = "true" *)    input logic MExtInt, SExtInt, MTimerInt, MSwInt,
 | 
					  (* mark_debug = "true" *)    input logic MExtInt, SExtInt, MTimerInt, MSwInt,
 | 
				
			||||||
    output logic [11:0] 	MIP_REGW, MIE_REGW,
 | 
					  output logic [11:0] 	MIP_REGW, MIE_REGW,
 | 
				
			||||||
    (* mark_debug = "true" *) output logic [11:0]   MIP_REGW_writeable // only SEIP, STIP, SSIP are actually writeable; the rest are hardwired to 0
 | 
					  (* mark_debug = "true" *) output logic [11:0]   MIP_REGW_writeable // only SEIP, STIP, SSIP are actually writeable; the rest are hardwired to 0
 | 
				
			||||||
  );
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logic [11:0]     MIP_WRITE_MASK, SIP_WRITE_MASK, MIE_WRITE_MASK;
 | 
					  logic [11:0]     MIP_WRITE_MASK, SIP_WRITE_MASK, MIE_WRITE_MASK;
 | 
				
			||||||
  logic            WriteMIPM, WriteMIEM, WriteSIPM, WriteSIEM;
 | 
					  logic            WriteMIPM, WriteMIEM, WriteSIPM, WriteSIEM;
 | 
				
			||||||
 | 
				
			|||||||
@ -34,63 +34,63 @@
 | 
				
			|||||||
`include "wally-config.vh"
 | 
					`include "wally-config.vh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module csrm #(parameter 
 | 
					module csrm #(parameter 
 | 
				
			||||||
    // Machine CSRs
 | 
					  // Machine CSRs
 | 
				
			||||||
    MVENDORID = 12'hF11,
 | 
					  MVENDORID = 12'hF11,
 | 
				
			||||||
    MARCHID = 12'hF12,
 | 
					  MARCHID = 12'hF12,
 | 
				
			||||||
    MIMPID = 12'hF13,
 | 
					  MIMPID = 12'hF13,
 | 
				
			||||||
    MHARTID = 12'hF14,
 | 
					  MHARTID = 12'hF14,
 | 
				
			||||||
    MCONFIGPTR = 12'hF15,
 | 
					  MCONFIGPTR = 12'hF15,
 | 
				
			||||||
    MSTATUS = 12'h300,
 | 
					  MSTATUS = 12'h300,
 | 
				
			||||||
    MISA_ADR = 12'h301,
 | 
					  MISA_ADR = 12'h301,
 | 
				
			||||||
    MEDELEG = 12'h302,
 | 
					  MEDELEG = 12'h302,
 | 
				
			||||||
    MIDELEG = 12'h303,
 | 
					  MIDELEG = 12'h303,
 | 
				
			||||||
    MIE = 12'h304,
 | 
					  MIE = 12'h304,
 | 
				
			||||||
    MTVEC = 12'h305,
 | 
					  MTVEC = 12'h305,
 | 
				
			||||||
    MCOUNTEREN = 12'h306,
 | 
					  MCOUNTEREN = 12'h306,
 | 
				
			||||||
    MSTATUSH = 12'h310,
 | 
					  MSTATUSH = 12'h310,
 | 
				
			||||||
    MCOUNTINHIBIT = 12'h320,
 | 
					  MCOUNTINHIBIT = 12'h320,
 | 
				
			||||||
    MSCRATCH = 12'h340,
 | 
					  MSCRATCH = 12'h340,
 | 
				
			||||||
    MEPC = 12'h341,
 | 
					  MEPC = 12'h341,
 | 
				
			||||||
    MCAUSE = 12'h342,
 | 
					  MCAUSE = 12'h342,
 | 
				
			||||||
    MTVAL = 12'h343,
 | 
					  MTVAL = 12'h343,
 | 
				
			||||||
    MIP = 12'h344,
 | 
					  MIP = 12'h344,
 | 
				
			||||||
    MTINST = 12'h34A,
 | 
					  MTINST = 12'h34A,
 | 
				
			||||||
    PMPCFG0 = 12'h3A0,
 | 
					  PMPCFG0 = 12'h3A0,
 | 
				
			||||||
    // .. up to 15 more at consecutive addresses
 | 
					  // .. up to 15 more at consecutive addresses
 | 
				
			||||||
    PMPADDR0 = 12'h3B0,
 | 
					  PMPADDR0 = 12'h3B0,
 | 
				
			||||||
    // ... up to 63 more at consecutive addresses
 | 
					  // ... up to 63 more at consecutive addresses
 | 
				
			||||||
    TSELECT = 12'h7A0,
 | 
					  TSELECT = 12'h7A0,
 | 
				
			||||||
    TDATA1 = 12'h7A1,
 | 
					  TDATA1 = 12'h7A1,
 | 
				
			||||||
    TDATA2 = 12'h7A2,
 | 
					  TDATA2 = 12'h7A2,
 | 
				
			||||||
    TDATA3 = 12'h7A3,
 | 
					  TDATA3 = 12'h7A3,
 | 
				
			||||||
    DCSR = 12'h7B0,
 | 
					  DCSR = 12'h7B0,
 | 
				
			||||||
    DPC = 12'h7B1,
 | 
					  DPC = 12'h7B1,
 | 
				
			||||||
    DSCRATCH0 = 12'h7B2,
 | 
					  DSCRATCH0 = 12'h7B2,
 | 
				
			||||||
    DSCRATCH1 = 12'h7B3,
 | 
					  DSCRATCH1 = 12'h7B3,
 | 
				
			||||||
    // Constants
 | 
					  // Constants
 | 
				
			||||||
    ZERO = {(`XLEN){1'b0}},
 | 
					  ZERO = {(`XLEN){1'b0}},
 | 
				
			||||||
    MEDELEG_MASK = ~(ZERO | `XLEN'b1 << 11),
 | 
					  MEDELEG_MASK = ~(ZERO | `XLEN'b1 << 11),
 | 
				
			||||||
    MIDELEG_MASK = 12'h222 // we choose to not make machine interrupts delegable
 | 
					  MIDELEG_MASK = 12'h222 // we choose to not make machine interrupts delegable
 | 
				
			||||||
  ) (
 | 
					) (
 | 
				
			||||||
    input logic 	     clk, reset, 
 | 
					  input logic 	     clk, reset, 
 | 
				
			||||||
    input logic 	     InstrValidNotFlushedM, 
 | 
					  input logic 	     InstrValidNotFlushedM, 
 | 
				
			||||||
    input logic 	     CSRMWriteM, MTrapM,
 | 
					  input logic 	     CSRMWriteM, MTrapM,
 | 
				
			||||||
    input logic [11:0] 	     CSRAdrM,
 | 
					  input logic [11:0] 	     CSRAdrM,
 | 
				
			||||||
    input logic [`XLEN-1:0]  NextEPCM, NextCauseM, NextMtvalM, MSTATUS_REGW, MSTATUSH_REGW,
 | 
					  input logic [`XLEN-1:0]  NextEPCM, NextCauseM, NextMtvalM, MSTATUS_REGW, MSTATUSH_REGW,
 | 
				
			||||||
    input logic [`XLEN-1:0]  CSRWriteValM,
 | 
					  input logic [`XLEN-1:0]  CSRWriteValM,
 | 
				
			||||||
    output logic [`XLEN-1:0] CSRMReadValM, MTVEC_REGW,
 | 
					  output logic [`XLEN-1:0] CSRMReadValM, MTVEC_REGW,
 | 
				
			||||||
    (* mark_debug = "true" *)  output logic [`XLEN-1:0] MEPC_REGW,    
 | 
					  (* mark_debug = "true" *)  output logic [`XLEN-1:0] MEPC_REGW,    
 | 
				
			||||||
    output logic [31:0]      MCOUNTEREN_REGW, MCOUNTINHIBIT_REGW, 
 | 
					  output logic [31:0]      MCOUNTEREN_REGW, MCOUNTINHIBIT_REGW, 
 | 
				
			||||||
(* mark_debug = "true" *)      output logic [`XLEN-1:0] MEDELEG_REGW,
 | 
					(* mark_debug = "true" *)      output logic [`XLEN-1:0] MEDELEG_REGW,
 | 
				
			||||||
(* mark_debug = "true" *)      output logic [11:0]      MIDELEG_REGW,
 | 
					(* mark_debug = "true" *)      output logic [11:0]      MIDELEG_REGW,
 | 
				
			||||||
    // 64-bit registers in RV64, or two 32-bit registers in RV32
 | 
					  // 64-bit registers in RV64, or two 32-bit registers in RV32
 | 
				
			||||||
    //output var logic [63:0]      PMPCFG_ARRAY_REGW[`PMP_ENTRIES/8-1:0],
 | 
					  //output var logic [63:0]      PMPCFG_ARRAY_REGW[`PMP_ENTRIES/8-1:0],
 | 
				
			||||||
    output 		     var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
					  output 		     var logic [7:0] PMPCFG_ARRAY_REGW[`PMP_ENTRIES-1:0],
 | 
				
			||||||
    output 		     var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW [`PMP_ENTRIES-1:0],
 | 
					  output 		     var logic [`XLEN-1:0] PMPADDR_ARRAY_REGW [`PMP_ENTRIES-1:0],
 | 
				
			||||||
    (* mark_debug = "true" *)  input logic [11:0] 	     MIP_REGW, MIE_REGW,
 | 
					  (* mark_debug = "true" *)  input logic [11:0] 	     MIP_REGW, MIE_REGW,
 | 
				
			||||||
    output logic 	     WriteMSTATUSM, WriteMSTATUSHM,
 | 
					  output logic 	     WriteMSTATUSM, WriteMSTATUSHM,
 | 
				
			||||||
    output logic 	     IllegalCSRMAccessM, IllegalCSRMWriteReadonlyM
 | 
					  output logic 	     IllegalCSRMAccessM, IllegalCSRMWriteReadonlyM
 | 
				
			||||||
  );
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logic [`XLEN-1:0] MISA_REGW, MHARTID_REGW;
 | 
					  logic [`XLEN-1:0] MISA_REGW, MHARTID_REGW;
 | 
				
			||||||
(* mark_debug = "true" *)  logic [`XLEN-1:0] MSCRATCH_REGW;
 | 
					(* mark_debug = "true" *)  logic [`XLEN-1:0] MSCRATCH_REGW;
 | 
				
			||||||
 | 
				
			|||||||
@ -45,7 +45,6 @@ module csrs #(parameter
 | 
				
			|||||||
    // Constants
 | 
					    // Constants
 | 
				
			||||||
   ZERO = {(`XLEN){1'b0}},
 | 
					   ZERO = {(`XLEN){1'b0}},
 | 
				
			||||||
   SEDELEG_MASK = ~(ZERO | `XLEN'b111 << 9)
 | 
					   SEDELEG_MASK = ~(ZERO | `XLEN'b111 << 9)
 | 
				
			||||||
 | 
					 | 
				
			||||||
  ) (
 | 
					  ) (
 | 
				
			||||||
    input logic 	     clk, reset, 
 | 
					    input logic 	     clk, reset, 
 | 
				
			||||||
    input logic 	     InstrValidNotFlushedM, 
 | 
					    input logic 	     InstrValidNotFlushedM, 
 | 
				
			||||||
@ -62,7 +61,7 @@ module csrs #(parameter
 | 
				
			|||||||
    (* mark_debug = "true" *) input logic [11:0] MIP_REGW, MIE_REGW, MIDELEG_REGW,
 | 
					    (* mark_debug = "true" *) input logic [11:0] MIP_REGW, MIE_REGW, MIDELEG_REGW,
 | 
				
			||||||
    output logic 	     WriteSSTATUSM,
 | 
					    output logic 	     WriteSSTATUSM,
 | 
				
			||||||
    output logic 	     IllegalCSRSAccessM
 | 
					    output logic 	     IllegalCSRSAccessM
 | 
				
			||||||
  );
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Supervisor mode CSRs sometimes supported
 | 
					  // Supervisor mode CSRs sometimes supported
 | 
				
			||||||
@ -70,7 +69,7 @@ module csrs #(parameter
 | 
				
			|||||||
    logic WriteSTVECM;
 | 
					    logic WriteSTVECM;
 | 
				
			||||||
    logic WriteSSCRATCHM, WriteSEPCM;
 | 
					    logic WriteSSCRATCHM, WriteSEPCM;
 | 
				
			||||||
    logic WriteSCAUSEM, WriteSTVALM, WriteSATPM, WriteSCOUNTERENM;
 | 
					    logic WriteSCAUSEM, WriteSTVALM, WriteSATPM, WriteSCOUNTERENM;
 | 
				
			||||||
(* mark_debug = "true" *)    logic [`XLEN-1:0] SSCRATCH_REGW, STVAL_REGW;
 | 
					    (* mark_debug = "true" *)    logic [`XLEN-1:0] SSCRATCH_REGW, STVAL_REGW;
 | 
				
			||||||
    (* mark_debug = "true" *) logic [`XLEN-1:0] SCAUSE_REGW;      
 | 
					    (* mark_debug = "true" *) logic [`XLEN-1:0] SCAUSE_REGW;      
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    assign WriteSSTATUSM = CSRSWriteM & (CSRAdrM == SSTATUS)  & InstrValidNotFlushedM;
 | 
					    assign WriteSSTATUSM = CSRSWriteM & (CSRAdrM == SSTATUS)  & InstrValidNotFlushedM;
 | 
				
			||||||
 | 
				
			|||||||
@ -43,7 +43,7 @@ module csru #(parameter
 | 
				
			|||||||
    output logic [2:0]       FRM_REGW,
 | 
					    output logic [2:0]       FRM_REGW,
 | 
				
			||||||
    output logic             WriteFRMM, WriteFFLAGSM,
 | 
					    output logic             WriteFRMM, WriteFFLAGSM,
 | 
				
			||||||
    output logic             IllegalCSRUAccessM
 | 
					    output logic             IllegalCSRUAccessM
 | 
				
			||||||
  );
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Floating Point CSRs in User Mode only needed if Floating Point is supported
 | 
					  // Floating Point CSRs in User Mode only needed if Floating Point is supported
 | 
				
			||||||
  if (`F_SUPPORTED | `D_SUPPORTED) begin:csru
 | 
					  if (`F_SUPPORTED | `D_SUPPORTED) begin:csru
 | 
				
			||||||
 | 
				
			|||||||
@ -32,13 +32,18 @@
 | 
				
			|||||||
module privdec (
 | 
					module privdec (
 | 
				
			||||||
  input  logic         clk, reset,
 | 
					  input  logic         clk, reset,
 | 
				
			||||||
  input  logic         StallM,
 | 
					  input  logic         StallM,
 | 
				
			||||||
  input  logic [31:20] InstrM,
 | 
					  input  logic [31:20] InstrM,                              // privileged instruction function field
 | 
				
			||||||
  input  logic         PrivilegedM, IllegalIEUInstrFaultM, IllegalCSRAccessM, IllegalFPUInstrM, 
 | 
					  input  logic         PrivilegedM,                         // is this a privileged instruction (from IEU controller)
 | 
				
			||||||
  input  logic [1:0]   PrivilegeModeW, 
 | 
					  input  logic         IllegalIEUInstrFaultM,               // Not a legal IEU instruction
 | 
				
			||||||
  input  logic         STATUS_TSR, STATUS_TVM, STATUS_TW,
 | 
					  input  logic         IllegalFPUInstrM,                    // Not a legal FPU instruction
 | 
				
			||||||
  output logic         IllegalInstrFaultM,
 | 
					  input  logic         IllegalCSRAccessM,                   // Not a legal CSR access
 | 
				
			||||||
  output logic         EcallFaultM, BreakpointFaultM,
 | 
					  input  logic [1:0]   PrivilegeModeW,                      // current privilege level
 | 
				
			||||||
  output logic         sretM, mretM, wfiM, sfencevmaM);
 | 
					  input  logic         STATUS_TSR, STATUS_TVM, STATUS_TW,   // status bits
 | 
				
			||||||
 | 
					  output logic         IllegalInstrFaultM,                  // Illegal instruction
 | 
				
			||||||
 | 
					  output logic         EcallFaultM, BreakpointFaultM,       // Ecall or breakpoint; must retire, so don't flush it when the trap occurs
 | 
				
			||||||
 | 
					  output logic         sretM, mretM, 
 | 
				
			||||||
 | 
					  output logic         wfiM, sfencevmaM
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logic IllegalPrivilegedInstrM;
 | 
					  logic IllegalPrivilegedInstrM;
 | 
				
			||||||
  logic WFITimeoutM;
 | 
					  logic WFITimeoutM;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user