CRC
This document presents the CRC analysis of the classes used for logic simulation.
It presents a detailed description of the class messages and instance variables
for each class.
Since any logic circuit is setup as a graph of components, where each component
is not merely a node in a graph. There are certain rules by which this
graph is constructed. No component can arbitrarily connect to any other
component. These rules must be inforced for correct and predictable simulation
of the circuit. These rules are listed below:
-
No two output terminals can be connected together.
-
No two input terminals can be connected together.
-
Two unconnected nodes cannot be connected to each other.
-
All other connections are permitted.
These constraints are enforced by the GUI.
Class Component
Derived from
Object
Description
Abstract base class to model a generic component with 'n' input terminals
and 'm' output terminals. The 'n' input terminals are logically maintained
as a dependency list of size 'n'. These are references to the 'n'
components and their respective terminals that feed their output signal
to this component. The set of 'm' output terminals are each lists of dependent
components that this component fans out to.
Functions action: and evaluateTerminal: are subclass responsibilites.
Class Variables
Instance Variables
-
numberOfInputs
an integer which holds the number of input terminals this component
has ('n').
-
numberOfOutputs
an integer which holds the number of output terminals this component
has ('m').
-
listOfOutputDependents
a list of a list of fanned out components.
-
listOfInputDependents
a list of components that this component is a dependent of.
-
anArrayOfInputTerminalValues
hold the tristate value of each of the 'numberOfInputs' terminals.
-
anArrayOfOutputTerminalValues
hold the tristate value of each of the 'numberOfOutputs' terminals.
-
semaphores
an array of boolean flags of size 'numberOfInputs' which indicate if
the particular component input terminal is blocked or not. This is needed
in the simulation.
Messages
evaluateTerminal: anOutputTerminalIndex
Evaluates the value of the terminal referenced by 'anOutputTerminalIndex'.
This function implements the logical expression of the gate or its truth
table which ever is applicable. This a purely virtual function and it is
the duty of the derived class to implement this function.
changeTerminal: anInputTerminalIndex to: aTristateValue
This message implements the dependency mechanism. On receiving a change
message from any component for which it itself is a dependent, it must
recompute its mapping functions. If the result of this function changes
any of its outputs, then it informs, specifically those dependents of the
change. This is performed recursively. This function also verifies with
the help of the semaphore, if the simulation has entered an inconsistent
loop, in which case it reports the exception to the GUI. In addition this
method calls the action method of component to do something if a change
has occured at any of the output terminals.
action: anOutputTerminalIndex
This is a purely virtual function and is a subclass responsibility.
reset
This messages resets all Terminal values (viz. anArrayOfInputTerminalValues
and anArrayOfOutputTerminalValues) to undefined (which is the tristate).
connectTerminal: aTerminalIndex toTerminal: anotherTerminalIndex ofComponent:
aComponent
This message is sent by the GUI to establish the dependency of terminals
of one component on terminals of another component. It is not clear as
to whether this message should inforce some of the rules. If it does then
it will return a succeed or fail value depending on whether the connection
is valid or not.
disconnectTerminal: aTerminalIndex toTerminal: anotherTerminalIndex ofComponent:
aComponent
Performs the reverse operation of connectTerminal:toTerminal:ofComponent.
valueOfTerminal: aTerminalIndex
Returns the tristate value of the output terminal aTerminalIndex.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Output
Derived from
Component
Description
Intended to model an LED. This componet has just one input terminal and
no output terminals. numberOfInputs=1, numberOfOutputs=0.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: aTerminalIndex
This is a dummy method which is implemented simply because it is a
subclass responsibility. It performs no action since this is no output
terminal and no component depends on it.
-
action: anOutputTerminalIndex
This is called when the output changes state. So it merely invalidates
its view in the GUI to tell it that the LED should glow or be turned out.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Input
Derived from
Component
Description
Intended to model a switch. This component has just one output terminal
and no input terminals. numberOfInputs=0, numberOfOutputs=1.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: anOutputTerminalIndex
This is a dummy method which is implemented simply because it is a
subclass responsibility. It performs no action since this is no input terminal
and no component can trigger it.
-
action: anOutputTerminalIndex
This component takes no action on change.
Collaborators
ComponentCustomView, ComponentCustomController.
Class And
Derived from
Component
Description
Models an 'and' gate. numberOfInputs=2, numberOfOutputs=1.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: aTerminalIndex
Computes the logical mapping from the following truth table:
| a,b |
0 |
1 |
u |
| 0 |
0 |
0 |
0 |
| 1 |
0 |
1 |
u |
| u |
0 |
u |
u |
-
action: anOutputTerminalIndex
Invalidates its view so that the view can show the change in state
of the input/output nodes.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Or
Derived from
Component
Description
Models an 'or' gate. numberOfInputs=2, numberOfOutputs=1.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: anOutputTerminalIndex
Computes the logical mapping from the following truth table:
| a,b |
0 |
1 |
u |
| 0 |
0 |
1 |
u |
| 1 |
1 |
1 |
1 |
| u |
u |
1 |
u |
-
action: anOutputTerminalIndex
Invalidates its view so that its view can show the change in state
of the input/output terminals.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Not
Derived from
Component
Description
Models a 'not' gate.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: anOutputTerminalIndex
Computes the logical mapping from the following truth table:
-
action: anOutputTerminalIndex
This is called when the output changes state. So it merely invalidates
its view in the GUI so that it may show the change in state of the input/output.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Node
Derived from
Component
Description
Models a junction or node in circuit analysis. numberOfInputs=1, numberOfOutputs=1.
Class Variables
Instance Variables
Messages
-
evaluateTerminal: anOutputTerminalIndex
This evaluates the output of a node to whatever the input is. It is
an identity mapping.
-
action: anOutputTerminalIndex
Invalidates its view.
Collaborators
ComponentCustomView, ComponentCustomController.
Class Circuit
Derived from
Component
Description
Models a black box component which is constructed with other components.
This class holds a collection of components that are dependent on each
other.
Class Variables
Instance Variables
-
listOfComponents
a list of all the components in the circuit.
-
listOfInputNodes
a list of 'numberOfInputs' node components. These are the nodes that connect
the circuit inputs to the outside.
-
listOfOutputNodes
a list of 'numberOfOutputs' node components. These are the nodes that connect
the circuit outputs to the outside.
Messages
-
evaluateTerminal: anOutputTerminalIndex
Dummy function, implemented because it is subclass responsibility.
-
changeTerminal: anInputTerminalIndex to: aTristateValue
This is to override the base class function with the same name. Instead
of evaluating each node with the evaluate function it triggers the dependencies
of the respective node from 'listOfInputNodes'.
-
action: anOutputTerminalIndex
Invalidates its view.
-
snapTerminal: anInputTerminal ofComponent: aComponent toInputTerminal: anInputTerminalIndex
Connects the input of some component to the specific input terminal of
this composite.
-
snapTerminal: anOutputTerminal ofComponent: aComponent toOutputTerminal:
anOutputTerminalIndex
Connects the output of some component to the specific output terminal
of this composite component.
Collaborators
ComponentCustomController, ComponentCustomView.