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

Subversion Repositories m32632

[/] [m32632/] [trunk/] [rtl/] [ICACHE.v] - Diff between revs 23 and 29

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 23 Rev 29
Line 1... Line 1...
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//
// This file is part of the M32632 project
// This file is part of the M32632 project
// http://opencores.org/project,m32632
// http://opencores.org/project,m32632
//
//
//      Filename:       ICACHE.v
//      Filename:       ICACHE.v
//      Version:        2.0
//      Version:        3.0 Cache Interface reworked
//      History:        1.0 first release of 30 Mai 2015
//      History:        2.0 50 MHz release of 14 August 2016
//      Date:           14 August 2016
//                              1.0 first release of 30 Mai 2015
 
//      Date:           2 December 2018
//
//
// Copyright (C) 2016 Udo Moeller
// Copyright (C) 2018 Udo Moeller
// 
// 
// This source file may be used and distributed without 
// This source file may be used and distributed without 
// restriction provided that this copyright statement is not 
// restriction provided that this copyright statement is not 
// removed from the file and that any derivative work contains 
// removed from the file and that any derivative work contains 
// the original copyright notice and the associated disclaimer.
// the original copyright notice and the associated disclaimer.
Line 29... Line 30...
// 
// 
// You should have received a copy of the GNU Lesser General 
// You should have received a copy of the GNU Lesser General 
// Public License along with this source; if not, download it 
// Public License along with this source; if not, download it 
// from http://www.opencores.org/lgpl.shtml 
// from http://www.opencores.org/lgpl.shtml 
// 
// 
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//
//      Modules contained in this file:
//      Modules contained in this file:
//      ICACHE          the instruction cache of M32632
//      ICACHE          the instruction cache of M32632
//
//
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 
module ICACHE( BCLK, MCLK, DRAMSZ, MDONE, BRESET, READ_I, IO_READY, PSR_USER, DATA_HOLD, PTB_WR, PTB_SEL, DRAM_WR,
module ICACHE( BCLK, DRAMSZ, MDONE, BRESET, READ_I, IO_READY, PSR_USER, DATA_HOLD, PTB_WR, PTB_SEL, DRAM_WR,
                           KDET, HOLD, CFG, DRAM_Q, CINVAL, IC_SIGS, IO_Q, IVAR, KOLLI_A, MCR_FLAGS, MMU_DIN, VADR, WADDR,
                           KDET, HOLD, CFG, DRAM_Q, CINVAL, IC_SIGS, IO_Q, IVAR, KOLLI_A, MCR_FLAGS, MMU_DIN, VADR,
                           WCTRL, IO_RD, DRAM_ACC, INIT_RUN, PROT_ERROR, ACC_OK, IC_PREQ, KOLLISION, ENA_HK, STOP_CINV,
                           INHIBIT, IO_RD, DRAM_ACC, INIT_RUN, PROT_ERROR, ACC_OK, IC_PREQ, KOLLISION, ENA_HK, STOP_CINV,
                           DRAM_A, IC_DQ, IC_VA, ICTODC, IO_A, ENDRAM );
                           DRAM_A, IC_DQ, IC_VA, ICTODC, IO_A, ENDRAM );
 
 
input                   BCLK;
input                   BCLK;
input                   MCLK;
 
