scoreboard.c
bool scoreboard_issue(stScoreboardCPU* a_pThis, command_row_t a_cmd) {
	stFunctionalUnit* currFunctionalUnit = scoreboard_getAvailableFU(a_pThis, (opcode_t)a_cmd.opcode);
	if (a_cmd.opcode == OPCODE_HALT) {
		return FAILURE;
	}
	if (((a_pThis->registerResultStatus[a_cmd.dst] == NULL) || a_cmd.opcode == OPCODE_ST) && (currFunctionalUnit != NULL)) { /* Check the Issue conditions */
		currFunctionalUnit->Busy = true;
		currFunctionalUnit->Fi = a_cmd.dst;
		currFunctionalUnit->Fj = a_cmd.src0;
		currFunctionalUnit->Fk = a_cmd.src1;
		if (a_cmd.opcode == OPCODE_LD) { /* If it's memory related op, save the immidiate value */
			currFunctionalUnit->tempImmidiate = a_cmd.imm;
			currFunctionalUnit->Rj = true;
			currFunctionalUnit->Rk = true;
		}
		else if (a_cmd.opcode == OPCODE_ST)
		{
			currFunctionalUnit->tempImmidiate = a_cmd.imm;
			currFunctionalUnit->Qk = a_pThis->registerResultStatus[a_cmd.src1];
			currFunctionalUnit->Rk = (currFunctionalUnit->Qk == NULL);
			currFunctionalUnit->Rj = true;
		}
		else
		{
			currFunctionalUnit->Qj = a_pThis->registerResultStatus[a_cmd.src0];
			currFunctionalUnit->Qk = a_pThis->registerResultStatus[a_cmd.src1];
			currFunctionalUnit->Rj = (currFunctionalUnit->Qj == NULL);
			currFunctionalUnit->Rk = (currFunctionalUnit->Qk == NULL);
		}
		a_pThis->registerResultStatus[a_cmd.dst] = currFunctionalUnit;
		currFunctionalUnit->relatedPC = (a_pThis->lastIssuedPC++); /* We return current issued PC and increase it by one */
		a_pThis->instructionStatus[ISSUE_STAGE_IDX][currFunctionalUnit->relatedPC] = a_pThis->cycle; /* Save the issue stage cycle */

		return SUCCESS;
	} else {
		return FAILURE;
	}
}
/* This function performs the issue stage of the scorecoard, Before issuing the command it checks if
 * there is no structural hazard (FU is available) and that there is no output dependency (WAW)
 * The function return SUCCESS (true) on sucess and FAILURE (false) otherwise */
