Skip to content

Commit

Permalink
Added TCDM scrubber (ECC manager).
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvan Tortorella committed Feb 27, 2024
1 parent 1bc74dd commit 71a92ab
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 69 deletions.
2 changes: 1 addition & 1 deletion include/pulp_soc_defines.sv
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
`define NB_CORES 12
`define NB_DMAS 4
`define NB_MPERIPHS 1
`define NB_SPERIPHS 10
`define NB_SPERIPHS 11
29 changes: 15 additions & 14 deletions packages/pulp_cluster_package.sv
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,25 @@ package pulp_cluster_package;
bit EnableRemapAddress;
} pulp_cluster_cfg_t;

parameter NB_SPERIPH_PLUGS_EU = 2;
parameter int unsigned NB_SPERIPH_PLUGS_EU = 2;

// number of master and slave cluster periphs
parameter NB_MPERIPHS = 1;
parameter NB_SPERIPHS = 10;
parameter int unsigned NB_MPERIPHS = 1;
parameter int unsigned NB_SPERIPHS = 11;

// position of peripherals on slave port of periph interconnect
parameter SPER_EOC_ID = 0; // 0x0000 - 0x0400
parameter SPER_TIMER_ID = 1; // 0x0400 - 0x0800
parameter SPER_EVENT_U_ID = 2; // 0x0800 - 0x1000
// 3 also used for Event Unit
parameter SPER_HWPE_ID = 4; // 0x1000 - 0x1400
parameter SPER_ICACHE_CTRL = 5; // 0x1400 - 0x1800
parameter SPER_DMA_CL_ID = 6; // 0x1800 - 0x1C00
parameter SPER_DMA_FC_ID = 7; // 0x1C00 - 0x2000
parameter SPER_HMR_UNIT_ID = 8; // 0x2000 - 0x2400
parameter SPER_EXT_ID = 9; // 0x2400 - 0x2800
parameter SPER_ERROR_ID = 10; // 0x2800 - 0x2C00
parameter int unsigned SPER_EOC_ID = 0; // 0x0000 - 0x0400
parameter int unsigned SPER_TIMER_ID = 1; // 0x0400 - 0x0800
parameter int unsigned SPER_EVENT_U_ID = 2; // 0x0800 - 0x1000
// 3 also used for Event Unit
parameter int unsigned SPER_HWPE_ID = 4; // 0x1000 - 0x1400
parameter int unsigned SPER_ICACHE_CTRL = 5; // 0x1400 - 0x1800
parameter int unsigned SPER_DMA_CL_ID = 6; // 0x1800 - 0x1C00
parameter int unsigned SPER_DMA_FC_ID = 7; // 0x1C00 - 0x2000
parameter int unsigned SPER_HMR_UNIT_ID = 8; // 0x2000 - 0x2400
parameter int unsigned SPER_TCDM_SCRUBBER_ID = 9; // 0x2400 - 0x2800
parameter int unsigned SPER_EXT_ID = 10; // 0x2800 - 0x2C00
parameter int unsigned SPER_ERROR_ID = 11; // 0x2C00 - 0x3000

// The following parameters refer to the cluster AXI crossbar
localparam byte_t NumAxiSubordinatePorts = 4;
Expand Down
2 changes: 1 addition & 1 deletion regression-tests
18 changes: 18 additions & 0 deletions rtl/cluster_peripherals.sv
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ module cluster_peripherals

XBAR_PERIPH_BUS.Master hwpe_cfg_master,
XBAR_PERIPH_BUS.Master hmr_cfg_master,
XBAR_PERIPH_BUS.Master tcdm_scrubber_cfg_master,
input logic [NB_CORES-1:0][3:0] hwpe_events_i,
output logic hwpe_en_o,
output hci_package::hci_interconnect_ctrl_t hci_ctrl_o,
Expand Down Expand Up @@ -358,6 +359,23 @@ module cluster_peripherals
assign hmr_cfg_master.be = speriph_slave[SPER_HMR_UNIT_ID].be;
assign hmr_cfg_master.id = speriph_slave[SPER_HMR_UNIT_ID].id;

//********************************************************
//******************** TCDM Scrubber *********************
//********************************************************

assign speriph_slave[SPER_TCDM_SCRUBBER_ID].gnt = tcdm_scrubber_cfg_master.gnt;
assign speriph_slave[SPER_TCDM_SCRUBBER_ID].r_rdata = tcdm_scrubber_cfg_master.r_rdata;
assign speriph_slave[SPER_TCDM_SCRUBBER_ID].r_opc = tcdm_scrubber_cfg_master.r_opc;
assign speriph_slave[SPER_TCDM_SCRUBBER_ID].r_id = tcdm_scrubber_cfg_master.r_id;
assign speriph_slave[SPER_TCDM_SCRUBBER_ID].r_valid = tcdm_scrubber_cfg_master.r_valid;

assign tcdm_scrubber_cfg_master.req = speriph_slave[SPER_TCDM_SCRUBBER_ID].req;
assign tcdm_scrubber_cfg_master.add = speriph_slave[SPER_TCDM_SCRUBBER_ID].add;
assign tcdm_scrubber_cfg_master.wen = speriph_slave[SPER_TCDM_SCRUBBER_ID].wen;
assign tcdm_scrubber_cfg_master.wdata = speriph_slave[SPER_TCDM_SCRUBBER_ID].wdata;
assign tcdm_scrubber_cfg_master.be = speriph_slave[SPER_TCDM_SCRUBBER_ID].be;
assign tcdm_scrubber_cfg_master.id = speriph_slave[SPER_TCDM_SCRUBBER_ID].id;

generate
if(FEATURE_DEMUX_MAPPED == 0) begin : eu_not_demux_mapped_gen
for(genvar i=0;i< NB_CORES; i++) begin
Expand Down
98 changes: 82 additions & 16 deletions rtl/pulp_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ module pulp_cluster
localparam int unsigned FpuOpCodeWidth = 6,
localparam int unsigned FpuTypeWidth = 3,
localparam int unsigned FpuInFlagsWidth = 15,
localparam int unsigned FpuOutFlagsWidth = 5
localparam int unsigned FpuOutFlagsWidth = 5,
// Number of parity bits for ECC in memory banks
localparam int unsigned ParityWidth = 7,
// TCDM banks data width extended with parity for ECCs
localparam int unsigned ProtectedTcdmWidth = DataWidth + ParityWidth
)(
input logic clk_i,
input logic rst_ni,
Expand Down Expand Up @@ -353,6 +357,9 @@ XBAR_PERIPH_BUS s_periph_dma_bus[1:0]();
// periph interconnect -> HMR unit
XBAR_PERIPH_BUS s_periph_hmr_bus ();

// periph interconnect -> TCDM scrubber
XBAR_PERIPH_BUS s_periph_tcdm_scrubber_bus ();

// debug
XBAR_TCDM_BUS s_debug_bus[Cfg.NumCores-1:0]();

Expand Down Expand Up @@ -729,6 +736,7 @@ cluster_peripherals #(

.dma_cfg_master ( s_periph_dma_bus ),
.hmr_cfg_master ( s_periph_hmr_bus ),
.tcdm_scrubber_cfg_master ( s_periph_tcdm_scrubber_bus ),

.dma_cl_event_i ( s_dma_cl_event ),
.dma_cl_irq_i ( s_dma_cl_irq ),
Expand Down Expand Up @@ -1282,30 +1290,88 @@ icache_hier_top #(
.IC_ctrl_unit_bus_main ( IC_ctrl_unit_bus_main )
);

assign s_core_instr_bus.aw_atop = '0;
assign s_core_instr_bus.aw_atop = '0;

`REG_BUS_TYPEDEF_ALL(tcdm_scrubber_reg, logic[31:0], logic[31:0], logic[3:0])

