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 40

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

powered by: WebSVN 2.1.0

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