forked from Github_Repos/cvw
		
	Merge branch 'main' of https://github.com/davidharrishmc/riscv-wally into main
This commit is contained in:
		
						commit
						9ab7c18baa
					
				
							
								
								
									
										18
									
								
								wally-pipelined/src/cache/dcachefsm.sv
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								wally-pipelined/src/cache/dcachefsm.sv
									
									
									
									
										vendored
									
									
								
							@ -169,7 +169,7 @@ module dcachefsm
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Flush dcache to next level of memory
 | 
							// Flush dcache to next level of memory
 | 
				
			||||||
		else if(FlushDCacheM  & ~(ExceptionM | PendingInterruptM)) begin
 | 
							else if(FlushDCacheM) begin
 | 
				
			||||||
		  NextState = STATE_FLUSH;
 | 
							  NextState = STATE_FLUSH;
 | 
				
			||||||
		  DCacheStall = 1'b1;
 | 
							  DCacheStall = 1'b1;
 | 
				
			||||||
		  SelAdrM = 2'b11;
 | 
							  SelAdrM = 2'b11;
 | 
				
			||||||
@ -178,7 +178,7 @@ module dcachefsm
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// amo hit
 | 
							// amo hit
 | 
				
			||||||
		else if(AtomicM[1] & (&MemRWM) & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit) begin
 | 
							else if(AtomicM[1] & (&MemRWM) & CacheableM & CacheHit) begin
 | 
				
			||||||
		  SelAdrM = 2'b10;
 | 
							  SelAdrM = 2'b10;
 | 
				
			||||||
		  DCacheStall = 1'b0;
 | 
							  DCacheStall = 1'b0;
 | 
				
			||||||
		  
 | 
							  
 | 
				
			||||||
@ -194,7 +194,7 @@ module dcachefsm
 | 
				
			|||||||
		  end
 | 
							  end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// read hit valid cached
 | 
							// read hit valid cached
 | 
				
			||||||
		else if(MemRWM[1] & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit) begin
 | 
							else if(MemRWM[1] & CacheableM & CacheHit) begin
 | 
				
			||||||
		  DCacheStall = 1'b0;
 | 
							  DCacheStall = 1'b0;
 | 
				
			||||||
		  LRUWriteEn = 1'b1;
 | 
							  LRUWriteEn = 1'b1;
 | 
				
			||||||
		  
 | 
							  
 | 
				
			||||||
@ -207,7 +207,7 @@ module dcachefsm
 | 
				
			|||||||
	      end
 | 
						      end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// write hit valid cached
 | 
							// write hit valid cached
 | 
				
			||||||
		else if (MemRWM[0] & CacheableM & ~(ExceptionM | PendingInterruptM) & CacheHit) begin
 | 
							else if (MemRWM[0] & CacheableM & CacheHit) begin
 | 
				
			||||||
		  SelAdrM = 2'b10;
 | 
							  SelAdrM = 2'b10;
 | 
				
			||||||
		  DCacheStall = 1'b0;
 | 
							  DCacheStall = 1'b0;
 | 
				
			||||||
		  SRAMWordWriteEnableM = 1'b1;
 | 
							  SRAMWordWriteEnableM = 1'b1;
 | 
				
			||||||
