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 34

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 34 qaztronic
    output reg [30:0] rx_index,
37 32 qaztronic
    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
  riffa_chnl_rx_fsm
52
    riffa_chnl_rx_fsm_i
53
    (
54
      .rx(chnl_in.rx),
55
      .rx_data_valid(chnl_in.rx_data_valid),
56
      .rx_ack(chnl_in.rx_ack),
57
      .*
58
    );
59
 
60
 
61
  // --------------------------------------------------------------------
62
  //
63
  always_ff @(posedge clk)
64
    if(chnl_in.rx & chnl_in.rx_ack)
65
    begin
66
      rx_last <= chnl_in.rx_last;
67
      rx_len <= chnl_in.rx_len;
68
      rx_off <= chnl_in.rx_off;
69
    end
70
 
71
 
72
  // --------------------------------------------------------------------
73
  //
74
  wire [(8*N)-1:0] wr_data = chnl_in.rx_data;
75
  wire wr_full;
76
  wire wr_en = chnl_in.rx_data_ren & chnl_in.rx_data_valid;
77
 
78
  tiny_sync_fifo #(.W((8*N)))
79
    tiny_sync_fifo_i(.*);
80
 
81
 
82
  // --------------------------------------------------------------------
83
  //
84
  always_ff @(posedge clk)
85
    if(reset | rx_done)
86
      rx_index = 0;
87
    else if(rd_en)
88 34 qaztronic
      rx_index <= rx_index + (N/4); // increment by 32 bit words
89 32 qaztronic
 
90
 
91
  // --------------------------------------------------------------------
92
  //
93
  assign rx_data_ren = ~wr_full;
94
 
95
 
96
// --------------------------------------------------------------------
97
//
98
endmodule
99
 

powered by: WebSVN 2.1.0

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