data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v
1: b'%Warning-WIDTH: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:190: Operator FUNCREF \'b2g\' expects 8 bits on the Function Argument, but Function Argument\'s VARREF \'dac_raddr\' generates 6 bits.\n                                                                                                 : ... In instance ad_axis_dma_tx\n    dac_raddr_g <= b2g(dac_raddr);\n                   ^~~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:190: Operator ASSIGNDLY expects 6 bits on the Assign RHS, but Assign RHS\'s FUNCREF \'b2g\' generates 8 bits.\n                                                                                                 : ... In instance ad_axis_dma_tx\n    dac_raddr_g <= b2g(dac_raddr);\n                ^~\n%Warning-WIDTH: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:201: Operator ASSIGNDLY expects 32 bits on the Assign RHS, but Assign RHS\'s CONST \'16\'h0\' generates 16 bits.\n                                                                                                 : ... In instance ad_axis_dma_tx\n      dma_clkcnt <= 16\'d0;\n                 ^~\n%Warning-WIDTH: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:226: Operator FUNCREF \'g2b\' expects 8 bits on the Function Argument, but Function Argument\'s VARREF \'dma_raddr_g_m2\' generates 6 bits.\n                                                                                                 : ... In instance ad_axis_dma_tx\n    dma_raddr <= g2b(dma_raddr_g_m2);\n                 ^~~\n%Warning-WIDTH: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:226: Operator ASSIGNDLY expects 6 bits on the Assign RHS, but Assign RHS\'s FUNCREF \'g2b\' generates 8 bits.\n                                                                                                 : ... In instance ad_axis_dma_tx\n    dma_raddr <= g2b(dma_raddr_g_m2);\n              ^~\n%Error: data/full_repos/permissive/40989439/AdiHDLLib/library/common/ad_axis_dma_tx.v:269: Cannot find file containing module: \'ad_mem\'\n  ad_mem #(.DATA_WIDTH(DATA_WIDTH), .ADDRESS_WIDTH(6)) i_mem (\n  ^~~~~~\n        ... Looked in:\n             data/full_repos/permissive/40989439/AdiHDLLib/library/common,data/full_repos/permissive/40989439/ad_mem\n             data/full_repos/permissive/40989439/AdiHDLLib/library/common,data/full_repos/permissive/40989439/ad_mem.v\n             data/full_repos/permissive/40989439/AdiHDLLib/library/common,data/full_repos/permissive/40989439/ad_mem.sv\n             ad_mem\n             ad_mem.v\n             ad_mem.sv\n             obj_dir/ad_mem\n             obj_dir/ad_mem.v\n             obj_dir/ad_mem.sv\n%Error: Exiting due to 1 error(s), 5 warning(s)\n'
module ad_axis_dma_tx (



  dma_clk,
  dma_rst,
  dma_fs,
  dma_valid,
  dma_data,
  dma_ready,
  dma_ovf,
  dma_unf,



  dac_clk,
  dac_rst,
  dac_rd,
  dac_valid,
  dac_data,



  dma_frmcnt);



  parameter       DATA_WIDTH = 64;
  localparam      DW = DATA_WIDTH - 1;
  localparam      BUF_THRESHOLD_LO = 6'd3;
  localparam      BUF_THRESHOLD_HI = 6'd60;
  localparam      RDY_THRESHOLD_LO = 6'd40;
  localparam      RDY_THRESHOLD_HI = 6'd50;



  input           dma_clk;
  input           dma_rst;
  output          dma_fs;
  input           dma_valid;
  input   [DW:0]  dma_data;
  output          dma_ready;
  output          dma_ovf;
  output          dma_unf;



  input           dac_clk;
  input           dac_rst;
  input           dac_rd;
  output          dac_valid;
  output  [DW:0]  dac_data;



  input   [31:0]  dma_frmcnt;



  reg             dac_start_m1 = 'd0;
  reg             dac_start = 'd0;
  reg             dac_resync_m1 = 'd0;
  reg             dac_resync = 'd0;
  reg     [ 5:0]  dac_raddr = 'd0;
  reg     [ 5:0]  dac_raddr_g = 'd0;
  reg             dac_rd_d = 'd0;
  reg             dac_rd_2d = 'd0;
  reg             dac_valid = 'd0;
  reg     [DW:0]  dac_data = 'd0;
  reg     [31:0]  dma_clkcnt = 'd0;
  reg             dma_fs = 'd0;
  reg     [ 5:0]  dma_raddr_g_m1 = 'd0;
  reg     [ 5:0]  dma_raddr_g_m2 = 'd0;
  reg     [ 5:0]  dma_raddr = 'd0;
  reg     [ 5:0]  dma_addr_diff = 'd0;
  reg             dma_ready = 'd0;
  reg             dma_almost_full = 'd0;
  reg             dma_almost_empty = 'd0;
  reg             dma_ovf = 'd0;
  reg             dma_unf = 'd0;
  reg             dma_resync = 'd0;
  reg             dma_start = 'd0;
  reg             dma_wr = 'd0;
  reg     [ 5:0]  dma_waddr = 'd0;
  reg     [DW:0]  dma_wdata = 'd0;



  wire            dma_wr_s;
  wire    [ 6:0]  dma_addr_diff_s;
  wire            dma_ovf_s;
  wire            dma_unf_s;
  wire    [DW:0]  dac_rdata_s;



  function [7:0] b2g;
    input [7:0] b;
    reg   [7:0] g;
    begin
      g[7] = b[7];
      g[6] = b[7] ^ b[6];
      g[5] = b[6] ^ b[5];
      g[4] = b[5] ^ b[4];
      g[3] = b[4] ^ b[3];
      g[2] = b[3] ^ b[2];
      g[1] = b[2] ^ b[1];
      g[0] = b[1] ^ b[0];
      b2g = g;
    end
  endfunction



  function [7:0] g2b;
    input [7:0] g;
    reg   [7:0] b;
    begin
      b[7] = g[7];
      b[6] = b[7] ^ g[6];
      b[5] = b[6] ^ g[5];
      b[4] = b[5] ^ g[4];
      b[3] = b[4] ^ g[3];
      b[2] = b[3] ^ g[2];
      b[1] = b[2] ^ g[1];
      b[0] = b[1] ^ g[0];
      g2b = b;
    end
  endfunction



  always @(posedge dac_clk) begin
    if (dac_rst == 1'b1) begin
      dac_start_m1 <= 'd0;
      dac_start <= 'd0;
      dac_resync_m1 <= 'd0;
      dac_resync <= 'd0;
    end else begin
      dac_start_m1 <= dma_start;
      dac_start <= dac_start_m1;
      dac_resync_m1 <= dma_resync;
      dac_resync <= dac_resync_m1;
    end
    if ((dac_start == 1'b0) || (dac_resync == 1'b1) || (dac_rst == 1'b1)) begin
      dac_raddr <= 6'd0;
    end else if (dac_rd == 1'b1) begin
      dac_raddr <= dac_raddr + 1'b1;
    end
    dac_raddr_g <= b2g(dac_raddr);
    dac_rd_d <= dac_rd;
    dac_rd_2d <= dac_rd_d;
    dac_valid <= dac_rd_2d;
    dac_data <= dac_rdata_s;
  end
    


  always @(posedge dma_clk) begin
    if ((dma_resync == 1'b1) || (dma_rst == 1'b1) || (dma_clkcnt >= dma_frmcnt)) begin
      dma_clkcnt <= 16'd0;
    end else begin
      dma_clkcnt <= dma_clkcnt + 1'b1;
    end
    if (dma_clkcnt == 32'd1) begin
      dma_fs <= 1'b1;
    end else begin
      dma_fs <= 1'b0;
    end
  end



  assign dma_addr_diff_s = {1'b1, dma_waddr} - dma_raddr;
  assign dma_ovf_s = (dma_addr_diff < BUF_THRESHOLD_LO) ? dma_almost_full : 1'b0;
  assign dma_unf_s = (dma_addr_diff > BUF_THRESHOLD_HI) ? dma_almost_empty : 1'b0;

  always @(posedge dma_clk) begin
    if (dma_rst == 1'b1) begin
      dma_raddr_g_m1 <= 'd0;
      dma_raddr_g_m2 <= 'd0;
    end else begin
      dma_raddr_g_m1 <= dac_raddr_g;
      dma_raddr_g_m2 <= dma_raddr_g_m1;
    end
    dma_raddr <= g2b(dma_raddr_g_m2);
    dma_addr_diff <= dma_addr_diff_s[5:0];
    if (dma_addr_diff >= RDY_THRESHOLD_HI) begin
      dma_ready <= 1'b0;
    end else if (dma_addr_diff <= RDY_THRESHOLD_LO) begin
      dma_ready <= 1'b1;
    end
    if (dma_addr_diff > BUF_THRESHOLD_HI) begin
      dma_almost_full <= 1'b1;
    end else begin
      dma_almost_full <= 1'b0;
    end
    if (dma_addr_diff < BUF_THRESHOLD_LO) begin
      dma_almost_empty <= 1'b1;
    end else begin
      dma_almost_empty <= 1'b0;
    end
    dma_ovf <= dma_ovf_s;
    dma_unf <= dma_unf_s;
    dma_resync <= dma_ovf | dma_unf;
  end



  assign dma_wr_s = dma_valid & dma_ready;

  always @(posedge dma_clk) begin
    if (dma_rst == 1'b1) begin
      dma_start <= 1'b0;
    end else if (dma_wr_s == 1'b1) begin
      dma_start <= 1'b1;
    end
    dma_wr <= dma_wr_s;
    if ((dma_resync == 1'b1) || (dma_rst == 1'b1)) begin
      dma_waddr <= 6'd0;
    end else if (dma_wr == 1'b1) begin
      dma_waddr <= dma_waddr + 1'b1;
    end
    dma_wdata <= dma_data;
  end



  ad_mem #(.DATA_WIDTH(DATA_WIDTH), .ADDRESS_WIDTH(6)) i_mem (
    .clka (dma_clk),
    .wea (dma_wr),
    .addra (dma_waddr),
    .dina (dma_wdata),
    .clkb (dac_clk),
    .addrb (dac_raddr),
    .doutb (dac_rdata_s));

endmodule
module ad_axis_dma_tx (



  dma_clk,
  dma_rst,
  dma_fs,
  dma_valid,
  dma_data,
  dma_ready,
  dma_ovf,
  dma_unf,



  dac_clk,
  dac_rst,
  dac_rd,
  dac_valid,
  dac_data,



  dma_frmcnt);




  parameter       DATA_WIDTH = 64;
  localparam      DW = DATA_WIDTH - 1;
  localparam      BUF_THRESHOLD_LO = 6'd3;
  localparam      BUF_THRESHOLD_HI = 6'd60;
  localparam      RDY_THRESHOLD_LO = 6'd40;
  localparam      RDY_THRESHOLD_HI = 6'd50;



  input           dma_clk;
  input           dma_rst;
  output          dma_fs;
  input           dma_valid;
  input   [DW:0]  dma_data;
  output          dma_ready;
  output          dma_ovf;
  output          dma_unf;



  input           dac_clk;
  input           dac_rst;
  input           dac_rd;
  output          dac_valid;
  output  [DW:0]  dac_data;



  input   [31:0]  dma_frmcnt;



  reg             dac_start_m1 = 'd0;
  reg             dac_start = 'd0;
  reg             dac_resync_m1 = 'd0;
  reg             dac_resync = 'd0;
  reg     [ 5:0]  dac_raddr = 'd0;
  reg     [ 5:0]  dac_raddr_g = 'd0;
  reg             dac_rd_d = 'd0;
  reg             dac_rd_2d = 'd0;
  reg             dac_valid = 'd0;
  reg     [DW:0]  dac_data = 'd0;
  reg     [31:0]  dma_clkcnt = 'd0;
  reg             dma_fs = 'd0;
  reg     [ 5:0]  dma_raddr_g_m1 = 'd0;
  reg     [ 5:0]  dma_raddr_g_m2 = 'd0;
  reg     [ 5:0]  dma_raddr = 'd0;
  reg     [ 5:0]  dma_addr_diff = 'd0;
  reg             dma_ready = 'd0;
  reg             dma_almost_full = 'd0;
  reg             dma_almost_empty = 'd0;
  reg             dma_ovf = 'd0;
  reg             dma_unf = 'd0;
  reg             dma_resync = 'd0;
  reg             dma_start = 'd0;
  reg             dma_wr = 'd0;
  reg     [ 5:0]  dma_waddr = 'd0;
  reg     [DW:0]  dma_wdata = 'd0;



  wire            dma_wr_s;
  wire    [ 6:0]  dma_addr_diff_s;
  wire            dma_ovf_s;
  wire            dma_unf_s;
  wire    [DW:0]  dac_rdata_s;



  function [7:0] b2g;
    input [7:0] b;
    reg   [7:0] g;
    begin
      g[7] = b[7];
      g[6] = b[7] ^ b[6];
      g[5] = b[6] ^ b[5];
      g[4] = b[5] ^ b[4];
      g[3] = b[4] ^ b[3];
      g[2] = b[3] ^ b[2];
      g[1] = b[2] ^ b[1];
      g[0] = b[1] ^ b[0];
      b2g = g;
    end
  endfunction



  function [7:0] g2b;
    input [7:0] g;
    reg   [7:0] b;
    begin
      b[7] = g[7];
      b[6] = b[7] ^ g[6];
      b[5] = b[6] ^ g[5];
      b[4] = b[5] ^ g[4];
      b[3] = b[4] ^ g[3];
      b[2] = b[3] ^ g[2];
      b[1] = b[2] ^ g[1];
      b[0] = b[1] ^ g[0];
      g2b = b;
    end
  endfunction



  always @(posedge dac_clk) begin
    if (dac_rst == 1'b1) begin
      dac_start_m1 <= 'd0;
      dac_start <= 'd0;
      dac_resync_m1 <= 'd0;
      dac_resync <= 'd0;
    end else begin
      dac_start_m1 <= dma_start;
      dac_start <= dac_start_m1;
      dac_resync_m1 <= dma_resync;
      dac_resync <= dac_resync_m1;
    end
    if ((dac_start == 1'b0) || (dac_resync == 1'b1) || (dac_rst == 1'b1)) begin
      dac_raddr <= 6'd0;
    end else if (dac_rd == 1'b1) begin
      dac_raddr <= dac_raddr + 1'b1;
    end
    dac_raddr_g <= b2g(dac_raddr);
    dac_rd_d <= dac_rd;
    dac_rd_2d <= dac_rd_d;
    dac_valid <= dac_rd_2d;
    dac_data <= dac_rdata_s;
  end
    


  always @(posedge dma_clk) begin
    if ((dma_resync == 1'b1) || (dma_rst == 1'b1) || (dma_clkcnt >= dma_frmcnt)) begin
      dma_clkcnt <= 16'd0;
    end else begin
      dma_clkcnt <= dma_clkcnt + 1'b1;
    end
    if (dma_clkcnt == 32'd1) begin
      dma_fs <= 1'b1;
    end else begin
      dma_fs <= 1'b0;
    end
  end



  assign dma_addr_diff_s = {1'b1, dma_waddr} - dma_raddr;
  assign dma_ovf_s = (dma_addr_diff < BUF_THRESHOLD_LO) ? dma_almost_full : 1'b0;
  assign dma_unf_s = (dma_addr_diff > BUF_THRESHOLD_HI) ? dma_almost_empty : 1'b0;

  always @(posedge dma_clk) begin
    if (dma_rst == 1'b1) begin
      dma_raddr_g_m1 <= 'd0;
      dma_raddr_g_m2 <= 'd0;
    end else begin
      dma_raddr_g_m1 <= dac_raddr_g;
      dma_raddr_g_m2 <= dma_raddr_g_m1;
    end
    dma_raddr <= g2b(dma_raddr_g_m2);
    dma_addr_diff <= dma_addr_diff_s[5:0];
    if (dma_addr_diff >= RDY_THRESHOLD_HI) begin
      dma_ready <= 1'b0;
    end else if (dma_addr_diff <= RDY_THRESHOLD_LO) begin
      dma_ready <= 1'b1;
    end
    if (dma_addr_diff > BUF_THRESHOLD_HI) begin
      dma_almost_full <= 1'b1;
    end else begin
      dma_almost_full <= 1'b0;
    end
    if (dma_addr_diff < BUF_THRESHOLD_LO) begin
      dma_almost_empty <= 1'b1;
    end else begin
      dma_almost_empty <= 1'b0;
    end
    dma_ovf <= dma_ovf_s;
    dma_unf <= dma_unf_s;
    dma_resync <= dma_ovf | dma_unf;
  end



  assign dma_wr_s = dma_valid & dma_ready;

  always @(posedge dma_clk) begin
    if (dma_rst == 1'b1) begin
      dma_start <= 1'b0;
    end else if (dma_wr_s == 1'b1) begin
      dma_start <= 1'b1;
    end
    dma_wr <= dma_wr_s;
    if ((dma_resync == 1'b1) || (dma_rst == 1'b1)) begin
      dma_waddr <= 6'd0;
    end else if (dma_wr == 1'b1) begin
      dma_waddr <= dma_waddr + 1'b1;
    end
    dma_wdata <= dma_data;
  end



  ad_mem #(.DATA_WIDTH(DATA_WIDTH), .ADDRESS_WIDTH(6)) i_mem (
    .clka (dma_clk),
    .wea (dma_wr),
    .addra (dma_waddr),
    .dina (dma_wdata),
    .clkb (dac_clk),
    .addrb (dac_raddr),
    .doutb (dac_rdata_s));

endmodule