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

Subversion Repositories m32632

[/] [m32632/] [trunk/] [rtl/] [ICACHE.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 9 ns32kum
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2
//
3
// This file is part of the M32632 project
4
// http://opencores.org/project,m32632
5
//
6 23 ns32kum
//      Filename:       ICACHE.v
7
//      Version:        2.0
8
//      History:        1.0 first release of 30 Mai 2015
9
//      Date:           14 August 2016
10 9 ns32kum
//
11 23 ns32kum
// Copyright (C) 2016 Udo Moeller
12 9 ns32kum
// 
13
// This source file may be used and distributed without 
14
// restriction provided that this copyright statement is not 
15
// removed from the file and that any derivative work contains 
16
// the original copyright notice and the associated disclaimer.
17
// 
18
// This source file is free software; you can redistribute it 
19
// and/or modify it under the terms of the GNU Lesser General 
20
// Public License as published by the Free Software Foundation;
21
// either version 2.1 of the License, or (at your option) any 
22
// later version. 
23
// 
24
// This source is distributed in the hope that it will be 
25
// useful, but WITHOUT ANY WARRANTY; without even the implied 
26
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
27
// PURPOSE. See the GNU Lesser General Public License for more 
28
// details. 
29
// 
30
// You should have received a copy of the GNU Lesser General 
31
// Public License along with this source; if not, download it 
32
// from http://www.opencores.org/lgpl.shtml 
33
// 
34
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
35
//
36
//      Modules contained in this file:
37
//      ICACHE          the instruction cache of M32632
38
//
39 11 ns32kum
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 9 ns32kum
 
41 23 ns32kum
module ICACHE( BCLK, MCLK, DRAMSZ, MDONE, BRESET, READ_I, IO_READY, PSR_USER, DATA_HOLD, PTB_WR, PTB_SEL, DRAM_WR,
42 11 ns32kum
                           KDET, HOLD, CFG, DRAM_Q, CINVAL, IC_SIGS, IO_Q, IVAR, KOLLI_A, MCR_FLAGS, MMU_DIN, VADR, WADDR,
43 9 ns32kum
                           WCTRL, IO_RD, DRAM_ACC, INIT_RUN, PROT_ERROR, ACC_OK, IC_PREQ, KOLLISION, ENA_HK, STOP_CINV,
44
                           DRAM_A, IC_DQ, IC_VA, ICTODC, IO_A, ENDRAM );
45
 
46
input                   BCLK;
47
input                   MCLK;
48 23 ns32kum
input    [2:0]   DRAMSZ;
49 9 ns32kum
input                   MDONE;
50
input                   BRESET;
51
input                   READ_I;
52
input                   IO_READY;
53
input                   PSR_USER;
54
input                   DATA_HOLD;
55
input                   PTB_WR;
56
input                   PTB_SEL;
57
input                   DRAM_WR;
58
input                   KDET;
59
input                   HOLD;
60
input    [1:0]   CFG;
61
input   [31:0]   DRAM_Q;
62
input    [1:0]   CINVAL;
63
input    [1:0]   IC_SIGS;
64
input   [31:0]   IO_Q;
65
input    [1:0]   IVAR;
66
input   [27:4]  KOLLI_A;
67
input    [3:0]   MCR_FLAGS;
68
input   [23:0]   MMU_DIN;
69
input   [31:0]   VADR;
70
input   [11:2]  WADDR;
71
input    [2:0]   WCTRL;
72
input                   ENA_HK;
73
input                   ENDRAM;
74
 
75
output                  IO_RD;
76
output                  DRAM_ACC;
77
output                  INIT_RUN;
78
output                  PROT_ERROR;
79
output                  ACC_OK;
80
output                  IC_PREQ;
81
output                  KOLLISION;
82
output                  STOP_CINV;
83
output  [31:0]   IC_DQ;
84
output [31:12]  IC_VA;
85
output   [3:0]   ICTODC;
86
output reg      [27:0]   DRAM_A;
87
output reg      [31:0]   IO_A;
88
 
89
reg             [31:0]   VADR_R;
90
reg             [31:0]   CAPDAT;
91
reg             [31:0]   DFFE_IOR;
92
reg                             HOLD_ON;
93
reg                             DFF_HDFF1;
94
reg                             DFF_IRD_REG;
95
 
96
wire    [4:0]    A_CV;
97
wire                    ACOK;
98
wire    [4:0]    ACV;
99
wire                    AUX_DAT;
100
wire                    CA_HIT;
101
wire                    CA_SET;
102
wire                    CUPDATE;
103
wire    [23:0]   D_CV;
104
wire                    HIT_ALL;
105
wire                    INIT_CA_RUN;
106
wire                    IO_ACC;
107
wire                    KILL;
108
wire                    NEW_PTB;
109
wire                    PTB_ONE;
110
wire   [31:12]  RADR;
111
wire                    READ;
112
wire                    RUN_ICRD;
113
wire                    STOP_ICRD;
114
wire    [23:0]   UPCD;
115
wire    [23:0]   UPDATE_C;
116
wire    [31:0]   UPDATE_M;
117
wire                    USE_CA;
118
wire                    USER;
119
wire    [11:7]  V_ADR;
120
wire                    WE_CV;
121
wire                    WEMV;
122
wire                    WRCRAM0;
123
wire                    WRCRAM1;
124
wire                    WRSET0;
125
wire                    WRSET1;
126
wire                    WRITE;
127
wire    [11:7]  KILLADR;
128
wire                    AUX_ALT;
129
wire                    VIRT_A;
130
wire                    CI;
131
wire                    MMU_HIT;
132
wire                    LD_DRAM_A;
133
wire                    IO_SPACE;
134
wire                    LAST_MUX;
135
wire                    VIRTUELL;
136
wire                    NEW_PTB_RUN;
137
wire    [31:0]   SET_DAT;
138
wire    [31:0]   ALT_DAT;
139
wire    [31:0]   DAT_MV;
140
wire     [3:0]   RADR_MV;
141
wire     [3:0]   WADR_MV;
142
wire    [23:0]   NEWCVAL;
143
wire                    KILL_C,KILL_K;
144
wire                    RMW;
145
 
146
// +++++++++++++++++++ Memories ++++++++++++++++++++
147
 
148
reg             [31:0]   DATA0 [0:1023];          // Data Set 0 : 4 kBytes
149
reg             [31:0]   SET_DAT0;
150
 
151
reg             [31:0]   DATA1 [0:1023];          // Data Set 1 : 4 kBytes
152
reg             [31:0]   SET_DAT1;
153
 
154
reg             [15:0]   TAGSET_0 [0:255];        // Tag Set for Data Set 0 : 256 entries of 16 bits
155
reg             [15:0]   TAG0;
156
 
157
reg             [15:0]   TAGSET_1 [0:255];        // Tag Set for Data Set 1 : 256 entries of 16 bits
158
reg             [15:0]   TAG1;
159
 
160 23 ns32kum
wire    [23:0]   CVALID;
161 9 ns32kum
 
162
reg             [35:0]   MMU_TAGS [0:255];        // Tag Set for MMU : 256 entries of 36 bits
163
reg             [35:0]   MMU_Q;
164
 
165
reg             [31:0]   MMU_VALID [0:15];        // Valid bits for MMU Tag Set : 16 entries of 32 bits
166
reg             [31:0]   MVALID;
167
 
168
reg             [15:0]   KTAGSET_0 [0:255];       // Kollision Tag Set for Data Set 0 : 256 entries of 16 bits
169
reg             [15:0]   KTAG0;
170
 
171
reg             [15:0]   KTAGSET_1 [0:255];       // Kollision Tag Set for Data Set 1 : 256 entries of 16 bits
172
reg             [15:0]   KTAG1;
173
 
174 23 ns32kum
wire    [23:0]   KCVALID;
175 9 ns32kum
 
176
assign  READ    = READ_I & ~HOLD_ON & RUN_ICRD;
177
assign  WRITE   = 1'b0;
178
assign  RMW             = 1'b0;
179
 
180
assign  ALT_DAT = AUX_ALT ? DFFE_IOR : CAPDAT ;
181
 
182
assign  RADR    = VIRT_A ? MMU_Q[19:0] : VADR_R[31:12] ;
183
 
184
assign  V_ADR   = STOP_ICRD ? KILLADR : VADR[11:7] ;
185
assign  ACV             = STOP_ICRD ? KILLADR : A_CV ;
186
assign  UPCD    = STOP_ICRD ? NEWCVAL : UPDATE_C ;
187
 
188
assign  IC_DQ   = LAST_MUX ? ALT_DAT : SET_DAT ;
189
 
190
assign  SET_DAT = CA_SET ? SET_DAT1 : SET_DAT0 ;
191
 
192
assign  KILL    = KILL_C | KILL_K;
193
 
194
assign  IC_VA   = VADR_R[31:12];
195
 
196
assign  VIRT_A  = ~CINVAL[0] & VIRTUELL;
197
 
198
assign  ACC_OK  = HOLD_ON | ACOK;
199
 
200
assign  USER    = ~MCR_FLAGS[3] & PSR_USER;
201
 
202
assign  AUX_ALT = HOLD_ON | DFF_IRD_REG;
203
 
204
assign  LAST_MUX = AUX_ALT | AUX_DAT;
205
 
206
assign  INIT_RUN = NEW_PTB_RUN | INIT_CA_RUN;
207
 
208
assign  LD_DRAM_A = ~DRAM_ACC | MDONE;
209
 
210
assign  ICTODC[3] = USER;
211
 
212
always @(posedge BCLK) VADR_R <= VADR;
213
 
214
always @(posedge BCLK) DFF_IRD_REG <= IO_RD;
215
 
216
always @(posedge BCLK) DFF_HDFF1 <= IO_READY;
217
 
218
always @(posedge BCLK) if (LD_DRAM_A) DRAM_A[27:0] <= {RADR[27:12],VADR_R[11:2],USE_CA,CA_SET};
219
 
220
always @(posedge BCLK) if (IO_ACC) IO_A <= {RADR[31:12],VADR_R[11:0]};
221
 
222
always @(posedge BCLK) if (IO_RD) DFFE_IOR <= IO_Q;
223
 
224
always @(posedge BCLK or negedge BRESET)
225
        if (!BRESET) HOLD_ON <= 1'b0;
226
                else HOLD_ON <= (DATA_HOLD & DFF_HDFF1) | (HOLD_ON & DATA_HOLD);
227
 
228
always @(posedge MCLK) if (WCTRL[2]) CAPDAT <= DRAM_Q;
229
 
230
// +++++++++++++++++++++++++  Cache Valid  +++++++++++++++++++
231
 
232 23 ns32kum
NEU_VALID       VALID_RAM(
233
        .BCLK(BCLK),
234
        .VALIN(D_CV),
235
        .WADR(ACV),
236
        .WREN(WE_CV),
237
        .RADR(V_ADR[11:7]),
238
        .VALOUT(CVALID) );
239 9 ns32kum
 
240
// +++++++++++++++++++++++++  Tag Set 0  +++++++++++++++++++++
241
 
242
always @(posedge BCLK) TAG0 <= TAGSET_0[VADR[11:4]];
243
 
244
always @(negedge BCLK) if (WRCRAM0) TAGSET_0[VADR_R[11:4]] <= RADR[27:12];
245
 
246
// +++++++++++++++++++++++++  Tag Set 1  +++++++++++++++++++++
247
 
248
always @(posedge BCLK) TAG1 <= TAGSET_1[VADR[11:4]];
249
 
250
always @(negedge BCLK) if (WRCRAM1) TAGSET_1[VADR_R[11:4]] <= RADR[27:12];
251
 
252
// +++++++++++++++++++++++++  Data Set 0  ++++++++++++++++++++
253
 
254
always @(posedge BCLK) SET_DAT0 <= DATA0[VADR[11:2]];
255
 
256
always @(posedge MCLK) if (WRSET0) DATA0[WADDR] <= DRAM_Q;
257
 
258
// +++++++++++++++++++++++++  Data Set 1  ++++++++++++++++++++
259
 
260
always @(posedge BCLK) SET_DAT1 <= DATA1[VADR[11:2]];
261
 
262
always @(posedge MCLK) if (WRSET1) DATA1[WADDR] <= DRAM_Q;
263
 
264
CA_MATCH        DCA_COMPARE(
265
        .INVAL_L(CINVAL[0]),
266
        .CI(CI),
267
        .MMU_HIT(MMU_HIT),
268
        .WRITE(WRITE),
269
        .KDET(1'b0),
270 23 ns32kum
        .ADDR({RADR[31:12],VADR_R[11:4]}),
271 9 ns32kum
        .CFG(CFG),
272
        .ENDRAM(ENDRAM),
273
        .CVALID(CVALID),
274
        .TAG0(TAG0),
275
        .TAG1(TAG1),
276
        .CA_HIT(CA_HIT),
277
        .CA_SET(CA_SET),
278
        .WB_ACC(),
279
        .USE_CA(USE_CA),
280 23 ns32kum
        .DRAMSZ(DRAMSZ),
281 9 ns32kum
        .IO_SPACE(IO_SPACE),
282
        .DC_ILO(1'b0),
283
        .KILL(KILL_C),
284
        .UPDATE(UPDATE_C));
285
 
286
DCA_CONTROL     DCA_CTRL(
287
        .BCLK(BCLK),
288
        .MCLK(1'b0),
289
        .WRCFG(1'b1),
290
        .BRESET(BRESET),
291
        .CA_SET(CA_SET),
292
        .HIT_ALL(HIT_ALL),
293
        .UPDATE(UPCD),
294
        .VADR_R(VADR_R[11:7]),
295
        .DRAM_ACC(DRAM_ACC),
296
        .CUPDATE(CUPDATE),
297
        .KILL(KILL),
298
        .WRITE(WRITE),
299
        .WCTRL(WCTRL[1:0]),
300
        .INVAL_A(CINVAL[1]),
301
        .DAT_CV(D_CV),
302
        .WADR_CV(A_CV),
303
        .WE_CV(WE_CV),
304
        .INIT_CA_RUN(INIT_CA_RUN),
305
        .WRCRAM0(WRCRAM0),
306
        .WRCRAM1(WRCRAM1),
307
        .WRSET0(WRSET0),
308
        .WRSET1(WRSET1));
309
 
310
ICACHE_SM       IC_SM(
311
        .BCLK(BCLK),
312
        .BRESET(BRESET),
313
        .IO_SPACE(IO_SPACE),
314
        .READ(READ),
315
        .MDONE(MDONE),
316
        .IO_READY(IO_READY),
317
        .MMU_HIT(MMU_HIT),
318
        .CA_HIT(CA_HIT),
319
        .USE_CA(USE_CA),
320
        .PTB_WR(PTB_WR),
321
        .PTB_SEL(PTB_SEL),
322
        .USER(USER),
323
        .PROT_ERROR(PROT_ERROR),
324
        .PTE_ACC(IC_SIGS[1]),
325
        .ACC_OK(ACOK),
326
        .PTB_ONE(PTB_ONE),
327
        .NEW_PTB(NEW_PTB),
328
        .AUX_DAT(AUX_DAT),
329
        .CUPDATE(CUPDATE),
330
        .IO_RD(IO_RD),
331
        .IO_ACC(IO_ACC),
332
        .DRAM_ACC(DRAM_ACC),
333
        .IC_PREQ(IC_PREQ),
334
        .HIT_ALL(HIT_ALL));
335
 
336
// +++++++++++++++++++++++++  Kollision Valid  +++++++++++++++
337
 
338 23 ns32kum
NEU_VALID       KOL_VAL(
339
        .BCLK(BCLK),
340
        .VALIN(D_CV),
341
        .WADR(ACV),
342
        .WREN(WE_CV),
343
        .RADR(KOLLI_A[11:7]),
344
        .VALOUT(KCVALID) );
345 9 ns32kum
 
346
// +++++++++++++++++++++++++  Kollision Tag Set 0  +++++++++++
347
 
348
always @(posedge BCLK) KTAG0 <= KTAGSET_0[KOLLI_A[11:4]];
349
 
350
always @(negedge BCLK) if (WRCRAM0) KTAGSET_0[VADR_R[11:4]] <= RADR[27:12];
351
 
352
// +++++++++++++++++++++++++  Kollision Tag Set 1  +++++++++++
353
 
354
always @(posedge BCLK) KTAG1 <= KTAGSET_1[KOLLI_A[11:4]];
355
 
356
always @(negedge BCLK) if (WRCRAM1) KTAGSET_1[VADR_R[11:4]] <= RADR[27:12];
357
 
358
KOLDETECT       KOLLOGIK(
359
        .DRAM_WR(DRAM_WR),
360
        .BCLK(BCLK),
361
        .READ_I(READ_I),
362
        .ACC_OK(ACC_OK),
363
        .BRESET(BRESET),
364
        .INVAL_A(CINVAL[1]),
365
        .KDET(KDET),
366
        .HOLD(HOLD),
367
        .ENA_HK(ENA_HK),
368
        .STOP_CINV(STOP_CINV),
369
        .ADDR(KOLLI_A),
370
        .C_VALID(KCVALID),
371
        .CFG(CFG),
372
        .CVALID(CVALID),
373
        .TAG0(KTAG0),
374
        .TAG1(KTAG1),
375
        .KOLLISION(KOLLISION),
376
        .STOP_ICRD(STOP_ICRD),
377
        .RUN_ICRD(RUN_ICRD),
378
        .KILL(KILL_K),
379
        .ICTODC(ICTODC[2:0]),
380
        .KILLADR(KILLADR),
381
        .NEWCVAL(NEWCVAL));
382
 
383
MMU_MATCH       MMU_COMPARE(
384
        .USER(USER),
385
        .READ(READ),
386
        .WRITE(WRITE),
387
        .RMW(RMW),
388
        .IVAR(IVAR),
389
        .MCR_FLAGS(MCR_FLAGS[2:0]),
390
        .MMU_VA(MMU_Q[35:20]),
391
        .MVALID(MVALID),
392
        .VADR_R(VADR_R[31:12]),
393
        .MMU_HIT(MMU_HIT),
394
        .PROT_ERROR(PROT_ERROR),
395
        .VIRTUELL(VIRTUELL),
396
        .CI(CI),
397
        .SEL_PTB1(),
398
        .UPDATE(UPDATE_M));
399
 
400
MMU_UP  MMU_CTRL(
401
        .NEW_PTB(NEW_PTB),
402
        .IVAR(IVAR[1]),
403
        .BRESET(BRESET),
404
        .PTB1(PTB_ONE),
405
        .BCLK(BCLK),
406
        .WR_MRAM(IC_SIGS[0]),
407
        .MVALID(MVALID),
408
        .UPDATE(UPDATE_M),
409
        .VADR(VADR[19:16]),
410
        .VADR_R(VADR_R[19:16]),
411
        .WE_MV(WEMV),
412
        .NEW_PTB_RUN(NEW_PTB_RUN),
413
        .DAT_MV(DAT_MV),
414
        .RADR_MV(RADR_MV),
415
        .WADR_MV(WADR_MV));
416
 
417
// +++++++++++++++++++++++++  MMU Valid  +++++++++++++++++++++
418
 
419
always @(posedge BCLK) MVALID <= MMU_VALID[RADR_MV];
420
 
421
always @(negedge BCLK) if (WEMV) MMU_VALID[WADR_MV] <= DAT_MV;
422
 
423
// +++++++++++++++++++++++++  MMU Tags  ++++++++++++++++++++++
424
 
425
always @(posedge BCLK) MMU_Q <= MMU_TAGS[VADR[19:12]];
426
 
427
always @(negedge BCLK) if (IC_SIGS[0]) MMU_TAGS[VADR_R[19:12]] <= {VADR_R[31:20],MMU_DIN[23:0]};
428
 
429
endmodule

powered by: WebSVN 2.1.0

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