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

Subversion Repositories m32632

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

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

powered by: WebSVN 2.1.0

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