Example #1
0
/*
  Run pipeline until one of following occurs:
  - An exception is encountered in WB.
  - max_instr instructions have completed through WB
  - max_cycle cycles have been simulated

  Return number of instructions executed.
  if statusp nonnull, then will be set to exception status of final instruction
  if ccp nonnull, then will be set to condition codes of final instruction
*/
int sim_run_pipe(int max_instr, int max_cycle, exc_t *statusp, cc_t *ccp)
{
    int icount = 0;
    int ccount = 0;
    exc_t status = EXC_NONE;
    while (icount < max_instr && ccount < max_cycle) {
	status = sim_step_pipe(max_instr-icount);
	if (status != EXC_BUBBLE)
	    icount++;
	if (status != EXC_NONE && status != EXC_BUBBLE)
	    break;
	ccount++;
    }
    if (statusp)
	*statusp = status;
    if (ccp)
	*ccp = cc;
    return icount;
}
Example #2
0
File: psim.c Project: PiffNP/CSAPP
/*
  Run pipeline until one of following occurs:
  - An error status is encountered in WB.
  - max_instr instructions have completed through WB
  - max_cycle cycles have been simulated

  Return number of instructions executed.
  if statusp nonnull, then will be set to status of final instruction
  if ccp nonnull, then will be set to condition codes of final instruction
*/
int sim_run_pipe(int max_instr, int max_cycle, byte_t *statusp, cc_t *ccp)
{
    int icount = 0;
    int ccount = 0;
    byte_t run_status = STAT_AOK;
    while (icount < max_instr && ccount < max_cycle) {
        run_status = sim_step_pipe(max_instr-icount, ccount);
	if (run_status != STAT_BUB)
	    icount++;
	if (run_status != STAT_AOK && run_status != STAT_BUB)
	    break;
	ccount++;
    }
    if (statusp)
	*statusp = run_status;
    if (ccp)
	*ccp = cc;
    return icount;
}