data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/rfnoc_block_axi_ram_fifo.v
 line:428: before: "if"
1: b'%Error: data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/rfnoc_block_axi_ram_fifo.v:183: Cannot find include file: axi_ram_fifo_regs.vh\n  `include "axi_ram_fifo_regs.vh" \n           ^~~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo,data/full_repos/permissive/214858095/axi_ram_fifo_regs.vh\n             data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo,data/full_repos/permissive/214858095/axi_ram_fifo_regs.vh.v\n             data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo,data/full_repos/permissive/214858095/axi_ram_fifo_regs.vh.sv\n             axi_ram_fifo_regs.vh\n             axi_ram_fifo_regs.vh.v\n             axi_ram_fifo_regs.vh.sv\n             obj_dir/axi_ram_fifo_regs.vh\n             obj_dir/axi_ram_fifo_regs.vh.v\n             obj_dir/axi_ram_fifo_regs.vh.sv\n%Error: data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/rfnoc_block_axi_ram_fifo.v:200: syntax error, unexpected \'(\', expecting IDENTIFIER\n    CHDR_W_must_be_a_multiple_of_MEM_DATA_W_or_vice_versa();\n                                                          ^\n%Error: data/full_repos/permissive/214858095/FPGA_Exploration/spartan6/B205mini/ISE_Project/lib/rfnoc/blocks/rfnoc_block_axi_ram_fifo/rfnoc_block_axi_ram_fifo.v:203: syntax error, unexpected \'(\', expecting IDENTIFIER\n    MEM_ADDR_W_must_be_greater_than_AWIDTH();\n                                           ^\n%Error: Exiting due to 3 error(s)\n'
module rfnoc_block_axi_ram_fifo #(
  parameter                            THIS_PORTID    = 0,
  parameter                            CHDR_W         = 64,
  parameter                            NUM_PORTS      = 1,
  parameter                            MTU            = 10,
  parameter                            MEM_DATA_W     = CHDR_W,
  parameter                            MEM_ADDR_W     = 32,
  parameter                            AWIDTH         = 32,
  parameter [NUM_PORTS*MEM_ADDR_W-1:0] FIFO_ADDR_BASE = {NUM_PORTS{ {MEM_ADDR_W{1'b0}} }},
  parameter [NUM_PORTS*MEM_ADDR_W-1:0] FIFO_ADDR_MASK = {NUM_PORTS{ {(MEM_ADDR_W-$clog2(NUM_PORTS)){1'b1}} }},
  parameter [        NUM_PORTS*32-1:0] BURST_TIMEOUT  = {NUM_PORTS{ 32'd256 }},
  parameter                            IN_FIFO_SIZE   = 11,
  parameter                            OUT_FIFO_SIZE  = 11,
  parameter                            BIST           = 1,
  parameter                            MEM_CLK_RATE   = 200e6
) (




  input wire rfnoc_chdr_clk,


  input  wire [NUM_PORTS*CHDR_W-1:0] s_rfnoc_chdr_tdata,
  input  wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tlast,
  input  wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tvalid,
  output wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tready,


  output wire [NUM_PORTS*CHDR_W-1:0] m_rfnoc_chdr_tdata,
  output wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tlast,
  output wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tvalid,
  input  wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tready,


  input  wire [511:0] rfnoc_core_config,
  output wire [511:0] rfnoc_core_status,






  input wire rfnoc_ctrl_clk,


  input  wire [31:0] s_rfnoc_ctrl_tdata,
  input  wire        s_rfnoc_ctrl_tlast,
  input  wire        s_rfnoc_ctrl_tvalid,
  output wire        s_rfnoc_ctrl_tready,


  output wire [31:0] m_rfnoc_ctrl_tdata,
  output wire        m_rfnoc_ctrl_tlast,
  output wire        m_rfnoc_ctrl_tvalid,
  input  wire        m_rfnoc_ctrl_tready,







  input wire mem_clk,
  input wire axi_rst,


  output wire [         NUM_PORTS*1-1:0] m_axi_awid,
  output wire [    NUM_PORTS*AWIDTH-1:0] m_axi_awaddr,
  output wire [         NUM_PORTS*8-1:0] m_axi_awlen,
  output wire [         NUM_PORTS*3-1:0] m_axi_awsize,
  output wire [         NUM_PORTS*2-1:0] m_axi_awburst,
  output wire [         NUM_PORTS*1-1:0] m_axi_awlock,
  output wire [         NUM_PORTS*4-1:0] m_axi_awcache,
  output wire [         NUM_PORTS*3-1:0] m_axi_awprot,
  output wire [         NUM_PORTS*4-1:0] m_axi_awqos,
  output wire [         NUM_PORTS*4-1:0] m_axi_awregion,
  output wire [         NUM_PORTS*1-1:0] m_axi_awuser,
  output wire [         NUM_PORTS*1-1:0] m_axi_awvalid,
  input  wire [         NUM_PORTS*1-1:0] m_axi_awready,
  

  output wire [  NUM_PORTS*MEM_DATA_W-1:0] m_axi_wdata,
  output wire [NUM_PORTS*MEM_DATA_W/8-1:0] m_axi_wstrb,
  output wire [           NUM_PORTS*1-1:0] m_axi_wlast,
  output wire [           NUM_PORTS*1-1:0] m_axi_wuser,
  output wire [           NUM_PORTS*1-1:0] m_axi_wvalid,
  input  wire [           NUM_PORTS*1-1:0] m_axi_wready,
  

  input  wire [         NUM_PORTS*1-1:0] m_axi_bid,
  input  wire [         NUM_PORTS*2-1:0] m_axi_bresp,
  input  wire [         NUM_PORTS*1-1:0] m_axi_buser,
  input  wire [         NUM_PORTS*1-1:0] m_axi_bvalid,
  output wire [         NUM_PORTS*1-1:0] m_axi_bready,
  

  output wire [         NUM_PORTS*1-1:0] m_axi_arid,
  output wire [    NUM_PORTS*AWIDTH-1:0] m_axi_araddr,
  output wire [         NUM_PORTS*8-1:0] m_axi_arlen,
  output wire [         NUM_PORTS*3-1:0] m_axi_arsize,
  output wire [         NUM_PORTS*2-1:0] m_axi_arburst,
  output wire [         NUM_PORTS*1-1:0] m_axi_arlock,
  output wire [         NUM_PORTS*4-1:0] m_axi_arcache,
  output wire [         NUM_PORTS*3-1:0] m_axi_arprot,
  output wire [         NUM_PORTS*4-1:0] m_axi_arqos,
  output wire [         NUM_PORTS*4-1:0] m_axi_arregion,
  output wire [         NUM_PORTS*1-1:0] m_axi_aruser,
  output wire [         NUM_PORTS*1-1:0] m_axi_arvalid,
  input  wire [         NUM_PORTS*1-1:0] m_axi_arready,
  

  input  wire [         NUM_PORTS*1-1:0] m_axi_rid,
  input  wire [NUM_PORTS*MEM_DATA_W-1:0] m_axi_rdata,
  input  wire [         NUM_PORTS*2-1:0] m_axi_rresp,
  input  wire [         NUM_PORTS*1-1:0] m_axi_rlast,
  input  wire [         NUM_PORTS*1-1:0] m_axi_ruser,
  input  wire [         NUM_PORTS*1-1:0] m_axi_rvalid,
  output wire [         NUM_PORTS*1-1:0] m_axi_rready
);

  `include "axi_ram_fifo_regs.vh"




  localparam KEEP_W = (MEM_DATA_W/CHDR_W) > 1 ? (MEM_DATA_W/CHDR_W) : 1;



  localparam WORD_W = (MEM_DATA_W < CHDR_W) ? MEM_DATA_W : CHDR_W;





  
  if (CHDR_W % MEM_DATA_W != 0 && MEM_DATA_W % CHDR_W != 0)
    CHDR_W_must_be_a_multiple_of_MEM_DATA_W_or_vice_versa();

  if (MEM_ADDR_W > AWIDTH)
    MEM_ADDR_W_must_be_greater_than_AWIDTH();






  wire mem_rst;

  wire        ctrlport_req_wr;
  wire        ctrlport_req_rd;
  wire [19:0] ctrlport_req_addr;
  wire [31:0] ctrlport_req_data;
  wire        ctrlport_resp_ack;
  wire [31:0] ctrlport_resp_data;

  wire axis_chdr_clk;
  wire axis_chdr_rst;

  wire [NUM_PORTS*CHDR_W-1:0] m_axis_chdr_tdata;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tlast;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tvalid;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tready;

  wire [NUM_PORTS*CHDR_W-1:0] s_axis_chdr_tdata;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tlast;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tvalid;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tready;

  noc_shell_axi_ram_fifo #(
    .THIS_PORTID (THIS_PORTID),
    .CHDR_W      (CHDR_W),
    .NUM_PORTS   (NUM_PORTS),
    .MTU         (MTU)
  ) noc_shell_axi_ram_fifo_i (
    .rfnoc_chdr_clk       (rfnoc_chdr_clk),
    .rfnoc_ctrl_clk       (rfnoc_ctrl_clk),
    .mem_clk              (mem_clk),
    .rfnoc_chdr_rst       (),
    .rfnoc_ctrl_rst       (),
    .mem_rst              (mem_rst),
    .rfnoc_core_config    (rfnoc_core_config),
    .rfnoc_core_status    (rfnoc_core_status),
    .s_rfnoc_chdr_tdata   (s_rfnoc_chdr_tdata),
    .s_rfnoc_chdr_tlast   (s_rfnoc_chdr_tlast),
    .s_rfnoc_chdr_tvalid  (s_rfnoc_chdr_tvalid),
    .s_rfnoc_chdr_tready  (s_rfnoc_chdr_tready),
    .m_rfnoc_chdr_tdata   (m_rfnoc_chdr_tdata),
    .m_rfnoc_chdr_tlast   (m_rfnoc_chdr_tlast),
    .m_rfnoc_chdr_tvalid  (m_rfnoc_chdr_tvalid),
    .m_rfnoc_chdr_tready  (m_rfnoc_chdr_tready),
    .s_rfnoc_ctrl_tdata   (s_rfnoc_ctrl_tdata),
    .s_rfnoc_ctrl_tlast   (s_rfnoc_ctrl_tlast),
    .s_rfnoc_ctrl_tvalid  (s_rfnoc_ctrl_tvalid),
    .s_rfnoc_ctrl_tready  (s_rfnoc_ctrl_tready),
    .m_rfnoc_ctrl_tdata   (m_rfnoc_ctrl_tdata),
    .m_rfnoc_ctrl_tlast   (m_rfnoc_ctrl_tlast),
    .m_rfnoc_ctrl_tvalid  (m_rfnoc_ctrl_tvalid),
    .m_rfnoc_ctrl_tready  (m_rfnoc_ctrl_tready),
    .ctrlport_clk         (),
    .ctrlport_rst         (),
    .m_ctrlport_req_wr    (ctrlport_req_wr),
    .m_ctrlport_req_rd    (ctrlport_req_rd),
    .m_ctrlport_req_addr  (ctrlport_req_addr),
    .m_ctrlport_req_data  (ctrlport_req_data),
    .m_ctrlport_resp_ack  (ctrlport_resp_ack),
    .m_ctrlport_resp_data (ctrlport_resp_data),
    .axis_chdr_clk        (axis_chdr_clk),
    .axis_chdr_rst        (axis_chdr_rst),
    .m_in_chdr_tdata      (m_axis_chdr_tdata),
    .m_in_chdr_tlast      (m_axis_chdr_tlast),
    .m_in_chdr_tvalid     (m_axis_chdr_tvalid),
    .m_in_chdr_tready     (m_axis_chdr_tready),
    .s_out_chdr_tdata     (s_axis_chdr_tdata),
    .s_out_chdr_tlast     (s_axis_chdr_tlast),
    .s_out_chdr_tvalid    (s_axis_chdr_tvalid),
    .s_out_chdr_tready    (s_axis_chdr_tready)
  );

  reg  mem_rst_block;


  always @(posedge mem_clk) begin
    mem_rst_block <= axi_rst | mem_rst;
  end






  wire [   NUM_PORTS-1:0] m_ctrlport_req_wr;
  wire [   NUM_PORTS-1:0] m_ctrlport_req_rd;
  wire [20*NUM_PORTS-1:0] m_ctrlport_req_addr;
  wire [32*NUM_PORTS-1:0] m_ctrlport_req_data;
  wire [   NUM_PORTS-1:0] m_ctrlport_resp_ack;
  wire [32*NUM_PORTS-1:0] m_ctrlport_resp_data;

  ctrlport_decoder #(
    .NUM_SLAVES   (NUM_PORTS),
    .BASE_ADDR    (0),
    .SLAVE_ADDR_W (RAM_FIFO_ADDR_W)
  ) ctrlport_decoder_i (
    .ctrlport_clk            (mem_clk),
    .ctrlport_rst            (mem_rst_block),
    .s_ctrlport_req_wr       (ctrlport_req_wr),
    .s_ctrlport_req_rd       (ctrlport_req_rd),
    .s_ctrlport_req_addr     (ctrlport_req_addr),
    .s_ctrlport_req_data     (ctrlport_req_data),
    .s_ctrlport_req_byte_en  (4'b1111),
    .s_ctrlport_req_has_time (1'b0),
    .s_ctrlport_req_time     (64'b0),
    .s_ctrlport_resp_ack     (ctrlport_resp_ack),
    .s_ctrlport_resp_status  (),
    .s_ctrlport_resp_data    (ctrlport_resp_data),
    .m_ctrlport_req_wr       (m_ctrlport_req_wr),
    .m_ctrlport_req_rd       (m_ctrlport_req_rd),
    .m_ctrlport_req_addr     (m_ctrlport_req_addr),
    .m_ctrlport_req_data     (m_ctrlport_req_data),
    .m_ctrlport_req_byte_en  (),
    .m_ctrlport_req_has_time (),
    .m_ctrlport_req_time     (),
    .m_ctrlport_resp_ack     (m_ctrlport_resp_ack),
    .m_ctrlport_resp_status  ({NUM_PORTS*2{1'b0}}),
    .m_ctrlport_resp_data    (m_ctrlport_resp_data)
  );






  genvar i;
  for (i = 0; i < NUM_PORTS; i = i + 1) begin : gen_ram_fifos

    wire [MEM_DATA_W-1:0] m_axis_mem_tdata;
    wire [    KEEP_W-1:0] m_axis_mem_tkeep;
    wire                  m_axis_mem_tlast;
    wire                  m_axis_mem_tvalid;
    wire                  m_axis_mem_tready;

    wire [MEM_DATA_W-1:0] s_axis_mem_tdata;
    wire [    KEEP_W-1:0] s_axis_mem_tkeep;
    wire                  s_axis_mem_tlast;
    wire                  s_axis_mem_tvalid;
    wire                  s_axis_mem_tready;










    axis_width_conv #(
      .WORD_W    (WORD_W),
      .IN_WORDS  (CHDR_W/WORD_W),
      .OUT_WORDS (MEM_DATA_W/WORD_W),
      .SYNC_CLKS (0),
      .PIPELINE  ("NONE")
    ) axis_width_conv_to_mem_i (
      .s_axis_aclk   (axis_chdr_clk),
      .s_axis_rst    (axis_chdr_rst),
      .s_axis_tdata  (m_axis_chdr_tdata[i*CHDR_W +: CHDR_W]),
      .s_axis_tkeep  ({CHDR_W/WORD_W{1'b1}}),
      .s_axis_tlast  (m_axis_chdr_tlast[i]),
      .s_axis_tvalid (m_axis_chdr_tvalid[i]),
      .s_axis_tready (m_axis_chdr_tready[i]),
      .m_axis_aclk   (mem_clk),
      .m_axis_rst    (mem_rst),
      .m_axis_tdata  (m_axis_mem_tdata),
      .m_axis_tkeep  (m_axis_mem_tkeep),
      .m_axis_tlast  (m_axis_mem_tlast),
      .m_axis_tvalid (m_axis_mem_tvalid),
      .m_axis_tready (m_axis_mem_tready)
    );

    axis_width_conv #(
      .WORD_W    (WORD_W),
      .IN_WORDS  (MEM_DATA_W/WORD_W),
      .OUT_WORDS (CHDR_W/WORD_W),
      .SYNC_CLKS (0),
      .PIPELINE  ("NONE")
    ) axis_width_conv_to_chdr_i (
      .s_axis_aclk   (mem_clk),
      .s_axis_rst    (mem_rst),
      .s_axis_tdata  (s_axis_mem_tdata),
      .s_axis_tkeep  (s_axis_mem_tkeep),
      .s_axis_tlast  (s_axis_mem_tlast),
      .s_axis_tvalid (s_axis_mem_tvalid),
      .s_axis_tready (s_axis_mem_tready),
      .m_axis_aclk   (axis_chdr_clk),
      .m_axis_rst    (axis_chdr_rst),
      .m_axis_tdata  (s_axis_chdr_tdata[i*CHDR_W +: CHDR_W]),
      .m_axis_tkeep  (),
      .m_axis_tlast  (s_axis_chdr_tlast[i]),
      .m_axis_tvalid (s_axis_chdr_tvalid[i]),
      .m_axis_tready (s_axis_chdr_tready[i])
    );





    wire [MEM_ADDR_W-1:0] m_axi_awaddr_int;
    wire [MEM_ADDR_W-1:0] m_axi_araddr_int;


    assign m_axi_awaddr[(AWIDTH*(i+1))-1:AWIDTH*i] = m_axi_awaddr_int;
    assign m_axi_araddr[(AWIDTH*(i+1))-1:AWIDTH*i] = m_axi_araddr_int;

    axi_ram_fifo #(
      .MEM_ADDR_W     (MEM_ADDR_W),
      .MEM_DATA_W     (MEM_DATA_W),
      .KEEP_W         (KEEP_W),
      .FIFO_ADDR_BASE (FIFO_ADDR_BASE[MEM_ADDR_W*i +: MEM_ADDR_W]),
      .FIFO_ADDR_MASK (FIFO_ADDR_MASK[MEM_ADDR_W*i +: MEM_ADDR_W]),
      .BURST_TIMEOUT  (BURST_TIMEOUT[32*i +: 32]),
      .BIST           (BIST),
      .CLK_RATE       (MEM_CLK_RATE),
      .IN_FIFO_SIZE   (IN_FIFO_SIZE),
      .OUT_FIFO_SIZE  (OUT_FIFO_SIZE)
    ) axi_ram_fifo_i (

      .clk(mem_clk),
      .rst(mem_rst_block),





      .s_ctrlport_req_wr      (m_ctrlport_req_wr[i]),
      .s_ctrlport_req_rd      (m_ctrlport_req_rd[i]),
      .s_ctrlport_req_addr    (m_ctrlport_req_addr[20*i +: 20]),
      .s_ctrlport_req_data    (m_ctrlport_req_data[32*i +: 32]),
      .s_ctrlport_resp_ack    (m_ctrlport_resp_ack[i]),
      .s_ctrlport_resp_data   (m_ctrlport_resp_data[32*i +: 32]),






      .s_tdata        (m_axis_mem_tdata),
      .s_tkeep        (m_axis_mem_tkeep),
      .s_tlast        (m_axis_mem_tlast),
      .s_tvalid       (m_axis_mem_tvalid),
      .s_tready       (m_axis_mem_tready),


      .m_tdata        (s_axis_mem_tdata),
      .m_tkeep        (s_axis_mem_tkeep),
      .m_tlast        (s_axis_mem_tlast),
      .m_tvalid       (s_axis_mem_tvalid),
      .m_tready       (s_axis_mem_tready),






      .m_axi_awid     (m_axi_awid[i]),
      .m_axi_awaddr   (m_axi_awaddr_int),
      .m_axi_awlen    (m_axi_awlen[(8*(i+1))-1:8*i]),
      .m_axi_awsize   (m_axi_awsize[(3*(i+1))-1:3*i]),
      .m_axi_awburst  (m_axi_awburst[(2*(i+1))-1:2*i]),
      .m_axi_awlock   (m_axi_awlock[i]),
      .m_axi_awcache  (m_axi_awcache[(4*(i+1))-1:4*i]),
      .m_axi_awprot   (m_axi_awprot[(3*(i+1))-1:3*i]),
      .m_axi_awqos    (m_axi_awqos[(4*(i+1))-1:4*i]),
      .m_axi_awregion (m_axi_awregion[(4*(i+1))-1:4*i]),
      .m_axi_awuser   (m_axi_awuser[i]),
      .m_axi_awvalid  (m_axi_awvalid[i]),
      .m_axi_awready  (m_axi_awready[i]),


      .m_axi_wdata    (m_axi_wdata[(MEM_DATA_W*(i+1))-1:MEM_DATA_W*i]),
      .m_axi_wstrb    (m_axi_wstrb[((MEM_DATA_W/8)*(i+1))-1:(MEM_DATA_W/8)*i]),
      .m_axi_wlast    (m_axi_wlast[i]),
      .m_axi_wuser    (m_axi_wuser[i]),
      .m_axi_wvalid   (m_axi_wvalid[i]),
      .m_axi_wready   (m_axi_wready[i]),


      .m_axi_bid      (m_axi_bid[i]),
      .m_axi_bresp    (m_axi_bresp[(2*(i+1))-1:2*i]),
      .m_axi_buser    (m_axi_buser[i]),
      .m_axi_bvalid   (m_axi_bvalid[i]),
      .m_axi_bready   (m_axi_bready[i]),


      .m_axi_arid     (m_axi_arid[i]),
      .m_axi_araddr   (m_axi_araddr_int),
      .m_axi_arlen    (m_axi_arlen[(8*(i+1))-1:8*i]),
      .m_axi_arsize   (m_axi_arsize[(3*(i+1))-1:3*i]),
      .m_axi_arburst  (m_axi_arburst[(2*(i+1))-1:2*i]),
      .m_axi_arlock   (m_axi_arlock[i]),
      .m_axi_arcache  (m_axi_arcache[(4*(i+1))-1:4*i]),
      .m_axi_arprot   (m_axi_arprot[(3*(i+1))-1:3*i]),
      .m_axi_arqos    (m_axi_arqos[(4*(i+1))-1:4*i]),
      .m_axi_arregion (m_axi_arregion[(4*(i+1))-1:4*i]),
      .m_axi_aruser   (m_axi_aruser[i]),
      .m_axi_arvalid  (m_axi_arvalid[i]),
      .m_axi_arready  (m_axi_arready[i]),


      .m_axi_rid      (m_axi_rid[i]),
      .m_axi_rdata    (m_axi_rdata[(MEM_DATA_W*(i+1))-1:MEM_DATA_W*i]),
      .m_axi_rresp    (m_axi_rresp[(2*(i+1))-1:2*i]),
      .m_axi_rlast    (m_axi_rlast[i]),
      .m_axi_ruser    (m_axi_ruser[i]),
      .m_axi_rvalid   (m_axi_rvalid[i]),
      .m_axi_rready   (m_axi_rready[i])
    );

  end

endmodule
module rfnoc_block_axi_ram_fifo #(
  parameter                            THIS_PORTID    = 0,
  parameter                            CHDR_W         = 64,
  parameter                            NUM_PORTS      = 1,
  parameter                            MTU            = 10,
  parameter                            MEM_DATA_W     = CHDR_W,
  parameter                            MEM_ADDR_W     = 32,
  parameter                            AWIDTH         = 32,
  parameter [NUM_PORTS*MEM_ADDR_W-1:0] FIFO_ADDR_BASE = {NUM_PORTS{ {MEM_ADDR_W{1'b0}} }},
  parameter [NUM_PORTS*MEM_ADDR_W-1:0] FIFO_ADDR_MASK = {NUM_PORTS{ {(MEM_ADDR_W-$clog2(NUM_PORTS)){1'b1}} }},
  parameter [        NUM_PORTS*32-1:0] BURST_TIMEOUT  = {NUM_PORTS{ 32'd256 }},
  parameter                            IN_FIFO_SIZE   = 11,
  parameter                            OUT_FIFO_SIZE  = 11,
  parameter                            BIST           = 1,
  parameter                            MEM_CLK_RATE   = 200e6
) (




  input wire rfnoc_chdr_clk,


  input  wire [NUM_PORTS*CHDR_W-1:0] s_rfnoc_chdr_tdata,
  input  wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tlast,
  input  wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tvalid,
  output wire [       NUM_PORTS-1:0] s_rfnoc_chdr_tready,


  output wire [NUM_PORTS*CHDR_W-1:0] m_rfnoc_chdr_tdata,
  output wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tlast,
  output wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tvalid,
  input  wire [       NUM_PORTS-1:0] m_rfnoc_chdr_tready,


  input  wire [511:0] rfnoc_core_config,
  output wire [511:0] rfnoc_core_status,






  input wire rfnoc_ctrl_clk,


  input  wire [31:0] s_rfnoc_ctrl_tdata,
  input  wire        s_rfnoc_ctrl_tlast,
  input  wire        s_rfnoc_ctrl_tvalid,
  output wire        s_rfnoc_ctrl_tready,


  output wire [31:0] m_rfnoc_ctrl_tdata,
  output wire        m_rfnoc_ctrl_tlast,
  output wire        m_rfnoc_ctrl_tvalid,
  input  wire        m_rfnoc_ctrl_tready,







  input wire mem_clk,
  input wire axi_rst,


  output wire [         NUM_PORTS*1-1:0] m_axi_awid,
  output wire [    NUM_PORTS*AWIDTH-1:0] m_axi_awaddr,
  output wire [         NUM_PORTS*8-1:0] m_axi_awlen,
  output wire [         NUM_PORTS*3-1:0] m_axi_awsize,
  output wire [         NUM_PORTS*2-1:0] m_axi_awburst,
  output wire [         NUM_PORTS*1-1:0] m_axi_awlock,
  output wire [         NUM_PORTS*4-1:0] m_axi_awcache,
  output wire [         NUM_PORTS*3-1:0] m_axi_awprot,
  output wire [         NUM_PORTS*4-1:0] m_axi_awqos,
  output wire [         NUM_PORTS*4-1:0] m_axi_awregion,
  output wire [         NUM_PORTS*1-1:0] m_axi_awuser,
  output wire [         NUM_PORTS*1-1:0] m_axi_awvalid,
  input  wire [         NUM_PORTS*1-1:0] m_axi_awready,
  

  output wire [  NUM_PORTS*MEM_DATA_W-1:0] m_axi_wdata,
  output wire [NUM_PORTS*MEM_DATA_W/8-1:0] m_axi_wstrb,
  output wire [           NUM_PORTS*1-1:0] m_axi_wlast,
  output wire [           NUM_PORTS*1-1:0] m_axi_wuser,
  output wire [           NUM_PORTS*1-1:0] m_axi_wvalid,
  input  wire [           NUM_PORTS*1-1:0] m_axi_wready,
  

  input  wire [         NUM_PORTS*1-1:0] m_axi_bid,
  input  wire [         NUM_PORTS*2-1:0] m_axi_bresp,
  input  wire [         NUM_PORTS*1-1:0] m_axi_buser,
  input  wire [         NUM_PORTS*1-1:0] m_axi_bvalid,
  output wire [         NUM_PORTS*1-1:0] m_axi_bready,
  

  output wire [         NUM_PORTS*1-1:0] m_axi_arid,
  output wire [    NUM_PORTS*AWIDTH-1:0] m_axi_araddr,
  output wire [         NUM_PORTS*8-1:0] m_axi_arlen,
  output wire [         NUM_PORTS*3-1:0] m_axi_arsize,
  output wire [         NUM_PORTS*2-1:0] m_axi_arburst,
  output wire [         NUM_PORTS*1-1:0] m_axi_arlock,
  output wire [         NUM_PORTS*4-1:0] m_axi_arcache,
  output wire [         NUM_PORTS*3-1:0] m_axi_arprot,
  output wire [         NUM_PORTS*4-1:0] m_axi_arqos,
  output wire [         NUM_PORTS*4-1:0] m_axi_arregion,
  output wire [         NUM_PORTS*1-1:0] m_axi_aruser,
  output wire [         NUM_PORTS*1-1:0] m_axi_arvalid,
  input  wire [         NUM_PORTS*1-1:0] m_axi_arready,
  

  input  wire [         NUM_PORTS*1-1:0] m_axi_rid,
  input  wire [NUM_PORTS*MEM_DATA_W-1:0] m_axi_rdata,
  input  wire [         NUM_PORTS*2-1:0] m_axi_rresp,
  input  wire [         NUM_PORTS*1-1:0] m_axi_rlast,
  input  wire [         NUM_PORTS*1-1:0] m_axi_ruser,
  input  wire [         NUM_PORTS*1-1:0] m_axi_rvalid,
  output wire [         NUM_PORTS*1-1:0] m_axi_rready
);


  `include "axi_ram_fifo_regs.vh"




  localparam KEEP_W = (MEM_DATA_W/CHDR_W) > 1 ? (MEM_DATA_W/CHDR_W) : 1;



  localparam WORD_W = (MEM_DATA_W < CHDR_W) ? MEM_DATA_W : CHDR_W;





  
  if (CHDR_W % MEM_DATA_W != 0 && MEM_DATA_W % CHDR_W != 0)
    CHDR_W_must_be_a_multiple_of_MEM_DATA_W_or_vice_versa();

  if (MEM_ADDR_W > AWIDTH)
    MEM_ADDR_W_must_be_greater_than_AWIDTH();






  wire mem_rst;

  wire        ctrlport_req_wr;
  wire        ctrlport_req_rd;
  wire [19:0] ctrlport_req_addr;
  wire [31:0] ctrlport_req_data;
  wire        ctrlport_resp_ack;
  wire [31:0] ctrlport_resp_data;

  wire axis_chdr_clk;
  wire axis_chdr_rst;

  wire [NUM_PORTS*CHDR_W-1:0] m_axis_chdr_tdata;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tlast;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tvalid;
  wire [       NUM_PORTS-1:0] m_axis_chdr_tready;

  wire [NUM_PORTS*CHDR_W-1:0] s_axis_chdr_tdata;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tlast;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tvalid;
  wire [       NUM_PORTS-1:0] s_axis_chdr_tready;

  noc_shell_axi_ram_fifo #(
    .THIS_PORTID (THIS_PORTID),
    .CHDR_W      (CHDR_W),
    .NUM_PORTS   (NUM_PORTS),
    .MTU         (MTU)
  ) noc_shell_axi_ram_fifo_i (
    .rfnoc_chdr_clk       (rfnoc_chdr_clk),
    .rfnoc_ctrl_clk       (rfnoc_ctrl_clk),
    .mem_clk              (mem_clk),
    .rfnoc_chdr_rst       (),
    .rfnoc_ctrl_rst       (),
    .mem_rst              (mem_rst),
    .rfnoc_core_config    (rfnoc_core_config),
    .rfnoc_core_status    (rfnoc_core_status),
    .s_rfnoc_chdr_tdata   (s_rfnoc_chdr_tdata),
    .s_rfnoc_chdr_tlast   (s_rfnoc_chdr_tlast),
    .s_rfnoc_chdr_tvalid  (s_rfnoc_chdr_tvalid),
    .s_rfnoc_chdr_tready  (s_rfnoc_chdr_tready),
    .m_rfnoc_chdr_tdata   (m_rfnoc_chdr_tdata),
    .m_rfnoc_chdr_tlast   (m_rfnoc_chdr_tlast),
    .m_rfnoc_chdr_tvalid  (m_rfnoc_chdr_tvalid),
    .m_rfnoc_chdr_tready  (m_rfnoc_chdr_tready),
    .s_rfnoc_ctrl_tdata   (s_rfnoc_ctrl_tdata),
    .s_rfnoc_ctrl_tlast   (s_rfnoc_ctrl_tlast),
    .s_rfnoc_ctrl_tvalid  (s_rfnoc_ctrl_tvalid),
    .s_rfnoc_ctrl_tready  (s_rfnoc_ctrl_tready),
    .m_rfnoc_ctrl_tdata   (m_rfnoc_ctrl_tdata),
    .m_rfnoc_ctrl_tlast   (m_rfnoc_ctrl_tlast),
    .m_rfnoc_ctrl_tvalid  (m_rfnoc_ctrl_tvalid),
    .m_rfnoc_ctrl_tready  (m_rfnoc_ctrl_tready),
    .ctrlport_clk         (),
    .ctrlport_rst         (),
    .m_ctrlport_req_wr    (ctrlport_req_wr),
    .m_ctrlport_req_rd    (ctrlport_req_rd),
    .m_ctrlport_req_addr  (ctrlport_req_addr),
    .m_ctrlport_req_data  (ctrlport_req_data),
    .m_ctrlport_resp_ack  (ctrlport_resp_ack),
    .m_ctrlport_resp_data (ctrlport_resp_data),
    .axis_chdr_clk        (axis_chdr_clk),
    .axis_chdr_rst        (axis_chdr_rst),
    .m_in_chdr_tdata      (m_axis_chdr_tdata),
    .m_in_chdr_tlast      (m_axis_chdr_tlast),
    .m_in_chdr_tvalid     (m_axis_chdr_tvalid),
    .m_in_chdr_tready     (m_axis_chdr_tready),
    .s_out_chdr_tdata     (s_axis_chdr_tdata),
    .s_out_chdr_tlast     (s_axis_chdr_tlast),
    .s_out_chdr_tvalid    (s_axis_chdr_tvalid),
    .s_out_chdr_tready    (s_axis_chdr_tready)
  );

  reg  mem_rst_block;


  always @(posedge mem_clk) begin
    mem_rst_block <= axi_rst | mem_rst;
  end






  wire [   NUM_PORTS-1:0] m_ctrlport_req_wr;
  wire [   NUM_PORTS-1:0] m_ctrlport_req_rd;
  wire [20*NUM_PORTS-1:0] m_ctrlport_req_addr;
  wire [32*NUM_PORTS-1:0] m_ctrlport_req_data;
  wire [   NUM_PORTS-1:0] m_ctrlport_resp_ack;
  wire [32*NUM_PORTS-1:0] m_ctrlport_resp_data;

  ctrlport_decoder #(
    .NUM_SLAVES   (NUM_PORTS),
    .BASE_ADDR    (0),
    .SLAVE_ADDR_W (RAM_FIFO_ADDR_W)
  ) ctrlport_decoder_i (
    .ctrlport_clk            (mem_clk),
    .ctrlport_rst            (mem_rst_block),
    .s_ctrlport_req_wr       (ctrlport_req_wr),
    .s_ctrlport_req_rd       (ctrlport_req_rd),
    .s_ctrlport_req_addr     (ctrlport_req_addr),
    .s_ctrlport_req_data     (ctrlport_req_data),
    .s_ctrlport_req_byte_en  (4'b1111),
    .s_ctrlport_req_has_time (1'b0),
    .s_ctrlport_req_time     (64'b0),
    .s_ctrlport_resp_ack     (ctrlport_resp_ack),
    .s_ctrlport_resp_status  (),
    .s_ctrlport_resp_data    (ctrlport_resp_data),
    .m_ctrlport_req_wr       (m_ctrlport_req_wr),
    .m_ctrlport_req_rd       (m_ctrlport_req_rd),
    .m_ctrlport_req_addr     (m_ctrlport_req_addr),
    .m_ctrlport_req_data     (m_ctrlport_req_data),
    .m_ctrlport_req_byte_en  (),
    .m_ctrlport_req_has_time (),
    .m_ctrlport_req_time     (),
    .m_ctrlport_resp_ack     (m_ctrlport_resp_ack),
    .m_ctrlport_resp_status  ({NUM_PORTS*2{1'b0}}),
    .m_ctrlport_resp_data    (m_ctrlport_resp_data)
  );






  genvar i;
  for (i = 0; i < NUM_PORTS; i = i + 1) begin : gen_ram_fifos

    wire [MEM_DATA_W-1:0] m_axis_mem_tdata;
    wire [    KEEP_W-1:0] m_axis_mem_tkeep;
    wire                  m_axis_mem_tlast;
    wire                  m_axis_mem_tvalid;
    wire                  m_axis_mem_tready;

    wire [MEM_DATA_W-1:0] s_axis_mem_tdata;
    wire [    KEEP_W-1:0] s_axis_mem_tkeep;
    wire                  s_axis_mem_tlast;
    wire                  s_axis_mem_tvalid;
    wire                  s_axis_mem_tready;










    axis_width_conv #(
      .WORD_W    (WORD_W),
      .IN_WORDS  (CHDR_W/WORD_W),
      .OUT_WORDS (MEM_DATA_W/WORD_W),
      .SYNC_CLKS (0),
      .PIPELINE  ("NONE")
    ) axis_width_conv_to_mem_i (
      .s_axis_aclk   (axis_chdr_clk),
      .s_axis_rst    (axis_chdr_rst),
      .s_axis_tdata  (m_axis_chdr_tdata[i*CHDR_W +: CHDR_W]),
      .s_axis_tkeep  ({CHDR_W/WORD_W{1'b1}}),
      .s_axis_tlast  (m_axis_chdr_tlast[i]),
      .s_axis_tvalid (m_axis_chdr_tvalid[i]),
      .s_axis_tready (m_axis_chdr_tready[i]),
      .m_axis_aclk   (mem_clk),
      .m_axis_rst    (mem_rst),
      .m_axis_tdata  (m_axis_mem_tdata),
      .m_axis_tkeep  (m_axis_mem_tkeep),
      .m_axis_tlast  (m_axis_mem_tlast),
      .m_axis_tvalid (m_axis_mem_tvalid),
      .m_axis_tready (m_axis_mem_tready)
    );

    axis_width_conv #(
      .WORD_W    (WORD_W),
      .IN_WORDS  (MEM_DATA_W/WORD_W),
      .OUT_WORDS (CHDR_W/WORD_W),
      .SYNC_CLKS (0),
      .PIPELINE  ("NONE")
    ) axis_width_conv_to_chdr_i (
      .s_axis_aclk   (mem_clk),
      .s_axis_rst    (mem_rst),
      .s_axis_tdata  (s_axis_mem_tdata),
      .s_axis_tkeep  (s_axis_mem_tkeep),
      .s_axis_tlast  (s_axis_mem_tlast),
      .s_axis_tvalid (s_axis_mem_tvalid),
      .s_axis_tready (s_axis_mem_tready),
      .m_axis_aclk   (axis_chdr_clk),
      .m_axis_rst    (axis_chdr_rst),
      .m_axis_tdata  (s_axis_chdr_tdata[i*CHDR_W +: CHDR_W]),
      .m_axis_tkeep  (),
      .m_axis_tlast  (s_axis_chdr_tlast[i]),
      .m_axis_tvalid (s_axis_chdr_tvalid[i]),
      .m_axis_tready (s_axis_chdr_tready[i])
    );





    wire [MEM_ADDR_W-1:0] m_axi_awaddr_int;
    wire [MEM_ADDR_W-1:0] m_axi_araddr_int;


    assign m_axi_awaddr[(AWIDTH*(i+1))-1:AWIDTH*i] = m_axi_awaddr_int;
    assign m_axi_araddr[(AWIDTH*(i+1))-1:AWIDTH*i] = m_axi_araddr_int;

    axi_ram_fifo #(
      .MEM_ADDR_W     (MEM_ADDR_W),
      .MEM_DATA_W     (MEM_DATA_W),
      .KEEP_W         (KEEP_W),
      .FIFO_ADDR_BASE (FIFO_ADDR_BASE[MEM_ADDR_W*i +: MEM_ADDR_W]),
      .FIFO_ADDR_MASK (FIFO_ADDR_MASK[MEM_ADDR_W*i +: MEM_ADDR_W]),
      .BURST_TIMEOUT  (BURST_TIMEOUT[32*i +: 32]),
      .BIST           (BIST),
      .CLK_RATE       (MEM_CLK_RATE),
      .IN_FIFO_SIZE   (IN_FIFO_SIZE),
      .OUT_FIFO_SIZE  (OUT_FIFO_SIZE)
    ) axi_ram_fifo_i (

      .clk(mem_clk),
      .rst(mem_rst_block),





      .s_ctrlport_req_wr      (m_ctrlport_req_wr[i]),
      .s_ctrlport_req_rd      (m_ctrlport_req_rd[i]),
      .s_ctrlport_req_addr    (m_ctrlport_req_addr[20*i +: 20]),
      .s_ctrlport_req_data    (m_ctrlport_req_data[32*i +: 32]),
      .s_ctrlport_resp_ack    (m_ctrlport_resp_ack[i]),
      .s_ctrlport_resp_data   (m_ctrlport_resp_data[32*i +: 32]),






      .s_tdata        (m_axis_mem_tdata),
      .s_tkeep        (m_axis_mem_tkeep),
      .s_tlast        (m_axis_mem_tlast),
      .s_tvalid       (m_axis_mem_tvalid),
      .s_tready       (m_axis_mem_tready),


      .m_tdata        (s_axis_mem_tdata),
      .m_tkeep        (s_axis_mem_tkeep),
      .m_tlast        (s_axis_mem_tlast),
      .m_tvalid       (s_axis_mem_tvalid),
      .m_tready       (s_axis_mem_tready),






      .m_axi_awid     (m_axi_awid[i]),
      .m_axi_awaddr   (m_axi_awaddr_int),
      .m_axi_awlen    (m_axi_awlen[(8*(i+1))-1:8*i]),
      .m_axi_awsize   (m_axi_awsize[(3*(i+1))-1:3*i]),
      .m_axi_awburst  (m_axi_awburst[(2*(i+1))-1:2*i]),
      .m_axi_awlock   (m_axi_awlock[i]),
      .m_axi_awcache  (m_axi_awcache[(4*(i+1))-1:4*i]),
      .m_axi_awprot   (m_axi_awprot[(3*(i+1))-1:3*i]),
      .m_axi_awqos    (m_axi_awqos[(4*(i+1))-1:4*i]),
      .m_axi_awregion (m_axi_awregion[(4*(i+1))-1:4*i]),
      .m_axi_awuser   (m_axi_awuser[i]),
      .m_axi_awvalid  (m_axi_awvalid[i]),
      .m_axi_awready  (m_axi_awready[i]),


      .m_axi_wdata    (m_axi_wdata[(MEM_DATA_W*(i+1))-1:MEM_DATA_W*i]),
      .m_axi_wstrb    (m_axi_wstrb[((MEM_DATA_W/8)*(i+1))-1:(MEM_DATA_W/8)*i]),
      .m_axi_wlast    (m_axi_wlast[i]),
      .m_axi_wuser    (m_axi_wuser[i]),
      .m_axi_wvalid   (m_axi_wvalid[i]),
      .m_axi_wready   (m_axi_wready[i]),


      .m_axi_bid      (m_axi_bid[i]),
      .m_axi_bresp    (m_axi_bresp[(2*(i+1))-1:2*i]),
      .m_axi_buser    (m_axi_buser[i]),
      .m_axi_bvalid   (m_axi_bvalid[i]),
      .m_axi_bready   (m_axi_bready[i]),


      .m_axi_arid     (m_axi_arid[i]),
      .m_axi_araddr   (m_axi_araddr_int),
      .m_axi_arlen    (m_axi_arlen[(8*(i+1))-1:8*i]),
      .m_axi_arsize   (m_axi_arsize[(3*(i+1))-1:3*i]),
      .m_axi_arburst  (m_axi_arburst[(2*(i+1))-1:2*i]),
      .m_axi_arlock   (m_axi_arlock[i]),
      .m_axi_arcache  (m_axi_arcache[(4*(i+1))-1:4*i]),
      .m_axi_arprot   (m_axi_arprot[(3*(i+1))-1:3*i]),
      .m_axi_arqos    (m_axi_arqos[(4*(i+1))-1:4*i]),
      .m_axi_arregion (m_axi_arregion[(4*(i+1))-1:4*i]),
      .m_axi_aruser   (m_axi_aruser[i]),
      .m_axi_arvalid  (m_axi_arvalid[i]),
      .m_axi_arready  (m_axi_arready[i]),


      .m_axi_rid      (m_axi_rid[i]),
      .m_axi_rdata    (m_axi_rdata[(MEM_DATA_W*(i+1))-1:MEM_DATA_W*i]),
      .m_axi_rresp    (m_axi_rresp[(2*(i+1))-1:2*i]),
      .m_axi_rlast    (m_axi_rlast[i]),
      .m_axi_ruser    (m_axi_ruser[i]),
      .m_axi_rvalid   (m_axi_rvalid[i]),
      .m_axi_rready   (m_axi_rready[i])
    );

  end

endmodule