OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [aeMB/] [verilog/] [src/] [aeMB2_iche.v] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 alirezamon
/* $Id: aeMB2_iche.v,v 1.5 2008-04-28 00:54:31 sybreon Exp $
2
**
3
** AEMB2 EDK 6.2 COMPATIBLE CORE
4
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
20
*/
21
/**
22
 * Instruction Cache Block
23
 * @file aeMB2_iche.v
24
 
25
 * This is a non-optional instruction cache for single cycle
26
   operations. The maximum line width is 16 words (512 bits)
27
 
28
 * Single port synchronous RAM is used as the main cache DATA
29
   block. A single port asynchronous RAM is used as the TAG block.
30
 
31
 * The sizes need to be selected carefully to minimise resource
32
   wastage. Details are provided in the documentation.
33
 
34
 
35
 
36
 
37
 */
38
 
39
// 63@158 - X3S
40
`timescale  1ns/1ps
41
module aeMB2_iche (/*AUTOARG*/
42
   // Outputs
43
   ich_dat, ich_hit, ich_fb,
44
   // Inputs
45
   ich_adr, iwb_dat_i, iwb_ack_i, gclk, grst, iena, gpha
46
   );
47
   parameter AEMB_IWB = 32;
48
   parameter AEMB_ICH = 11;
49
   parameter AEMB_IDX = 6;
50
   parameter AEMB_HTX = 1;
51
 
52
   // Cache
53
   input [AEMB_IWB-1:2] ich_adr;
54
   output [31:0]         ich_dat;
55
   output               ich_hit; ///< cache hit
56
   output               ich_fb; ///< cache hit
57
 
58
   // Wishbone
59
   input [31:0]  iwb_dat_i;
60
   input                iwb_ack_i;
61
 
62
   // SYS signals
63
   input                gclk,
64
                        grst,
65
                        iena,
66
                        gpha;
67
 
68
   // SOME MATH
69
   localparam           SIZ = AEMB_ICH-2; // 2^SIZ entries
70
   localparam           BLK = AEMB_ICH-AEMB_IDX; // 2^BLK blocks 
71
   localparam           LNE = AEMB_IDX-2; // 2^LNE lines per block
72
 
73
   localparam           TAG = AEMB_IWB-AEMB_ICH; // TAG length
74
   localparam           VAL = (1<<LNE); // VAL values (max 16)
75
 
76
   /*AUTOWIRE*/
77
   /*AUTOREG*/
78
 
79
   assign               ich_fb = ich_hit;
80
 
81
   // 1-of-X decoder
82
   // FIXME: Make decoder dynamic.
83
   // TODO: Factorise into primitive
84
   reg [VAL:1]          rDEC;
85
   always @(/*AUTOSENSE*/ich_adr)
86
     case (ich_adr[AEMB_IDX-1:2])
87
       4'h0: rDEC <= #1 16'h0001;
88
       4'h1: rDEC <= #1 16'h0002;
89
       4'h2: rDEC <= #1 16'h0004;
90
       4'h3: rDEC <= #1 16'h0008;
91
       4'h4: rDEC <= #1 16'h0010;
92
       4'h5: rDEC <= #1 16'h0020;
93
       4'h6: rDEC <= #1 16'h0040;
94
       4'h7: rDEC <= #1 16'h0080;
95
       4'h8: rDEC <= #1 16'h0100;
96
       4'h9: rDEC <= #1 16'h0200;
97
       4'hA: rDEC <= #1 16'h0400;
98
       4'hB: rDEC <= #1 16'h0800;
99
       4'hC: rDEC <= #1 16'h1000;
100
       4'hD: rDEC <= #1 16'h2000;
101
       4'hE: rDEC <= #1 16'h4000;
102
       4'hF: rDEC <= #1 16'h8000;
103
     endcase // case (ich_adr[AEMB_IDX-1:2])
104
 
105
        localparam     VALID_WIDTH      =       2**BLK;
106
        wire     VLD;
107
        reg     [VALID_WIDTH-1          :       0]       valid;
108
 
109
 
110
 
111
   wire [VAL:1]         wDEC = rDEC[VAL:1]; // resize decoder   
112
 
113
   // explode the address bits
114
   wire [VAL:1]         oVAL, iVAL,oVAL_out;
115
   wire [SIZ:1]         aLNE = ich_adr[AEMB_ICH-1:2]; // line address
116
   wire [BLK:1]         aTAG = ich_adr[AEMB_ICH-1:AEMB_IDX]; // block address   
117
   wire [TAG:1]         iTAG = ich_adr[AEMB_IWB-1:AEMB_ICH]; // current TAG value
118
   wire [TAG:1]         oTAG,oTAG_out;
119
 
120
   // HIT CHECKS
121
   wire                 hTAG = ((iTAG ^ oTAG) == {(TAG){1'b0}}); // 100.0
122
                        //~|(iTAG ^ oTAG); // 98
123
                        //(iTAG == oTAG); // 85
124
   wire                 hVAL = //|(oVAL & wDEC);   
125
                        ((oVAL & wDEC) != {(VAL){1'b0}});
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
        assign VLD  = valid[aTAG[BLK:1]];
134
 
135
        always @(posedge gclk or posedge grst ) begin
136
                if (grst) valid = 0;
137
                else if (iwb_ack_i) valid[aTAG[BLK:1]] = 1'b1;
138
        end
139
 
140
 
141
 
142
 
143
 
144
 
145
   assign               ich_hit = hTAG & hVAL;
146
   assign               iVAL = (hTAG) ? // BLOCK/LINE fill check
147
                              oVAL | wDEC : // LINE fill
148
                              wDEC; // BLOCK replace
149
 
150
 
151
 
152
 
153
 
154
        /*
155
    aeMB2_tpsram AUTO_TEMPLATE (
156
    .AW(SIZ),
157
    .DW(6'd32),
158
 
159
    .dat_o(),
160
    .dat_i(iwb_dat_i[31:0]),
161
    .adr_i(aLNE[SIZ:1]),
162
    .rst_i(),
163
    .ena_i(iwb_ack_i),
164
    .clk_i(gclk),
165
    .wre_i(iwb_ack_i),
166
 
167
    .xdat_o(ich_dat[31:0]),
168
    .xdat_i(),
169
    .xadr_i(aLNE[SIZ:1]),
170
    .xrst_i(grst),
171
    .xena_i(iena),
172
    .xclk_i(gclk),
173
    .xwre_i(),
174
    )
175
 
176
    aeMB2_sparam AUTO_TEMPLATE (
177
    .AW(BLK),
178
    .DW(VAL+TAG),
179
 
180
    .dat_o({oVAL, oTAG}),
181
    .dat_i({iVAL, iTAG}),
182
    .adr_i(aTAG[BLK:1]),
183
    .ena_i(iwb_ack_i),
184
    .clk_i(gclk),
185
    .wre_i(iwb_ack_i),
186
    )
187
    */
188
 
189
         assign oTAG = (VLD) ? oTAG_out :       {TAG{1'b0}};
190
         assign oVAL = (VLD) ? oVAL_out :       {VAL{1'b0}};
191
 
192
 
193
   // CACHE TAG BLOCK
194
   aeMB2_sparam
195
     #(/*AUTOINSTPARAM*/
196
       // Parameters
197
       .AW                              (BLK),                   // Templated
198
       .DW                              (VAL+TAG))               // Templated
199
   tag0
200
     (/*AUTOINST*/
201
      // Outputs
202
      .dat_o                            ({oVAL_out, oTAG_out}),          // Templated
203
      // Inputs
204
      .adr_i                            (aTAG[BLK:1]),           // Templated
205
      .dat_i                            ({iVAL, iTAG}),          // Templated
206
      .wre_i                            (iwb_ack_i),             // Templated
207
      .clk_i                            (gclk),                  // Templated
208
      .ena_i                            (iwb_ack_i));            // Templated
209
 
210
   // CACHE DATA BLOCK   
211
   // Writes on successful IWB bus transfers.
212
   // Reads on pipeline enable.
213
   aeMB2_tpsram
214
     #(/*AUTOINSTPARAM*/
215
       // Parameters
216
       .AW                              (SIZ),                   // Templated
217
       .DW                              (6'd32))                 // Templated
218
   data0
219
     (/*AUTOINST*/
220
      // Outputs
221
      .dat_o                            (),                      // Templated
222
      .xdat_o                           (ich_dat[31:0]),  // Templated
223
      // Inputs
224
      .adr_i                            (aLNE[SIZ:1]),           // Templated
225
      .dat_i                            (iwb_dat_i[31:0]),        // Templated
226
      .wre_i                            (iwb_ack_i),             // Templated
227
      .ena_i                            (iwb_ack_i),             // Templated
228
      .rst_i                            (),                      // Templated
229
      .clk_i                            (gclk),                  // Templated
230
      .xadr_i                           (aLNE[SIZ:1]),           // Templated
231
      .xdat_i                           (),                      // Templated
232
      .xwre_i                           (),                      // Templated
233
      .xena_i                           (iena),                  // Templated
234
      .xrst_i                           (grst),                  // Templated
235
      .xclk_i                           (gclk));                         // Templated
236
 
237
endmodule // aeMB2_iche
238
 
239
/*
240
 $Log: not supported by cvs2svn $
241
 Revision 1.4  2008/04/26 17:57:43  sybreon
242
 Minor performance improvements.
243
 
244
 Revision 1.3  2008/04/26 01:09:06  sybreon
245
 Passes basic tests. Minor documentation changes to make it compatible with iverilog pre-processor.
246
 
247
 Revision 1.2  2008/04/20 16:34:32  sybreon
248
 Basic version with some features left out.
249
 
250
 Revision 1.1  2008/04/18 00:21:52  sybreon
251
 Initial import.
252
*/

powered by: WebSVN 2.1.0

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