tcdm_scrubber_reg_req_t tcdm_scrubber_reg_req;
tcdm_scrubber_reg_rsp_t tcdm_scrubber_reg_rsp;

periph_to_reg #(
.AW ( AddrWidth ),
.DW ( DataWidth ),
.BW ( 8 ),
.IW ( Cfg.NumCores + 1 ),
.req_t ( tcdm_scrubber_reg_req_t ),
.rsp_t ( tcdm_scrubber_reg_rsp_t )
) i_periph_to_tcdm_scrubber (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.req_i ( s_periph_tcdm_scrubber_bus.req ),
.add_i ( s_periph_tcdm_scrubber_bus.add ),
.wen_i ( s_periph_tcdm_scrubber_bus.wen ),
.wdata_i ( s_periph_tcdm_scrubber_bus.wdata ),
.be_i ( s_periph_tcdm_scrubber_bus.be ),
.id_i ( s_periph_tcdm_scrubber_bus.id ),
.gnt_o ( s_periph_tcdm_scrubber_bus.gnt ),
.r_rdata_o ( s_periph_tcdm_scrubber_bus.r_rdata ),
.r_opc_o ( s_periph_tcdm_scrubber_bus.r_opc ),
.r_id_o ( s_periph_tcdm_scrubber_bus.r_id ),
.r_valid_o ( s_periph_tcdm_scrubber_bus.r_valid ),
.reg_req_o ( tcdm_scrubber_reg_req ),
.reg_rsp_i ( tcdm_scrubber_reg_rsp )
);

