Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hw,ac_range_check] Implement range check logic #25357

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hw/ip/tlul/lint/tlul_request_loopback.vlt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
5 changes: 5 additions & 0 deletions hw/ip/tlul/lint/tlul_request_loopback.waiver
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# waiver file for TLUL request loopback
63 changes: 63 additions & 0 deletions hw/ip/tlul/request_loopback.core
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
CAPI=2:
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
name: "lowrisc:tlul:request_loopback:0.1"
description: "TL-UL request loopback"

filesets:
files_rtl:
depend:
- lowrisc:prim:util
- lowrisc:prim:assert
- lowrisc:tlul:common
files:
- rtl/tlul_request_loopback.sv
file_type: systemVerilogSource

files_verilator_waiver:
depend:
# common waivers
- lowrisc:lint:common
files:
- lint/tlul_request_loopback.vlt
file_type: vlt

files_ascentlint_waiver:
depend:
# common waivers
- lowrisc:lint:common
files:
- lint/tlul_request_loopback.waiver
file_type: waiver

files_veriblelint_waiver:
depend:
# common waivers
- lowrisc:lint:common

parameters:
SYNTHESIS:
datatype: bool
paramtype: vlogdefine


targets:
default: &default_target
filesets:
- tool_verilator ? (files_verilator_waiver)
- tool_ascentlint ? (files_ascentlint_waiver)
- tool_veriblelint ? (files_veriblelint_waiver)
- files_rtl
toplevel: tlul_request_loopback

lint:
<<: *default_target
default_tool: verilator
parameters:
- SYNTHESIS=true
tools:
verilator:
mode: lint-only
verilator_options:
- "-Wall"
108 changes: 108 additions & 0 deletions hw/ip/tlul/rtl/tlul_request_loopback.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

module tlul_request_loopback
import tlul_pkg::*;
(
input logic clk_i,
input logic rst_ni,
input logic squash_req_i,
input tlul_pkg::tl_h2d_t tl_h2d_i, // Incoming request
output tlul_pkg::tl_d2h_t tl_d2h_o, // Response
output tlul_pkg::tl_h2d_t tl_h2d_o, // Feed through request if not squashed to the target
input tlul_pkg::tl_d2h_t tl_d2h_i // Response from the target
);

// A valid request is loop-backed if the squash_req_i is asserted in the same cycle
// Regarless the request is squashed or not, the request payload is NOT modified by this module
logic loopback_request;
assign loopback_request = tl_h2d_i.a_valid & squash_req_i;

// Assemble the non-squashed request
assign tl_h2d_o.a_valid = tl_h2d_i.a_valid & ~squash_req_i;
assign tl_h2d_o.a_opcode = tl_h2d_i.a_opcode;
assign tl_h2d_o.a_param = tl_h2d_i.a_param;
assign tl_h2d_o.a_size = tl_h2d_i.a_size;
assign tl_h2d_o.a_source = tl_h2d_i.a_source;
assign tl_h2d_o.a_address = tl_h2d_i.a_address;
assign tl_h2d_o.a_mask = tl_h2d_i.a_mask;
assign tl_h2d_o.a_data = tl_h2d_i.a_data;
assign tl_h2d_o.a_user = tl_h2d_i.a_user;
assign tl_h2d_o.d_ready = tl_h2d_i.d_ready;

// Assemble the RAZWI response if the request is squashed
tlul_pkg::tl_d2h_t tl_razwi_rsp_pre_intg, tl_razwi_rsp;
logic loopback_request_q;

prim_flop #(
.Width(1)
) u_loopback_valid (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.d_i ( loopback_request ),
.q_o ( loopback_request_q )
);

prim_flop #(
.Width(1)
) u_squash_req (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.d_i ( squash_req_i ),
.q_o ( squash_req_q )
);

prim_flop #(
.Width($bits(tlul_pkg::tl_d_op_e)),
.ResetValue({AccessAck})
) u_rsp_opcode (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.d_i ( (tl_h2d_i.a_opcode == Get) ? AccessAckData : AccessAck ),
.q_o ( tl_razwi_rsp_pre_intg.d_opcode )
);

prim_flop #(
.Width(top_pkg::TL_SZW)
) u_rsp_size (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.d_i ( tl_h2d_i.a_size ),
.q_o ( tl_razwi_rsp_pre_intg.d_size )
);

prim_flop #(
.Width(top_pkg::TL_AIW)
) u_rsp_source (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.d_i ( tl_h2d_i.a_source ),
.q_o ( tl_razwi_rsp_pre_intg.d_source )
);

assign tl_razwi_rsp_pre_intg.d_valid = loopback_request_q;
assign tl_razwi_rsp_pre_intg.a_ready = 1'b1;

assign tl_razwi_rsp_pre_intg.d_param = '0;
assign tl_razwi_rsp_pre_intg.d_sink = '0;
assign tl_razwi_rsp_pre_intg.d_data = '0;
assign tl_razwi_rsp_pre_intg.d_user = '0;
assign tl_razwi_rsp_pre_intg.d_error = squash_req_q;

// Compute integrity bits from the manually assembled RAZWI reponse
tlul_rsp_intg_gen gen_intg_razwi_rsp (
.tl_i ( tl_razwi_rsp_pre_intg ),
.tl_o ( tl_razwi_rsp )
);

// Mux reponse if request was squased
always_comb begin
if (loopback_request_q) begin
tl_d2h_o = tl_razwi_rsp;
end else begin
tl_d2h_o = tl_d2h_i;
end
end

endmodule
1 change: 1 addition & 0 deletions hw/ip/tlul/tlul.core
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ filesets:
- lowrisc:tlul:jtag_dtm
- lowrisc:tlul:sram2tlul
- lowrisc:tlul:lc_gate
- lowrisc:tlul:request_loopback

targets:
default:
Expand Down
6 changes: 6 additions & 0 deletions hw/ip_templates/ac_range_check/data/ac_range_check.hjson.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
type: "int",
default: "${num_ranges}",
},
{ name: "DenyCountWidth",
desc: "Witdth of the deny counter",
type: "int",
default: "8",
local: "true"
},
],
inter_signal_list: [
{ name: "range_check_overwrite"
Expand Down
Loading
Loading