mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Cleaned up the implementation changes for wfi.
This commit is contained in:
		
							parent
							
								
									c58f04c901
								
							
						
					
					
						commit
						3322ff915e
					
				| @ -27,7 +27,6 @@ | |||||||
| ////////////////////////////////////////////////////////////////////////////////////////////////
 | ////////////////////////////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| module hazard ( | module hazard ( | ||||||
|   input  logic clk, reset, |  | ||||||
|   // Detect hazards
 |   // Detect hazards
 | ||||||
|   input  logic  BPWrongE, CSRWriteFenceM, RetM, TrapM,    |   input  logic  BPWrongE, CSRWriteFenceM, RetM, TrapM,    | ||||||
|   input  logic  LoadStallD, StoreStallD, MDUStallD, CSRRdStallD, |   input  logic  LoadStallD, StoreStallD, MDUStallD, CSRRdStallD, | ||||||
| @ -46,10 +45,8 @@ module hazard ( | |||||||
|   logic                                       FlushDCause, FlushECause, FlushMCause, FlushWCause; |   logic                                       FlushDCause, FlushECause, FlushMCause, FlushWCause; | ||||||
| 
 | 
 | ||||||
|   logic WFIStallM, WFIInterruptedM; |   logic WFIStallM, WFIInterruptedM; | ||||||
|   logic wfiW; |  | ||||||
| 
 | 
 | ||||||
|   // WFI logic
 |   // WFI logic
 | ||||||
|   flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW); |  | ||||||
|   assign WFIStallM = wfiM & ~IntPendingM;         // WFI waiting for an interrupt or timeout
 |   assign WFIStallM = wfiM & ~IntPendingM;         // WFI waiting for an interrupt or timeout
 | ||||||
|   assign WFIInterruptedM = wfiM & IntPendingM;    // WFI detects a pending interrupt.  Retire WFI; trap if interrupt is enabled.
 |   assign WFIInterruptedM = wfiM & IntPendingM;    // WFI detects a pending interrupt.  Retire WFI; trap if interrupt is enabled.
 | ||||||
|    |    | ||||||
| @ -77,7 +74,6 @@ module hazard ( | |||||||
|   assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPWrongE & ~(DivBusyE | FDivBusyE)); |   assign FlushECause = TrapM | RetM | CSRWriteFenceM |(BPWrongE & ~(DivBusyE | FDivBusyE)); | ||||||
|   assign FlushMCause = TrapM | RetM | CSRWriteFenceM; |   assign FlushMCause = TrapM | RetM | CSRWriteFenceM; | ||||||
|   assign FlushWCause = TrapM & ~WFIInterruptedM; |   assign FlushWCause = TrapM & ~WFIInterruptedM; | ||||||
|   //assign FlushWCause = TrapM;
 |  | ||||||
| 
 | 
 | ||||||
|   // Stall causes
 |   // Stall causes
 | ||||||
|   //  Most data depenency stalls are identified in the decode stage
 |   //  Most data depenency stalls are identified in the decode stage
 | ||||||
