scoreboard.c
bool scoreboard_init(stScoreboardCPU* a_pThis, configuration* a_pConfiguration, uint32_t* a_pMemory, int a_NumberOfInstructions) {
	size_t i = 0;
	a_pThis->pConfiguration = a_pConfiguration;
	a_pThis->pMemory = a_pMemory;
	a_pThis->PC = 0;
	a_pThis->cycle = 1; /* we start from cycle No. 1 */
	a_pThis->lastIssuedPC = 0;
	a_pThis->InstructionQ = InstQ_ConstructQueue(INSTRUCTION_QUEUE_LENGTH);
	a_pThis->pTracedUnit = NULL;
	a_pThis->halted = false;
	scoreboard_initializeFUs(a_pThis);
	if (a_pThis->pTracedUnit == NULL) {
		printf("[Error] Did not found the requested traced unit\n");
		return FAILURE;
	}
	/* Allocating mem for the instruction FU strings (for trace purposes) */
	a_pThis->instructionFUs = calloc(a_NumberOfInstructions, sizeof(char*));
	for (i=0; i<(size_t)a_NumberOfInstructions; ++i) {
		a_pThis->instructionFUs[i] = calloc(MAX_LENGTH_OF_FU_NAME, sizeof(char));
	}
	if (!a_pThis->pLD_FUs || !a_pThis->pST_FUs || !a_pThis->pADD_FUs || !a_pThis->pSUB_FUs || !a_pThis->pMULT_FUs || !a_pThis->pDIV_FUs || !a_pThis->InstructionQ) {
		return FAILURE;
	}
	for (i=0; i<4; ++i) {
		a_pThis->instructionStatus[i] = calloc(a_NumberOfInstructions, sizeof(uint32_t));
		if (!a_pThis->instructionStatus[i]) {
			return FAILURE;
		}
	}
	for (i=0; i<NUM_OF_REGISTERS; ++i) {
		a_pThis->Register[i] = i;
		a_pThis->registerResultStatus[i] = NULL;
	}
	return SUCCESS;
}
/* This function initializes the scoreboard module
 * The function return SUCCESS (true) on sucess and FAILURE (false) otherwise */
This function initializes the scoreboard module
The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
This function initializes the scoreboard module The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
bool scoreboard_init(stScoreboardCPU* a_pThis, configuration* a_pConfiguration, uint32_t* a_pMemory, int a_NumberOfInstructions) {
	size_t i = 0;
	a_pThis->pConfiguration = a_pConfiguration;
	a_pThis->pMemory = a_pMemory;
	a_pThis->PC = 0;
	a_pThis->cycle = 1; 
	a_pThis->lastIssuedPC = 0;
	a_pThis->InstructionQ = InstQ_ConstructQueue(INSTRUCTION_QUEUE_LENGTH);
	a_pThis->pTracedUnit = NULL;
	a_pThis->halted = false;
	scoreboard_initializeFUs(a_pThis);
	if (a_pThis->pTracedUnit == NULL) {
		printf("[Error] Did not found the requested traced unit\n");
		return FAILURE;
	}
	a_pThis->instructionFUs = calloc(a_NumberOfInstructions, sizeof(char*));
	for (i=0; i<(size_t)a_NumberOfInstructions; ++i) {
		a_pThis->instructionFUs[i] = calloc(MAX_LENGTH_OF_FU_NAME, sizeof(char));
	}
	if (!a_pThis->pLD_FUs || !a_pThis->pST_FUs || !a_pThis->pADD_FUs || !a_pThis->pSUB_FUs || !a_pThis->pMULT_FUs || !a_pThis->pDIV_FUs || !a_pThis->InstructionQ) {
		return FAILURE;
	}
	for (i=0; i<4; ++i) {
		a_pThis->instructionStatus[i] = calloc(a_NumberOfInstructions, sizeof(uint32_t));
		if (!a_pThis->instructionStatus[i]) {
			return FAILURE;
		}
	}
	for (i=0; i<NUM_OF_REGISTERS; ++i) {
		a_pThis->Register[i] = i;
		a_pThis->registerResultStatus[i] = NULL;
	}
	return SUCCESS;
}
bool scoreboard_init ( stScoreboardCPU * a_pThis , configuration * a_pConfiguration , uint32_t * a_pMemory , int a_NumberOfInstructions ) { size_t i = 0 ; a_pThis -> pConfiguration = a_pConfiguration ; a_pThis -> pMemory = a_pMemory ; a_pThis -> PC = 0 ; a_pThis -> cycle = 1 ; a_pThis -> lastIssuedPC = 0 ; a_pThis -> InstructionQ = InstQ_ConstructQueue ( INSTRUCTION_QUEUE_LENGTH ) ; a_pThis -> pTracedUnit = NULL ; a_pThis -> halted = false ; scoreboard_initializeFUs ( a_pThis ) ; if ( a_pThis -> pTracedUnit == NULL ) { printf ( " \n " ) ; return FAILURE ; } a_pThis -> instructionFUs = calloc ( a_NumberOfInstructions , sizeof ( char * ) ) ; for ( i = 0 ; i < ( size_t ) a_NumberOfInstructions ; ++ i ) { a_pThis -> instructionFUs [ i ] = calloc ( MAX_LENGTH_OF_FU_NAME , sizeof ( char ) ) ; } if ( ! a_pThis -> pLD_FUs || ! a_pThis -> pST_FUs || ! a_pThis -> pADD_FUs || ! a_pThis -> pSUB_FUs || ! a_pThis -> pMULT_FUs || ! a_pThis -> pDIV_FUs || ! a_pThis -> InstructionQ ) { return FAILURE ; } for ( i = 0 ; i < 4 ; ++ i ) { a_pThis -> instructionStatus [ i ] = calloc ( a_NumberOfInstructions , sizeof ( uint32_t ) ) ; if ( ! a_pThis -> instructionStatus [ i ] ) { return FAILURE ; } } for ( i = 0 ; i < NUM_OF_REGISTERS ; ++ i ) { a_pThis -> Register [ i ] = i ; a_pThis -> registerResultStatus [ i ] = NULL ; } return SUCCESS ; }
This function initializes the scoreboard module
 The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
This function initializes the scoreboard module The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
/* we start from cycle No. 1 */ /* Allocating mem for the instruction FU strings (for trace purposes) */