This function performs the issue stage of the scorecoard, Before issuing the command it checks if
there is no structural hazard (FU is available) and that there is no output dependency (WAW)
The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
This function performs the issue stage of the scorecoard Before issuing the command it checks if there is no structural hazard ( FU is available ) and that there is no output dependency ( WAW ) The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
bool scoreboard_issue(stScoreboardCPU* a_pThis, command_row_t a_cmd) {
	stFunctionalUnit* currFunctionalUnit = scoreboard_getAvailableFU(a_pThis, (opcode_t)a_cmd.opcode);
	if (a_cmd.opcode == OPCODE_HALT) {
		return FAILURE;
	}
	if (((a_pThis->registerResultStatus[a_cmd.dst] == NULL) || a_cmd.opcode == OPCODE_ST) && (currFunctionalUnit != NULL)) { 
		currFunctionalUnit->Busy = true;
		currFunctionalUnit->Fi = a_cmd.dst;
		currFunctionalUnit->Fj = a_cmd.src0;
		currFunctionalUnit->Fk = a_cmd.src1;
		if (a_cmd.opcode == OPCODE_LD) { 
			currFunctionalUnit->tempImmidiate = a_cmd.imm;
			currFunctionalUnit->Rj = true;
			currFunctionalUnit->Rk = true;
		}
		else if (a_cmd.opcode == OPCODE_ST)
		{
			currFunctionalUnit->tempImmidiate = a_cmd.imm;
			currFunctionalUnit->Qk = a_pThis->registerResultStatus[a_cmd.src1];
			currFunctionalUnit->Rk = (currFunctionalUnit->Qk == NULL);
			currFunctionalUnit->Rj = true;
		}
		else
		{
			currFunctionalUnit->Qj = a_pThis->registerResultStatus[a_cmd.src0];
			currFunctionalUnit->Qk = a_pThis->registerResultStatus[a_cmd.src1];
			currFunctionalUnit->Rj = (currFunctionalUnit->Qj == NULL);
			currFunctionalUnit->Rk = (currFunctionalUnit->Qk == NULL);
		}
		a_pThis->registerResultStatus[a_cmd.dst] = currFunctionalUnit;
		currFunctionalUnit->relatedPC = (a_pThis->lastIssuedPC++); 
		a_pThis->instructionStatus[ISSUE_STAGE_IDX][currFunctionalUnit->relatedPC] = a_pThis->cycle; 
		return SUCCESS;
	} else {
		return FAILURE;
	}
}
bool scoreboard_issue ( stScoreboardCPU * a_pThis , command_row_t a_cmd ) { stFunctionalUnit * currFunctionalUnit = scoreboard_getAvailableFU ( a_pThis , ( opcode_t ) a_cmd . opcode ) ; if ( a_cmd . opcode == OPCODE_HALT ) { return FAILURE ; } if ( ( ( a_pThis -> registerResultStatus [ a_cmd . dst ] == NULL ) || a_cmd . opcode == OPCODE_ST ) && ( currFunctionalUnit != NULL ) ) { currFunctionalUnit -> Busy = true ; currFunctionalUnit -> Fi = a_cmd . dst ; currFunctionalUnit -> Fj = a_cmd . src0 ; currFunctionalUnit -> Fk = a_cmd . src1 ; if ( a_cmd . opcode == OPCODE_LD ) { currFunctionalUnit -> tempImmidiate = a_cmd . imm ; currFunctionalUnit -> Rj = true ; currFunctionalUnit -> Rk = true ; } else if ( a_cmd . opcode == OPCODE_ST ) { currFunctionalUnit -> tempImmidiate = a_cmd . imm ; currFunctionalUnit -> Qk = a_pThis -> registerResultStatus [ a_cmd . src1 ] ; currFunctionalUnit -> Rk = ( currFunctionalUnit -> Qk == NULL ) ; currFunctionalUnit -> Rj = true ; } else { currFunctionalUnit -> Qj = a_pThis -> registerResultStatus [ a_cmd . src0 ] ; currFunctionalUnit -> Qk = a_pThis -> registerResultStatus [ a_cmd . src1 ] ; currFunctionalUnit -> Rj = ( currFunctionalUnit -> Qj == NULL ) ; currFunctionalUnit -> Rk = ( currFunctionalUnit -> Qk == NULL ) ; } a_pThis -> registerResultStatus [ a_cmd . dst ] = currFunctionalUnit ; currFunctionalUnit -> relatedPC = ( a_pThis -> lastIssuedPC ++ ) ; a_pThis -> instructionStatus [ ISSUE_STAGE_IDX ] [ currFunctionalUnit -> relatedPC ] = a_pThis -> cycle ; return SUCCESS ; } else { return FAILURE ; } }
This function performs the issue stage of the scorecoard, Before issuing the command it checks if
 there is no structural hazard (FU is available) and that there is no output dependency (WAW)
 The function return SUCCESS (true) on sucess and FAILURE (false) otherwise
This function performs the issue stage of the scorecoard Before issuing the command it checks if there is no structural hazard ( FU is available ) and that there is no output dependency ( WAW ) The function return SUCCESS ( true ) on sucess and FAILURE ( false ) otherwise
/* Check the Issue conditions */ /* If it's memory related op, save the immidiate value */ /* We return current issued PC and increase it by one */ /* Save the issue stage cycle */