hades.models.io
Class ClockGen2

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.gates.GenericGate
          extended byhades.models.io.ClockGen2
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable, Wakeable

public class ClockGen2
extends GenericGate
implements Simulatable, Wakeable, java.io.Serializable

ClockGen2 - a clock generator with selectable frequency, duty cycle and phase. Default is a symmetric 1 Hz clock signal. Signals are expected to be StdLogic1164 objects.

                    +----+     +----+     +----+
   +----------------+    +-----+    +-----+    +-----+ ....
   |                |          |          |          |
   |< offset       >|< period >|<  >|     | 
                                 dutycycle 
 

See Also:
Serialized Form

Field Summary
protected  java.lang.String bindkey
           
protected  Circle circleOnOff
           
protected  boolean debug
           
protected  double dutycycle
           
protected  int n_clicks
           
protected  int n_cycles
           
protected  double offset
           
protected  StdLogic1164 output_0
           
protected  StdLogic1164 output_1
           
protected  StdLogic1164 output_U
           
protected  double period
           
protected  PortStdLogic1164 port_Y
           
protected  boolean running
           
protected  java.awt.Color runningColor
           
protected  StdLogic1164 state
           
 
Fields inherited from class hades.models.gates.GenericGate
t_delay
 
Fields inherited from class hades.simulator.SimObject
classloader, console, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
ClockGen2()
          ClockGen2: create a ClockGen2 with default parameters (1Hz symmetric clock).
 
Method Summary
 void configure()
          configure: display a dialog window to specify the ClockGen2 instance name and the period, initial offset, and duty cycle timing parameters.
 void elaborate(java.lang.Object arg)
          elaborate: store a reference to our simulator, then schedule the events for the initial "U" phase, the first "1" phase, and the first wakeup.
 void evaluate(java.lang.Object arg)
          evaluate: as the ClockGen2 has no input signals, this method should never be called.
 java.lang.String getBindkey()
          return the bindkey as a String.
 double getDutycycle()
           
 double getOffset()
           
 double getPeriod()
           
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a tool tip message (with the timing parameters)
 boolean initialize(java.lang.String s)
          initialize a ClockGen2'erator from a String, which contains its integer version id, and the double values for clock period (in seconds), dutycycle (fraction 0.0 ..
 void keyPressed(java.awt.event.KeyEvent ke)
          react to a KeyEvent.
 void mouseOrKeyPressed(boolean isShiftDown)
           
 void mousePressed(java.awt.event.MouseEvent me)
          start or stop this ClockGen2'erator
 double parse(java.lang.String s)
           
 void setBindkey(java.lang.String s)
           
 void setDutycycle(double d)
           
 void setDutycycle(java.lang.String s)
           
 void setOffset(double d)
           
 void setOffset(java.lang.String s)
           
 void setPeriod(double d)
           
 void setPeriod(java.lang.String s)
           
 void setSymbol(Symbol s)
           
 java.lang.String toString()
          toString: generate a short description including class name, full instance name, and the timing parameters.
 void wakeup(java.lang.Object arg)
          wakeup(): Called by the simulator as a reaction to our own scheduleWakeup()-calls.
 void write(java.io.PrintWriter ps)
          write: write versionId, period [seconds], dutycycle [ratio], and initial offset [seconds].
 
Methods inherited from class hades.models.gates.GenericGate
copy, getDelay, scheduleEvent, scheduleEventAfter, scheduleOutputValue, scheduleOutputValueAfter, setDelay, setDelay
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, message, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hades.simulator.Simulatable
message
 

Field Detail

port_Y

protected PortStdLogic1164 port_Y

state

protected StdLogic1164 state

output_U

protected StdLogic1164 output_U

output_0

protected StdLogic1164 output_0

output_1

protected StdLogic1164 output_1

period

protected double period

dutycycle

protected double dutycycle

offset

protected double offset

n_cycles

protected int n_cycles