input    [2:0]   DRAMSZ;
input    [2:0]   DRAMSZ;
input                   MDONE;
input                   MDONE;
input                   BRESET;
input                   BRESET;
input                   READ_I;
input                   READ_I;
input                   IO_READY;
input                   IO_READY;
Line 56... Line 56...
input                   PTB_SEL;
input                   PTB_SEL;
input                   DRAM_WR;
input                   DRAM_WR;
input                   KDET;
input                   KDET;
input                   HOLD;
input                   HOLD;
input    [1:0]   CFG;
input    [1:0]   CFG;
input   [31:0]   DRAM_Q;
input  [127:0]   DRAM_Q;
input    [1:0]   CINVAL;
input    [1:0]   CINVAL;
input    [1:0]   IC_SIGS;
input    [1:0]   IC_SIGS;
input   [31:0]   IO_Q;
input   [31:0]   IO_Q;
input    [1:0]   IVAR;
input    [1:0]   IVAR;
input   [27:4]  KOLLI_A;
input   [28:4]  KOLLI_A;
input    [3:0]   MCR_FLAGS;
input    [3:0]   MCR_FLAGS;
input   [23:0]   MMU_DIN;
input   [23:0]   MMU_DIN;
input   [31:0]   VADR;
input   [31:0]   VADR;
input   [11:2]  WADDR;
input                   INHIBIT;
input    [2:0]   WCTRL;
 
input                   ENA_HK;
input                   ENA_HK;
input                   ENDRAM;
input                   ENDRAM;
 
 
output                  IO_RD;
output                  IO_RD;
output                  DRAM_ACC;
output                  DRAM_ACC;
Line 81... Line 80...
output                  KOLLISION;
output                  KOLLISION;
output                  STOP_CINV;
output                  STOP_CINV;
output  [31:0]   IC_DQ;
output  [31:0]   IC_DQ;
output [31:12]  IC_VA;
output [31:12]  IC_VA;
output   [3:0]   ICTODC;
output   [3:0]   ICTODC;
output reg      [27:0]   DRAM_A;
output reg      [28:0]   DRAM_A;
output reg      [31:0]   IO_A;
output reg      [31:0]   IO_A;
 
 
reg             [31:0]   VADR_R;
reg             [31:0]   VADR_R;
reg             [31:0]   CAPDAT;
reg             [31:0]   CAPDAT;
reg             [31:0]   DFFE_IOR;
reg             [31:0]   DFFE_IOR;
Line 140... Line 139...
wire     [3:0]   RADR_MV;
wire     [3:0]   RADR_MV;
wire     [3:0]   WADR_MV;
wire     [3:0]   WADR_MV;
wire    [23:0]   NEWCVAL;
wire    [23:0]   NEWCVAL;
wire                    KILL_C,KILL_K;
wire                    KILL_C,KILL_K;
wire                    RMW;
wire                    RMW;
 
wire    [31:0]   CAP_Q;
 
wire   [28:12]  TAGDAT;
 
 
// +++++++++++++++++++ Memories ++++++++++++++++++++
// +++++++++++++++++++ Memories ++++++++++++++++++++
 
 
reg             [31:0]   DATA0 [0:1023];          // Data Set 0 : 4 kBytes
reg        [127:0]       DATA0 [0:255];           // Data Set 0 : 4 kBytes
 
reg        [127:0]       RDDATA0;
reg             [31:0]   SET_DAT0;
reg             [31:0]   SET_DAT0;
 
 
reg             [31:0]   DATA1 [0:1023];          // Data Set 1 : 4 kBytes
reg        [127:0]       DATA1 [0:255];           // Data Set 1 : 4 kBytes
 
