Line 108... |
Line 108... |
unsigned long evalsim_reg32(int regno)
|
unsigned long evalsim_reg32(int regno)
|
{
|
{
|
if (regno < MAX_GPRS) {
|
if (regno < MAX_GPRS) {
|
return reg[regno];
|
return reg[regno];
|
} else {
|
} else {
|
printf("\nABORT: read out of registers\n");
|
PRINTF("\nABORT: read out of registers\n");
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
Line 125... |
Line 125... |
value = 0;
|
value = 0;
|
|
|
if (regno < MAX_GPRS) {
|
if (regno < MAX_GPRS) {
|
reg[regno] = value;
|
reg[regno] = value;
|
} else {
|
} else {
|
printf("\nABORT: write out of registers\n");
|
PRINTF("\nABORT: write out of registers\n");
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
}
|
}
|
}
|
}
|
|
|
/* Implementation specific.
|
/* Implementation specific.
|
Line 143... |
Line 143... |
if ((unsigned long)delta < (unsigned long)MAX_RAW_RANGE)
|
if ((unsigned long)delta < (unsigned long)MAX_RAW_RANGE)
|
raw_stats.range[delta]++;
|
raw_stats.range[delta]++;
|
#endif /* RAW_RANGE */
|
#endif /* RAW_RANGE */
|
return reg[regno];
|
return reg[regno];
|
} else {
|
} else {
|
printf("\nABORT: read out of registers\n");
|
PRINTF("\nABORT: read out of registers\n");
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
Line 156... |
Line 156... |
|
|
inline static void set_reg32(int regno, unsigned long value)
|
inline static void set_reg32(int regno, unsigned long value)
|
{
|
{
|
#if 0
|
#if 0
|
if (strcmp(regstr, FRAME_REG) == 0) {
|
if (strcmp(regstr, FRAME_REG) == 0) {
|
printf("FP (%s) modified by insn at %x. ", FRAME_REG, pc);
|
PRINTF("FP (%s) modified by insn at %x. ", FRAME_REG, pc);
|
printf("Old:%.8lx New:%.8lx\n", eval_reg(regno), value);
|
PRINTF("Old:%.8lx New:%.8lx\n", eval_reg(regno), value);
|
}
|
}
|
|
|
if (strcmp(regstr, STACK_REG) == 0) {
|
if (strcmp(regstr, STACK_REG) == 0) {
|
printf("SP (%s) modified by insn at %x. ", STACK_REG, pc);
|
PRINTF("SP (%s) modified by insn at %x. ", STACK_REG, pc);
|
printf("Old:%.8lx New:%.8lx\n", eval_reg(regmo), value);
|
PRINTF("Old:%.8lx New:%.8lx\n", eval_reg(regmo), value);
|
}
|
}
|
#endif
|
#endif
|
|
|
if (regno < MAX_GPRS) {
|
if (regno < MAX_GPRS) {
|
reg[regno] = value;
|
reg[regno] = value;
|
#if RAW_RANGE_STATS
|
#if RAW_RANGE_STATS
|
raw_stats.reg[regno] = runtime.sim.cycles;
|
raw_stats.reg[regno] = runtime.sim.cycles;
|
#endif /* RAW_RANGE */
|
#endif /* RAW_RANGE */
|
} else {
|
} else {
|
printf("\nABORT: write out of registers\n");
|
PRINTF("\nABORT: write out of registers\n");
|
runtime.sim.cont_run = 0;
|
runtime.sim.cont_run = 0;
|
}
|
}
|
}
|
}
|
|
|
/* Does srcoperand depend on computation of dstoperand? Return
|
/* Does srcoperand depend on computation of dstoperand? Return
|
Line 365... |
Line 365... |
static inline sbuf_store (int cyc) {
|
static inline sbuf_store (int cyc) {
|
int delta = runtime.sim.cycles - sbuf_prev_cycles;
|
int delta = runtime.sim.cycles - sbuf_prev_cycles;
|
sbuf_total_cyc += cyc;
|
sbuf_total_cyc += cyc;
|
sbuf_prev_cycles = runtime.sim.cycles;
|
sbuf_prev_cycles = runtime.sim.cycles;
|
|
|
//printf (">STORE %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//PRINTF (">STORE %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//printf ("|%i,%i\n", sbuf_total_cyc, sbuf_wait_cyc);
|
//PRINTF ("|%i,%i\n", sbuf_total_cyc, sbuf_wait_cyc);
|
/* Take stores from buffer, that occured meanwhile */
|
/* Take stores from buffer, that occured meanwhile */
|
while (sbuf_count && delta >= sbuf_buf[sbuf_tail]) {
|
while (sbuf_count && delta >= sbuf_buf[sbuf_tail]) {
|
delta -= sbuf_buf[sbuf_tail];
|
delta -= sbuf_buf[sbuf_tail];
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_count--;
|
sbuf_count--;
|
Line 388... |
Line 388... |
}
|
}
|
/* Put newest store in the buffer */
|
/* Put newest store in the buffer */
|
sbuf_buf[sbuf_head] = cyc;
|
sbuf_buf[sbuf_head] = cyc;
|
sbuf_head = (sbuf_head + 1) % MAX_SBUF_LEN;
|
sbuf_head = (sbuf_head + 1) % MAX_SBUF_LEN;
|
sbuf_count++;
|
sbuf_count++;
|
//printf ("|STORE %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//PRINTF ("|STORE %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
}
|
}
|
|
|
/* Store buffer analysis - previous stores should commit, before any load */
|
/* Store buffer analysis - previous stores should commit, before any load */
|
static inline sbuf_load () {
|
static inline sbuf_load () {
|
int delta = runtime.sim.cycles - sbuf_prev_cycles;
|
int delta = runtime.sim.cycles - sbuf_prev_cycles;
|
sbuf_prev_cycles = runtime.sim.cycles;
|
sbuf_prev_cycles = runtime.sim.cycles;
|
|
|
//printf (">LOAD %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//PRINTF (">LOAD %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//printf ("|%i,%i\n", sbuf_total_cyc, sbuf_wait_cyc);
|
//PRINTF ("|%i,%i\n", sbuf_total_cyc, sbuf_wait_cyc);
|
/* Take stores from buffer, that occured meanwhile */
|
/* Take stores from buffer, that occured meanwhile */
|
while (sbuf_count && delta >= sbuf_buf[sbuf_tail]) {
|
while (sbuf_count && delta >= sbuf_buf[sbuf_tail]) {
|
delta -= sbuf_buf[sbuf_tail];
|
delta -= sbuf_buf[sbuf_tail];
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_count--;
|
sbuf_count--;
|
Line 415... |
Line 415... |
runtime.sim.mem_cycles += sbuf_buf[sbuf_tail];
|
runtime.sim.mem_cycles += sbuf_buf[sbuf_tail];
|
sbuf_prev_cycles += sbuf_buf[sbuf_tail];
|
sbuf_prev_cycles += sbuf_buf[sbuf_tail];
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_tail = (sbuf_tail + 1) % MAX_SBUF_LEN;
|
sbuf_count--;
|
sbuf_count--;
|
}
|
}
|
//printf ("|LOAD %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
//PRINTF ("|LOAD %i,%i,%i,%i,%i\n", delta, sbuf_count, sbuf_tail, sbuf_head, sbuf_buf[sbuf_tail], sbuf_buf[sbuf_head]);
|
}
|
}
|
|
|
/* Outputs dissasembled instruction */
|
/* Outputs dissasembled instruction */
|
void dump_exe_log ()
|
void dump_exe_log ()
|
{
|
{
|
Line 483... |
Line 483... |
int i;
|
int i;
|
char temp[100];
|
char temp[100];
|
|
|
dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4, 1, 0);
|
dumpmemory(iqueue[0].insn_addr, iqueue[0].insn_addr + 4, 1, 0);
|
generate_time_pretty (temp, runtime.sim.cycles * config.sim.clkcycle_ps);
|
generate_time_pretty (temp, runtime.sim.cycles * config.sim.clkcycle_ps);
|
printf(" (executed) [time %s, #%i]\n", temp, runtime.cpu.instructions);
|
PRINTF(" (executed) [time %s, #%i]\n", temp, runtime.cpu.instructions);
|
if (config.cpu.superscalar)
|
if (config.cpu.superscalar)
|
printf ("Superscalar CYCLES: %u", runtime.cpu.supercycles);
|
PRINTF ("Superscalar CYCLES: %u", runtime.cpu.supercycles);
|
if (config.cpu.hazards)
|
if (config.cpu.hazards)
|
printf (" HAZARDWAIT: %u\n", runtime.cpu.hazardwait);
|
PRINTF (" HAZARDWAIT: %u\n", runtime.cpu.hazardwait);
|
else
|
else
|
if (config.cpu.superscalar)
|
if (config.cpu.superscalar)
|
printf ("\n");
|
PRINTF ("\n");
|
|
|
dumpmemory(pc, pc + 4, 1, 0);
|
dumpmemory(pc, pc + 4, 1, 0);
|
printf(" (next insn) %s", (delay_insn?"(delay insn)":""));
|
PRINTF(" (next insn) %s", (delay_insn?"(delay insn)":""));
|
for(i = 0; i < MAX_GPRS; i++) {
|
for(i = 0; i < MAX_GPRS; i++) {
|
if (i % 4 == 0)
|
if (i % 4 == 0)
|
printf("\n");
|
PRINTF("\n");
|
printf("GPR%.2u: %.8lx ", i, evalsim_reg32(i));
|
PRINTF("GPR%.2u: %.8lx ", i, evalsim_reg32(i));
|
}
|
}
|
printf("flag: %u\n", flag);
|
PRINTF("flag: %u\n", flag);
|
}
|
}
|
|
|
/* Generated/built in decoding/executing function */
|
/* Generated/built in decoding/executing function */
|
static inline void decode_execute (struct iqueue_entry *current);
|
static inline void decode_execute (struct iqueue_entry *current);
|
|
|
Line 557... |
Line 557... |
setsprbits(SPR_VR, SPR_VR_VER, config.cpu.ver);
|
setsprbits(SPR_VR, SPR_VR_VER, config.cpu.ver);
|
setsprbits(SPR_VR, SPR_VR_REV, config.cpu.rev);
|
setsprbits(SPR_VR, SPR_VR_REV, config.cpu.rev);
|
mtspr(SPR_SR, config.cpu.sr);
|
mtspr(SPR_SR, config.cpu.sr);
|
|
|
pcnext = 0x0; /* MM1409: All programs should start at reset vector entry! */
|
pcnext = 0x0; /* MM1409: All programs should start at reset vector entry! */
|
if (config.sim.verbose) printf ("Starting at 0x%08x\n", pcnext);
|
if (config.sim.verbose) PRINTF ("Starting at 0x%08x\n", pcnext);
|
pc = pcnext;
|
pc = pcnext;
|
pc_phy = pc;
|
pc_phy = pc;
|
pcnext += 4;
|
pcnext += 4;
|
debug(1, "reset ...\n");
|
debug(1, "reset ...\n");
|
|
|
Line 571... |
Line 571... |
|
|
/* Simulates one CPU clock cycle */
|
/* Simulates one CPU clock cycle */
|
inline int cpu_clock ()
|
inline int cpu_clock ()
|
{
|
{
|
if(fetch()) {
|
if(fetch()) {
|
printf ("Breakpoint hit.\n");
|
PRINTF ("Breakpoint hit.\n");
|
runtime.sim.cont_run = 0; /* memory breakpoint encountered */
|
runtime.sim.cont_run = 0; /* memory breakpoint encountered */
|
return 1;
|
return 1;
|
}
|
}
|
decode_execute_wrapper (&iqueue[0]);
|
decode_execute_wrapper (&iqueue[0]);
|
update_pc();
|
update_pc();
|