@ -223,29 +223,25 @@ module dcachefsm
 | 
				
			|||||||
		  end
 | 
							  end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// read or write miss valid cached
 | 
							// read or write miss valid cached
 | 
				
			||||||
		else if((|MemRWM) & CacheableM & ~(ExceptionM | PendingInterruptM) & ~CacheHit) begin
 | 
							else if((|MemRWM) & CacheableM & ~CacheHit) begin
 | 
				
			||||||
		  NextState = STATE_MISS_FETCH_WDV;
 | 
							  NextState = STATE_MISS_FETCH_WDV;
 | 
				
			||||||
		  CntReset = 1'b1;
 | 
							  CntReset = 1'b1;
 | 
				
			||||||
		  DCacheStall = 1'b1;
 | 
							  DCacheStall = 1'b1;
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// uncached write
 | 
							// uncached write
 | 
				
			||||||
		else if(MemRWM[0] & ~CacheableM & ~(ExceptionM | PendingInterruptM)) begin
 | 
							else if(MemRWM[0] & ~CacheableM) begin
 | 
				
			||||||
		  NextState = STATE_UNCACHED_WRITE;
 | 
							  NextState = STATE_UNCACHED_WRITE;
 | 
				
			||||||
		  CntReset = 1'b1;
 | 
							  CntReset = 1'b1;
 | 
				
			||||||
		  DCacheStall = 1'b1;
 | 
							  DCacheStall = 1'b1;
 | 
				
			||||||
		  AHBWrite = 1'b1;
 | 
							  AHBWrite = 1'b1;
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// uncached read
 | 
							// uncached read
 | 
				
			||||||
		else if(MemRWM[1] & ~CacheableM & ~(ExceptionM | PendingInterruptM)) begin
 | 
							else if(MemRWM[1] & ~CacheableM) begin
 | 
				
			||||||
		  NextState = STATE_UNCACHED_READ;
 | 
							  NextState = STATE_UNCACHED_READ;
 | 
				
			||||||
		  CntReset = 1'b1;
 | 
							  CntReset = 1'b1;
 | 
				
			||||||
		  DCacheStall = 1'b1;
 | 
							  DCacheStall = 1'b1;
 | 
				
			||||||
		  AHBRead = 1'b1;	  
 | 
							  AHBRead = 1'b1;	  
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		// fault
 | 
					 | 
				
			||||||
		else if(AnyCPUReqM & (ExceptionM | PendingInterruptM)) begin
 | 
					 | 
				
			||||||
		  NextState = STATE_READY;
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
		else NextState = STATE_READY;
 | 
							else NextState = STATE_READY;
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								wally-pipelined/src/cache/icachefsm.sv
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								wally-pipelined/src/cache/icachefsm.sv
									
									
									
									
										vendored
									
									
								
							@ -163,6 +163,7 @@ module icachefsm
 | 
				
			|||||||
		  NextState = STATE_HIT_SPILL;
 | 
							  NextState = STATE_HIT_SPILL;
 | 
				
			||||||
        end else if (~hit & ~spill) begin
 | 
					        end else if (~hit & ~spill) begin
 | 
				
			||||||
          CntReset = 1'b1;
 | 
					          CntReset = 1'b1;
 | 
				
			||||||
 | 
							  SelAdr = 2'b01;                                         /// *********(
 | 
				
			||||||
          NextState = STATE_MISS_FETCH_WDV;
 | 
					          NextState = STATE_MISS_FETCH_WDV;
 | 
				
			||||||
        end else if (~hit & spill) begin
 | 
					        end else if (~hit & spill) begin
 | 
				
			||||||
          CntReset = 1'b1;
 | 
					          CntReset = 1'b1;
 | 
				
			||||||
@ -294,8 +295,8 @@ module icachefsm
 | 
				
			|||||||
          ICacheStallF = 1'b0;
 | 
					          ICacheStallF = 1'b0;
 | 
				
			||||||
		  LRUWriteEn = 1'b1;
 | 
							  LRUWriteEn = 1'b1;
 | 
				
			||||||
		  if(StallF) begin
 | 
							  if(StallF) begin
 | 
				
			||||||
			NextState = STATE_CPU_BUSY;
 | 
								NextState = STATE_CPU_BUSY_SPILL;
 | 
				
			||||||
			SelAdr = 2'b01;
 | 
								SelAdr = 2'b10;
 | 
				
			||||||
		  end else begin
 | 
							  end else begin
 | 
				
			||||||
            NextState = STATE_READY;
 | 
					            NextState = STATE_READY;
 | 
				
			||||||
		  end
 | 
							  end
 | 
				
			||||||
 | 
				
			|||||||
