hades.simulator
Class RealTimeSimKernel

java.lang.Object
  extended byhades.simulator.SimKernel
      extended byhades.simulator.RealTimeSimKernel
All Implemented Interfaces:
ContextToolTip, java.lang.Runnable, Simulatable

public class RealTimeSimKernel
extends SimKernel
implements java.lang.Runnable

RealTimeSimKernel -- A subclass of the event-based HADES simulation engine with support for interactive 'real time' simulation 'a la DIGLOG.

Once started, the RealTimeSimKernel will dispatch Events in real time: No events will be processed faster than their scheduled time (in seconds). Naturally, Events cannot be processed faster than the Java virtual machine allows.

If no Events remain, the RealTimeSimKernel will enter into a sleep phase, polling the EventList all 100msec, to look for further interactive (user generated) Events.


Field Summary
(package private) static boolean ddebug
           
(package private) static boolean debug
           
(package private)  int delta_resync_iterations
           
(package private)  double eventTime
           
(package private)  int global_errors
           
(package private)  double lastSyncTime
           
(package private)  int n_resync_iterations
           
(package private)  double realTime
           
static int t_sleep
           
(package private)  long t0
           
(package private)  long t1
           
(package private) static java.lang.String versionString
           
 
Fields inherited from class hades.simulator.SimKernel
commandQueue, console, controlPanel, design, ELABORATE, endTime, eventList, n_interactive, n_interactive_transferred, n_iterations, n_processed, n_scheduled, n_simulators, name, painter, PAUSED, RESET, runner, RUNNING, shouldStop, simTime, simulatorID, SINGLESTEP, state, STOPPED
 
Constructor Summary
RealTimeSimKernel()
          constructor for an so far idle simulation engine
 
Method Summary
 void addPendingEvent(SimEvent se, Port target)
          the standard simulation engines don't support VHDL-style two-list simulation with delta-cycles.
 void initializeSimulator()
          initialize the simulator: stop any running simulation, then create a new eventlist, initialize start and end times, ...
 void printStatus()
          printStatus(): print a short message about current simulation and real times, as well as the number of scheduled and processed events.
 void resync()
          resync(): update our 'realTime' variable from the JVM system clock.
 void run()
          run the simulation until ready or interrupted.
 void runForever()
          set the simulation end time to Double.MAX_VALUE, then start/continue the simulation from the current time.
 void sleep()
          sleep for t_sleep milliseconds.
 java.lang.String toString()
          standard identification method
 
Methods inherited from class hades.simulator.SimKernel
checkClearWaveforms, continueSimulation, dbg, deleteAllEventsFromSource, elaborate, elaborateComponents, evaluate, executeSingleStep, getDebug, getEventList, getNumberOfProcessedEvents, getNumberOfScheduledEvents, getSimTime, getState, getSyncPainter, getToolTip, hasEvents, isPaused, isReset, isRunning, isSingleStep, main, message, pauseSimulation_NEW, pauseSimulation, printNextPendingEvent, processPendingRepaints, run_debug, runFor, scheduleEvent, scheduleInteractiveEvent, scheduleWakeup, setConsole, setControlPanel, setDebug, setDesign, setName, setSyncPainter, singleStep, stopSimulation_NEW, stopSimulation, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

static boolean debug

ddebug

static boolean ddebug

versionString

static java.lang.String versionString

realTime

double realTime

lastSyncTime

double lastSyncTime

eventTime

double eventTime

t0

long t0

t1

long t1

n_resync_iterations

int n_resync_iterations

delta_resync_iterations

int delta_resync_iterations

global_errors

int global_errors

t_sleep

public static int t_sleep
Constructor Detail

RealTimeSimKernel

public RealTimeSimKernel()
constructor for an so far idle simulation engine

Method Detail

runForever

public void runForever()
set the simulation end time to Double.MAX_VALUE, then start/continue the simulation from the current time.

Overrides:
runForever in class SimKernel

initializeSimulator

public void initializeSimulator()
Description copied from class: SimKernel
initialize the simulator: stop any running simulation, then create a new eventlist, initialize start and end times, ...

Overrides:
initializeSimulator in class SimKernel

addPendingEvent

public void addPendingEvent(SimEvent se,
                            Port target)
the standard simulation engines don't support VHDL-style two-list simulation with delta-cycles. Therefore, instead of storing a 'pending event' for later execution, we execute it right now.

Overrides:
addPendingEvent in class SimKernel

run

public void run()
run the simulation until ready or interrupted. This method processes all remaining SimEvents in 'real time' as follows: All Events with scheduled time smaller than the current time are processed as fast as possible. If no such Events remain, the simulator Thread will sleep() itself for 100msec. each, until the user generates new Events or the time is ripe for the Events scheduled for later times.

Variable 't0' holds the JVM clock at start of the simulation, 't1' is used for the curent JVM clock value.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class SimKernel

resync

public void resync()
resync(): update our 'realTime' variable from the JVM system clock.


printStatus

public void printStatus()
printStatus(): print a short message about current simulation and real times, as well as the number of scheduled and processed events.

Overrides:
printStatus in class SimKernel

sleep

public void sleep()
sleep for t_sleep milliseconds.


toString

public java.lang.String toString()
standard identification method

Overrides:
toString in class SimKernel