hades.simulator
Class SimKernel

java.lang.Object
  extended byhades.simulator.SimKernel
All Implemented Interfaces:
ContextToolTip, java.lang.Runnable, Simulatable
Direct Known Subclasses:
BatchModeSimKernel, InteractiveSimKernel, RealTimeSimKernel, VhdlSimKernel

public class SimKernel
extends java.lang.Object
implements java.lang.Runnable, Simulatable, ContextToolTip

SimKernel -- Basic event-based HADES simulation engine.


Field Summary
protected  CommandQueue commandQueue
           
protected  Console console
           
protected  SimControlPanel controlPanel
           
 boolean debug
           
protected  Design design
           
static int ELABORATE
           
protected  double endTime
           
protected  EventList eventList
           
protected  int n_interactive
           
protected  int n_interactive_transferred
           
protected  int n_iterations
           
protected  int n_processed
           
protected  int n_scheduled
           
protected static int n_simulators
           
protected  java.lang.String name
           
protected  SyncPainter painter
           
static int PAUSED
           
static int RESET
           
protected  java.lang.Thread runner
           
static int RUNNING
           
protected  boolean shouldStop
           
protected  double simTime
           
protected  int simulatorID
           
static int SINGLESTEP
           
protected  int state
           
static int STOPPED
           
static java.lang.String versionString
           
 
Constructor Summary
SimKernel()
          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 checkClearWaveforms()
          this method is called from elaborateComponents after elaboration of the design under test, but before the start of the simulation.
 void continueSimulation()
          continue the simulation from the current simulation time.
 void dbg(java.lang.String msg)
           
 void deleteAllEventsFromSource(SimObject source)
           
 void elaborate(java.lang.Object arg)
          elaborate(): called by the Simulation engine (ourselves...) at the start of the simulation.
 void elaborateComponents()
           
 void evaluate(java.lang.Object arg)
          evaluate(): called by the Simulation engine.
 void executeSingleStep()
           
 boolean getDebug()
          get debug status
 EventList getEventList()
          get the event list
 long getNumberOfProcessedEvents()
           
 long getNumberOfScheduledEvents()
           
 double getSimTime()
          get the current simulation time
 java.lang.String getState()
          getState(): print current state
 SyncPainter getSyncPainter()
          get the current painter object
 java.lang.String getToolTip(java.awt.Point mouse_pos, long millis)
          get the message to display as a tool tip, depending on the current position of the cursor, and the elapsed idle time in milliseconds.
 boolean hasEvents()
          check whether events are scheduled with this simulator
 void initializeSimulator()
          initialize the simulator: stop any running simulation, then create a new eventlist, initialize start and end times, ...
 boolean isPaused()
          check whether this simulator is currently interrupted
 boolean isReset()
           
 boolean isRunning()
          check whether this simulator is running
 boolean isSingleStep()
           
static void main(java.lang.String[] argv)
          main(): simple self test for the simulation engine
 void message(java.lang.String msg)
          message(): print or display messages
 void pauseSimulation_NEW()
          pause the simulation, if running
 void pauseSimulation()
          pause the simulation, if running
 void printNextPendingEvent()
           
 void printStatus()
           
 void processPendingRepaints()
          request a repaint of all pending animation repaints
 void run_debug()
           
 void run()
          run the simulation until ready or interrupted
 void runFor(double delta_t)
          continue the simulation for the specified interval of time.
 void runForever()
          set the simulation end time to Double.MAX_VALUE, then start/continue the simulation from the current time.
 void scheduleEvent(SimEvent se)
          schedule an arbitrary simulation event
 void scheduleInteractiveEvent(SimEvent se)
          schedule an interactive (=asynchronous) simulation event
 void scheduleWakeup(Wakeable target, double time, java.lang.Object arg)
          schedule an SimObject wakeup at time t
 void setConsole(Console c)
           
 void setControlPanel(SimControlPanel scp)
          set the SimControlPanel class for this simulator
 void setDebug(boolean onoff)
          set debug status on/off
 void setDesign(Design design)
          set the (toplevel) Design to simulate
 void setName(java.lang.String name)
           
 void setSyncPainter(SyncPainter painter)
          set a painter object for synchronous repaints
 void singleStep()
          singleStep(): execute the one next event (if any).
 void stopSimulation_NEW()
          stop the simulation, no questions asked
 void stopSimulation()
          stop the simulation, no questions asked
 java.lang.String toString()
          standard identification method
static void usage()
          usage(): how to use the SimKernel selftest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

versionString

public static java.lang.String versionString

debug

public boolean debug

console

protected Console console

controlPanel

protected SimControlPanel controlPanel

painter

protected SyncPainter painter

RESET

public static final int RESET
See Also:
Constant Field Values

ELABORATE

public static final int ELABORATE
See Also:
Constant Field Values

RUNNING

public static final int RUNNING
See Also:
Constant Field Values

PAUSED

public static final int PAUSED
See Also:
Constant Field Values

SINGLESTEP

public static final int SINGLESTEP
See Also:
Constant Field Values

STOPPED