@ -103,6 +103,9 @@ module ifu (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
(* mark_debug = "true" *)  logic [`PA_BITS-1:0]         PCPFmmu, PCNextFPhys; // used to either truncate or expand PCPF and PCNextF into `PA_BITS width.
 | 
					(* mark_debug = "true" *)  logic [`PA_BITS-1:0]         PCPFmmu, PCNextFPhys; // used to either truncate or expand PCPF and PCNextF into `PA_BITS width.
 | 
				
			||||||
  logic [`XLEN+1:0]            PCFExt;
 | 
					  logic [`XLEN+1:0]            PCFExt;
 | 
				
			||||||
 | 
					  logic [`XLEN-1:0] 		   PCBPWrongInvalidate;
 | 
				
			||||||
 | 
					  logic 					   BPPredWrongM;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  generate
 | 
					  generate
 | 
				
			||||||
    if (`XLEN==32) begin
 | 
					    if (`XLEN==32) begin
 | 
				
			||||||
@ -187,8 +190,13 @@ module ifu (
 | 
				
			|||||||
         .s(BPPredWrongE),
 | 
					         .s(BPPredWrongE),
 | 
				
			||||||
         .y(PCNext1F));
 | 
					         .y(PCNext1F));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // December 20, 2021 Ross Thompson, If instructions in ID and IF are already invalid we don't pick PCE on icache invalidate.
 | 
				
			||||||
 | 
					  // this only happens because of branch class miss prediction.  The Fence instruction was incorrectly predicted as a branch
 | 
				
			||||||
 | 
					  // this means on the previous cycle the BPPredWrongE updated PCNextF to the correct fall through address.
 | 
				
			||||||
 | 
					  // to fix we need to select the correct address PCF as the next PCNextF. Unforunately we must still flush the instruction in IF
 | 
				
			||||||
 | 
					  // as we are deliberately invalidating the icache.  This address has to be refetched by the icache.
 | 
				
			||||||
  mux2 #(`XLEN) pcmux2(.d0(PCNext1F),
 | 
					  mux2 #(`XLEN) pcmux2(.d0(PCNext1F),
 | 
				
			||||||
         .d1(PCE),
 | 
					         .d1(PCBPWrongInvalidate),
 | 
				
			||||||
         .s(InvalidateICacheM),
 | 
					         .s(InvalidateICacheM),
 | 
				
			||||||
         .y(PCNext2F));
 | 
					         .y(PCNext2F));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -205,6 +213,14 @@ module ifu (
 | 
				
			|||||||
  flop #(1) resetReg (.clk(clk),
 | 
					  flop #(1) resetReg (.clk(clk),
 | 
				
			||||||
        .d(reset),
 | 
					        .d(reset),
 | 
				
			||||||
        .q(reset_q));
 | 
					        .q(reset_q));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  flopenrc #(1) BPPredWrongMReg(.clk, .reset, .en(~StallM), .clear(FlushM),
 | 
				
			||||||
 | 
													.d(BPPredWrongE), .q(BPPredWrongM));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mux2 #(`XLEN) pcmuxBPWrongInvalidateFlush(.d0(PCE), .d1(PCF), 
 | 
				
			||||||
 | 
																.s(BPPredWrongM & InvalidateICacheM), 
 | 
				
			||||||
 | 
																.y(PCBPWrongInvalidate));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  assign  PCNextF = {UnalignedPCNextF[`XLEN-1:1], 1'b0}; // hart-SPEC p. 21 about 16-bit alignment
 | 
					  assign  PCNextF = {UnalignedPCNextF[`XLEN-1:1], 1'b0}; // hart-SPEC p. 21 about 16-bit alignment
 | 
				
			||||||
 | 
				
			|||||||
@ -198,7 +198,9 @@ module lsu
 | 
				
			|||||||
  assign SelReplayCPURequest = (NextState == STATE_T0_REPLAY) | (NextState == STATE_T0_FAULT_REPLAY);
 | 
					  assign SelReplayCPURequest = (NextState == STATE_T0_REPLAY) | (NextState == STATE_T0_FAULT_REPLAY);
 | 
				
			||||||
  assign SelHPTW = (CurrState == STATE_T3_DTLB_MISS) | (CurrState == STATE_T4_ITLB_MISS) |
 | 
					  assign SelHPTW = (CurrState == STATE_T3_DTLB_MISS) | (CurrState == STATE_T4_ITLB_MISS) |
 | 
				
			||||||
				  (CurrState == STATE_T5_ITLB_MISS) | (CurrState == STATE_T7_DITLB_MISS);
 | 
									  (CurrState == STATE_T5_ITLB_MISS) | (CurrState == STATE_T7_DITLB_MISS);
 | 
				
			||||||
  assign IgnoreRequest = CurrState == STATE_T0_READY & (ITLBMissF | DTLBMissM);
 | 
					  assign IgnoreRequest = (CurrState == STATE_T0_READY & (ITLBMissF | DTLBMissM | ExceptionM | PendingInterruptM)) |
 | 
				
			||||||
 | 
											 ((CurrState == STATE_T0_REPLAY | CurrState == STATE_T0_FAULT_REPLAY)
 | 
				
			||||||
 | 
											  & (ExceptionM | PendingInterruptM));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  assign WalkerInstrPageFaultF = WalkerInstrPageFaultRaw | CurrState == STATE_T0_FAULT_REPLAY;
 | 
					  assign WalkerInstrPageFaultF = WalkerInstrPageFaultRaw | CurrState == STATE_T0_FAULT_REPLAY;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user