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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [avalon_lib/] [src/] [fifo_to_ast.sv] - Blame information for rev 49

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

Line No. Rev Author Line
1 35 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
 
29
module
30
  fifo_to_ast
31
  #(
32
    READYLATENCY,
33
    EW = 1, // error signal width in bits.
34
    CW = 1, // channel width in bits.
35
    SW = 8, // Data symbol width in bits. Should be 8 for byte oriented interfaces.
36
    NSB, // Numbers of symbols per beat
37
    NSB_L = (NSB == 1) ? 1 : $clog2(NSB), // empty width
38
    D = 2,
39
    UB = $clog2(D)
40
  )
41
  (
42
    output            wr_full,
43
    input             wr_en,
44
 
45
    ast_if            ast_in,
46
    ast_if            ast_out,
47
    input             clk,
48
    input             reset
49
  );
50
 
51
  // --------------------------------------------------------------------
52
  //
53
  reg [READYLATENCY:0] ready_r;
54
  wire ready_cycle = ready_r[READYLATENCY];
55
 
56
  always_ff @(posedge clk)
57
    if(reset)
58
      ready_r <= 0;
59
    else
60
      ready_r <= {ready_r[READYLATENCY-1:0], ast_out.ready};
61
 
62
 
63
  // --------------------------------------------------------------------
64
  //
65
  localparam FW = (SW*NSB) + 1 + 1 + NSB_L + CW + EW;
66
 
67
 
68
  // --------------------------------------------------------------------
69
  //
70
  wire [FW-1:0] wr_data =
71
                { ast_in.channel
72
                , ast_in.error
73
                , ast_in.data
74
                , ast_in.empty
75
                , ast_in.endofpacket
76
                , ast_in.startofpacket
77
                };
78
 
79
  wire [FW-1:0] rd_data;
80
  assign  { ast_out.channel
81
          , ast_out.error
82
          , ast_out.data
83
          , ast_out.empty
84
          , ast_out.endofpacket
85
          , ast_out.startofpacket
86
          } = rd_data;
87
 
88
 
89
  // --------------------------------------------------------------------
90
  //
91
  wire rd_empty;
92
  wire rd_en = ready_cycle & ~rd_empty;
93
  wire [UB:0] count;
94
 
95
 
96
  sync_fifo #(.W(FW), .D(D))
97
    sync_fifo_i(.*);
98
 
99
 
100
  // --------------------------------------------------------------------
101
  //
102
  assign ast_out.valid = rd_en;
103
 
104
 
105
// --------------------------------------------------------------------
106
//
107
endmodule
108
 
109
 

powered by: WebSVN 2.1.0

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