From 536eab569a3921aebc053c01849985775e5a7a9d Mon Sep 17 00:00:00 2001 From: Gianmarco Ottavi Date: Mon, 26 Aug 2024 16:14:44 +0200 Subject: [PATCH] Added ECC for BHT --- core/frontend/bht.sv | 87 +++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/core/frontend/bht.sv b/core/frontend/bht.sv index c3799ed6ad..31b4e4816a 100644 --- a/core/frontend/bht.sv +++ b/core/frontend/bht.sv @@ -51,12 +51,15 @@ module bht #( // we are not interested in all bits of the address unread i_unread (.d_i(|vpc_i)); - struct packed { - logic valid; - logic [1:0] saturation_counter; - } - bht_d[NR_ROWS-1:0][ariane_pkg::INSTR_PER_FETCH-1:0], - bht_q[NR_ROWS-1:0][ariane_pkg::INSTR_PER_FETCH-1:0]; + localparam int unsigned BhtBits = $bits(ariane_pkg::bht_t); + localparam int unsigned BhtCorrBits = EccEnable ? $clog2(BhtBits) + 2 : 0;' + localparam int unsigned BhtSize = BhtBits + BhtCorrBits; + + logic [BhtSize-1:0] bht_d[NR_ROWS-1:0][ariane_pkg::INSTR_PER_FETCH-1:0], + bht_q[NR_ROWS-1:0][ariane_pkg::INSTR_PER_FETCH-1:0]; + + bht_t bht_update_entry_dec, bht_update_ecc_in, bht_update_ecc_out; + bht_t [ariane_pkg::INSTR_PER_FETCH-1:0] bht_pred_entry_dec; logic [$clog2(NR_ROWS)-1:0] index, update_pc; logic [ROW_INDEX_BITS-1:0] update_row_index; @@ -69,36 +72,78 @@ module bht #( assign update_row_index = '0; end + if (EccEnable) begin: gen_enc_dec + hsiao_ecc_enc #( + .DataWidth ( BhtBits ), + .ProtWidth ( BhtCorrBits ) + ) i_ecc_update_enc ( + .in ( bht_update_ecc_in ), + .out ( bht_update_ecc_out ) + ); + + hsiao_ecc_dec #( + .DataWidth ( BhtBits ), + .ProtWidth ( BhtCorrBits ) + ) i_ecc_update_dec ( + .in ( bht_d[update_pc][update_row_index] ), + .out ( bht_update_entry_dec ), + .syndrome_o (), + .err_o () + ); + + for (genvar i=0; i