From d5e826107a72b13424976b2805ef93475606f39f Mon Sep 17 00:00:00 2001 From: Yvan Tortorella Date: Sat, 30 Sep 2023 11:11:56 +0200 Subject: [PATCH] Connected rapid recovery signals to core. --- packages/pulp_cluster_package.sv | 2 -- rtl/core_region.sv | 56 +++++++++++++++++++++++++++++--- rtl/pulp_cluster.sv | 17 +++------- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/packages/pulp_cluster_package.sv b/packages/pulp_cluster_package.sv index 7bee53a5..88207829 100644 --- a/packages/pulp_cluster_package.sv +++ b/packages/pulp_cluster_package.sv @@ -88,8 +88,6 @@ package pulp_cluster_package; logic [31:0] data_wdata; logic irq_ack; logic [4:0] irq_ack_id; - // logic debug_havereset; - // logic debug_running; logic debug_halted; logic core_busy; rapid_recovery_pkg::regfile_write_t regfile_backup; diff --git a/rtl/core_region.sv b/rtl/core_region.sv index 63365ef4..c6524c36 100644 --- a/rtl/core_region.sv +++ b/rtl/core_region.sv @@ -24,6 +24,7 @@ //`define DUMP_INSTR_FETCH module core_region +import rapid_recovery_pkg::*; #( // CORE PARAMETERS parameter CORE_TYPE_CL = 0, // 0 for CV32, 1 RI5CY, 2 for IBEX RV32IMC @@ -88,6 +89,12 @@ module core_region output logic debug_havereset_o, output logic debug_running_o, output logic debug_halted_o, + // Recovery bus + input rapid_recovery_pkg::rapid_recovery_t recovery_bus_i, + // Backup bus + output rapid_recovery_pkg::regfile_write_t regfile_backup_o, + output rapid_recovery_pkg::pc_intf_t pc_backup_o, + output rapid_recovery_pkg::csrs_intf_t csr_backup_o, input logic [N_EXT_PERF_COUNTERS-1:0] ext_perf_i, @@ -285,18 +292,57 @@ module core_region .sec_lvl_o ( ), // Debug Interface .debug_req_i ( debug_req_i ), - // .debug_havereset_o ( debug_havereset_o ), // Useful for HMR - // .debug_running_o ( debug_running_o ), // Useful for HMR - // .debug_halted_o ( debug_halted_o ), // Useful for HMR + .debug_mode_o ( debug_halted_o ), // Yet other control signals .fetch_enable_i ( fetch_en_i ), .core_busy_o ( core_busy_o ), // External performance monitoring signals - .ext_perf_counters_i ( ext_perf_i ) + .ext_perf_counters_i ( ext_perf_i ), + // RF recovery ports + .recover_i ( recovery_bus_i.rf_recovery_en ), + // Write port A + .regfile_waddr_a_i ( recovery_bus_i.rf_recovery_wdata.waddr_a ), + .regfile_wdata_a_i ( recovery_bus_i.rf_recovery_wdata.wdata_a ), + .regfile_we_a_i ( recovery_bus_i.rf_recovery_wdata.we_a ), + // Write port B + .regfile_waddr_b_i ( recovery_bus_i.rf_recovery_wdata.waddr_b ), + .regfile_wdata_b_i ( recovery_bus_i.rf_recovery_wdata.wdata_b ), + .regfile_we_b_i ( recovery_bus_i.rf_recovery_wdata.we_b ), + // Outputs from RF + // Port A + .regfile_we_a_o ( regfile_backup_o.we_a ), + .regfile_waddr_a_o ( regfile_backup_o.waddr_a ), + .regfile_wdata_a_o ( regfile_backup_o.wdata_a ), + // Port B + .regfile_we_b_o ( regfile_backup_o.we_b ), + .regfile_waddr_b_o ( regfile_backup_o.waddr_b ), + .regfile_wdata_b_o ( regfile_backup_o.wdata_b ), + // Program Counter Backup + .backup_program_counter_o ( pc_backup_o.program_counter ), + .backup_branch_o ( pc_backup_o.is_branch ), + .backup_branch_addr_o ( pc_backup_o.branch_addr ), + // Program Counter Recovery + .pc_recover_i ( recovery_bus_i.pc_recovery_en ), + .recovery_program_counter_i ( recovery_bus_i.pc_recovery.program_counter ), + .recovery_branch_i ( recovery_bus_i.pc_recovery.is_branch ), + .recovery_branch_addr_i ( recovery_bus_i.pc_recovery.branch_addr ), + // CSRs Backup + .backup_mstatus_o ( csr_backup_o.csr_mstatus ), + .backup_mtvec_o ( csr_backup_o.csr_mtvec ), + .backup_mscratch_o ( csr_backup_o.csr_mscratch ), + .backup_mepc_o ( csr_backup_o.csr_mepc ), + .backup_mcause_o ( csr_backup_o.csr_mcause ), + // CSRs Recovery + .recovery_mstatus_i ( recovery_bus_i.csr_recovery.csr_mstatus ), + .recovery_mtvec_i ( recovery_bus_i.csr_recovery.csr_mtvec ), + .recovery_mscratch_i ( recovery_bus_i.csr_recovery.csr_mscratch ), + .recovery_mepc_i ( recovery_bus_i.csr_recovery.csr_mepc ), + .recovery_mcause_i ( recovery_bus_i.csr_recovery.csr_mcause ) ); assign debug_havereset_o = '0; assign debug_running_o = '0; - assign debug_halted_o = '0; + assign csr_backup_o.csr_mie = '0; + assign csr_backup_o.csr_mip = '0; end else begin: IBEX_CORE assign boot_addr = boot_addr_i & 32'hFFFFFF00; // RI5CY expects 0x80 offset, Ibex expects 0x00 offset (adds reset offset 0x80 internally) // Core busy diff --git a/rtl/pulp_cluster.sv b/rtl/pulp_cluster.sv index 751f5e13..ce37847c 100644 --- a/rtl/pulp_cluster.sv +++ b/rtl/pulp_cluster.sv @@ -932,22 +932,17 @@ generate //debug unit bind .debug_req_i ( recovery_bus[i].debug_req | s_core_dbg_irq[i] ), - // .debug_halted_o ( dbg_core_halted[i] ), .debug_halted_o ( core2hmr[i].debug_halted ), .debug_havereset_o ( dbg_core_havereset[i] ), .debug_running_o ( dbg_core_running[i] ), .ext_perf_i ( ext_perf[i] ), .core_data_req_o ( core_data_req[i] ), .core_data_rsp_i ( core_data_rsp[i] ), - // .debug_resume_i ( recovery_bus[i].debug_resume ), // Useful for HMR, consider keeping //HMR Recovery Bus - // .csr_recovery_i ( recovery_bus[i].csr_recovery ), - // .pc_recovery_i ( recovery_bus[i].pc_recovery ), - // .instr_lock_i ( recovery_bus[i].instr_lock ), - // .pc_recovery_en ( recovery_bus[i].pc_recovery_en ), - // .rf_recovery_en ( recovery_bus[i].rf_recovery_en ), - // .rf_recovery_wdata ( recovery_bus[i].rf_recovery_wdata ), - // .rf_recovery_rdata ( recovery_bus[i].rf_recovery_rdata ), + .recovery_bus_i ( recovery_bus[i] ), + .regfile_backup_o ( core2hmr[i].regfile_backup ), + .pc_backup_o ( core2hmr[i].pc_backup ), + .csr_backup_o ( core2hmr[i].csr_backup ), //apu interface .apu_master_req_o ( s_apu_master_req [i] ), .apu_master_gnt_i ( s_apu_master_gnt [i] ), @@ -999,10 +994,6 @@ generate assign core2hmr[i].data_wdata = core_data_req[i].data; assign core2hmr[i].data_be = core_data_req[i].be; - assign core2hmr[i].regfile_backup = '0; - assign core2hmr[i].csr_backup = '0; - assign core2hmr[i].pc_backup = '0; - core_demux_wrap #( .AddrWidth ( ADDR_WIDTH ), .DataWidth ( DATA_WIDTH ),