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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_lite_lib/] [src/] [axi4_lite_register_file.sv] - Blame information for rev 37

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

Line No. Rev Author Line
1 29 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
  axi4_lite_register_file
30
  #(
31
    A   = 32,     //  address bus width, must be 32 or greater for axi lite
32
    N   = 8,      //  data bus width in bytes, must be 4 or 8 for axi lite
33 31 qaztronic
    I   = 1,      //  ID width
34
    MW  = 3       //  mux select width
35 29 qaztronic
  )
36
  (
37
    axi4_if               axi4_s,
38
    axi4_lite_register_if r_if,
39
    input                 aclk,
40
    input                 aresetn
41
  );
42
 
43
  // --------------------------------------------------------------------
44
  //
45 31 qaztronic
  localparam MI = 2 ** MW; //  mux inputs
46 29 qaztronic
  localparam LB = (N == 8) ? 3 : 2;
47 31 qaztronic
  localparam UB = LB + MW - 1;
48 29 qaztronic
 
49
 
50
  // --------------------------------------------------------------------
51
  //
52
  wire aw_rd_empty;
53
  wire w_rd_empty;
54
  wire b_wr_full;
55
  wire rf_wr_en = ~aw_rd_empty & ~w_rd_empty & ~b_wr_full;
56
  wire aw_rd_en = rf_wr_en;
57
  wire w_rd_en = rf_wr_en;
58
  wire b_wr_en = rf_wr_en;
59
 
60
  axi4_if #(.A(A), .N(N), .I(I))
61
    axi4_write_fifo(.*);
62
 
63 31 qaztronic
  axi4_s_to_write_fifos #(.A(A), .N(N), .I(I), .USE_ADVANCED_PROTOCOL(0))
64
    axi4_s_to_write_fifos_i(.*);
65 29 qaztronic
 
66
 
67
  // --------------------------------------------------------------------
68
  //
69 31 qaztronic
  wire register_select [MI-1:0];
70 29 qaztronic
  genvar j;
71
 
72
  generate
73 31 qaztronic
    for(j = 0; j < MI; j = j + 1)
74 29 qaztronic
    begin: decoder_gen
75
      assign register_select[j] = (axi4_write_fifo.awaddr[UB:LB] == j) ? 1 : 0;
76 37 qaztronic
      assign r_if.wr_en[j]      = rf_wr_en & register_select[j];
77 29 qaztronic
 
78
      always_ff @(posedge aclk)
79
        if(~aresetn)
80
          r_if.register_out[j] <= 0;
81 37 qaztronic
        else if(r_if.wr_en[j])
82 29 qaztronic
          r_if.register_out[j] <= axi4_write_fifo.wdata;
83
    end
84
  endgenerate
85
 
86
 
87
  // --------------------------------------------------------------------
88
  //
89
  wire ar_rd_empty;
90
  wire r_wr_full;
91
  wire rf_rd_en = ~ar_rd_empty & ~r_wr_full;
92
  wire ar_rd_en = rf_rd_en;
93
  wire r_wr_en = rf_rd_en;
94
 
95
  axi4_if #(.A(A), .N(N), .I(I))
96
    axi4_read_fifo(.*);
97
 
98 31 qaztronic
  axi4_s_to_read_fifos #(.A(A), .N(N), .I(I), .USE_ADVANCED_PROTOCOL(0))
99
    axi4_s_to_read_fifos_i(.*);
100 29 qaztronic
 
101
 
102
  // --------------------------------------------------------------------
103
  //
104 31 qaztronic
  recursive_mux #(.A(MW), .W(N*8))
105 29 qaztronic
    recursive_mux_i
106
    (
107
      .select(axi4_read_fifo.araddr[UB:LB]),
108
      .data_in(r_if.register_in),
109
      .data_out(axi4_read_fifo.rdata)
110
    );
111
 
112
 
113
  // --------------------------------------------------------------------
114
  //
115
  assign axi4_read_fifo.rid   = 0;
116
  assign axi4_read_fifo.rlast = 1;
117
  assign axi4_read_fifo.rresp = 0;
118
 
119
 
120
  // --------------------------------------------------------------------
121
  //
122
  assign axi4_write_fifo.bid   = 0;
123
  assign axi4_write_fifo.bresp = 0;
124
 
125
 
126
// --------------------------------------------------------------------
127
//
128
 
129
endmodule
130
 

powered by: WebSVN 2.1.0

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