OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 141 to Rev 142
    Reverse comparison

Rev 141 → Rev 142

/trunk/or1ksim/cpu/or32/execute.c
299,14 → 299,33
if(!GlobalMode) /* Original mode */
set_reg32(STACK_REGNO, (MEMORY_START + MEMORY_LEN) - STACK_SIZE);
/* MM: does not reset, but jumps to _reset label instead. */
/*except_handle(EXCEPT_RESET, 0);*/
/* If we are in old mode, this behavior is acceptable. However,
in the new mode, there are no labels defined, and therefore
it is impossible to jump to a label. I have reenabled this
if we are running with gdb. CZ 21/06/01 */
if(GlobalMode)
except_handle(EXCEPT_RESET, 0);
}
 
int DIR_insn_injected = 0; /* CZ 21/06/01 */
/* Modified by CZ 26/05/01 for new mode execution */
/* Fetch returns nonzero if instruction should NOT be executed. */
inline int fetch() {
debug("fetch()\n");
 
/* Do this here rather than update_pc so the reset exception
will happen normally. NOTE: During debugging and
modification of the simulator, please keep in mind that
pc and pcnext are NOT guaranteed to be at their correct
values until after this is called. If you add stuff to
the main loop in toplevel.c before this call, you may
not get correct results. This can safely be moved to
the toplevel.c main loop, as long as the fetch() routine
is not called from anywhere else in the code. I have
placed it here for safety. CZ 21/06/01 */
 
PrepareException(); /* Update the pc for pending exceptions */
 
/* MM: Check for breakpoint. This has to be done in fetch cycle,
because of peripheria. */
if (mem[pc_phy].brk)
326,54 → 345,75
pc_phy %= MEMORY_START + MEMORY_LEN;
 
/* Fetch instruction. */
/* CZ 21/06/01: If there is an instruction waiting in the
debug unit DIR, execute that first! Note the insn_addr
may not be valid in this instance....hope that doesn't
hurt. */
{
unsigned int _insn;
_insn = eval_mem32 (pc_phy, &breakpoint);
if(!OverrideFetch(&_insn))
{
_insn = eval_mem32 (pc_phy, &breakpoint);
iqueue[0].insn_addr = pc;
}
else
{
iqueue[0].insn_addr = -1;
DIR_insn_injected = 1;
}
 
iqueue[0].insn_index = insn_decode(_insn);
iqueue[0].insn = _insn;
}
iqueue[0].insn_addr = pc;
/*************************************************/
/* THIS HAS BEEN DELAYED UNTIL AFTER EXECUTION */
/*************************************************/
/* Increment program counter. */
#if 0
pc = pcnext;
pcnext += 4;
/* update_pc will be called after execution */
 
/* Simulate instruction cache and IMMU. */
pc_phy = simulate_ic_mmu_fetch(pc);
if ((pc_phy < MEMORY_START) || (pc_phy > MEMORY_START + MEMORY_LEN) ||
(!mem[pc_phy].insn && !GlobalMode)) {
except_handle(EXCEPT_BUSERR, pc);
return 0;
}
/* Check for breakpoint. */
if (mem[pc_phy].brk)
cont_run = 0; /* Breakpoint set. */
nop_period++;
#endif
return 0;
}
 
/* Added by CZ on 27/05/01 */
inline void update_pc()
/* This code actually updates the PC value. CZ 21/06/01 */
inline void _execute_update_pc(unsigned long t_pc,unsigned long t_pcnext)
{
pc = pcnext;
pcnext = delay_insn ? pcdelay : pcnext+4;
pc = t_pc;
pcnext = t_pcnext;
 
/* Simulate instruction cache and IMMU. */
pc_phy = simulate_ic_mmu_fetch(pc);
if ((pc_phy < MEMORY_START) || (pc_phy > MEMORY_START + MEMORY_LEN)) {
if ((pc_phy < MEMORY_START) || (pc_phy > MEMORY_START + MEMORY_LEN))
except_handle(EXCEPT_BUSERR, pc);
return;
}
}
 
/* Added by CZ on 27/05/01 */
/* Modified 21/06/01: If a breakpoint exception has stalled
the cpu, then we do not want to update the PC. This causes
GDB to barf uncontrollably. We act normally if the PC
is not stalled, or precalculate the values that will be
used if the PC is stalled. These are passed to prepare
exception, which will call execute_update_pc at the
appropriate time */
 
inline void update_pc()
{
unsigned long t_pc = pcnext;
unsigned long t_pcnext = delay_insn ? pcdelay : pcnext+4;
extern int cpu_stalled; /* CZ from debug_interface */
 
/* If an insn was injected, don't increment the PC value,
as it should not affect the existing instruction stream */
if(DIR_insn_injected)
{
t_pc = pc;
t_pcnext = delay_insn ? pcdelay : pcnext;
}
DIR_insn_injected = 0;
 
if(!cpu_stalled)
_execute_update_pc(t_pc,t_pcnext);
else
PrepareExceptionPC(t_pc,t_pcnext);
 
nop_period++;
}
 
796,9 → 836,6
}
}
void l_sys() {
int dummy1 = 0;
int dummy2 = 0;
int dummy3 = 0;
 
if (!GlobalMode && eval_operand(0, &breakpoint) > 200) {
unsigned long stackaddr, fmtaddr, args;
835,6 → 872,11
else
except_handle(EXCEPT_SYSCALL, 0);
}
 
void l_trap() {
except_handle(EXCEPT_BREAK, 0);
}
 
void l_mac() {
sprword lo, hi;
LONGEST l;
876,3 → 918,4
void l_invalid() {
except_handle(EXCEPT_ILLEGAL, 0);
}
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.