forked from Github_Repos/cvw
		
	IFU cleanup
This commit is contained in:
		
							parent
							
								
									bdd5796f3a
								
							
						
					
					
						commit
						5ab06fef20
					
				@ -107,10 +107,10 @@ module ifu (
 | 
				
			|||||||
  logic 					   CacheableF;
 | 
					  logic 					   CacheableF;
 | 
				
			||||||
  logic [`XLEN-1:0]			   PCNextFSpill;
 | 
					  logic [`XLEN-1:0]			   PCNextFSpill;
 | 
				
			||||||
  logic [`XLEN-1:0] 		   PCFSpill;
 | 
					  logic [`XLEN-1:0] 		   PCFSpill;
 | 
				
			||||||
  logic 					   SelNextSpill;
 | 
					  logic 					   SelNextSpillF;
 | 
				
			||||||
  logic 					   ICacheFetchLine;
 | 
					  logic 					   ICacheFetchLine;
 | 
				
			||||||
  logic 					   BusStall;
 | 
					  logic 					   BusStall;
 | 
				
			||||||
  logic 					   ICacheStallF;
 | 
					  logic 					   ICacheStallF, IFUCacheBusStallF;
 | 
				
			||||||
  logic 					   IgnoreRequest;
 | 
					  logic 					   IgnoreRequest;
 | 
				
			||||||
  logic 					   CPUBusy;
 | 
					  logic 					   CPUBusy;
 | 
				
			||||||
(* mark_debug = "true" *)  logic [31:0] 				   PostSpillInstrRawF;
 | 
					(* mark_debug = "true" *)  logic [31:0] 				   PostSpillInstrRawF;
 | 
				
			||||||
@ -118,59 +118,60 @@ module ifu (
 | 
				
			|||||||
  localparam integer   SPILLTHRESHOLD = `MEM_ICACHE ? `ICACHE_LINELENINBITS/32 : 1;
 | 
					  localparam integer   SPILLTHRESHOLD = `MEM_ICACHE ? `ICACHE_LINELENINBITS/32 : 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(`C_SUPPORTED) begin : SpillSupport
 | 
					  if(`C_SUPPORTED) begin : SpillSupport
 | 
				
			||||||
    logic [`XLEN-1:0] 		   PCFp2;
 | 
					    logic [`XLEN-1:0] 		   PCPlus2F;
 | 
				
			||||||
    logic                      Spill;
 | 
					    logic                      TakeSpillF;
 | 
				
			||||||
    logic                      SelSpill, SpillSave;
 | 
					    logic                      SpillF;
 | 
				
			||||||
 | 
					    logic                      SelSpillF, SpillSaveF;
 | 
				
			||||||
    logic [15:0]               SpillDataLine0;
 | 
					    logic [15:0]               SpillDataLine0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // *** PLACE ALL THIS IN A MODULE
 | 
					    // *** PLACE ALL THIS IN A MODULE
 | 
				
			||||||
    // this exists only if there are compressed instructions.
 | 
					    // this exists only if there are compressed instructions.
 | 
				
			||||||
    //assign PCFp2 = PCF + `XLEN'b10;  **
 | 
					    // reuse PC+2/4 circuitry to avoid needing a second CPA to add 2
 | 
				
			||||||
    assign PCFp2 = PCF[1] ? {PCPlusUpperF, 2'b00} : {PCF[`XLEN-1:2], 2'b10};  // recode as mux
 | 
					    mux2 #(`XLEN) pcplus2mux(.d0({PCF[`XLEN-1:2], 2'b10}), .d1({PCPlusUpperF, 2'b00}), .s(PCF[1]), .y(PCPlus2F));
 | 
				
			||||||
 | 
					    mux2 #(`XLEN) pcnextspillmux(.d0(PCNextF), .d1(PCPlus2F), .s(SelNextSpillF), .y(PCNextFSpill));
 | 
				
			||||||
 | 
					    mux2 #(`XLEN) pcspillmux(.d0(PCF), .d1(PCPlus2F), .s(SelSpillF), .y(PCFSpill));
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
    assign PCNextFSpill = SelNextSpill ? PCFp2 : PCNextF;
 | 
					    assign SpillF = &PCF[$clog2(SPILLTHRESHOLD)+1:1];
 | 
				
			||||||
    assign PCFSpill = SelSpill ? PCFp2 : PCF;
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
    assign Spill = &PCF[$clog2(SPILLTHRESHOLD)+1:1];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    typedef enum               {STATE_SPILL_READY, STATE_SPILL_SPILL} statetype;
 | 
					    typedef enum               {STATE_SPILL_READY, STATE_SPILL_SPILL} statetype;
 | 
				
			||||||
    (* mark_debug = "true" *)  statetype CurrState, NextState;
 | 
					    (* mark_debug = "true" *)  statetype CurrState, NextState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    always_ff @(posedge clk)
 | 
					    always_ff @(posedge clk)
 | 
				
			||||||
      if (reset)    CurrState <= #1 STATE_SPILL_READY;
 | 
					      if (reset)    CurrState <= #1 STATE_SPILL_READY;
 | 
				
			||||||
      else CurrState <= #1 NextState;
 | 
					      else CurrState <= #1 NextState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assign TakeSpillF = SpillF & ~IFUCacheBusStallF;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    always_comb begin
 | 
					    always_comb begin
 | 
				
			||||||
      case (CurrState)
 | 
					      case (CurrState)
 | 
				
			||||||
      STATE_SPILL_READY: if (Spill & ~(ICacheStallF | BusStall)) NextState = STATE_SPILL_SPILL;
 | 
					        STATE_SPILL_READY: if (TakeSpillF) NextState = STATE_SPILL_SPILL;
 | 
				
			||||||
          else                                    NextState = STATE_SPILL_READY;
 | 
					          else                                    NextState = STATE_SPILL_READY;
 | 
				
			||||||
      STATE_SPILL_SPILL: if(ICacheStallF | BusStall | StallF)    NextState = STATE_SPILL_SPILL;
 | 
					        STATE_SPILL_SPILL: if(IFUCacheBusStallF | StallF)    NextState = STATE_SPILL_SPILL;
 | 
				
			||||||
          else                                    NextState = STATE_SPILL_READY;
 | 
					          else                                    NextState = STATE_SPILL_READY;
 | 
				
			||||||
        default:                                                   NextState = STATE_SPILL_READY;
 | 
					        default:                                                   NextState = STATE_SPILL_READY;
 | 
				
			||||||
      endcase
 | 
					      endcase
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assign SelSpill = CurrState == STATE_SPILL_SPILL;
 | 
					    assign SelSpillF = (CurrState == STATE_SPILL_SPILL);
 | 
				
			||||||
    assign SelNextSpill = (CurrState == STATE_SPILL_READY & (Spill & ~(ICacheStallF | BusStall))) |
 | 
					    assign SelNextSpillF = (CurrState == STATE_SPILL_READY & TakeSpillF) |
 | 
				
			||||||
                (CurrState == STATE_SPILL_SPILL & (ICacheStallF | BusStall));
 | 
					                (CurrState == STATE_SPILL_SPILL & IFUCacheBusStallF);
 | 
				
			||||||
    assign SpillSave = CurrState == STATE_SPILL_READY & (Spill & ~(ICacheStallF | BusStall));
 | 
					    assign SpillSaveF = (CurrState == STATE_SPILL_READY) & TakeSpillF;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    flopenr #(16) SpillInstrReg(.clk(clk),
 | 
					    flopenr #(16) SpillInstrReg(.clk(clk),
 | 
				
			||||||
                  .en(SpillSave),
 | 
					                  .en(SpillSaveF),
 | 
				
			||||||
                  .reset(reset),
 | 
					                  .reset(reset),
 | 
				
			||||||
                  .d(`MEM_ICACHE ? InstrRawF[15:0] : InstrRawF[31:16]),
 | 
					                  .d(`MEM_ICACHE ? InstrRawF[15:0] : InstrRawF[31:16]),
 | 
				
			||||||
                  .q(SpillDataLine0));
 | 
					                  .q(SpillDataLine0));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assign PostSpillInstrRawF = Spill ? {InstrRawF[15:0], SpillDataLine0} : InstrRawF;
 | 
					    assign PostSpillInstrRawF = SpillF ? {InstrRawF[15:0], SpillDataLine0} : InstrRawF;
 | 
				
			||||||
    assign CompressedF = PostSpillInstrRawF[1:0] != 2'b11;
 | 
					    assign CompressedF = PostSpillInstrRawF[1:0] != 2'b11;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// end of spill support
 | 
						// end of spill support
 | 
				
			||||||
  end else begin : NoSpillSupport // line: SpillSupport
 | 
					  end else begin : NoSpillSupport // line: SpillSupport
 | 
				
			||||||
    assign PCNextFSpill = PCNextF;
 | 
					    assign PCNextFSpill = PCNextF;
 | 
				
			||||||
    assign PCFSpill = PCF;
 | 
					    assign PCFSpill = PCF;
 | 
				
			||||||
    assign SelNextSpill = 0;
 | 
					    assign SelNextSpillF = 0;
 | 
				
			||||||
    assign PostSpillInstrRawF = InstrRawF;
 | 
					    assign PostSpillInstrRawF = InstrRawF;
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -315,8 +316,9 @@ module ifu (
 | 
				
			|||||||
				.s(SelUncachedAdr),
 | 
									.s(SelUncachedAdr),
 | 
				
			||||||
				.y(InstrRawF));
 | 
									.y(InstrRawF));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  assign IFUStallF = ICacheStallF | BusStall | SelNextSpill;
 | 
					  assign IFUCacheBusStallF = ICacheStallF | BusStall;
 | 
				
			||||||
  assign CPUBusy = StallF & ~SelNextSpill;
 | 
					  assign IFUStallF = IFUCacheBusStallF | SelNextSpillF;
 | 
				
			||||||
 | 
					  assign CPUBusy = StallF & ~SelNextSpillF;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //assign IgnoreRequest = ITLBMissF | ExceptionM | PendingInterruptM;
 | 
					  //assign IgnoreRequest = ITLBMissF | ExceptionM | PendingInterruptM;
 | 
				
			||||||
  // this is a difference with the dcache.
 | 
					  // this is a difference with the dcache.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user