Skip to content

Commit

Permalink
Add Zicfiss and Zicfilp CSR definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
emanueleparisi committed Apr 17, 2024
1 parent ed868dc commit d74f5af
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions core/include/riscv_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ package riscv;

typedef struct packed {
logic sd; // signal dirty state - read-only
logic [62:34] wpri6; // writes preserved reads ignored
logic [62:34] wpri7; // writes preserved reads ignored
xlen_e uxl; // variable user mode xlen - hardwired to zero
logic [11:0] wpri5; // writes preserved reads ignored
logic [7:0] wpri6; // writes preserved reads ignored
logic spelp; // hold previous ELP in S-mode
logic [2:0] wpri5; // writes preserved reads ignored
logic mxr; // make executable readable
logic sum; // permit supervisor user memory access
logic wpri4; // writes preserved reads ignored
Expand Down Expand Up @@ -123,14 +125,17 @@ package riscv;

typedef struct packed {
logic sd; // signal dirty state - read-only
logic [62:40] wpri4; // writes preserved reads ignored
logic [62:42] wpri5; // writes preserved reads ignored
logic mpelp; // hold previous ELP in M-mode
logic wpri4; // writes preserved reads ignored
logic mpv; // machine previous virtualization mode
logic gva; // variable set when trap writes to stval
logic mbe; // endianness memory accesses made from M-mode
logic sbe; // endianness memory accesses made from S-mode
xlen_e sxl; // variable supervisor mode xlen - hardwired to zero
xlen_e uxl; // variable user mode xlen - hardwired to zero
logic [8:0] wpri3; // writes preserved reads ignored
logic [7:0] wpri3; // writes preserved reads ignored
logic spelp; // hold previous ELP in S-mode
logic tsr; // trap sret
logic tw; // time wait
logic tvm; // trap virtual memory
Expand All @@ -152,14 +157,27 @@ package riscv;
logic wpri0; // writes preserved reads ignored
} mstatus_rv_t;

typedef struct packed {
logic [63:11] wpri1; // writes preserved reads ignored
logic mlpe; // enable Zicfilp in M-mode
logic sseed; // not implemented - requires Zkr extension
logic useed; // not implemented - requires Zkr extension
logic [7:3] wpri0; // writes preserved reads ignored
logic rlb; // not implemented - requires Smepmp extension
logic mmwp; // not implemented - requires Smepmp extension
logic mml; // not implemented - requires Smepmp extension
} mseccfg_t;

typedef struct packed {
logic stce; // not implemented - requires Sctc extension
logic pbmte; // not implemented - requires Svpbmt extension
logic [61:8] wpri1; // writes preserved reads ignored
logic cbze; // not implemented - requires Zicboz extension
logic cbcfe; // not implemented - requires Zicbom extension
logic [1:0] cbie; // not implemented - requires Zicbom extension
logic [2:0] wpri0; // writes preserved reads ignored
logic sse; // enable Zicfiss in less priviledged modes
logic lpe; // enable Zicfilp in less priviledged modes
logic wpri0; // writes preserved reads ignored
logic fiom; // fence of I/O implies memory
} envcfg_rv_t;

Expand Down Expand Up @@ -581,6 +599,8 @@ package riscv;
CSR_MCYCLEH = 12'hB80,
CSR_MINSTRET = 12'hB02,
CSR_MINSTRETH = 12'hB82,
CSR_MSECCFG = 12'h747,
CSR_MSECCFGH = 12'h757,
//Performance Counters
CSR_MHPM_COUNTER_3 = 12'hB03,
CSR_MHPM_COUNTER_4 = 12'hB04,
Expand Down Expand Up @@ -658,6 +678,8 @@ package riscv;
CSR_DPC = 12'h7b1,
CSR_DSCRATCH0 = 12'h7b2, // optional
CSR_DSCRATCH1 = 12'h7b3, // optional
// Control-Flow Integrity - Zicfiss
CSR_SSP = 12'h011,
// Counters and Timers (User Mode - R/O Shadows)
CSR_CYCLE = 12'hC00,
CSR_CYCLEH = 12'hC80,
Expand Down Expand Up @@ -736,6 +758,7 @@ package riscv;
localparam logic [63:0] SSTATUS_XS = 'h00018000;
localparam logic [63:0] SSTATUS_SUM = 'h00040000;
localparam logic [63:0] SSTATUS_MXR = 'h00080000;
localparam logic [63:0] SSTATUS_SPELP = 'h00800000;
localparam logic [63:0] SSTATUS_UPIE = 'h00000010;
localparam logic [63:0] SSTATUS_UXL = 64'h0000000300000000;
localparam logic [63:0] SSTATUS_SD = {IS_XLEN64, 31'h00000000, ~IS_XLEN64, 31'h00000000};
Expand Down Expand Up @@ -767,14 +790,18 @@ package riscv;
localparam logic [63:0] MSTATUS_MPRV = 'h00020000;
localparam logic [63:0] MSTATUS_SUM = 'h00040000;
localparam logic [63:0] MSTATUS_MXR = 'h00080000;
localparam logic [63:0] MSTATUS_SPELP = 'h00800000;
localparam logic [63:0] MSTATUS_TVM = 'h00100000;
localparam logic [63:0] MSTATUS_TW = 'h00200000;
localparam logic [63:0] MSTATUS_TSR = 'h00400000;
localparam logic [63:0] MSTATUS_UXL = {30'h0000000, IS_XLEN64, IS_XLEN64, 32'h00000000};
localparam logic [63:0] MSTATUS_SXL = {28'h0000000, IS_XLEN64, IS_XLEN64, 34'h00000000};
localparam logic [63:0] MSTATUS_MPELP = 'h0000020000000000;
localparam logic [63:0] MSTATUS_SD = {IS_XLEN64, 31'h00000000, ~IS_XLEN64, 31'h00000000};

localparam logic [63:0] MENVCFG_FIOM = 'h00000001;
localparam logic [63:0] MENVCFG_LPE = 'h00000004;
localparam logic [63:0] MENVCFG_SSE = 'h00000008;
localparam logic [63:0] MENVCFG_CBIE = 'h00000030;
localparam logic [63:0] MENVCFG_CBFE = 'h00000040;
localparam logic [63:0] MENVCFG_CBZE = 'h00000080;
Expand Down Expand Up @@ -847,7 +874,8 @@ package riscv;
// -----
typedef struct packed {
logic [31:28] xdebugver;
logic [27:18] zero2;
logic [27:19] zero2;
logic pelp;
logic ebreakvs;
logic ebreakvu;
logic ebreakm;
Expand Down

0 comments on commit d74f5af

Please sign in to comment.