Merge branch 'openhwgroup:main' into feature/smrnmi

This commit is contained in:
szbieg 2023-10-16 09:33:29 +02:00 committed by GitHub
commit 148acc5c20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 21 deletions

View file

@ -545,7 +545,7 @@ Machine Vendor ID (mvendorid)
CSR Address: ``0xF11``
Reset Value: ``0x0000_0000``
Reset Value: ``CSR_MVENDORID_VALUE``
Use the ``CSR_MVENDORID_VALUE`` parameter in :file:`rtl/cve2_pkg.sv` to change the fixed value.
Details of what the ID represents can be found in the RISC-V Privileged Specification.
@ -555,10 +555,10 @@ Machine Architecture ID (marchid)
CSR Address: ``0xF12``
Reset Value: ``0x0000_0016``
Reset Value: ``CSR_MARCHID_VALUE``
Use the ``CSR_MARCHID_VALUE`` parameter in :file:`rtl/cve2_pkg.sv` to change the fixed value.
The value used is allocated specifically to Ibex.
The value used is allocated specifically to cve2. See https://github.com/riscv/riscv-isa-manual/blob/master/marchid.md.
If significant changes are made a different ID should be used.
Details of what the ID represents can be found in the RISC-V Privileged Specification.

View file

@ -142,7 +142,7 @@ module cve2_controller #(
logic enter_debug_mode;
logic ebreak_into_debug;
logic handle_irq;
logic irq_enabled;
logic [3:0] mfip_id;
logic unused_irq_timer;
@ -295,12 +295,15 @@ module cve2_controller #(
priv_mode_i == PRIV_LVL_U ? debug_ebreaku_i :
1'b0;
// MIE bit only applies when in M mode
assign irq_enabled = csr_mstatus_mie_i | (priv_mode_i == PRIV_LVL_U);
// Interrupts including NMI are ignored,
// - while in debug mode [Debug Spec v0.13.2, p.39],
// - while in NMI mode (nested NMIs are not supported, NMI has highest priority and
// cannot be interrupted by regular interrupts).
// - while single stepping.
assign handle_irq = ~debug_mode_q & ~debug_single_step_i & ~nmi_mode_q &
assign handle_irq = ~debug_mode_q & ~nmi_mode_q &
(irq_nm_i | (irq_pending_i & csr_mstatus_mie_i));
// generate ID of fast interrupts, highest priority to lowest ID
@ -537,11 +540,11 @@ module cve2_controller #(
csr_save_cause_o = 1'b1;
if (trigger_match_i) begin
debug_cause_o = DBG_CAUSE_TRIGGER;
end else if (debug_single_step_i) begin
debug_cause_o = DBG_CAUSE_STEP;
debug_cause_o = DBG_CAUSE_TRIGGER; // (priority 4)
end else if (debug_req_i) begin
debug_cause_o = DBG_CAUSE_HALTREQ; // (priority 1)
end else begin
debug_cause_o = DBG_CAUSE_HALTREQ;
debug_cause_o = DBG_CAUSE_STEP; // (priority 0, lowest)
end
// enter debug mode
@ -691,9 +694,14 @@ module cve2_controller #(
// Leave all other signals as is to ensure CSRs and PC get set as if
// core was entering exception handler, entry to debug mode will then
// see the appropriate state and setup dpc correctly.
// If an EBREAK instruction is causing us to enter debug mode on the
// same cycle as a debug_req or single step, honor the EBREAK and
// proceed to DBG_TAKEN_ID.
// proceed to DBG_TAKEN_ID, as it has the highest priority.
// [Debug Spec v1.0.0-STABLE, p.53]
// cause==EBREAK -> prio 3 (highest)
// cause==debug_req -> prio 2
// cause==step -> prio 1 (lowest)
if (enter_debug_mode_prio_q && !(ebrk_insn_prio && ebreak_into_debug)) begin
ctrl_fsm_ns = DBG_TAKEN_IF;
end

View file

@ -486,6 +486,16 @@ module cve2_cs_registers #(
illegal_csr = 1'b1;
end
endcase
if (!PMPEnable) begin
if (csr_addr inside {CSR_PMPCFG0, CSR_PMPCFG1, CSR_PMPCFG2, CSR_PMPCFG3,
CSR_PMPADDR0, CSR_PMPADDR1, CSR_PMPADDR2, CSR_PMPADDR3,
CSR_PMPADDR4, CSR_PMPADDR5, CSR_PMPADDR6, CSR_PMPADDR7,
CSR_PMPADDR8, CSR_PMPADDR9, CSR_PMPADDR10, CSR_PMPADDR11,
CSR_PMPADDR12, CSR_PMPADDR13, CSR_PMPADDR14, CSR_PMPADDR15}) begin
illegal_csr = 1'b1;
end
end
end
// write logic

View file

@ -566,25 +566,24 @@ package cve2_pkg;
parameter int unsigned CSR_MSECCFG_MMWP_BIT = 1;
parameter int unsigned CSR_MSECCFG_RLB_BIT = 2;
// Vendor ID
// No JEDEC ID has been allocated to lowRISC so the value is 0 to indicate the field is not
// implemented
localparam logic [31:0] CSR_MVENDORID_VALUE = 32'b0;
// Machine Vendor ID - OpenHW JEDEC ID is '2 decimal (bank 13)'
parameter MVENDORID_OFFSET = 7'h2; // Final byte without parity bit
parameter MVENDORID_BANK = 25'hC; // Number of continuation codes
// Architecture ID
// Top bit is unset to indicate an open source project. The lower bits are an ID allocated by the
// RISC-V Foundation. Note this is allocated specifically to Ibex, should significant changes be
// made a different architecture ID should be supplied.
localparam logic [31:0] CSR_MARCHID_VALUE = {1'b0, 31'd22};
// Machine Architecture ID (https://github.com/riscv/riscv-isa-manual/blob/master/marchid.md)
parameter MARCHID = 32'd35;
localparam logic [31:0] CSR_MVENDORID_VALUE = {MVENDORID_BANK, MVENDORID_OFFSET};
localparam logic [31:0] CSR_MARCHID_VALUE = MARCHID;
// Implementation ID
// 0 indicates this field is not implemeted. Ibex implementors may wish to indicate an RTL/netlist
// 0 indicates this field is not implemeted. cve2 implementors may wish to indicate an RTL/netlist
// version here using their own unique encoding (e.g. 32 bits of the git hash of the implemented
// commit).
localparam logic [31:0] CSR_MIMPID_VALUE = 32'b0;
// Machine Configuration Pointer
// 0 indicates the configuration data structure does not eixst. Ibex implementors may wish to
// 0 indicates the configuration data structure does not eixst. cve2 implementors may wish to
// alter this to point to their system specific configuration data structure.
localparam logic [31:0] CSR_MCONFIGPTR_VALUE = 32'b0;