Constructs an instance of the OutputElement class.
The index of the output element. See Input's index
parameter.
A string representing the label of the output element.
See Input's label
parameter.
The input bus connected to this output element.
Attach a logger to this loggable object so that messages logged with log will be send to this logger. Note that this can be called multiple times and multiple loggers can be attached to the same object. Log messages will be sent to all attached loggers.
The logger to attach to this object.
Detach a logger from this loggable object so that messages logged with log will no longer be sent to it. If the logger is not attached, nothing happens.
The logger to detach from this object.
Everything that is loggable gets a unique ID, which can help identify instances of objects in logs when many such instances exist. This ID is normally generated automatically by CircuitLoggable when it is instantiated, unless this method has been by child classes.
A unique ID among all loggable objects.
Get the index of this output.
The index number that was passed into the constructor.
Retrieve the input buses going in to this circuit element, in the order that they were passed to the CircuitElement constructor.
An array of CircuitBus objects.
Get the label of this output.
The label string that was passed into the constructor.
Retrieve the output buses going out from this circuit element, in the order that they were passed to the CircuitElement constructor.
An array of CircuitBus objects.
Protected
getGet the stored propagation delay. See comments for setPropagationDelay.
The stored propagation delay. If no delay was ever set with
setPropagationDelay, then 0
is returned.
Get this output's value.
The value on the input bus connected to this output.
Protected
logLog a message, sending it to all loggers associated with this loggable.
The log level to log the message at.
The message to log.
Optional
data: anyAny additional data to associate with the message.
Propagate all registered loggers (present and future) to the given loggable. This function will register the loggable object with the object it is being called on, establishing a parent-child relationship where all changes to the parent loggers will be propagated to the children.
The loggable object to attach all registered loggers to.
This method resets the circuit element to a known state, and is called at the beginning of each simulation run, but not between clock cycles. It is expected to be overridden only by child elements who have internal state which they may need to reset when the circuit is re-run with new inputs.
For example, see the Splitter element or any of the flip-flops, which are sequential elements and thus must retain a history of inputs and outputs to know how to propagate new outputs.
If you are going to override this method, be sure to still call the superclass
method first: super.reset()
.
Compute this element's output values after the input values have changed. This function can use getInputs to get the inputs in the same order they were passed to the constructor. It is helpful to destructure the array using the same names as were provided to the constructor. Likewise, this function can use getOutputs to get the output buses in the same order they were passed to the constructor.
The goal of this function is to actually do the logic of the element, translating the values on the input buses to values on the output buses.
The actual propagation delay of this element. Even though this class provides getPropagationDelay and setPropagationDelay, a circuit element may actually take more or less time to evaluate itself, and in some cases, a fixed call to setPropagationDelay with a static number isn't appropriate at all (e.g. in the case of SubCircuit, which inherits the propagation delay from the actual subcircuit.)
Set the index of this output. This function is used to ensure the proper functionality of subcircuits.
This is intended to be used by CircuitLoaders only. You should never call this function from code outside of a loader implementation.
The new index.
This output for method chaining.
Set the label on this element. Some circuit simulators allow arbitrary labels on all elements, which is useful for debugging purposes. If a label is provided, it will be printed in the logs to more easily identify circuit elements.
The label of this circuit element.
An instance of this element for method chaining.
Store a propagation delay number. This function is useful when loading in circuit elements which support custom propagation delays, so that resolve can return the result of getPropagationDelay if it is constant and doesn't change with each resolution.
The propagation delay to store.
An instance of this element for method chaining.
Set a new value for this output, which will be back-propagated to the circuit. This is a hack that allows users to set the state of sequential circuits properly.
The value to send to the input buses.
Convert this element to a string for representation in log output.
A string in the format of ClassName[id=XXX]('YYY')
where ClassName
is the name of the class, XXX
is the unique loggable ID of the specific
class instance, and YYY
is the user-provided label set by setLabel,
if any.
The output element is the primary means of interfacing with a circuit. It allows you to extract data out of the circuit being evaluated, and makes provisions for reading bus values directly in code. Well-crafted circuits will contain ample outputs which can be populated with values and retrieved by label via Circuit.run. See the documentation for that method for the normal way of retrieving outputs from circuits.s