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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB2_iche.v] - Blame information for rev 134

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

Line No. Rev Author Line
1 134 sybreon
/* $Id: aeMB2_iche.v,v 1.4 2008-04-26 17:57:43 sybreon Exp $
2 118 sybreon
**
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 120 sybreon
 * This is a non-optional instruction cache for single cycle
26
   operations. The maximum line width is 16 words (512 bits)
27 118 sybreon
 
28 120 sybreon
 * 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 118 sybreon
 */
35
 
36 120 sybreon
// 63@158 - X3S
37
 
38 118 sybreon
module aeMB2_iche (/*AUTOARG*/
39
   // Outputs
40
   ich_dat, ich_hit, ich_fb,
41
   // Inputs
42 120 sybreon
   ich_adr, iwb_dat_i, iwb_ack_i, gclk, grst, iena, gpha
43 118 sybreon
   );
44
   parameter AEMB_IWB = 32;
45
   parameter AEMB_ICH = 11;
46 120 sybreon
   parameter AEMB_IDX = 6;
47 118 sybreon
   parameter AEMB_HTX = 1;
48
 
49
   // Cache
50
   input [AEMB_IWB-1:2] ich_adr;
51
   output [31:0]         ich_dat;
52 120 sybreon
   output               ich_hit; ///< cache hit
53
   output               ich_fb; ///< cache hit
54 118 sybreon
 
55
   // Wishbone
56
   input [31:0]  iwb_dat_i;
57 120 sybreon
   input                iwb_ack_i;
58 118 sybreon
 
59
   // SYS signals
60
   input                gclk,
61
                        grst,
62
                        iena,
63
                        gpha;
64 120 sybreon
 
65
   // SOME MATH
66
   localparam           SIZ = AEMB_ICH-2; // 2^SIZ entries
67
   localparam           BLK = AEMB_ICH-AEMB_IDX; // 2^BLK blocks 
68
   localparam           LNE = AEMB_IDX-2; // 2^LNE lines per block
69
 
70
   localparam           TAG = AEMB_IWB-AEMB_ICH; // TAG length
71
   localparam           VAL = (1<<LNE); // VAL values (max 16)
72 118 sybreon
 
73
   /*AUTOWIRE*/
74
   /*AUTOREG*/
75
 
76 120 sybreon
   assign               ich_fb = ich_hit;
77 118 sybreon
 
78 120 sybreon
   // 1-of-X decoder
79
   // FIXME: Make decoder dynamic.
80
   // TODO: Factorise into primitive
81
   reg [VAL:1]          rDEC;
82
   always @(/*AUTOSENSE*/ich_adr)
83
     case (ich_adr[AEMB_IDX-1:2])
84
       4'h0: rDEC <= #1 16'h0001;
85
       4'h1: rDEC <= #1 16'h0002;
86
       4'h2: rDEC <= #1 16'h0004;
87
       4'h3: rDEC <= #1 16'h0008;
88
       4'h4: rDEC <= #1 16'h0010;
89
       4'h5: rDEC <= #1 16'h0020;
90
       4'h6: rDEC <= #1 16'h0040;
91
       4'h7: rDEC <= #1 16'h0080;
92
       4'h8: rDEC <= #1 16'h0100;
93
       4'h9: rDEC <= #1 16'h0200;
94
       4'hA: rDEC <= #1 16'h0400;
95
       4'hB: rDEC <= #1 16'h0800;
96
       4'hC: rDEC <= #1 16'h1000;
97
       4'hD: rDEC <= #1 16'h2000;
98
       4'hE: rDEC <= #1 16'h4000;
99
       4'hF: rDEC <= #1 16'h8000;
100 131 sybreon
     endcase // case (ich_adr[AEMB_IDX-1:2])
101 118 sybreon
 
102 120 sybreon
   wire [VAL:1]         wDEC = rDEC[VAL:1]; // resize decoder   
103
 
104
   // explode the address bits
105
   wire [SIZ:1]         aLNE = ich_adr[AEMB_ICH-1:2]; // line address
106
   wire [BLK:1]         aTAG = ich_adr[AEMB_ICH-1:AEMB_IDX]; // block address   
107
   wire [TAG:1]         iTAG = ich_adr[AEMB_IWB-1:AEMB_ICH]; // current TAG value
108
 
109
   wire [VAL:1]         oVAL, iVAL;
110
   wire [TAG:1]         oTAG;
111 134 sybreon
 
112
   wire [31:0]           wIREG;
113 118 sybreon
 
114 120 sybreon
   // HIT CHECKS
115 134 sybreon
   wire                 hTAG = ~|(iTAG ^ oTAG);