logic [Cfg.TcdmNumBank] bank_faults;
logic [Cfg.TcdmNumBank] ecc_single_error;
logic [Cfg.TcdmNumBank] ecc_multiple_error;
logic [Cfg.TcdmNumBank] scrubber_fix;
logic [Cfg.TcdmNumBank] scrubber_uncorrectable;
logic [Cfg.TcdmNumBank] scrubber_trigger;
logic [Cfg.TcdmNumBank][ProtectedTcdmWidth-1:0] test_write_mask_n;

assign bank_faults = ecc_single_error | ecc_multiple_error; // TODO: check

ecc_manager #(
.NumBanks ( Cfg.TcdmNumBank ),
.ecc_mgr_req_t ( tcdm_scrubber_reg_req_t ),
.ecc_mgr_rsp_t ( tcdm_scrubber_reg_rsp_t )
) i_tcdm_scrubber (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.ecc_mgr_req_i ( tcdm_scrubber_reg_req ),
.ecc_mgr_rsp_o ( tcdm_scrubber_reg_rsp ),
.bank_faults_i ( bank_faults ),
.scrub_fix_i ( scrubber_fix ),
.scrub_uncorrectable_i( scrubber_uncorrectable ),
.scrub_trigger_o ( scrubber_trigger ),
.test_write_mask_no ( test_write_mask_n )
);

/* TCDM banks */
tcdm_banks_wrap #(
.BankSize ( TcdmNumRows ),
.NbBanks ( Cfg.TcdmNumBank ),
.DataWidth ( DataWidth ),
.AddrWidth ( AddrWidth ),
.BeWidth ( BeWidth ),
.IdWidth ( TCDM_ID_WIDTH ),
.EnableEcc ( 1 ),
.EccInterco ( 0 ) // Not supported at the moment
tcdm_banks_wrap #(
.BankSize ( TcdmNumRows ),
.NbBanks ( Cfg.TcdmNumBank ),
.DataWidth ( DataWidth ),
.AddrWidth ( AddrWidth ),
.BeWidth ( BeWidth ),
.IdWidth ( TCDM_ID_WIDTH ),
.EnableEcc ( 1 ),
.EccInterco ( 0 ), // Not supported at the moment
.ProtectedWidth ( ProtectedTcdmWidth )
) tcdm_banks_i (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.test_mode_i ( test_mode_i ),
// Scrubber
.scrub_trigger_i ( '0 ), // TODO: to be connected to a register
.scrub_trigger_i ( scrubber_trigger ),
// in the cluster control unit.
.scrub_fix_o ( /* TODO: left pending */ ),
.scrub_uncorrectable_o ( /* TODO: left pending */ ),
.scrub_fix_o ( scrubber_fix ),
.scrub_uncorrectable_o ( scrubber_uncorrectable ),
// ECC
.ecc_single_error_o ( /* TODO: left pending */ ),
.ecc_multile_error_o ( /* TODO: left pending */ ),
.ecc_single_error_o ( ecc_single_error ),
.ecc_multiple_error_o ( ecc_multiple_error ),
.test_write_mask_ni ( test_write_mask_n ),
.tcdm_slave ( s_tcdm_bus_sram ) //PMU ??
);

Expand Down
68 changes: 32 additions & 36 deletions rtl/tcdm_banks_wrap.sv
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,32 @@
*/

module tcdm_banks_wrap #(
parameter int unsigned BankSize = 256, //- -> OVERRIDE
parameter int unsigned NbBanks = 1, // --> OVERRIDE
parameter int unsigned DataWidth = 32,
parameter int unsigned AddrWidth = 32,
parameter int unsigned BeWidth = DataWidth/8,
parameter int unsigned IdWidth = 1,
parameter bit EnableEcc = 1,
parameter bit EccInterco = 0
parameter int unsigned BankSize = 256, //- -> OVERRIDE
parameter int unsigned NbBanks = 1, // --> OVERRIDE
parameter int unsigned DataWidth = 32,
parameter int unsigned AddrWidth = 32,
parameter int unsigned BeWidth = DataWidth/8,
parameter int unsigned IdWidth = 1,
parameter bit EnableEcc = 1,
parameter bit EccInterco = 0,
parameter int unsigned ProtectedWidth = DataWidth + 7
) (
input logic clk_i,
input logic rst_ni,
input logic test_mode_i,
input logic clk_i,
input logic rst_ni,
input logic test_mode_i,
// Scrubber
input logic scrub_trigger_i,
output logic scrub_fix_o,
output logic scrub_uncorrectable_o,
input logic [NbBanks-1:0] scrub_trigger_i,
output logic [NbBanks-1:0] scrub_fix_o,
output logic [NbBanks-1:0] scrub_uncorrectable_o,
// ECC
output logic ecc_single_error_o,
output logic ecc_multile_error_o,
output logic [NbBanks-1:0] ecc_single_error_o,
output logic [NbBanks-1:0] ecc_multiple_error_o,
input logic [NbBanks-1:0][ProtectedWidth-1:0] test_write_mask_ni,
hci_mem_intf.slave tcdm_slave[NbBanks-1:0]
);