| @ -91,12 +87,10 @@ module hazard ( | |||||||
|   assign StallDCause = (LoadStallD | StoreStallD | MDUStallD | CSRRdStallD | FCvtIntStallD | FPUStallD) & ~FlushDCause; |   assign StallDCause = (LoadStallD | StoreStallD | MDUStallD | CSRRdStallD | FCvtIntStallD | FPUStallD) & ~FlushDCause; | ||||||
|   assign StallECause = (DivBusyE | FDivBusyE) & ~FlushECause;  |   assign StallECause = (DivBusyE | FDivBusyE) & ~FlushECause;  | ||||||
|   assign StallMCause = WFIStallM & ~FlushMCause; |   assign StallMCause = WFIStallM & ~FlushMCause; | ||||||
|   //assign StallMCause = '0; 
 |  | ||||||
|   // Need to gate IFUStallF when the equivalent FlushFCause = FlushDCause = 1.
 |   // Need to gate IFUStallF when the equivalent FlushFCause = FlushDCause = 1.
 | ||||||
|   // assign StallWCause = ((IFUStallF & ~FlushDCause) | LSUStallM) & ~FlushWCause;
 |   // assign StallWCause = ((IFUStallF & ~FlushDCause) | LSUStallM) & ~FlushWCause;
 | ||||||
|   // Because FlushWCause is a strict subset of FlushDCause, FlushWCause is factored out.
 |   // Because FlushWCause is a strict subset of FlushDCause, FlushWCause is factored out.
 | ||||||
|   assign StallWCause = (IFUStallF & ~FlushDCause) | (LSUStallM & ~FlushWCause); |   assign StallWCause = (IFUStallF & ~FlushDCause) | (LSUStallM & ~FlushWCause); | ||||||
|   //assign StallWCause = (IFUStallF & ~FlushDCause) | ((LSUStallM | WFIStallM) & ~FlushWCause);
 |  | ||||||
| 
 | 
 | ||||||
|   // Stall each stage for cause or if the next stage is stalled
 |   // Stall each stage for cause or if the next stage is stalled
 | ||||||
|   // coverage off: StallFCause is always 0
 |   // coverage off: StallFCause is always 0
 | ||||||
|  | |||||||
| @ -39,7 +39,6 @@ module csr import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   input  logic                     CSRReadM, CSRWriteM,       // read or write CSR
 |   input  logic                     CSRReadM, CSRWriteM,       // read or write CSR
 | ||||||
|   input  logic                     TrapM,                     // trap is occurring
 |   input  logic                     TrapM,                     // trap is occurring
 | ||||||
|   input  logic                     mretM, sretM, wfiM,        // return or WFI instruction
 |   input  logic                     mretM, sretM, wfiM,        // return or WFI instruction
 | ||||||
|   output logic                     wfiW,  |  | ||||||
|   input  logic                     IntPendingM,               // at least one interrupt is pending and could occur if enabled
 |   input  logic                     IntPendingM,               // at least one interrupt is pending and could occur if enabled
 | ||||||
|   input  logic                     InterruptM,                // interrupt is occurring
 |   input  logic                     InterruptM,                // interrupt is occurring
 | ||||||
|   input  logic                     ExceptionM,                // interrupt is occurring
 |   input  logic                     ExceptionM,                // interrupt is occurring
 | ||||||
| @ -201,7 +200,6 @@ module csr import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|   // CSR Write values
 |   // CSR Write values
 | ||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|   flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW); |  | ||||||
| 
 | 
 | ||||||
|   assign CSRAdrM = InstrM[31:20]; |   assign CSRAdrM = InstrM[31:20]; | ||||||
|   assign UnalignedNextEPCM = TrapM ? PCM : CSRWriteValM; |   assign UnalignedNextEPCM = TrapM ? PCM : CSRWriteValM; | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ module privdec import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   output logic         IllegalInstrFaultM,                  // Illegal instruction
 |   output logic         IllegalInstrFaultM,                  // Illegal instruction
 | ||||||
|   output logic         EcallFaultM, BreakpointFaultM,       // Ecall or breakpoint; must retire, so don't flush it when the trap occurs
 |   output logic         EcallFaultM, BreakpointFaultM,       // Ecall or breakpoint; must retire, so don't flush it when the trap occurs
 | ||||||
|   output logic         sretM, mretM,                        // return instructions
 |   output logic         sretM, mretM,                        // return instructions
 | ||||||
|   output logic         wfiM, sfencevmaM                     // wfi / sfence.vma / sinval.vma instructions
 |   output logic         wfiM, wfiW, sfencevmaM               // wfi / sfence.vma / sinval.vma instructions
 | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|   logic                rs1zeroM;                            // rs1 field = 0
 |   logic                rs1zeroM;                            // rs1 field = 0
 | ||||||