n_clicks

protected int n_clicks

running

protected boolean running

debug

protected boolean debug

bindkey

protected java.lang.String bindkey

circleOnOff

protected Circle circleOnOff

runningColor

protected java.awt.Color runningColor
Constructor Detail

ClockGen2

public ClockGen2()
ClockGen2: create a ClockGen2 with default parameters (1Hz symmetric clock).

Method Detail

setSymbol

public void setSymbol(Symbol s)
Overrides:
setSymbol in class SimObject

getPeriod

public double getPeriod()

getOffset

public double getOffset()

getDutycycle

public double getDutycycle()

setPeriod

public void setPeriod(double d)

setOffset

public void setOffset(double d)

setDutycycle

public void setDutycycle(double d)

setPeriod

public void setPeriod(java.lang.String s)

setOffset

public void setOffset(java.lang.String s)

setDutycycle

public void setDutycycle(java.lang.String s)

getBindkey

public java.lang.String getBindkey()
Description copied from class: SimObject
return the bindkey as a String.

Returns the lowercase bindkey character as a String; this key is used by KeyHandler to check whether this SimObject should be activated (via keyPressed()) in view-mode. We return null here. Should be overridden by SimObject's that want to be notified by and react to global key-events on the main editor canvas.

If you plan to enable a bindkey for your SimObject, please: override getBindkey(), implement setBindkey() - e.g. via NameMangler.getBindkey(), change write() to write the bindkey string, change initialize() to parse the bindkey string, modify getToolTip() to print the bindkey, and change configure() to allow setting the bindkey.

Overrides:
getBindkey in class SimObject

setBindkey

public void setBindkey(java.lang.String s)

parse

public double parse(java.lang.String s)

initialize

public boolean initialize(java.lang.String s)
initialize a ClockGen2'erator from a String, which contains its integer version id, and the double values for clock period (in seconds), dutycycle (fraction 0.0 .. 1.0), and offset (in seconds), e.g. 1001 1.0E-9 0.5 0.3E-9 for a 1nsec clock.

Overrides:
initialize in class GenericGate

write

public void write(java.io.PrintWriter ps)
write: write versionId, period [seconds], dutycycle [ratio], and initial offset [seconds].

Overrides:
write in class GenericGate

configure

public void configure()
configure: display a dialog window to specify the ClockGen2 instance name and the period, initial offset, and duty cycle timing parameters.

Overrides:
configure in class GenericGate

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
start or stop this ClockGen2'erator

Overrides:
mousePressed in class SimObject

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Description copied from class: SimObject
react to a KeyEvent. The base SimObject ignores all KeyEvents. this method is currently only used by a few classes in hades.models.io, e.g. IpinWithBindkey.

At the moment this is actually called from KeyHandler.keyTyped(), but this naming mismatch is not considered critical...

Overrides:
keyPressed in class SimObject

mouseOrKeyPressed

public void mouseOrKeyPressed(boolean isShiftDown)

elaborate

public void elaborate(java.lang.Object arg)
elaborate: store a reference to our simulator, then schedule the events for the initial "U" phase, the first "1" phase, and the first wakeup.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class GenericGate

evaluate

public void evaluate(java.lang.Object arg)
evaluate: as the ClockGen2 has no input signals, this method should never be called.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - an arbitrary object argument

wakeup

public void wakeup(java.lang.Object arg)
wakeup(): Called by the simulator as a reaction to our own scheduleWakeup()-calls. One period of the clock has expired, calculate new values. We expect an Integer passed-in as the WakeupEvent payload, and check whether that value matches the current n_clicks value. If not, we ignore the wakeup, because the user has made mouse/key input in the meantime.

Specified by:
wakeup in interface Wakeable

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
construct a tool tip message (with the timing parameters)

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class GenericGate

toString

public java.lang.String toString()
toString: generate a short description including class name, full instance name, and the timing parameters.

Overrides:
toString in class SimObject