logic [NbBanks-1:0] ecc_single_error, ecc_multiple_error,
scrub_fix, scrub_uncorrectable;

assign ecc_single_error_o = |ecc_single_error;
assign ecc_multiple_error_o = |ecc_multiple_error;
assign scrub_fix_o = |scrub_fix;
assign scrub_uncorrectable_o = |scrub_uncorrectable;

for(genvar i=0; i<NbBanks; i++) begin : banks_gen

Expand All @@ -67,18 +64,18 @@ for(genvar i=0; i<NbBanks; i++) begin : banks_gen
/* TODO: blank for the moment */
end else begin: gen_ecc_banks_only
ecc_sram_wrap #(
.BankSize ( BankSize ),
.InputECC ( EccInterco ),
.UnprotectedWidth ( 32 ),
.ProtectedWidth ( 39 )
.BankSize ( BankSize ),
.InputECC ( EccInterco ),
.UnprotectedWidth ( DataWidth ),
.ProtectedWidth ( ProtectedWidth )
) i_ecc_bank (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.test_enable_i ( test_mode_i ),
// Scrubber
.scrub_trigger_i ( scrub_trigger_i ),
.scrubber_fix_o ( scrub_fix[i] ),
.scrub_uncorrectable_o ( scrub_uncorrectable[i] ),
.scrub_trigger_i ( scrub_trigger_i[i] ),
.scrubber_fix_o ( scrub_fix_o[i] ),
.scrub_uncorrectable_o ( scrub_uncorrectable_o[i] ),
// TCDM interface
.tcdm_wdata_i ( tcdm_slave[i].data ),
.tcdm_add_i ( tcdm_slave[i].add ),
Expand All @@ -88,18 +85,17 @@ for(genvar i=0; i<NbBanks; i++) begin : banks_gen
.tcdm_rdata_o ( tcdm_slave[i].r_data ),
.tcdm_gnt_o ( tcdm_slave[i].gnt ),
// ECC
.single_error_o ( ecc_single_error[i] ),
.multi_error_o ( ecc_multiple_error[i] ),
.test_write_mask_ni ( '0 ) // TODO: needed?
.single_error_o ( ecc_single_error_o[i] ),
.multi_error_o ( ecc_multiple_error_o[i] ),
.test_write_mask_ni ( test_write_mask_ni[i] )
);
end
end else begin: gen_standard_banks

assign tcdm_slave[i].gnt = 1'b1;
assign ecc_single_error[i] = 1'b0;
assign ecc_multiple_error[i] = 1'b0;
assign scrub_fix[i] = 1'b0;
assign scrub_uncorrectable[i] = 1'b0;
assign ecc_single_error_o[i] = '0;
assign ecc_multiple_error_o[i] = '0;
assign scrub_fix_o[i] = '0;
assign scrub_uncorrectable_o[i] = '0;

tc_sram #(
.NumWords (BankSize ), // Number of Words in data array
Expand Down

0 comments on commit 71a92ab

Please sign in to comment.