../src/lowrisc_tlul_common_0.1/rtl/tlul_fifo_sync.sv Cov: 100%
1: // Copyright lowRISC contributors.
2: // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3: // SPDX-License-Identifier: Apache-2.0
4: //
5: // TL-UL fifo, used to add elasticity or an asynchronous clock crossing
6: // to an TL-UL bus. This instantiates two FIFOs, one for the request side,
7: // and one for the response side.
8:
9: module tlul_fifo_sync #(
10: parameter int unsigned ReqPass = 1'b1,
11: parameter int unsigned RspPass = 1'b1,
12: parameter int unsigned ReqDepth = 2,
13: parameter int unsigned RspDepth = 2,
14: parameter int unsigned SpareReqW = 1,
15: parameter int unsigned SpareRspW = 1
16: ) (
17: input clk_i,
18: input rst_ni,
19: input tlul_pkg::tl_h2d_t tl_h_i,
20: output tlul_pkg::tl_d2h_t tl_h_o,
21: output tlul_pkg::tl_h2d_t tl_d_o,
22: input tlul_pkg::tl_d2h_t tl_d_i,
23: input [SpareReqW-1:0] spare_req_i,
24: output [SpareReqW-1:0] spare_req_o,
25: input [SpareRspW-1:0] spare_rsp_i,
26: output [SpareRspW-1:0] spare_rsp_o
27: );
28:
29: // Put everything on the request side into one FIFO
30: localparam int unsigned REQFIFO_WIDTH = $bits(tlul_pkg::tl_h2d_t) -2 + SpareReqW;
31:
32: prim_fifo_sync #(.Width(REQFIFO_WIDTH), .Pass(ReqPass), .Depth(ReqDepth)) reqfifo (
33: .clk_i,
34: .rst_ni,
35: .clr_i (1'b0 ),
36: .wvalid (tl_h_i.a_valid),
37: .wready (tl_h_o.a_ready),
38: .wdata ({tl_h_i.a_opcode ,
39: tl_h_i.a_param ,
40: tl_h_i.a_size ,
41: tl_h_i.a_source ,
42: tl_h_i.a_address,
43: tl_h_i.a_mask ,
44: tl_h_i.a_data ,
45: tl_h_i.a_user ,
46: spare_req_i}),
47: .depth (),
48: .rvalid (tl_d_o.a_valid),
49: .rready (tl_d_i.a_ready),
50: .rdata ({tl_d_o.a_opcode ,
51: tl_d_o.a_param ,
52: tl_d_o.a_size ,
53: tl_d_o.a_source ,
54: tl_d_o.a_address,
55: tl_d_o.a_mask ,
56: tl_d_o.a_data ,
57: tl_d_o.a_user ,
58: spare_req_o}));
59:
60: // Put everything on the response side into the other FIFO
61:
62: localparam int unsigned RSPFIFO_WIDTH = $bits(tlul_pkg::tl_d2h_t) -2 + SpareRspW;
63:
64: prim_fifo_sync #(.Width(RSPFIFO_WIDTH), .Pass(RspPass), .Depth(RspDepth)) rspfifo (
65: .clk_i,
66: .rst_ni,
67: .clr_i (1'b0 ),
68: .wvalid (tl_d_i.d_valid),
69: .wready (tl_d_o.d_ready),
70: .wdata ({tl_d_i.d_opcode,
71: tl_d_i.d_param ,
72: tl_d_i.d_size ,
73: tl_d_i.d_source,
74: tl_d_i.d_sink ,
75: (tl_d_i.d_opcode == tlul_pkg::AccessAckData) ? tl_d_i.d_data :
76: {top_pkg::TL_DW{1'b0}} ,
77: tl_d_i.d_user ,
78: tl_d_i.d_error ,
79: spare_rsp_i}),
80: .depth (),
81: .rvalid (tl_h_o.d_valid),
82: .rready (tl_h_i.d_ready),
83: .rdata ({tl_h_o.d_opcode,
84: tl_h_o.d_param ,
85: tl_h_o.d_size ,
86: tl_h_o.d_source,
87: tl_h_o.d_sink ,
88: tl_h_o.d_data ,
89: tl_h_o.d_user ,
90: tl_h_o.d_error ,
91: spare_rsp_o}));
92:
93: endmodule
94: