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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [src/] [RIFFA/] [riffa_chnl_rx.sv] - Blame information for rev 32

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

Line No. Rev Author Line
1 32 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
  riffa_chn_rx
30
  #(
31
    N //  data bus width in bytes
32
  )
33
  (
34
    riffa_chnl_if chnl_in,
35
    output rx_done,
36
    output reg [31:0] rx_index,
37
    output reg rx_last,
38
    output reg [31:0] rx_len,
39
    output reg [30:0] rx_off,
40
    output rx_data_ren,
41
    output rd_empty,
42
    output [(8*N)-1:0] rd_data,
43
    input rd_en,
44
 
45
    input clk,
46
    input reset
47
  );
48
 
49
  // --------------------------------------------------------------------
50
  //
51
  localparam RW = (N/4); // width of the bus in 32 bit words
52
 
53
 
54
  // --------------------------------------------------------------------
55
  //
56
  riffa_chnl_rx_fsm
57
    riffa_chnl_rx_fsm_i
58
    (
59
      .rx(chnl_in.rx),
60
      .rx_data_valid(chnl_in.rx_data_valid),
61
      .rx_ack(chnl_in.rx_ack),
62
      .*
63
    );
64
 
65
 
66
  // --------------------------------------------------------------------
67
  //
68
  always_ff @(posedge clk)
69
    if(chnl_in.rx & chnl_in.rx_ack)
70
    begin
71
      rx_last <= chnl_in.rx_last;
72
      rx_len <= chnl_in.rx_len;
73
      rx_off <= chnl_in.rx_off;
74
    end
75
 
76
 
77
  // --------------------------------------------------------------------
78
  //
79
  wire [(8*N)-1:0] wr_data = chnl_in.rx_data;
80
  wire wr_full;
81
  wire wr_en = chnl_in.rx_data_ren & chnl_in.rx_data_valid;
82
 
83
  tiny_sync_fifo #(.W((8*N)))
84
    tiny_sync_fifo_i(.*);
85
 
86
 
87
  // --------------------------------------------------------------------
88
  //
89
  always_ff @(posedge clk)
90
    if(reset | rx_done)
91
      rx_index = 0;
92
    else if(rd_en)
93
      rx_index <= rx_index + RW;
94
 
95
 
96
  // --------------------------------------------------------------------
97
  //
98
  assign rx_data_ren = ~wr_full;
99
 
100
 
101
// --------------------------------------------------------------------
102
//
103
endmodule
104
 

powered by: WebSVN 2.1.0

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