Skip to content

Commit

Permalink
[racl] Arbitrate IP internal simultaneous errors
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Schilling <[email protected]>
  • Loading branch information
Razer6 authored and andreaskurth committed Feb 14, 2025
1 parent d862db4 commit ca041a3
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 43 deletions.
1 change: 1 addition & 0 deletions hw/ip/mbx/mbx.core
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ filesets:
files_rtl:
depend:
- lowrisc:prim:all
- lowrisc:prim:racl_error_arb
- lowrisc:tlul:headers
- lowrisc:ip:tlul
- lowrisc:systems:top_racl_pkg
Expand Down
32 changes: 21 additions & 11 deletions hw/ip/mbx/rtl/mbx_sysif.sv
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,24 @@ module mbx_sysif
mbx_soc_reg2hw_t reg2hw;
mbx_soc_hw2reg_t hw2reg;

top_racl_pkg::racl_error_log_t racl_error_regs_soc;
top_racl_pkg::racl_error_log_t racl_error_win_soc_wdata;
top_racl_pkg::racl_error_log_t racl_error_win_soc_rdata;

// We are combining all racl errors here because only one of them can be set at any time.
assign racl_error_o = racl_error_regs_soc |
racl_error_win_soc_wdata |
racl_error_win_soc_rdata;
top_racl_pkg::racl_error_log_t racl_error[3];
if (EnableRacl) begin : gen_racl_error_arb
// Arbitrate between all simultaneously valid error log requests.
prim_racl_error_arb #(
.N ( 3 )
) u_prim_err_arb (
.clk_i,
.rst_ni,
.error_log_i ( racl_error ),
.error_log_o ( racl_error_o )
);
end else begin : gen_no_racl_error_arb
logic unused_signals;
always_comb begin
unused_signals = ^{racl_error[0] ^ racl_error[1] ^ racl_error[2]};
racl_error_o = '0;
end
end

// Interface for the custom register interface with bus blocking support
tlul_pkg::tl_h2d_t tl_win_h2d[2];
Expand All @@ -96,7 +106,7 @@ module mbx_sysif
.reg2hw ( reg2hw ),
.hw2reg ( hw2reg ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_regs_soc ),
.racl_error_o ( racl_error[0] ),
.intg_err_o ( intg_err_o )
);

Expand Down Expand Up @@ -234,7 +244,7 @@ module mbx_sysif
.en_ifetch_i ( prim_mubi_pkg::MuBi4False ),
.intg_error_o ( ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_win_soc_wdata ),
.racl_error_o ( racl_error[1] ),
.we_o ( reg_wdata_we ),
// No Reading of the write register. Always reads zero
.re_o ( ),
Expand Down Expand Up @@ -265,7 +275,7 @@ module mbx_sysif
.en_ifetch_i ( prim_mubi_pkg::MuBi4False ),
.intg_error_o ( ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_win_soc_rdata ),
.racl_error_o ( racl_error[2] ),
// No writing to the read register
.we_o ( read_data_write_valid_o ),
.re_o ( read_data_read_valid_o ),
Expand Down
31 changes: 21 additions & 10 deletions hw/ip/spi_device/rtl/spi_device.sv
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,24 @@ module spi_device
spi_device_reg_pkg::spi_device_reg2hw_t reg2hw;
spi_device_reg_pkg::spi_device_hw2reg_t hw2reg;

top_racl_pkg::racl_error_log_t racl_error_regs;
top_racl_pkg::racl_error_log_t racl_error_win_egress_buffer;
top_racl_pkg::racl_error_log_t racl_error_win_ingress_buffer;
// We are combining all racl errors here because only one of them can be set at any time.
assign racl_error_o = racl_error_regs |
racl_error_win_egress_buffer |
racl_error_win_ingress_buffer;
top_racl_pkg::racl_error_log_t racl_error[3];
if (EnableRacl) begin : gen_racl_error_arb
// Arbitrate between all simultaneously valid error log requests.
prim_racl_error_arb #(
.N ( 3 )
) u_prim_err_arb (
.clk_i,
.rst_ni,
.error_log_i ( racl_error ),
.error_log_o ( racl_error_o )
);
end else begin : gen_no_racl_error_arb
logic unused_signals;
always_comb begin
unused_signals = ^{racl_error[0] ^ racl_error[1] ^ racl_error[2]};
racl_error_o = '0;
end
end

