hades.models.io
Class Ipin

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.gates.GenericGate
          extended byhades.models.io.Ipin
All Implemented Interfaces:
Assignable, java.lang.Cloneable, ContextToolTip, InputConnector, java.io.Serializable, Simulatable, Wakeable
Direct Known Subclasses:
IpinLarge, IpinStdLogic1164, IpinVertical, PulseSwitch

public class Ipin
extends GenericGate
implements InputConnector, Assignable, Wakeable

Ipin - a simple subclass of GenericGate that models an switch. Also, a Ipin object is automatically interpreted as an input for a hierarchical Design - like a standard-CAD 'ipin'.

Starting with 28.05.2005, this class also supports a 'bindkey' that allows the user to simply type the bindkey instead of clicking the switch. We only allow lowercase keys a-z and 0-9 as bindkeys. Just typing such key is handled the same as a normal left-button mouseclick, namely toggling between the '0' and '1' states. For the a-z keys, the shift+key combination is interpreted the same as a shift-mouseclick, namely toggling between '0', '1', 'Z', 'X' states.

See Also:
Serialized Form

Field Summary
protected  java.lang.String bindkey
           
protected  double delay
           
protected  StdLogic1164 output_0
           
protected  StdLogic1164 output_1
           
protected  StdLogic1164 output_U
           
protected  StdLogic1164 output_X
           
protected  StdLogic1164 output_Z
           
protected  PortStdLogic1164 port_toplevel
           
protected  PortStdLogic1164 port_Y
           
protected  ColoredCircle showOnOff
           
protected  StdLogic1164 startValue
           
protected  int state
           
 
Fields inherited from class hades.models.gates.GenericGate
t_delay
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
Ipin()
          Ipin(): simple constructor
 
