Line 37... |
Line 37... |
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "toplevel-support.h"
|
#include "toplevel-support.h"
|
#include "sched.h"
|
#include "sched.h"
|
#include "execute.h"
|
#include "execute.h"
|
#include "pic.h"
|
#include "pic.h"
|
|
#include "jtag.h"
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/*!Initialize the simulator.
|
/*!Initialize the simulator.
|
|
|
Line 147... |
Line 148... |
|
|
/* Loop until we have done enough cycles (or forever if we had a negative
|
/* Loop until we have done enough cycles (or forever if we had a negative
|
duration) */
|
duration) */
|
while (duration < 0.0 || (runtime.sim.cycles < runtime.sim.end_cycles))
|
while (duration < 0.0 || (runtime.sim.cycles < runtime.sim.end_cycles))
|
{
|
{
|
|
|
long long int time_start = runtime.sim.cycles;
|
long long int time_start = runtime.sim.cycles;
|
int i; /* Interrupt # */
|
int i; /* Interrupt # */
|
|
|
/* Each cycle has counter of mem_cycles; this value is joined with cycles
|
/* Each cycle has counter of mem_cycles; this value is joined with cycles
|
* at the end of the cycle; no sim originated memory accesses should be
|
* at the end of the cycle; no sim originated memory accesses should be
|
* performed inbetween.
|
* performed in between. */
|
*/
|
|
|
|
runtime.sim.mem_cycles = 0;
|
runtime.sim.mem_cycles = 0;
|
|
|
if (cpu_clock ())
|
if (cpu_clock ())
|
{
|
{
|
return OR1KSIM_RC_BRKPT; /* Hit a breakpoint */
|
return OR1KSIM_RC_BRKPT; /* Hit a breakpoint */
|
Line 196... |
Line 194... |
}
|
}
|
}
|
}
|
}
|
}
|
|
|
/* Update the scheduler queue */
|
/* Update the scheduler queue */
|
|
|
scheduler.job_queue->time -= (runtime.sim.cycles - time_start);
|
scheduler.job_queue->time -= (runtime.sim.cycles - time_start);
|
|
|
if (scheduler.job_queue->time <= 0)
|
if (scheduler.job_queue->time <= 0)
|
{
|
{
|
do_scheduler ();
|
do_scheduler ();
|
Line 384... |
Line 381... |
{
|
{
|
runtime.sim.ext_int_clr |= 1 << i; // Better not be > 31!
|
runtime.sim.ext_int_clr |= 1 << i; // Better not be > 31!
|
}
|
}
|
} /* or1ksim_interrupt() */
|
} /* or1ksim_interrupt() */
|
|
|
No newline at end of file
|
No newline at end of file
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/*!Reset the JTAG interface
|
|
|
|
@note Like all the JTAG interface functions, this must not be called
|
|
re-entrantly while a call to any other function (e.g. or1kim_run ())
|
|
is in progress. It is the responsibility of the caller to ensure this
|
|
constraint is met, for example by use of a SystemC mutex.
|
|
|
|
@return The time in seconds which the reset took. */
|
|
/*---------------------------------------------------------------------------*/
|
|
double
|
|
or1ksim_jtag_reset ()
|
|
{
|
|
return (double) jtag_reset () * (double) config.debug.jtagcycle_ps / 1.0e12;
|
|
|
|
} /* or1ksim_jtag_reset () */
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/*!Shift a JTAG instruction register
|
|
|
|
@note Like all the JTAG interface functions, this must not be called
|
|
re-entrantly while a call to any other function (e.g. or1kim_run ())
|
|
is in progress. It is the responsibility of the caller to ensure this
|
|
constraint is met, for example by use of a SystemC mutex.
|
|
|
|
The register is represented as a vector of bytes, with the byte at offset
|
|
zero being shifted first, and the least significant bit in each byte being
|
|
shifted first. Where the register will not fit in an exact number of bytes,
|
|
the odd bits are in the highest numbered byte, shifted to the low end.
|
|
|
|
The only JTAG instruction for which we have any significant behavior in
|
|
this model is DEBUG. For completeness the register is parsed and a warning
|
|
given if any register other than DEBUG is shifted.
|
|
|
|
@param[in,out] jreg The register to shift in, and the register shifted
|
|
back out.
|
|
|
|
@return The time in seconds which the shift took. */
|
|
/*---------------------------------------------------------------------------*/
|
|
double
|
|
or1ksim_jtag_shift_ir (unsigned char *jreg)
|
|
{
|
|
return (double) jtag_shift_ir (jreg) * (double) config.debug.jtagcycle_ps /
|
|
1.0e12;
|
|
|
|
} /* or1ksim_jtag_shift_ir () */
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/*!Shift a JTAG data register
|
|
|
|
@note Like all the JTAG interface functions, this must not be called
|
|
re-entrantly while a call to any other function (e.g. or1kim_run ())
|
|
is in progress. It is the responsibility of the caller to ensure this
|
|
constraint is met, for example by use of a SystemC mutex.
|
|
|
|
The register is represented as a vector of bytes, with the byte at offset
|
|
zero being shifted first, and the least significant bit in each byte being
|
|
shifted first. Where the register will not fit in an exact number of bytes,
|
|
the odd bits are in the highest numbered byte, shifted to the low end.
|
|
|
|
The register is parsed to determine which of the six possible register
|
|
types it could be.
|
|
- MODULE_SELECT
|
|
- WRITE_COMMNAND
|
|
- READ_COMMAND
|
|
- GO_COMMAND
|
|
- WRITE_CONTROL
|
|
- READ_CONTROL
|
|
|
|
@note In practice READ_COMMAND is not used. However the functionality is
|
|
provided for future compatibility.
|
|
|
|
@param[in,out] jreg The register to shift in, and the register shifted
|
|
back out.
|
|
|
|
@return The time in seconds which the shift took. */
|
|
/*---------------------------------------------------------------------------*/
|
|
double
|
|
or1ksim_jtag_shift_dr (unsigned char *jreg)
|
|
{
|
|
return (double) jtag_shift_dr (jreg) * (double) config.debug.jtagcycle_ps /
|
|
1.0e12;
|
|
|
|
} /* or1ksim_jtag_shift_dr () */
|
|
|
No newline at end of file
|
No newline at end of file
|