tlul_pkg::tl_h2d_t tl_sram_h2d[2];
tlul_pkg::tl_d2h_t tl_sram_d2h[2];
Expand Down Expand Up @@ -1719,7 +1730,7 @@ module spi_device
.wr_collision_i (1'b0),
.write_pending_i (1'b0),
.racl_policies_i (racl_policies_i),
.racl_error_o (racl_error_win_egress_buffer)
.racl_error_o (racl_error[1])
);

tlul_adapter_sram_racl #(
Expand Down Expand Up @@ -1757,7 +1768,7 @@ module spi_device
.wr_collision_i (1'b0),
.write_pending_i (1'b0),
.racl_policies_i (racl_policies_i),
.racl_error_o (racl_error_win_ingress_buffer)
.racl_error_o (racl_error[2])
);
assign sys_sram_l2m[SysSramFwEgress].wstrb =
sram_mask2strb(sys_sram_l2m_fw_wmask[SPI_DEVICE_EGRESS_BUFFER_IDX]);
Expand Down Expand Up @@ -1910,7 +1921,7 @@ module spi_device

// RACL interface
.racl_policies_i (racl_policies_i),
.racl_error_o (racl_error_regs),
.racl_error_o (racl_error[0]),

// SEC_CM: BUS.INTEGRITY
.intg_err_o (alerts[0])
Expand Down
1 change: 1 addition & 0 deletions hw/ip/spi_device/spi_device.core
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ filesets:
- lowrisc:prim:ram_1r1w_async_adv
- lowrisc:prim:edge_detector
- lowrisc:prim:rst_sync
- lowrisc:prim:racl_error_arb
- lowrisc:ip:lc_ctrl_pkg
- lowrisc:prim:lc_sync
- lowrisc:ip:spi_device_pkg
Expand Down
27 changes: 21 additions & 6 deletions hw/ip/spi_host/rtl/spi_host.sv
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,24 @@ module spi_host
spi_host_reg2hw_t reg2hw;
spi_host_hw2reg_t hw2reg;

top_racl_pkg::racl_error_log_t racl_error_regs;
top_racl_pkg::racl_error_log_t racl_error_window;
// We are combining all racl errors here because only one of them can be set at any time.
assign racl_error_o = racl_error_regs | racl_error_window;
top_racl_pkg::racl_error_log_t racl_error[3];
if (EnableRacl) begin : gen_racl_error_arb
// Arbitrate between all simultaneously valid error log requests.
prim_racl_error_arb #(
.N ( 3 )
) u_prim_err_arb (
.clk_i,
.rst_ni,
.error_log_i ( racl_error ),
.error_log_o ( racl_error_o )
);
end else begin : gen_no_racl_error_arb
logic unused_signals;
always_comb begin
unused_signals = ^{racl_error[0] ^ racl_error[1] ^ racl_error[2]};
racl_error_o = '0;
end
end

tlul_pkg::tl_h2d_t fifo_win_h2d [2];
tlul_pkg::tl_d2h_t fifo_win_d2h [2];
Expand All @@ -86,7 +100,7 @@ module spi_host
// SEC_CM: BUS.INTEGRITY
.intg_err_o ( alerts[0] ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_regs )
.racl_error_o ( racl_error[0] )
);

// Alerts
Expand Down Expand Up @@ -331,7 +345,8 @@ module spi_host
.rx_data_i ( rx_data ),
.rx_ready_o ( rx_ready ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_window )
.racl_error_tx_o ( racl_error[1] ),
.racl_error_rx_o ( racl_error[2] )
);

logic [31:0] core_tx_data;
Expand Down
14 changes: 4 additions & 10 deletions hw/ip/spi_host/rtl/spi_host_window.sv
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module spi_host_window
output logic rx_ready_o,
// RACL interface
input top_racl_pkg::racl_policy_vec_t racl_policies_i,
output top_racl_pkg::racl_error_log_t racl_error_o
output top_racl_pkg::racl_error_log_t racl_error_tx_o,
output top_racl_pkg::racl_error_log_t racl_error_rx_o
);