116
                        //(iTAG == oTAG);   
117
                        //((iTAG ^ oTAG) == {(TAG){1'b0}});                     
118 120 sybreon
   wire                 hVAL = |(oVAL & wDEC);
119
                        //((oVAL & wDEC) != {(VAL){1'b0}});
120 118 sybreon
 
121 120 sybreon
   assign               ich_hit = hTAG & hVAL;
122
   assign               iVAL = (hTAG) ? // BLOCK/LINE fill check
123
                               oVAL | wDEC : // LINE fill
124
                               wDEC; // BLOCK replace
125 134 sybreon
 
126
   assign               ich_dat = wIREG;
127
 
128 120 sybreon
   /*
129
    aeMB2_tpsram AUTO_TEMPLATE (
130
    .dat_o(),
131
    .dat_i(iwb_dat_i[31:0]),
132
    .adr_i(aLNE[SIZ:1]),
133
    .rst_i(),
134
    .ena_i(iwb_ack_i),
135
    .clk_i(gclk),
136
    .wre_i(iwb_ack_i),
137
 
138 134 sybreon
    .xdat_o(wIREG[31:0]),
139 120 sybreon
    .xdat_i(),
140
    .xadr_i(aLNE[SIZ:1]),
141
    .xrst_i(grst),
142
    .xena_i(iena),
143 118 sybreon
    .xclk_i(gclk),
144 120 sybreon
    .xwre_i(),
145
    )
146 118 sybreon
 
147 120 sybreon
    aeMB2_sparam AUTO_TEMPLATE (
148
    .dat_o({oVAL, oTAG}),
149
    .dat_i({iVAL, iTAG}),
150
    .adr_i(aTAG[BLK:1]),
151
    .ena_i(iwb_ack_i),
152 118 sybreon
    .clk_i(gclk),
153 120 sybreon
    .wre_i(iwb_ack_i),
154
    )
155
    */
156
 
157
   // CACHE TAG BLOCK
158
   aeMB2_sparam
159
     #(.AW(BLK), .DW(VAL+TAG))
160
   tag0
161 118 sybreon
     (/*AUTOINST*/
162
      // Outputs
163 120 sybreon
      .dat_o                            ({oVAL, oTAG}),          // Templated
164 118 sybreon
      // Inputs
165 120 sybreon
      .adr_i                            (aTAG[BLK:1]),           // Templated
166
      .dat_i                            ({iVAL, iTAG}),          // Templated
167
      .wre_i                            (iwb_ack_i),             // Templated
168
      .clk_i                            (gclk),                  // Templated
169
      .ena_i                            (iwb_ack_i));            // Templated
170
 
171
   // CACHE DATA BLOCK   
172
   // Writes on successful IWB bus transfers.
173
   // Reads on pipeline enable.
174
   aeMB2_tpsram
175
     #(.AW(SIZ), .DW(32))
176
   data0
177
     (/*AUTOINST*/
178
      // Outputs
179
      .dat_o                            (),                      // Templated
180 134 sybreon
      .xdat_o                           (wIREG[31:0]),            // Templated
181 120 sybreon
      // Inputs
182
      .adr_i                            (aLNE[SIZ:1]),           // Templated
183 118 sybreon
      .dat_i                            (iwb_dat_i[31:0]),        // Templated
184 120 sybreon
      .wre_i                            (iwb_ack_i),             // Templated
185
      .ena_i                            (iwb_ack_i),             // Templated
186
      .rst_i                            (),                      // Templated
187 118 sybreon
      .clk_i                            (gclk),                  // Templated
188 120 sybreon
      .xadr_i                           (aLNE[SIZ:1]),           // Templated
189
      .xdat_i                           (),                      // Templated
190
      .xwre_i                           (),                      // Templated
191
      .xena_i                           (iena),                  // Templated
192
      .xrst_i                           (grst),                  // Templated
193
      .xclk_i                           (gclk));                         // Templated
194 118 sybreon
 
195
endmodule // aeMB2_iche
196
 
197 131 sybreon
/*
198
 $Log: not supported by cvs2svn $
199 134 sybreon
 Revision 1.3  2008/04/26 01:09:06  sybreon
200
 Passes basic tests. Minor documentation changes to make it compatible with iverilog pre-processor.
201
 
202 131 sybreon
 Revision 1.2  2008/04/20 16:34:32  sybreon
203
 Basic version with some features left out.
204
 
205
 Revision 1.1  2008/04/18 00:21:52  sybreon
206
 Initial import.
207
*/

powered by: WebSVN 2.1.0

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