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] - Blame information for rev 31

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
module
29
  axis_register_slice
30
  #(
31
    N = 8,          // data bus width in bytes
32
    I = 0,          // TID width
33
    D = 0,          // TDEST width
34
    U = 1,          // TUSER width
35
    USE_TSTRB = 0,  //  set to 1 to enable, 0 to disable
36
    USE_TKEEP = 0   //  set to 1 to enable, 0 to disable
37
  )
38
  (
39 31 qaztronic
    axis_if axis_in,
40
    axis_if axis_out,
41
    input   aclk,
42
    input   aresetn
43 28 qaztronic
  );
44
 
45 31 qaztronic
// --------------------------------------------------------------------
46
// synthesis translate_off
47
  initial
48
  begin
49
    a_tid_unsuported:   assert(I == 0) else $fatal;
50
    a_tdest_unsuported: assert(D == 0) else $fatal;
51
  end
52
// synthesis translate_on
53
// --------------------------------------------------------------------
54
 
55
 
56 28 qaztronic
  // --------------------------------------------------------------------
57
  //
58
  localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
59
 
60
 
61
  // --------------------------------------------------------------------
62
  //
63 31 qaztronic
  wire          wr_full;
64
  wire [W-1:0]  wr_data;
65
  wire          wr_en;
66 28 qaztronic
 
67 31 qaztronic
  wire          rd_empty;
68
  wire [W-1:0]  rd_data;
69
  wire          rd_en;
70 28 qaztronic
 
71 31 qaztronic
  tiny_sync_fifo #(.W(W))
72
    tiny_sync_fifo_i(.clk(aclk), .reset(~aresetn), .*);
73 28 qaztronic
 
74 31 qaztronic
 
75 28 qaztronic
  // --------------------------------------------------------------------
76
  //
77
  generate
78
    begin: assign_gen
79
      if(USE_TSTRB & USE_TKEEP)
80
      begin
81 31 qaztronic
        assign wr_data =
82 28 qaztronic
          {
83
            axis_in.tdata,
84
            axis_in.tlast,
85
            axis_in.tuser,
86
            axis_in.tstrb,
87
            axis_in.tkeep
88
          };
89
        assign
90
          {
91
            axis_out.tdata,
92
            axis_out.tlast,
93
            axis_out.tuser,
94
            axis_out.tstrb,
95
            axis_out.tkeep
96 31 qaztronic
          } = rd_data;
97 28 qaztronic
      end
98
      else if(USE_TSTRB)
99
      begin
100 31 qaztronic
        assign wr_data =
101 28 qaztronic
          {
102
            axis_in.tdata,
103
            axis_in.tlast,
104
            axis_in.tuser,
105
            axis_in.tstrb
106
          };
107
        assign
108
          {
109
            axis_out.tdata,
110
            axis_out.tlast,
111
            axis_out.tuser,
112
            axis_out.tstrb
113 31 qaztronic
          } = rd_data;
114 28 qaztronic
      end
115
      else if(USE_TKEEP)
116
      begin
117 31 qaztronic
        assign wr_data =
118 28 qaztronic
          {
119
            axis_in.tdata,
120
            axis_in.tlast,
121
            axis_in.tuser,
122
            axis_in.tkeep
123
          };
124
        assign
125
          {
126
            axis_out.tdata,
127
            axis_out.tlast,
128
            axis_out.tuser,
129
            axis_out.tkeep
130 31 qaztronic
          } = rd_data;
131 28 qaztronic
      end
132
      else
133
      begin
134 31 qaztronic
        assign wr_data =
135 28 qaztronic
          {
136
            axis_in.tdata,
137
            axis_in.tlast,
138
            axis_in.tuser
139
          };
140
        assign
141
          {
142
            axis_out.tdata,
143
            axis_out.tlast,
144
            axis_out.tuser
145 31 qaztronic
          } = rd_data;
146 28 qaztronic
      end
147
    end
148
  endgenerate
149
 
150
 
151
  // --------------------------------------------------------------------
152
  //
153 31 qaztronic
  assign axis_in.tready   = ~wr_full;
154
  assign wr_en            = axis_in.tvalid & ~wr_full;
155
  assign axis_out.tvalid  = ~rd_empty;
156
  assign rd_en            = axis_out.tready & ~rd_empty;
157 28 qaztronic
 
158
 
159 31 qaztronic
// --------------------------------------------------------------------
160
//
161 28 qaztronic
endmodule
162
 

powered by: WebSVN 2.1.0

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