public static final int STOPPED
See Also:
Constant Field Values

state

protected int state

n_simulators

protected static int n_simulators

simulatorID

protected int simulatorID

commandQueue

protected CommandQueue commandQueue

eventList

protected EventList eventList

simTime

protected double simTime

endTime

protected double endTime

n_scheduled

protected int n_scheduled

n_processed

protected int n_processed

n_iterations

protected int n_iterations

n_interactive

protected int n_interactive

n_interactive_transferred

protected int n_interactive_transferred

runner

protected java.lang.Thread runner

shouldStop

protected boolean shouldStop

design

protected Design design
Constructor Detail

SimKernel

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

Method Detail

executeSingleStep

public void executeSingleStep()

setName

public void setName(java.lang.String name)

setDesign

public void setDesign(Design design)
set the (toplevel) Design to simulate


getNumberOfScheduledEvents

public long getNumberOfScheduledEvents()

getNumberOfProcessedEvents

public long getNumberOfProcessedEvents()

setControlPanel

public void setControlPanel(SimControlPanel scp)
set the SimControlPanel class for this simulator


setConsole

public void setConsole(Console c)

setDebug

public void setDebug(boolean onoff)
set debug status on/off


getDebug

public boolean getDebug()
get debug status


setSyncPainter

public void setSyncPainter(SyncPainter painter)
set a painter object for synchronous repaints


getSyncPainter

public SyncPainter getSyncPainter()
get the current painter object


processPendingRepaints

public void processPendingRepaints()
request a repaint of all pending animation repaints


hasEvents

public boolean hasEvents()
check whether events are scheduled with this simulator


isRunning

public boolean isRunning()
check whether this simulator is running


isPaused

public boolean isPaused()
check whether this simulator is currently interrupted


isReset

public boolean isReset()

isSingleStep

public boolean isSingleStep()

getSimTime

public double getSimTime()
get the current simulation time


getEventList

public EventList getEventList()
get the event list


scheduleEvent

public void scheduleEvent(SimEvent se)
schedule an arbitrary simulation event


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.


scheduleWakeup

public void scheduleWakeup(Wakeable target,
                           double time,
                           java.lang.Object arg)
schedule an SimObject wakeup at time t


scheduleInteractiveEvent

public void scheduleInteractiveEvent(SimEvent se)
schedule an interactive (=asynchronous) simulation event


elaborateComponents

public void elaborateComponents()

checkClearWaveforms

public void checkClearWaveforms()
this method is called from elaborateComponents after elaboration of the design under test, but before the start of the simulation. We try to reset the waveform data from a previous simulation run, if any.

FIXME: As the SimKernel currently has no direct access to neither the Editor nor the Waveform viewer but only to a Design, this method works by following the simkernel->design->editor->waveformviewer pointer chain. This is clearly not an optimal design pattern.


deleteAllEventsFromSource

public void deleteAllEventsFromSource(SimObject source)

pauseSimulation_NEW

public void pauseSimulation_NEW()
pause the simulation, if running


pauseSimulation

public void pauseSimulation()
pause the simulation, if running


stopSimulation_NEW

public void stopSimulation_NEW()
stop the simulation, no questions asked


stopSimulation

public void stopSimulation()
stop the simulation, no questions asked


initializeSimulator

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


continueSimulation

public void continueSimulation()
continue the simulation from the current simulation time. At the first call, this starts elaboration of all models and afterwards starts the simulation!


runForever

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


runFor

public void runFor(double delta_t)
continue the simulation for the specified interval of time.


singleStep

public void singleStep()
singleStep(): execute the one next event (if any). Start and elaborate the simulation, if necessary. Also, print information about the next event (if any) to allow the user to concentrate on that event.


printNextPendingEvent

public void printNextPendingEvent()

run

public void run()
run the simulation until ready or interrupted

Specified by:
run in interface java.lang.Runnable

run_debug

public void run_debug()

printStatus

public void printStatus()

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): called by the Simulation engine (ourselves...) at the start of the simulation. We just return from this method.

Specified by:
elaborate in interface Simulatable
Parameters:
arg - an arbitrary argument

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): called by the Simulation engine. This method is used to implement simulation controlled interrupts by scheduling InterruptEvent objects at the desired simulation times.

Specified by:
evaluate in interface Simulatable
Parameters:
arg - an arbitrary argument

toString

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


getToolTip

public java.lang.String getToolTip(java.awt.Point mouse_pos,
                                   long millis)
Description copied from interface: ContextToolTip
get the message to display as a tool tip, depending on the current position of the cursor, and the elapsed idle time in milliseconds.

Naturally, both the position and millis parameters simply may be ignored by classes implementing this interface.

Specified by:
getToolTip in interface ContextToolTip

message

public void message(java.lang.String msg)
message(): print or display messages

Specified by:
message in interface Simulatable

getState

public java.lang.String getState()
getState(): print current state


dbg

public void dbg(java.lang.String msg)

usage

public static void usage()
usage(): how to use the SimKernel selftest


main

public static void main(java.lang.String[] argv)
main(): simple self test for the simulation engine