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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [src/] [RIFFA/] [riffa_register_file.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) 2017 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_register_file
30
  #(
31 34 qaztronic
    A, //  address bus width
32 32 qaztronic
    N, //  data bus width in bytes
33
    MW = 3 //  mux select width
34
  )
35
  (
36
    riffa_chnl_if chnl_in,
37
    riffa_register_if r_if,
38
    input clk,  // must be same clock domain as rx_clk & tx_clk
39
    input reset // must be same clock domain as rx_clk & tx_clk
40
  );
41
 
42
// --------------------------------------------------------------------
43
// synthesis translate_off
44
    initial
45
      a_data_bus_mod: assert(N % 4 == 0) else $fatal;
46
// synthesis translate_on
47
// --------------------------------------------------------------------
48
 
49
 
50
  // --------------------------------------------------------------------
51
  //
52
  localparam RW = (N/4); // width of the bus in 32 bit words
53
  localparam MI = 2 ** MW; //  mux inputs
54
  localparam LB = $clog2(RW);
55
  localparam UB = LB + MW;
56
 
57
 
58
  // --------------------------------------------------------------------
59
  //
60
  wire rx_done;
61
  wire [31:0] rx_index;
62
  wire rx_last;
63
  wire [31:0] rx_len;
64
  wire [30:0] rx_off;
65
  wire rx_data_ren;
66
  wire rd_empty;
67
  wire [(8*N)-1:0] rd_data;
68
  wire rd_en;
69
 
70
  riffa_chn_rx #(.N(N))
71
    riffa_chn_rx_i(.*);
72
 
73
 
74
  // --------------------------------------------------------------------
75
  //
76
  wire register_select [MI-1:0];
77
  genvar j;
78
 
79
  generate
80
    for(j = 0; j < MI; j = j + 1)
81
    begin: decoder_gen
82
      assign register_select[j] = (rx_index[UB:LB] == j) & (rx_index[31:UB] == 0) ? 1 : 0;
83
 
84
      always_ff @(posedge clk)
85
        if(reset)
86
          r_if.register_out[j] <= 0;
87
        else if(rd_en & register_select[j])
88
          r_if.register_out[j] <= rd_data;
89
    end
90
  endgenerate
91
 
92
 
93
  // --------------------------------------------------------------------
94
  //
95
  assign chnl_in.rx_data_ren = rx_data_ren;
96
  assign rd_en = ~rd_empty;
97
 
98
 
99
  // --------------------------------------------------------------------
100
  //
101
  wire tx_ready = 1;
102
  wire tx_last = 1;
103
  wire [31:0] tx_len = RW*MI;
104
  wire [30:0] tx_off = 0;
105
  wire [31:0] tx_index;
106
  wire tx_done = (tx_index >= chnl_in.tx_len - RW);
107
 
108
  riffa_chn_tx #(.N(N))
109
    riffa_chn_tx_i(.*);
110
 
111
 
112
  // --------------------------------------------------------------------
113
  //
114
  recursive_mux #(.A(MW), .W(N*8))
115
    recursive_mux_i
116
    (
117
      .select(tx_index[UB:LB]),
118
      .data_in(r_if.register_in),
119
      .data_out(chnl_in.tx_data)
120
    );
121
 
122
 
123
  // --------------------------------------------------------------------
124
  //
125
  assign chnl_in.rx_clk = clk;
126
  assign chnl_in.tx_clk = clk;
127
  assign chnl_in.rx_reset = reset;
128
  assign chnl_in.tx_reset = reset;
129
  assign chnl_in.tx_last = 1;
130
  assign chnl_in.tx_len = RW*MI;
131
  assign chnl_in.tx_off = 0;
132
  assign chnl_in.tx_data_valid = 1;
133
 
134
 
135
// --------------------------------------------------------------------
136
//
137
endmodule
138
 

powered by: WebSVN 2.1.0

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