| @ -75,8 +75,6 @@ module privdec import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|   // WFI timeout Privileged Spec 3.1.6.5
 |   // WFI timeout Privileged Spec 3.1.6.5
 | ||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|   logic                wfiW;  // *** need to merge with others
 |  | ||||||
|   flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW); // *** remove 
 |  | ||||||
| 
 | 
 | ||||||
|   if (P.U_SUPPORTED) begin:wfi |   if (P.U_SUPPORTED) begin:wfi | ||||||
|     logic [P.WFI_TIMEOUT_BIT:0] WFICount, WFICountPlus1; |     logic [P.WFI_TIMEOUT_BIT:0] WFICount, WFICountPlus1; | ||||||
| @ -88,6 +86,8 @@ module privdec import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   // coverage on
 |   // coverage on
 | ||||||
|   end else assign WFITimeoutM = 0; |   end else assign WFITimeoutM = 0; | ||||||
| 
 | 
 | ||||||
|  |   flopenrc #(1) wfiWReg(clk, reset, FlushW, ~StallW, wfiM, wfiW); | ||||||
|  | 
 | ||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|   // Extract exceptions by name and handle them 
 |   // Extract exceptions by name and handle them 
 | ||||||
|   ///////////////////////////////////////////
 |   ///////////////////////////////////////////
 | ||||||
|  | |||||||
| @ -125,12 +125,12 @@ module privileged import cvw::*;  #(parameter cvw_t P) ( | |||||||
|   privdec #(P) pmd(.clk, .reset, .StallM, .StallW, .FlushW, .InstrM(InstrM[31:15]),  |   privdec #(P) pmd(.clk, .reset, .StallM, .StallW, .FlushW, .InstrM(InstrM[31:15]),  | ||||||
|     .PrivilegedM, .IllegalIEUFPUInstrM, .IllegalCSRAccessM,  |     .PrivilegedM, .IllegalIEUFPUInstrM, .IllegalCSRAccessM,  | ||||||
|     .PrivilegeModeW, .STATUS_TSR, .STATUS_TVM, .STATUS_TW, .IllegalInstrFaultM,  |     .PrivilegeModeW, .STATUS_TSR, .STATUS_TVM, .STATUS_TW, .IllegalInstrFaultM,  | ||||||
|     .EcallFaultM, .BreakpointFaultM, .sretM, .mretM, .wfiM, .sfencevmaM); |     .EcallFaultM, .BreakpointFaultM, .sretM, .mretM, .wfiM, .wfiW, .sfencevmaM); | ||||||
| 
 | 
 | ||||||
|   // Control and Status Registers
 |   // Control and Status Registers
 | ||||||
|   csr #(P) csr(.clk, .reset, .FlushM, .FlushW, .StallE, .StallM, .StallW, |   csr #(P) csr(.clk, .reset, .FlushM, .FlushW, .StallE, .StallM, .StallW, | ||||||
|     .InstrM, .InstrOrigM, .PCM, .SrcAM, .IEUAdrM, .PC2NextF, |     .InstrM, .InstrOrigM, .PCM, .SrcAM, .IEUAdrM, .PC2NextF, | ||||||
|     .CSRReadM, .CSRWriteM, .TrapM, .mretM, .sretM, .wfiM, .wfiW, .IntPendingM, .InterruptM, |     .CSRReadM, .CSRWriteM, .TrapM, .mretM, .sretM, .wfiM, .IntPendingM, .InterruptM, | ||||||
|     .MTimerInt, .MExtInt, .SExtInt, .MSwInt, |     .MTimerInt, .MExtInt, .SExtInt, .MSwInt, | ||||||
|     .MTIME_CLINT, .InstrValidM, .FRegWriteM, .LoadStallD, .StoreStallD, |     .MTIME_CLINT, .InstrValidM, .FRegWriteM, .LoadStallD, .StoreStallD, | ||||||
|     .BPDirPredWrongM, .BTAWrongM, .RASPredPCWrongM, .BPWrongM, |     .BPDirPredWrongM, .BTAWrongM, .RASPredPCWrongM, .BPWrongM, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user