localparam int AW = spi_host_reg_pkg::BlockAw;
Expand All @@ -45,13 +46,6 @@ module spi_host_window
logic rx_access_error;
assign rx_access_error = rx_we;

top_racl_pkg::racl_error_log_t racl_error_win_rxdata;
top_racl_pkg::racl_error_log_t racl_error_win_txdata;

// We are combining all racl errors here because only one of them can be set at any time.
assign racl_error_o = racl_error_win_rxdata |
racl_error_win_txdata;

tlul_adapter_reg_racl #(
.RegAw ( AW ),
.RegDw ( DW ),
Expand All @@ -67,7 +61,7 @@ module spi_host_window
.en_ifetch_i ( prim_mubi_pkg::MuBi4False ),
.intg_error_o ( ),
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_win_rxdata ),
.racl_error_o ( racl_error_rx_o ),
.we_o ( rx_we ),
.re_o ( rx_ready_o ),
.addr_o ( ),
Expand Down Expand Up @@ -124,7 +118,7 @@ module spi_host_window
.wr_collision_i(1'b0),
.write_pending_i(1'b0),
.racl_policies_i (racl_policies_i),
.racl_error_o (racl_error_win_txdata)
.racl_error_o (racl_error_tx_o)
);

endmodule : spi_host_window
1 change: 1 addition & 0 deletions hw/ip/spi_host/spi_host.core
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ filesets:
- lowrisc:constants:top_pkg
- lowrisc:prim:all
- lowrisc:prim:flop_en
- lowrisc:prim:racl_error_arb
- lowrisc:ip:tlul
- lowrisc:ip:spi_device_pkg
- lowrisc:systems:top_racl_pkg
Expand Down
24 changes: 18 additions & 6 deletions hw/ip/sram_ctrl/rtl/sram_ctrl.sv
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,22 @@ module sram_ctrl

`ASSERT_INIT(NonceWidthsLessThanSource_A, NonceWidth + LfsrWidth <= otp_ctrl_pkg::SramNonceWidth)

top_racl_pkg::racl_error_log_t racl_error_regs;
top_racl_pkg::racl_error_log_t racl_error_ram;
// We are combining all racl errors here because only one of them can be set at any time.
assign racl_error_o = racl_error_regs | racl_error_ram;
top_racl_pkg::racl_error_log_t racl_error[2];
if (EnableRacl) begin : gen_racl_error_arb
// Arbitrate between all simultaneously valid error log requests.
prim_racl_error_arb #(
.N ( 2 )
) u_prim_err_arb (
.clk_i,
.rst_ni,
.error_log_i ( racl_error ),
.error_log_o ( racl_error_o )
);
end else begin : gen_no_racl_error_arb
logic unused_signals;
assign unused_signals = ^{racl_error[0] ^ racl_error[1]};
assign racl_error_o = '0;
end

/////////////////////////////////////
// Anchor incoming seeds and constants
Expand Down Expand Up @@ -142,7 +154,7 @@ module sram_ctrl
.hw2reg,
// RACL interface
.racl_policies_i ( racl_policies_i ),
.racl_error_o ( racl_error_regs ),
.racl_error_o ( racl_error[0] ),
// SEC_CM: BUS.INTEGRITY
.intg_err_o ( bus_integ_error[0] )
);
Expand Down Expand Up @@ -542,7 +554,7 @@ module sram_ctrl
.write_pending_i (sram_wpending),
// RACL interface
.racl_policies_i (racl_policies_i),
.racl_error_o (racl_error_ram)
.racl_error_o (racl_error[1])
);

logic key_valid;
Expand Down
1 change: 1 addition & 0 deletions hw/ip/sram_ctrl/sram_ctrl.core
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ filesets:
- lowrisc:prim:lc_sync
- lowrisc:prim:count
- lowrisc:prim:ram_1p_scr
- lowrisc:prim:racl_error_arb
- lowrisc:tlul:adapter_sram
- lowrisc:ip:tlul
- lowrisc:ip:sram_ctrl_pkg
Expand Down

0 comments on commit ca041a3

Please sign in to comment.