Method Summary
 void assign(java.lang.String value, double time)
          used to specify a new Ipin output value from an external source (e.g.
 void configure()
          configure: display a dialog to specify the Ipin instance name, initial output value, and gate propagation delay.
 void elaborate(java.lang.Object arg)
          elaborate(): This method is called by the simulation engine to initialize the simulation object.
 void evaluate(java.lang.Object arg)
          evaluate: as interactive Ipin events are handled by mousePressed(), this method is only called by the simulation engine whenever our (hidden) toplevel signal changes.
 java.lang.String getBindkey()
          return our bindkey as a String
 double getDelay()
           
 java.lang.String getStartValue()
           
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a logic gate with name, class name, and gate delay.
protected  void initDisplay()
           
 boolean initialize(java.lang.String s)
          initialize an Ipin from a String, which contains the integer version id, and optionally the start value of this Ipin (the latter encoded via StdLogic1164.getChar() values, 'U' 'X' '0' ...
 void keyPressed(java.awt.event.KeyEvent evt)
          react to a KeyEvent.
 void mouseOrKeyEvent(boolean shiftDown)
           
 void mousePressed(java.awt.event.MouseEvent me)
          handle a mouse click on this IpinWithBindkey's graphical symbol.
protected  void schedule(int state, double delay, boolean interactive)
           
 void setBindkey(java.lang.String s)
           
 void setDelay(java.lang.String s)
           
 void setName(java.lang.String name)
          set the name of this SimObject.
 void setStartState()
           
 void setStartValue(java.lang.String s)
           
 void setSymbol(Symbol s)
           
 void setValueAtTime(StdLogic1164 value, double time)
          Deprecated. please use assign(String,time) instead
 void showState()
           
 void wakeup(java.lang.Object arg)
          wakeup: this method is currently used to handle "external" events on this Ipin via the assign call, which schedules a Wakeup event to update the Ipin symbol at the correct simulation time.
 void write(java.io.PrintWriter ps)
          write the versionID and the start value of this Ipin (the latter as StdLogic1164.getChar() value), e.g.
 
Methods inherited from class hades.models.gates.GenericGate
copy, scheduleEvent, scheduleEventAfter, scheduleOutputValue, scheduleOutputValueAfter, 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, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown, toString
 
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

state

protected int state

port_Y

protected PortStdLogic1164 port_Y

port_toplevel

protected PortStdLogic1164 port_toplevel

output_1

protected StdLogic1164 output_1

output_0

protected StdLogic1164 output_0

output_Z

protected StdLogic1164 output_Z

output_X

protected StdLogic1164 output_X

output_U

protected StdLogic1164 output_U

startValue

protected StdLogic1164 startValue

delay

protected double delay

showOnOff

protected ColoredCircle showOnOff

bindkey

protected java.lang.String bindkey
Constructor Detail

Ipin

public Ipin()
Ipin(): simple constructor

Method Detail

getDelay

public double getDelay()
Overrides:
getDelay in class GenericGate

setDelay

public void setDelay(java.lang.String s)
Overrides:
setDelay in class GenericGate

getStartValue

public java.lang.String getStartValue()

setStartValue

public void setStartValue(java.lang.String s)

initialize

public boolean initialize(java.lang.String s)
initialize an Ipin from a String, which contains the integer version id, and optionally the start value of this Ipin (the latter encoded via StdLogic1164.getChar() values, 'U' 'X' '0' ... 'D'), e.g. "1001 U"

Overrides:
initialize in class GenericGate

write

public void write(java.io.PrintWriter ps)
write the versionID and the start value of this Ipin (the latter as StdLogic1164.getChar() value), e.g. "1001 Z"

Overrides:
write in class GenericGate

getBindkey

public java.lang.String getBindkey()
return our bindkey as a String

Overrides:
getBindkey in class SimObject

setBindkey

public void setBindkey(java.lang.String s)

setSymbol

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

setName

public void setName(java.lang.String name)
Description copied from class: SimObject
set the name of this SimObject. If there is a Symbol for this SimObject, we also try to set the InstanceLabel in the Symbol.

To avoid consistency problems, when the user changes a SimObject's name interactively, we also try to enforce a unique name.

Overrides:
setName in class SimObject

initDisplay

protected void initDisplay()

setStartState

public void setStartState()

showState

public void showState()

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
handle a mouse click on this IpinWithBindkey's graphical symbol. Toggle the Ipin output value, schedule a corresponding output event with the new output value, and update the graphical symbol. For a normal mouse-click, the output value toggles between "0-1-0...", while a shift-mouse-click toggles between "0-1-Z-U-0..." states.

Overrides:
mousePressed in class SimObject

mouseOrKeyEvent

public void mouseOrKeyEvent(boolean shiftDown)

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
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

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): This method is called by the simulation engine to initialize the simulation object.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class GenericGate
Parameters:
arg - This parameter is ignored by Ipin

schedule

protected void schedule(int state,
                        double delay,
                        boolean interactive)

setValueAtTime

public void setValueAtTime(StdLogic1164 value,
                           double time)
Deprecated. please use assign(String,time) instead

used to specify a new Ipin output value from an external source (e.g. a script). Note that this method only schedules an output value, but does _not_ update the graphical representation of the Ipin. This should probably be corrected...


assign

public void assign(java.lang.String value,
                   double time)
used to specify a new Ipin output value from an external source (e.g. a script). Calling this method will result both in the corresponding output event and an update/repaint of the Ipin graphical symbol at the specified simulation time. The 'value' String is expected to have a one-character encoding of the StdLogic1164 value, namely "U" "X" "0" "1" "Z" "H" "L" "W" "D".

Internally, the latter graphical symbol update is implemented via a Wakeup event for this Ipin.

Specified by:
assign in interface Assignable

evaluate

public void evaluate(java.lang.Object arg)
evaluate: as interactive Ipin events are handled by mousePressed(), this method is only called by the simulation engine whenever our (hidden) toplevel signal changes. Take the toplevel signal value and propagate to our local signal.

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: this method is currently used to handle "external" events on this Ipin via the assign call, which schedules a Wakeup event to update the Ipin symbol at the correct simulation time. To this end, the "arg" argument is expected to hold a WakeupEvent whose arg member is a StdLogic1164 object.

Specified by:
wakeup in interface Wakeable

configure

public void configure()
configure: display a dialog to specify the Ipin instance name, initial output value, and gate propagation delay.

Overrides:
configure in class GenericGate

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
Description copied from class: GenericGate
construct a (short) tool tip message for a logic gate with name, class name, and gate delay.

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