reg        [127:0]       RDDATA1;
reg             [31:0]   SET_DAT1;
reg             [31:0]   SET_DAT1;
 
 
reg             [15:0]   TAGSET_0 [0:255];        // Tag Set for Data Set 0 : 256 entries of 16 bits
reg             [16:0]   TAGSET_0 [0:255];        // Tag Set for Data Set 0 : 256 entries of 17 bits
reg             [15:0]   TAG0;
reg             [16:0]   TAG0;
 
 
reg             [15:0]   TAGSET_1 [0:255];        // Tag Set for Data Set 1 : 256 entries of 16 bits
reg             [16:0]   TAGSET_1 [0:255];        // Tag Set for Data Set 1 : 256 entries of 17 bits
reg             [15:0]   TAG1;
reg             [16:0]   TAG1;
 
 
wire    [23:0]   CVALID;
wire    [23:0]   CVALID;
 
 
reg             [35:0]   MMU_TAGS [0:255];        // Tag Set for MMU : 256 entries of 36 bits
reg             [35:0]   MMU_TAGS [0:255];        // Tag Set for MMU : 256 entries of 36 bits
reg             [35:0]   MMU_Q;
reg             [35:0]   MMU_Q;
 
 
reg             [31:0]   MMU_VALID [0:15];        // Valid bits for MMU Tag Set : 16 entries of 32 bits
reg             [31:0]   MMU_VALID [0:15];        // Valid bits for MMU Tag Set : 16 entries of 32 bits
reg             [31:0]   MVALID;
reg             [31:0]   MVALID;
 
 
reg             [15:0]   KTAGSET_0 [0:255];       // Kollision Tag Set for Data Set 0 : 256 entries of 16 bits
reg             [16:0]   KTAGSET_0 [0:255];       // Kollision Tag Set for Data Set 0 : 256 entries of 17 bits
reg             [15:0]   KTAG0;
reg             [16:0]   KTAG0;
 
 
reg             [15:0]   KTAGSET_1 [0:255];       // Kollision Tag Set for Data Set 1 : 256 entries of 16 bits
reg             [16:0]   KTAGSET_1 [0:255];       // Kollision Tag Set for Data Set 1 : 256 entries of 17 bits
reg             [15:0]   KTAG1;
reg             [16:0]   KTAG1;
 
 
wire    [23:0]   KCVALID;
wire    [23:0]   KCVALID;
 
 
assign  READ    = READ_I & ~HOLD_ON & RUN_ICRD;
assign  READ    = READ_I & ~HOLD_ON & RUN_ICRD;
assign  WRITE   = 1'b0;
assign  WRITE   = 1'b0;
Line 213... Line 216...
 
 
always @(posedge BCLK) DFF_IRD_REG <= IO_RD;
always @(posedge BCLK) DFF_IRD_REG <= IO_RD;
 
 
always @(posedge BCLK) DFF_HDFF1 <= IO_READY;
always @(posedge BCLK) DFF_HDFF1 <= IO_READY;
 
 
always @(posedge BCLK) if (LD_DRAM_A) DRAM_A[27:0] <= {RADR[27:12],VADR_R[11:2],USE_CA,CA_SET};
always @(posedge BCLK) if (LD_DRAM_A) DRAM_A <= {RADR[28:12],VADR_R[11:2],USE_CA,CA_SET};
 
 
always @(posedge BCLK) if (IO_ACC) IO_A <= {RADR[31:12],VADR_R[11:0]};
always @(posedge BCLK) if (IO_ACC) IO_A <= {RADR[31:12],VADR_R[11:0]};
 
 
always @(posedge BCLK) if (IO_RD) DFFE_IOR <= IO_Q;
always @(posedge BCLK) if (IO_RD) DFFE_IOR <= IO_Q;
 
 
always @(posedge BCLK or negedge BRESET)
always @(posedge BCLK or negedge BRESET)
        if (!BRESET) HOLD_ON <= 1'b0;
        if (!BRESET) HOLD_ON <= 1'b0;
                else HOLD_ON <= (DATA_HOLD & DFF_HDFF1) | (HOLD_ON & DATA_HOLD);
                else HOLD_ON <= (DATA_HOLD & DFF_HDFF1) | (HOLD_ON & DATA_HOLD);
 
 
always @(posedge MCLK) if (WCTRL[2]) CAPDAT <= DRAM_Q;
DMUX  DMUX_4TO1 (
 
        .DRAM_Q(DRAM_Q),
 
        .ADDR(VADR_R[3:2]),
 
        .CAP_Q(CAP_Q) );
 
 
 
always @(posedge BCLK) if (MDONE) CAPDAT <= CAP_Q;
 
 
 
