../src/lowrisc_tlul_common_0.1/rtl/tlul_fifo_async.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: `include "prim_assert.sv"
  10: 
  11: module tlul_fifo_async #(
  12:   parameter int unsigned ReqDepth = 3,
  13:   parameter int unsigned RspDepth = 3
  14: ) (
  15:   input                      clk_h_i,
  16:   input                      rst_h_ni,
  17:   input                      clk_d_i,
  18:   input                      rst_d_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: );
  24: 
  25:   // Put everything on the request side into one FIFO
  26:   localparam int unsigned REQFIFO_WIDTH = $bits(tlul_pkg::tl_h2d_t)-2;
  27: 
  28:   prim_fifo_async #(.Width(REQFIFO_WIDTH), .Depth(ReqDepth)) reqfifo (
  29:     .clk_wr_i      (clk_h_i),
  30:     .rst_wr_ni     (rst_h_ni),
  31:     .clk_rd_i      (clk_d_i),
  32:     .rst_rd_ni     (rst_d_ni),
  33:     .wvalid        (tl_h_i.a_valid),
  34:     .wready        (tl_h_o.a_ready),
  35:     .wdata         ({tl_h_i.a_opcode ,
  36:                      tl_h_i.a_param  ,
  37:                      tl_h_i.a_size   ,
  38:                      tl_h_i.a_source ,
  39:                      tl_h_i.a_address,
  40:                      tl_h_i.a_mask   ,
  41:                      tl_h_i.a_data   ,
  42:                      tl_h_i.a_user   }),
  43:     .rvalid        (tl_d_o.a_valid),
  44:     .rready        (tl_d_i.a_ready),
  45:     .rdata         ({tl_d_o.a_opcode ,
  46:                      tl_d_o.a_param  ,
  47:                      tl_d_o.a_size   ,
  48:                      tl_d_o.a_source ,
  49:                      tl_d_o.a_address,
  50:                      tl_d_o.a_mask   ,
  51:                      tl_d_o.a_data   ,
  52:                      tl_d_o.a_user   }),
  53:     .wdepth        (),
  54:     .rdepth        ()
  55:   );
  56: 
  57:   // Put everything on the response side into the other FIFO
  58: 
  59:   localparam int unsigned RSPFIFO_WIDTH = $bits(tlul_pkg::tl_d2h_t) -2;
  60: 
  61:   prim_fifo_async #(.Width(RSPFIFO_WIDTH), .Depth(RspDepth)) rspfifo (
  62:     .clk_wr_i      (clk_d_i),
  63:     .rst_wr_ni     (rst_d_ni),
  64:     .clk_rd_i      (clk_h_i),
  65:     .rst_rd_ni     (rst_h_ni),
  66:     .wvalid        (tl_d_i.d_valid),
  67:     .wready        (tl_d_o.d_ready),
  68:     .wdata         ({tl_d_i.d_opcode,
  69:                      tl_d_i.d_param ,
  70:                      tl_d_i.d_size  ,
  71:                      tl_d_i.d_source,
  72:                      tl_d_i.d_sink  ,
  73:                      tl_d_i.d_data  ,
  74:                      tl_d_i.d_user  ,
  75:                      tl_d_i.d_error }),
  76:     .rvalid        (tl_h_o.d_valid),
  77:     .rready        (tl_h_i.d_ready),
  78:     .rdata         ({tl_h_o.d_opcode,
  79:                      tl_h_o.d_param ,
  80:                      tl_h_o.d_size  ,
  81:                      tl_h_o.d_source,
  82:                      tl_h_o.d_sink  ,
  83:                      tl_h_o.d_data  ,
  84:                      tl_h_o.d_user  ,
  85:                      tl_h_o.d_error }),
  86:     .wdepth        (),
  87:     .rdepth        ()
  88:   );
  89: 
  90:   ////////////////
  91:   // Assertions //
  92:   ////////////////
  93:   `ASSERT_INIT(DepthGTE3_A, ReqDepth >= 3 && RspDepth >= 3)
  94: 
  95: endmodule
  96: