⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 completionunit.cpp

📁 ppc750 system design simulator using system c
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	{		/* Load/store unit produced a floating point rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": load/Store unit produce floating point rename buffer #" << (int) inLoadStoreResultTag[0] << endl;#endif		/* Validate the floating point rename buffer */		registersBinding->ValidateFloatingPointRenameBuffer(inLoadStoreResultTag[0]);	}	else if(inLoadStoreResultValid[0])	{		/* Load/store unit produced a rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": load/Store unit produce rename buffer #" << (int) inLoadStoreResultTag[0] << endl;#endif		/* validate the rename buffer */		registersBinding->ValidateRenameBuffer(inLoadStoreResultTag[0]);	}			if(inLoadStoreResultValid[1])	{		/* Load/store unit produced a rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": load/Store unit produce rename buffer #" << (int) inLoadStoreResultTag[1] << endl;#endif		/* validate the rename buffer */		registersBinding->ValidateRenameBuffer(inLoadStoreResultTag[1]);	}		if(inBranchResultLRValid)	{		/* Branch unit produced a LR rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": branch unit produce rename LR buffer #" << (int) inBranchResultLRTag << endl;#endif		/* Validate the LR rename buffer */		registersBinding->ValidateLRRenameBuffer(inBranchResultLRTag);	}			if(inBranchResultCTRValid)	{		/* branch unit produced a CTR rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": branch unit produce rename buffer #" << (int) inBranchResultCTRTag << endl;#endif		/* valid the CTR rename buffer */		registersBinding->ValidateCTRRenameBuffer(inBranchResultCTRTag);	}		if(inSystemRegisterResultValid)	{		/* System Register Unit produced a rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": system register unit produce rename buffer #" << (int) inSystemRegisterResultTag << endl;#endif		/* Validate the rename buffer */		registersBinding->ValidateRenameBuffer(inSystemRegisterResultTag);	}			if(inSystemRegisterResultLRValid)	{		/* System Register Unit produced a LR rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": system register unit produce LR rename buffer #" << (int) inSystemRegisterResultLRTag << endl;#endif		/* Validate the LR rename buffer */		registersBinding->ValidateLRRenameBuffer(inSystemRegisterResultLRTag);	}		if(inSystemRegisterResultCTRValid)	{		/* System register Unit produced a CTR rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": system register unit produce CTR rename buffer #" << (int) inSystemRegisterResultCTRTag << endl;#endif		/* Validate the CTR rename buffer */		registersBinding->ValidateCTRRenameBuffer(inSystemRegisterResultCTRTag);	}		if(inSystemRegisterResultCRValid)	{		/* System Register Unit produced a CR field rename buffer */#ifdef DEBUG		if(Debug(DebugCompletionUnit))			cout << name() << ": system register unit produce CR rename buffer #" << (int) inSystemRegisterResultCRTag << endl;#endif		/* Validate the CR field rename buffer */		registersBinding->ValidateCRRenameBuffer(inSystemRegisterResultCRTag);	}		/* Finish */		for(i = 0; i < nIntegerUnit; i++)	{		if(inIntegerFinished[i])		{			/* An integer unit finished an instruction */			tag_t tag = inIntegerTag[i];#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": integer unit " << i << " has finished an instruction (tag = " << (int) tag << ")" << endl;				if(!rob->Contains(tag))				{					cout << name() << ": Error : Reorder buffer does not contain tag " << (int) tag << endl;					ABORT();				}			}#endif			/* Get the reorder buffer entry containing that instruction */			ReorderBufferEntry& robEntry = rob->GetEntry(tag);			/* Finish the instruction */			robEntry.finished = true;			/* Collect result that must be temporaly stored into the reorder buffer (XER[OV] and XER[CA])*/			if(robEntry.extra.integer.writeOverflow) robEntry.extra.integer.overflow = inIntegerOverflow[i];			if(robEntry.extra.integer.writeCarry) robEntry.extra.integer.carry = inIntegerCarry[i];			if(robEntry.executionSerialized) outIntegerExecute[i] = false;#ifdef TRACE			if(Trace(TraceCompletionUnit))			{				trace_file->Begin("finish");				trace_file->Value("number", robEntry.dbgInstructionCounter);				trace_file->Value("pc", robEntry.dbgProgramCounter);				trace_file->End("finish");			}#endif		}	}		for(i = 0; i < nFloatingPointUnits; i++)	{		if(inFloatingPointFinished[i])		{			/* A Floating point unit finished an instruction */			tag_t tag = inFloatingPointTag[i];#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": floating point unit " << i << " has finished an instruction (tag = " << (int) tag << ")" << endl;				if(!rob->Contains(tag))				{					cout << name() << ": Error : Reorder buffer does not contain tag " << (int) tag << endl;					ABORT();				}			}#endif			/* Get the reorder buffer entry containing that instruction */			ReorderBufferEntry& robEntry = rob->GetEntry(tag);			/* Finish the instruction */			robEntry.finished = true;			if(robEntry.executionSerialized) outFloatingPointExecute[i] = false;		}	}		for(i = 0; i < 2; i++)	{		if(inLoadStoreFinished[i])		{			/* Load/store unit finished an instruction */			tag_t tag = inLoadStoreTag[i];#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": load/store unit has finished an instruction (tag = " << (int) tag  << ")" << endl;				if(!rob->Contains(tag))				{					cout << name() << ": Reorder buffer does not contain this instruction (tag = " << (int) tag << ")" << endl;					ABORT();				}			}#endif			/* Get the reorder buffer entry containing that instruction */			ReorderBufferEntry& robEntry = rob->GetEntry(tag);			/* Finish the instruction */			robEntry.finished = true;		}	}		if(inSystemRegisterFinished)	{		/* System Register Unit finished an instruction */		tag_t tag = inSystemRegisterTag;#ifdef DEBUG		if(Debug(DebugCompletionUnit))		{			cout << name() << ": system register unit has finished an instruction (tag = " << (int) tag << ")" << endl;			if(!rob->Contains(tag))			{				cout << name() << ": Reorder buffer does not contain this instruction (tag = " << (int) tag << ")" << endl;				ABORT();			}		}#endif		/* Get the reorder buffer entry containing that instruction */		ReorderBufferEntry& robEntry = rob->GetEntry(tag);		/* Finish the instruction */		robEntry.finished = true;		if(robEntry.extra.systemRegister.writeCR) robEntry.extra.systemRegister.cr = inSystemRegisterCRData;	}		if(inBranchFinished)	{		/* Branch unit finished an instruction */		if(inBranchTag != -1)		{#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": branch unit has finished an instruction (tag = " << (int) inBranchTag << ")" << endl;				if(!rob->Contains(inBranchTag))				{					cout << name() << ": Reorder buffer does not contain this instruction (tag = " << (int) inBranchTag << ")" << endl;					ABORT();				}			}#endif			/* Get the reorder buffer entry containing that instruction */			ReorderBufferEntry& robEntry = rob->GetEntry(inBranchTag);			/* Finish the instruction */			robEntry.finished = true;				}		else		{			nRetiredInstructions++;		}				if(inMispredictedBranch)		{			/* If branch has been mispredicted then flush dependent instructions */#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": Mispredicted Branch" << endl;				cout << name() << ": Reorder buffer content before flushing :" << endl << *rob;				cout << name() << ": Registers Binding before flushing :" << endl << *registersBinding;			}#endif			Flush();#ifdef DEBUG			if(Debug(DebugCompletionUnit))			{				cout << name() << ": Reorder buffer content after flushing :" << endl << *rob;				cout << name() << ": Registers Binding after flushing :" << endl << *registersBinding;			}#endif		}		else		{			/* The branch has been resolved and branch preduction was good */#ifdef DEBUG			if(Debug(DebugCompletionUnit))				cout << name() << ": Decrement Branch Counter" << endl;#endif			rob->DecrementBranchCounter();		}	}	#ifdef DEBUG	if(Debug(DebugCompletionUnit))	{		cout << "Reorder buffer content :" << endl;		cout << *rob;	}#endif}void CompletionUnit::OnFallingEdge(){	if(nMaxRetiredInstructions > 0 && nRetiredInstructions >= nMaxRetiredInstructions)	{		StopSimulation();	}}void CompletionUnit::Flush(){	int j;		/* Flush instructions that have their branch counter > 0 */	/* Instructions that are flushed release some rename buffers (in reverse order they are allocated) */	while(!rob->Empty())	{		ReorderBufferEntry& robEntry = rob->GetHead();				if(robEntry.branchCounter == 0) return;		#ifdef DEBUG		if(Debug(DebugCompletionUnit))		{			cout << name() << ": Flushing instruction (" << robEntry.dbgInstructionCounter << ")  ";			ppc_disassemble_to_stream(robEntry.dbgInstruction, robEntry.dbgProgramCounter, stdout);			cout << endl;		}#endif		switch(robEntry.unitIdent)		{			case IntegerUnitIdent:				if(robEntry.extra.integer.tags.resultTag >= 0)					registersBinding->FreeRenameBufferReverseOrder(robEntry.extra.integer.tags.resultTag);									if(robEntry.extra.integer.tags.CRTag >= 0)					registersBinding->FreeCRRenameBufferReverseOrder(robEntry.extra.integer.tags.CRTag);									break;							case FloatingPointUnitIdent:				if(robEntry.extra.floatingPoint.tags.resultTag >= 0)					registersBinding->FreeFloatingPointRenameBufferReverseOrder(robEntry.extra.floatingPoint.tags.resultTag);									if(robEntry.extra.floatingPoint.tags.CRTag >= 0)					registersBinding->FreeCRRenameBufferReverseOrder(robEntry.extra.floatingPoint.tags.CRTag);									break;						case LoadStoreUnitIdent:				if(robEntry.extra.loadStore.tags.resultTags[0] >= 0)				{					if(robEntry.extra.loadStore.floatingPoint)					{						registersBinding->FreeFloatingPointRenameBufferReverseOrder(robEntry.extra.loadStore.tags.resultTags[0]);					}					else					{						registersBinding->FreeRenameBufferReverseOrder(robEntry.extra.loadStore.tags.resultTags[0]);					}				}				if(robEntry.extra.loadStore.tags.resultTags[1] >= 0)						registersBinding->FreeRenameBufferReverseOrder(robEntry.extra.loadStore.tags.resultTags[1]);				break;							case BranchUnitIdent:				if(robEntry.extra.branch.tags.LRTag >= 0)					registersBinding->FreeLRRenameBufferReverseOrder(robEntry.extra.branch.tags.LRTag);									if(robEntry.extra.branch.tags.CTRTag >= 0)					registersBinding->FreeCTRRenameBufferReverseOrder(robEntry.extra.branch.tags.CTRTag);									break;							case SystemRegisterUnitIdent:				if(robEntry.extra.systemRegister.tags.resultTag >= 0)					registersBinding->FreeRenameBufferReverseOrder(robEntry.extra.systemRegister.tags.resultTag);										if(robEntry.extra.systemRegister.tags.LRTag >= 0)					registersBinding->FreeLRRenameBufferReverseOrder(robEntry.extra.systemRegister.tags.LRTag);										if(robEntry.extra.systemRegister.tags.CTRTag >= 0)					registersBinding->FreeCTRRenameBufferReverseOrder(robEntry.extra.systemRegister.tags.CTRTag);									if(robEntry.extra.systemRegister.tags.CRTag >= 0)					registersBinding->FreeCRRenameBufferReverseOrder(robEntry.extra.systemRegister.tags.CRTag);									break;		}				rob->ReleaseHead();	}}void CompletionUnit::Reset(){	nInstructionsToRetire = 0;	nRetiredInstructions = 0;	nMaxRetiredInstructions = 0;	rob->Flush();}void CompletionUnit::Stop(int ninstructions){	nRetiredInstructions = 0;	nMaxRetiredInstructions = ninstructions;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -