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