OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [src/] [axis_register_slice.sv] - Diff between revs 28 and 31

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 28 Rev 31
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
module
module
  axis_register_slice
  axis_register_slice
  #(
  #(
    N = 8,          // data bus width in bytes
    N = 8,          // data bus width in bytes
    I = 0,          // TID width
    I = 0,          // TID width
    D = 0,          // TDEST width
    D = 0,          // TDEST width
    U = 1,          // TUSER width
    U = 1,          // TUSER width
    USE_TSTRB = 0,  //  set to 1 to enable, 0 to disable
    USE_TSTRB = 0,  //  set to 1 to enable, 0 to disable
    USE_TKEEP = 0   //  set to 1 to enable, 0 to disable
    USE_TKEEP = 0   //  set to 1 to enable, 0 to disable
  )
  )
  (
  (
    input           axis_en,
    axis_if axis_in,
    axis_if.slave   axis_in,
    axis_if axis_out,
    axis_if.master  axis_out,
 
    input           aclk,
    input           aclk,
    input           aresetn
    input   aresetn
  );
  );
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
// synthesis translate_off
  localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
  initial
 
  begin
 
    a_tid_unsuported:   assert(I == 0) else $fatal;
 
    a_tdest_unsuported: assert(D == 0) else $fatal;
 
  end
 
// synthesis translate_on
 
// --------------------------------------------------------------------
 
 
  fifo_write_if #(.W(W)) fifo_sink(aclk, ~aresetn);
 
  fifo_read_if  #(.W(W)) fifo_source(aclk, ~aresetn);
 
 
 
  tiny_sync_fifo #(.W(W))
  // --------------------------------------------------------------------
    tiny_sync_fifo_i(.source(fifo_sink.fifo), .sink(fifo_source.fifo));
  //
 
  localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
  //
  wire data_to_axis_fsm_error;
  wire          wr_full;
 
  wire [W-1:0]  wr_data;
 
  wire          wr_en;
 
 
 
  wire          rd_empty;
 
  wire [W-1:0]  rd_data;
 
  wire          rd_en;
 
 
  data_to_axis_fsm
  tiny_sync_fifo #(.W(W))
    data_to_axis_fsm_i
    tiny_sync_fifo_i(.clk(aclk), .reset(~aresetn), .*);
    (
 
      .axis_tvalid(axis_out.tvalid),
 
      .axis_tready(axis_out.tready),
 
      .fifo_empty(fifo_source.empty),
 
      .fifo_rd_en(fifo_source.rd_en),
 
      .fifo_watermark(1'b1),
 
      .*
 
    );
 
 
 
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
  //
  generate
  generate
    begin: assign_gen
    begin: assign_gen
 
 
      if(USE_TSTRB & USE_TKEEP)
      if(USE_TSTRB & USE_TKEEP)
      begin
      begin
        assign fifo_sink.wr_data =
        assign wr_data =
          {
          {
            axis_in.tdata,
            axis_in.tdata,
            axis_in.tlast,
            axis_in.tlast,
            axis_in.tuser,
            axis_in.tuser,
            axis_in.tstrb,
            axis_in.tstrb,
            axis_in.tkeep
            axis_in.tkeep
          };
          };
        assign
        assign
          {
          {
            axis_out.tdata,
            axis_out.tdata,
            axis_out.tlast,
            axis_out.tlast,
            axis_out.tuser,
            axis_out.tuser,
            axis_out.tstrb,
            axis_out.tstrb,
            axis_out.tkeep
            axis_out.tkeep
          } = fifo_source.rd_data;
          } = rd_data;
      end
      end
      else if(USE_TSTRB)
      else if(USE_TSTRB)
      begin
      begin
        assign fifo_sink.wr_data =
        assign wr_data =
          {
          {
            axis_in.tdata,
            axis_in.tdata,
            axis_in.tlast,
            axis_in.tlast,
            axis_in.tuser,
            axis_in.tuser,
            axis_in.tstrb
            axis_in.tstrb
          };
          };
        assign
        assign
          {
          {
            axis_out.tdata,
            axis_out.tdata,
            axis_out.tlast,
            axis_out.tlast,
            axis_out.tuser,
            axis_out.tuser,
            axis_out.tstrb
            axis_out.tstrb
          } = fifo_source.rd_data;
          } = rd_data;
      end
      end
      else if(USE_TKEEP)
      else if(USE_TKEEP)
      begin
      begin
        assign fifo_sink.wr_data =
        assign wr_data =
          {
          {
            axis_in.tdata,
            axis_in.tdata,
            axis_in.tlast,
            axis_in.tlast,
            axis_in.tuser,
            axis_in.tuser,
            axis_in.tkeep
            axis_in.tkeep
          };
          };
        assign
        assign
          {
          {
            axis_out.tdata,
            axis_out.tdata,
            axis_out.tlast,
            axis_out.tlast,
            axis_out.tuser,
            axis_out.tuser,
            axis_out.tkeep
            axis_out.tkeep
          } = fifo_source.rd_data;
          } = rd_data;
      end
      end
      else
      else
      begin
      begin
        assign fifo_sink.wr_data =
        assign wr_data =
          {
          {
            axis_in.tdata,
            axis_in.tdata,
            axis_in.tlast,
            axis_in.tlast,
            axis_in.tuser
            axis_in.tuser
          };
          };
        assign
        assign
          {
          {
            axis_out.tdata,
            axis_out.tdata,
            axis_out.tlast,
            axis_out.tlast,
            axis_out.tuser
            axis_out.tuser
          } = fifo_source.rd_data;
          } = rd_data;
      end
      end
 
 
    end
    end
  endgenerate
  endgenerate
  // --------------------------------------------------------------------
  // --------------------------------------------------------------------
  //
  //
  assign axis_in.tready   = ~fifo_sink.full;
  assign axis_in.tready   = ~wr_full;
  assign fifo_sink.wr_en  = axis_in.tvalid & ~fifo_sink.full;
  assign wr_en            = axis_in.tvalid & ~wr_full;
 
  assign axis_out.tvalid  = ~rd_empty;
 
  assign rd_en            = axis_out.tready & ~rd_empty;
 
 
 
 
 
// --------------------------------------------------------------------
 
//
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.