FILTCMP  FILT_CMP(
 
        .RADR({RADR[28:12],VADR_R[11:4]}),
 
        .DRAMSZ(DRAMSZ),
 
        .DRAM_A(25'd0),
 
        .TAGDAT(TAGDAT),
 
        .ADR_EQU());
 
 
// +++++++++++++++++++++++++  Cache Valid  +++++++++++++++++++
// +++++++++++++++++++++++++  Cache Valid  +++++++++++++++++++
 
 
NEU_VALID       VALID_RAM(
NEU_VALID       VALID_RAM(
        .BCLK(BCLK),
        .BCLK(BCLK),
Line 239... Line 254...
 
 
// +++++++++++++++++++++++++  Tag Set 0  +++++++++++++++++++++
// +++++++++++++++++++++++++  Tag Set 0  +++++++++++++++++++++
 
 
always @(posedge BCLK) TAG0 <= TAGSET_0[VADR[11:4]];
always @(posedge BCLK) TAG0 <= TAGSET_0[VADR[11:4]];
 
 
always @(negedge BCLK) if (WRCRAM0) TAGSET_0[VADR_R[11:4]] <= RADR[27:12];
always @(negedge BCLK) if (WRCRAM0) TAGSET_0[VADR_R[11:4]] <= TAGDAT;
 
 
// +++++++++++++++++++++++++  Tag Set 1  +++++++++++++++++++++
// +++++++++++++++++++++++++  Tag Set 1  +++++++++++++++++++++
 
 
always @(posedge BCLK) TAG1 <= TAGSET_1[VADR[11:4]];
always @(posedge BCLK) TAG1 <= TAGSET_1[VADR[11:4]];
 
 
always @(negedge BCLK) if (WRCRAM1) TAGSET_1[VADR_R[11:4]] <= RADR[27:12];
always @(negedge BCLK) if (WRCRAM1) TAGSET_1[VADR_R[11:4]] <= TAGDAT;
 
 
// +++++++++++++++++++++++++  Data Set 0  ++++++++++++++++++++
// +++++++++++++++++++++++++  Data Set 0  ++++++++++++++++++++
 
 
always @(posedge BCLK) SET_DAT0 <= DATA0[VADR[11:2]];
always @(posedge BCLK) RDDATA0 <= DATA0[VADR[11:4]];
 
 
 
always @(RDDATA0 or VADR_R)
 
        case (VADR_R[3:2])
 
          2'b00 : SET_DAT0 <= RDDATA0[31:0];
 
          2'b01 : SET_DAT0 <= RDDATA0[63:32];
 
          2'b10 : SET_DAT0 <= RDDATA0[95:64];
 
          2'b11 : SET_DAT0 <= RDDATA0[127:96];
 
        endcase
 
 
always @(posedge MCLK) if (WRSET0) DATA0[WADDR] <= DRAM_Q;
always @(posedge BCLK) if (WRSET0) DATA0[VADR_R[11:4]] <= DRAM_Q;
 
 
// +++++++++++++++++++++++++  Data Set 1  ++++++++++++++++++++
// +++++++++++++++++++++++++  Data Set 1  ++++++++++++++++++++
 
 
always @(posedge BCLK) SET_DAT1 <= DATA1[VADR[11:2]];
always @(posedge BCLK) RDDATA1 <= DATA1[VADR[11:4]];
 
 
always @(posedge MCLK) if (WRSET1) DATA1[WADDR] <= DRAM_Q;
always @(RDDATA1 or VADR_R)
 
        case (VADR_R[3:2])
 
          2'b00 : SET_DAT1 <= RDDATA1[31:0];
 
          2'b01 : SET_DAT1 <= RDDATA1[63:32];
 
          2'b10 : SET_DAT1 <= RDDATA1[95:64];
 
          2'b11 : SET_DAT1 <= RDDATA1[127:96];
 
        endcase
 
 
 
always @(posedge BCLK) if (WRSET1) DATA1[VADR_R[11:4]] <= DRAM_Q;
 
 
CA_MATCH        DCA_COMPARE(
CA_MATCH        DCA_COMPARE(
        .INVAL_L(CINVAL[0]),
        .INVAL_L(CINVAL[0]),
        .CI(CI),
        .CI(CI),
        .MMU_HIT(MMU_HIT),
        .MMU_HIT(MMU_HIT),
Line 283... Line 314...
        .KILL(KILL_C),
        .KILL(KILL_C),
        .UPDATE(UPDATE_C));
        .UPDATE(UPDATE_C));
 
 
DCA_CONTROL     DCA_CTRL(
DCA_CONTROL     DCA_CTRL(
        .BCLK(BCLK),
        .BCLK(BCLK),
        .MCLK(1'b0),
 
        .WRCFG(1'b1),
 
        .BRESET(BRESET),
        .BRESET(BRESET),
        .CA_SET(CA_SET),
        .CA_SET(CA_SET),
        .HIT_ALL(HIT_ALL),
        .HIT_ALL(HIT_ALL),
        .UPDATE(UPCD),
        .UPDATE(UPCD),
        .VADR_R(VADR_R[11:7]),
        .VADR_R(VADR_R[11:7]),
        .DRAM_ACC(DRAM_ACC),
        .DRAM_ACC(DRAM_ACC),
        .CUPDATE(CUPDATE),
        .CUPDATE(CUPDATE),
        .KILL(KILL),
        .KILL(KILL),
        .WRITE(WRITE),
        .WRITE(WRITE),
        .WCTRL(WCTRL[1:0]),
        .USE_CA(DRAM_A[1]),
 
        .INHIBIT(INHIBIT),
        .INVAL_A(CINVAL[1]),
        .INVAL_A(CINVAL[1]),
 
        .MDONE(MDONE),
        .DAT_CV(D_CV),
        .DAT_CV(D_CV),
        .WADR_CV(A_CV),
        .WADR_CV(A_CV),
        .WE_CV(WE_CV),
        .WE_CV(WE_CV),
        .INIT_CA_RUN(INIT_CA_RUN),
        .INIT_CA_RUN(INIT_CA_RUN),
        .WRCRAM0(WRCRAM0),
        .WRCRAM0(WRCRAM0),
Line 345... Line 376...
 
 
// +++++++++++++++++++++++++  Kollision Tag Set 0  +++++++++++
// +++++++++++++++++++++++++  Kollision Tag Set 0  +++++++++++
 
 
always @(posedge BCLK) KTAG0 <= KTAGSET_0[KOLLI_A[11:4]];
always @(posedge BCLK) KTAG0 <= KTAGSET_0[KOLLI_A[11:4]];
 
 
always @(negedge BCLK) if (WRCRAM0) KTAGSET_0[VADR_R[11:4]] <= RADR[27:12];
always @(negedge BCLK) if (WRCRAM0) KTAGSET_0[VADR_R[11:4]] <= TAGDAT;
 
 
// +++++++++++++++++++++++++  Kollision Tag Set 1  +++++++++++
// +++++++++++++++++++++++++  Kollision Tag Set 1  +++++++++++
 
 
always @(posedge BCLK) KTAG1 <= KTAGSET_1[KOLLI_A[11:4]];
always @(posedge BCLK) KTAG1 <= KTAGSET_1[KOLLI_A[11:4]];
 
 
always @(negedge BCLK) if (WRCRAM1) KTAGSET_1[VADR_R[11:4]] <= RADR[27:12];
always @(negedge BCLK) if (WRCRAM1) KTAGSET_1[VADR_R[11:4]] <= TAGDAT;
 
 
KOLDETECT       KOLLOGIK(
KOLDETECT       KOLLOGIK(
        .DRAM_WR(DRAM_WR),
        .DRAM_WR(DRAM_WR),
        .BCLK(BCLK),
        .BCLK(BCLK),
        .READ_I(READ_I),
        .READ_I(READ_I),

powered by: WebSVN 2.1.0

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