Skip to content

Commit da71882

Browse files
committed
hw/reqrsp: Add generic reqrsp-like interface cut
1 parent 8640752 commit da71882

File tree

5 files changed

+101
-34
lines changed

5 files changed

+101
-34
lines changed

Bender.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ sources:
4141
# reqrsp_interface
4242
- files:
4343
# Level 0
44+
- hw/reqrsp_interface/src/generic_reqrsp_cut.sv
4445
- hw/reqrsp_interface/src/reqrsp_pkg.sv
4546
# Level 1
4647
- hw/reqrsp_interface/src/reqrsp_intf.sv

hw/reqrsp_interface/include/reqrsp_interface/assign.svh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@
44

55
// Author: Florian Zaruba <[email protected]>
66
// Author: Fabian Schuiki <[email protected]>
7+
// Author: Luca Colagrande <[email protected]>
78

89
// Macros to assign reqrsp Interfaces and Structs
910

1011
`ifndef REQRSP_ASSIGN_SVH_
1112
`define REQRSP_ASSIGN_SVH_
1213

14+
// Tie off a generic reqrsp-like interface
15+
`define REQRSP_TIE_OFF_REQ(__if) \
16+
assign ``__if``.q = '0; \
17+
assign ``__if``.q_valid = 1'b0; \
18+
assign ``__if``.p_ready = 1'b0;
19+
`define REQRSP_TIE_OFF_RSP(__if) \
20+
assign ``__if``.p = '0; \
21+
assign ``__if``.p_valid = 1'b0; \
22+
assign ``__if``.q_ready = 1'b0;
23+
1324
// Assign an reqrsp handshake.
1425
`define REQRSP_ASSIGN_VALID(__opt_as, __dst, __src, __chan) \
1526
__opt_as ``__dst``.``__chan``_valid = ``__src``.``__chan``_valid;

hw/reqrsp_interface/include/reqrsp_interface/typedef.svh

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,34 @@
2525
logic error; \
2626
} __rsp_chan_t;
2727

28+
`define GENERIC_REQRSP_REQ_STRUCT(__req_chan_t) \
29+
struct packed { \
30+
__req_chan_t q; \
31+
logic q_valid; \
32+
logic p_ready; \
33+
}
34+
35+
`define GENERIC_REQRSP_RSP_STRUCT(__rsp_chan_t) \
36+
struct packed { \
37+
__rsp_chan_t p; \
38+
logic p_valid; \
39+
logic q_ready; \
40+
}
41+
2842
`define REQRSP_TYPEDEF_REQ_T(__req_t, __req_chan_t) \
29-
typedef struct packed { \
30-
__req_chan_t q; \
31-
logic q_valid; \
32-
logic p_ready; \
33-
} __req_t;
43+
typedef `GENERIC_REQRSP_REQ_STRUCT(__req_chan_t) __req_t;
3444

3545
`define REQRSP_TYPEDEF_RSP_T(__rsp_t, __rsp_chan_t) \
36-
typedef struct packed { \
37-
__rsp_chan_t p; \
38-
logic p_valid; \
39-
logic q_ready; \
40-
} __rsp_t;
46+
typedef `GENERIC_REQRSP_RSP_STRUCT(__rsp_chan_t) __rsp_t;
4147

4248
`define REQRSP_TYPEDEF_ALL(__name, __addr_t, __data_t, __strb_t, __user_t) \
4349
`REQRSP_TYPEDEF_REQ_CHAN_T(__name``_req_chan_t, __addr_t, __data_t, __strb_t, __user_t) \
4450
`REQRSP_TYPEDEF_RSP_CHAN_T(__name``_rsp_chan_t, __data_t) \
4551
`REQRSP_TYPEDEF_REQ_T(__name``_req_t, __name``_req_chan_t) \
4652
`REQRSP_TYPEDEF_RSP_T(__name``_rsp_t, __name``_rsp_chan_t)
4753

