-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tlul,request_loopback,rtl] Add request loopback
Signed-off-by: Robert Schilling <[email protected]>
- Loading branch information
Showing
5 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters