forked from Github_Repos/cvw
mcause test fixes and s-mode interrupt bugfix
This commit is contained in:
parent
3b9ecc8275
commit
7b98e7aa2f
@ -55,7 +55,7 @@ module csr #(parameter
|
|||||||
output logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW, UEPC_REGW, UTVEC_REGW, STVEC_REGW, MTVEC_REGW,
|
output logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW, UEPC_REGW, UTVEC_REGW, STVEC_REGW, MTVEC_REGW,
|
||||||
output logic [`XLEN-1:0] MEDELEG_REGW, MIDELEG_REGW, SEDELEG_REGW, SIDELEG_REGW,
|
output logic [`XLEN-1:0] MEDELEG_REGW, MIDELEG_REGW, SEDELEG_REGW, SIDELEG_REGW,
|
||||||
output logic [`XLEN-1:0] SATP_REGW,
|
output logic [`XLEN-1:0] SATP_REGW,
|
||||||
output logic [11:0] MIP_REGW, MIE_REGW,
|
output logic [11:0] MIP_REGW, MIE_REGW, SIP_REGW, SIE_REGW,
|
||||||
output logic STATUS_MIE, STATUS_SIE,
|
output logic STATUS_MIE, STATUS_SIE,
|
||||||
output logic STATUS_MXR, STATUS_SUM,
|
output logic STATUS_MXR, STATUS_SUM,
|
||||||
output logic STATUS_MPRV,
|
output logic STATUS_MPRV,
|
||||||
@ -80,7 +80,6 @@ module csr #(parameter
|
|||||||
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 [11:0] SIP_REGW, SIE_REGW;
|
|
||||||
//logic [11:0] UIP_REGW, UIE_REGW = 0; // N user-mode exceptions not supported
|
//logic [11:0] UIP_REGW, UIE_REGW = 0; // N user-mode exceptions not supported
|
||||||
logic IllegalCSRCAccessM, IllegalCSRMAccessM, IllegalCSRSAccessM, IllegalCSRUAccessM, IllegalCSRNAccessM, InsufficientCSRPrivilegeM;
|
logic IllegalCSRCAccessM, IllegalCSRMAccessM, IllegalCSRSAccessM, IllegalCSRUAccessM, IllegalCSRNAccessM, InsufficientCSRPrivilegeM;
|
||||||
logic IllegalCSRMWriteReadonlyM;
|
logic IllegalCSRMWriteReadonlyM;
|
||||||
|
@ -96,7 +96,7 @@ module privileged (
|
|||||||
logic [1:0] STATUS_MPP;
|
logic [1:0] STATUS_MPP;
|
||||||
logic STATUS_SPP, STATUS_TSR, STATUS_MPRV; // **** status mprv is unused outside of the csr module as of 4 June 2021. should it be deleted alltogether from the module, or should I leav the pin here in case someone needs it?
|
logic STATUS_SPP, STATUS_TSR, STATUS_MPRV; // **** status mprv is unused outside of the csr module as of 4 June 2021. should it be deleted alltogether from the module, or should I leav the pin here in case someone needs it?
|
||||||
logic STATUS_MIE, STATUS_SIE;
|
logic STATUS_MIE, STATUS_SIE;
|
||||||
logic [11:0] MIP_REGW, MIE_REGW;
|
logic [11:0] MIP_REGW, MIE_REGW, SIP_REGW, SIE_REGW;
|
||||||
logic md, sd;
|
logic md, sd;
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ module trap (
|
|||||||
input logic mretM, sretM, uretM,
|
input logic mretM, sretM, uretM,
|
||||||
input logic [1:0] PrivilegeModeW, NextPrivilegeModeM,
|
input logic [1:0] PrivilegeModeW, NextPrivilegeModeM,
|
||||||
input logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW, UEPC_REGW, UTVEC_REGW, STVEC_REGW, MTVEC_REGW,
|
input logic [`XLEN-1:0] MEPC_REGW, SEPC_REGW, UEPC_REGW, UTVEC_REGW, STVEC_REGW, MTVEC_REGW,
|
||||||
input logic [11:0] MIP_REGW, MIE_REGW,
|
input logic [11:0] MIP_REGW, MIE_REGW, SIP_REGW, SIE_REGW,
|
||||||
input logic STATUS_MIE, STATUS_SIE,
|
input logic STATUS_MIE, STATUS_SIE,
|
||||||
input logic [`XLEN-1:0] PCM,
|
input logic [`XLEN-1:0] PCM,
|
||||||
input logic [`XLEN-1:0] InstrMisalignedAdrM, MemAdrM,
|
input logic [`XLEN-1:0] InstrMisalignedAdrM, MemAdrM,
|
||||||
@ -58,7 +58,7 @@ module trap (
|
|||||||
// Determine pending enabled interrupts
|
// Determine pending enabled interrupts
|
||||||
assign MIntGlobalEnM = (PrivilegeModeW != `M_MODE) || STATUS_MIE; // if M ints enabled or lower priv 3.1.9
|
assign MIntGlobalEnM = (PrivilegeModeW != `M_MODE) || STATUS_MIE; // if M ints enabled or lower priv 3.1.9
|
||||||
assign SIntGlobalEnM = (PrivilegeModeW == `U_MODE) || STATUS_SIE; // if S ints enabled or lower priv 3.1.9
|
assign SIntGlobalEnM = (PrivilegeModeW == `U_MODE) || STATUS_SIE; // if S ints enabled or lower priv 3.1.9
|
||||||
assign PendingIntsM = (MIP_REGW & MIE_REGW) & ({12{MIntGlobalEnM}} & 12'h888) | ({12{SIntGlobalEnM}} & 12'h222);
|
assign PendingIntsM = ((MIP_REGW & MIE_REGW) & ({12{MIntGlobalEnM}} & 12'h888)) | ((SIP_REGW & SIE_REGW) & ({12{SIntGlobalEnM}} & 12'h222));
|
||||||
assign InterruptM = (|PendingIntsM) & InstrValidM & ~CommittedM;
|
assign InterruptM = (|PendingIntsM) & InstrValidM & ~CommittedM;
|
||||||
// interrupt if any sources are pending
|
// interrupt if any sources are pending
|
||||||
// & with a M stage valid bit to avoid interrupts from interrupt a nonexistent flushed instruction (in the M stage)
|
// & with a M stage valid bit to avoid interrupts from interrupt a nonexistent flushed instruction (in the M stage)
|
||||||
|
@ -27,22 +27,22 @@
|
|||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module clint (
|
module clint (
|
||||||
input logic HCLK, HRESETn,
|
input logic HCLK, HRESETn,
|
||||||
input logic HSELCLINT,
|
input logic HSELCLINT,
|
||||||
input logic [15:0] HADDR,
|
input logic [15:0] HADDR,
|
||||||
input logic HWRITE,
|
input logic HWRITE,
|
||||||
input logic [`XLEN-1:0] HWDATA,
|
input logic [`XLEN-1:0] HWDATA,
|
||||||
output logic [`XLEN-1:0] HREADCLINT,
|
|
||||||
output logic HRESPCLINT, HREADYCLINT,
|
|
||||||
input logic HREADY,
|
input logic HREADY,
|
||||||
input logic [1:0] HTRANS,
|
input logic [1:0] HTRANS,
|
||||||
output logic TimerIntM, SwIntM);
|
output logic [`XLEN-1:0] HREADCLINT,
|
||||||
|
output logic HRESPCLINT, HREADYCLINT,
|
||||||
|
output logic TimerIntM, SwIntM);
|
||||||
|
|
||||||
logic [63:0] MTIMECMP, MTIME;
|
logic [63:0] MTIMECMP, MTIME;
|
||||||
logic MSIP;
|
logic MSIP;
|
||||||
|
|
||||||
logic [15:0] entry, entryd;
|
logic [15:0] entry, entryd;
|
||||||
logic memread, memwrite;
|
logic memread, memwrite;
|
||||||
logic initTrans;
|
logic initTrans;
|
||||||
|
|
||||||
assign initTrans = HREADY & HSELCLINT & (HTRANS != 2'b00);
|
assign initTrans = HREADY & HSELCLINT & (HTRANS != 2'b00);
|
||||||
|
@ -53,7 +53,7 @@ def writeVectors(storecmd, returningInstruction):
|
|||||||
csrrs x0, {fromMode}status, x1
|
csrrs x0, {fromMode}status, x1
|
||||||
|
|
||||||
la x18, {clintAddr}
|
la x18, {clintAddr}
|
||||||
lw x11, 0(x18)
|
{loadcmd} x11, 0(x18)
|
||||||
li x1, 0x3fffffffffffffff
|
li x1, 0x3fffffffffffffff
|
||||||
{storecmd} x1, 0(x18)
|
{storecmd} x1, 0(x18)
|
||||||
|
|
||||||
@ -310,9 +310,11 @@ for xlen in xlens:
|
|||||||
formatrefstr = "{:08x}" # format as xlen-bit hexadecimal number with no leading 0x
|
formatrefstr = "{:08x}" # format as xlen-bit hexadecimal number with no leading 0x
|
||||||
if (xlen == 32):
|
if (xlen == 32):
|
||||||
storecmd = "sw"
|
storecmd = "sw"
|
||||||
|
loadcmd = "lw"
|
||||||
wordsize = 4
|
wordsize = 4
|
||||||
else:
|
else:
|
||||||
storecmd = "sd"
|
storecmd = "sd"
|
||||||
|
loadcmd = "ld"
|
||||||
wordsize = 8
|
wordsize = 8
|
||||||
|
|
||||||
# testMode can be m, s, and u. User mode traps are deprecated, so this should likely just be ["m", "s"]
|
# testMode can be m, s, and u. User mode traps are deprecated, so this should likely just be ["m", "s"]
|
||||||
|
Loading…
Reference in New Issue
Block a user