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 28

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
    input           axis_en,
40
    axis_if.slave   axis_in,
41
    axis_if.master  axis_out,
42
    input           aclk,
43
    input           aresetn
44
  );
45
 
46
  // --------------------------------------------------------------------
47
  //
48
  localparam W = (N * 8) + (N * USE_TSTRB) + (N * USE_TKEEP) + I + D + U + 1;
49
 
50
  fifo_write_if #(.W(W)) fifo_sink(aclk, ~aresetn);
51
  fifo_read_if  #(.W(W)) fifo_source(aclk, ~aresetn);
52
 
53
  tiny_sync_fifo #(.W(W))
54
    tiny_sync_fifo_i(.source(fifo_sink.fifo), .sink(fifo_source.fifo));
55
 
56
 
57
  // --------------------------------------------------------------------
58
  //
59
  wire data_to_axis_fsm_error;
60
 
61
  data_to_axis_fsm
62
    data_to_axis_fsm_i
63
    (
64
      .axis_tvalid(axis_out.tvalid),
65
      .axis_tready(axis_out.tready),
66
      .fifo_empty(fifo_source.empty),
67
      .fifo_rd_en(fifo_source.rd_en),
68
      .fifo_watermark(1'b1),
69
      .*
70
    );
71
 
72
 
73
  // --------------------------------------------------------------------
74
  //
75
  generate
76
    begin: assign_gen
77
 
78
      if(USE_TSTRB & USE_TKEEP)
79
      begin
80
        assign fifo_sink.wr_data =
81
          {
82
            axis_in.tdata,
83
            axis_in.tlast,
84
            axis_in.tuser,
85
            axis_in.tstrb,
86
            axis_in.tkeep
87
          };
88
        assign
89
          {
90
            axis_out.tdata,
91
            axis_out.tlast,
92
            axis_out.tuser,
93
            axis_out.tstrb,
94
            axis_out.tkeep
95
          } = fifo_source.rd_data;
96
      end
97
      else if(USE_TSTRB)
98
      begin
99
        assign fifo_sink.wr_data =
100
          {
101
            axis_in.tdata,
102
            axis_in.tlast,
103
            axis_in.tuser,
104
            axis_in.tstrb
105
          };
106
        assign
107
          {
108
            axis_out.tdata,
109
            axis_out.tlast,
110
            axis_out.tuser,
111
            axis_out.tstrb
112
          } = fifo_source.rd_data;
113
      end
114
      else if(USE_TKEEP)
115
      begin
116
        assign fifo_sink.wr_data =
117
          {
118
            axis_in.tdata,
119
            axis_in.tlast,
120
            axis_in.tuser,
121
            axis_in.tkeep
122
          };
123
        assign
124
          {
125
            axis_out.tdata,
126
            axis_out.tlast,
127
            axis_out.tuser,
128
            axis_out.tkeep
129
          } = fifo_source.rd_data;
130
      end
131
      else
132
      begin
133
        assign fifo_sink.wr_data =
134
          {
135
            axis_in.tdata,
136
            axis_in.tlast,
137
            axis_in.tuser
138
          };
139
        assign
140
          {
141
            axis_out.tdata,
142
            axis_out.tlast,
143
            axis_out.tuser
144
          } = fifo_source.rd_data;
145
      end
146
 
147
    end
148
  endgenerate
149
 
150
 
151
  // --------------------------------------------------------------------
152
  //
153
  assign axis_in.tready   = ~fifo_sink.full;
154
  assign fifo_sink.wr_en  = axis_in.tvalid & ~fifo_sink.full;
155
 
156
 
157
 
158
endmodule
159
 

powered by: WebSVN 2.1.0

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