54+
`define GENERIC_REQRSP_TYPEDEF_ALL(__name, __req_chan_t, __rsp_chan_t) \
55+
`REQRSP_TYPEDEF_REQ_T(__name``_req_t, __req_chan_t) \
56+
`REQRSP_TYPEDEF_RSP_T(__name``_rsp_t, __rsp_chan_t)
57+
4858
`endif
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2025 ETH Zurich and University of Bologna.
2+
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
3+
// SPDX-License-Identifier: SHL-0.51
4+
5+
// Author: Luca Colagrande <[email protected]>
6+
7+
`include "reqrsp_interface/typedef.svh"
8+
9+
/// Cut all combinatorial paths through a generic `reqrsp`-like interface.
10+
module generic_reqrsp_cut #(
11+
/// Request type.
12+
parameter type req_chan_t = logic,
13+
/// Response type.
14+
parameter type rsp_chan_t = logic,
15+
/// Bypass request channel.
16+
parameter bit BypassReq = 0,
17+
/// Bypass Response channel.
18+
parameter bit BypassRsp = 0,
19+
/// Derived parameters *Do not override*
20+
localparam type req_t = `GENERIC_REQRSP_REQ_STRUCT(req_chan_t),
21+
localparam type rsp_t = `GENERIC_REQRSP_RSP_STRUCT(rsp_chan_t)
22+
) (
23+
input logic clk_i,
24+
input logic rst_ni,
25+
input req_t slv_req_i,
26+
output rsp_t slv_rsp_o,
27+
output req_t mst_req_o,
28+
input rsp_t mst_rsp_i
29+
);
30+
31+
spill_register #(
32+
.T (req_chan_t),
33+
.Bypass(BypassReq)
34+
) i_spill_register_q (
35+
.clk_i,
36+
.rst_ni,
37+
.valid_i(slv_req_i.q_valid),
38+
.ready_o(slv_rsp_o.q_ready),
39+
.data_i (slv_req_i.q),
40+
.valid_o(mst_req_o.q_valid),
41+
.ready_i(mst_rsp_i.q_ready),
42+
.data_o (mst_req_o.q)
43+
);
44+
45+
spill_register #(
46+
.T (rsp_chan_t),
47+
.Bypass(BypassRsp)
48+
) i_spill_register_p (
49+
.clk_i,
50+
.rst_ni,
51+
.valid_i(mst_rsp_i.p_valid),
52+
.ready_o(mst_req_o.p_ready),
53+
.data_i (mst_rsp_i.p),
54+
.valid_o(slv_rsp_o.p_valid),
55+
.ready_i(slv_req_i.p_ready),
56+
.data_o (slv_rsp_o.p)
57+
);
58+
59+
endmodule

hw/reqrsp_interface/src/reqrsp_cut.sv

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,18 @@ module reqrsp_cut #(
3838

3939
`REQRSP_TYPEDEF_ALL(reqrsp, addr_t, data_t, strb_t, user_t)
4040

41-
spill_register #(
42-
.T (reqrsp_req_chan_t),
43-
.Bypass ( BypassReq )
44-
) i_spill_register_q (
45-
.clk_i,
46-
.rst_ni,
47-
.valid_i (slv_req_i.q_valid) ,
48-
.ready_o (slv_rsp_o.q_ready) ,
49-
.data_i (slv_req_i.q),
50-
.valid_o (mst_req_o.q_valid),
51-
.ready_i (mst_rsp_i.q_ready),
52-
.data_o (mst_req_o.q)
53-
);
54-
55-
spill_register #(
56-
.T (reqrsp_rsp_chan_t),
57-
.Bypass ( BypassRsp )
58-
) i_spill_register_p (
41+
generic_reqrsp_cut #(
42+
.req_chan_t(reqrsp_req_chan_t),
43+
.rsp_chan_t(reqrsp_rsp_chan_t),
44+
.BypassReq (BypassReq),
45+
.BypassRsp (BypassRsp)
46+
) i_generic_reqrsp_cut (
5947
.clk_i,
6048
.rst_ni,
61-
.valid_i (mst_rsp_i.p_valid) ,
62-
.ready_o (mst_req_o.p_ready) ,
63-
.data_i (mst_rsp_i.p),
64-
.valid_o (slv_rsp_o.p_valid),
65-
.ready_i (slv_req_i.p_ready),
66-
.data_o (slv_rsp_o.p)
49+
.slv_req_i (slv_req_i),
50+
.slv_rsp_o (slv_rsp_o),
51+
.mst_req_o (mst_req_o),
52+
.mst_rsp_i (mst_rsp_i)
6753
);
6854

6955
endmodule

0 commit comments

Comments
 (0)