scoreboard.c
bool scoreboard_cycle(stScoreboardCPU* a_pThis, char *path) {
	command_row_t currCmd;
	FILE* fp;
	fp = fopen(path, "w"); /* Upon successful completion fopen() return a FILE pointer. Otherwise, NULL is returned and errno is set to indicate the error. */
	if (fp == NULL) {
		perror("fopen");
		return FAILURE;
	}
	while (true) {
		if (a_pThis->halted != true) {
			if (scoreboard_fetch(a_pThis) == FAILURE) {
				printf("FAILURE scoreboard_fetch, currCmd.opcode=%d\n", currCmd.opcode);
				return FAILURE;
			}
		}
		if (InstQ_Peek(a_pThis->InstructionQ, &currCmd) == SUCCESS) { /* Issue the next command in queue only if it's valid */
			if (scoreboard_issue(a_pThis, currCmd) == SUCCESS) { /* If the issue was successful we pop the command from the Q */
				if (DEBUG) {
					scoreboard_printCommand(&(a_pThis->InstructionQ->head->m_Instr));
				}
				if (InstQ_Pop(a_pThis->InstructionQ) == FAILURE) {
					printf("FAILURE InstQ_Pop\n");
					return FAILURE;
				}
			}
		}
		scoreboard_readOperands(a_pThis);
		scoreboard_execution(a_pThis);
		scoreboard_writeResults(a_pThis);
		scoreboard_writeTracedUnit(a_pThis, fp);
		if (scoreboard_checkExitConditions(a_pThis, currCmd)) { /* scoreboard_checkExitConditions() return true if the simulation ended */
			break;
		} else {
			a_pThis->cycle++;
		}
	}
	// closed the traceunit file
	fclose(fp);
	return SUCCESS;
}
/************************************************************************/
/*	Public functions declaration					*/
/************************************************************************/
/* This function runs the pipeline
 * The function return SUCCESS (true) on sucess and FAILURE (false) otherwise */
Public functions declaration
This function runs the pipeline
The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
Public functions declaration This function runs the pipeline The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
bool scoreboard_cycle(stScoreboardCPU* a_pThis, char *path) {
	command_row_t currCmd;
	FILE* fp;
	fp = fopen(path, "w"); 
	if (fp == NULL) {
		perror("fopen");
		return FAILURE;
	}
	while (true) {
		if (a_pThis->halted != true) {
			if (scoreboard_fetch(a_pThis) == FAILURE) {
				printf("FAILURE scoreboard_fetch, currCmd.opcode=%d\n", currCmd.opcode);
				return FAILURE;
			}
		}
		if (InstQ_Peek(a_pThis->InstructionQ, &currCmd) == SUCCESS) { 
			if (scoreboard_issue(a_pThis, currCmd) == SUCCESS) { 
				if (DEBUG) {
					scoreboard_printCommand(&(a_pThis->InstructionQ->head->m_Instr));
				}
				if (InstQ_Pop(a_pThis->InstructionQ) == FAILURE) {
					printf("FAILURE InstQ_Pop\n");
					return FAILURE;
				}
			}
		}
		scoreboard_readOperands(a_pThis);
		scoreboard_execution(a_pThis);
		scoreboard_writeResults(a_pThis);
		scoreboard_writeTracedUnit(a_pThis, fp);
		if (scoreboard_checkExitConditions(a_pThis, currCmd)) { 
			break;
		} else {
			a_pThis->cycle++;
		}
	}
	fclose(fp);
	return SUCCESS;
}
bool scoreboard_cycle ( stScoreboardCPU * a_pThis , char * path ) { command_row_t currCmd ; FILE * fp ; fp = fopen ( path , " " ) ; if ( fp == NULL ) { perror ( " " ) ; return FAILURE ; } while ( true ) { if ( a_pThis -> halted != true ) { if ( scoreboard_fetch ( a_pThis ) == FAILURE ) { printf ( " \n " , currCmd . opcode ) ; return FAILURE ; } } if ( InstQ_Peek ( a_pThis -> InstructionQ , & currCmd ) == SUCCESS ) { if ( scoreboard_issue ( a_pThis , currCmd ) == SUCCESS ) { if ( DEBUG ) { scoreboard_printCommand ( & ( a_pThis -> InstructionQ -> head -> m_Instr ) ) ; } if ( InstQ_Pop ( a_pThis -> InstructionQ ) == FAILURE ) { printf ( " \n " ) ; return FAILURE ; } } } scoreboard_readOperands ( a_pThis ) ; scoreboard_execution ( a_pThis ) ; scoreboard_writeResults ( a_pThis ) ; scoreboard_writeTracedUnit ( a_pThis , fp ) ; if ( scoreboard_checkExitConditions ( a_pThis , currCmd ) ) { break ; } else { a_pThis -> cycle ++ ; } } fclose ( fp ) ; return SUCCESS ; }
Public functions declaration
This function runs the pipeline
 The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
Public functions declaration This function runs the pipeline The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
/* Upon successful completion fopen() return a FILE pointer. Otherwise, NULL is returned and errno is set to indicate the error. */ /* Issue the next command in queue only if it's valid */ /* If the issue was successful we pop the command from the Q */ /* scoreboard_checkExitConditions() return true if the simulation ended */ // closed the traceunit file