new module:Logic()
Members
-
static state :Number
-
Enum for logic states.
States:
off
on
unknown
oscillating
-
static stateList :Array
-
list of all states that can be used in the simulation
This getter iterates over Logic.state and returns an array containing all values of Logic.state's members
Methods
-
static and(a, b) → {Logic.state}
-
Logic AND
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state
-
static nand(a, b) → {Logic.state}
-
Logic NAND
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state
-
static nor(a, b) → {Logic.state}
-
Logic NOR
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state
-
static not(a) → {Logic.state}
-
Logic NOT
Parameters:
Name Type Description a
Logic.state first input state
Returns:
Logic.state -output state
-
static or(a, b) → {Logic.state}
-
Logic OR
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state
-
static runSymmetricRules(a, b, rules) → {Logic.state}
-
Finds the correct rule in the array of rules and returns the corresponding return value. This function expects rules to be symmetric (so
a RULE b
should returns the same value asb RULE a
), which allows to cut down on therules
array quite a bitParameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
rules
Array Array of arrays. Each inner array represents a rule in the format [input1, input2, output]. The function finds an array, where
a === input1
andb === input1
(ora === input2
andb === input1
) and returnsoutput
from this array.Returns:
Logic.state -output state
-
static xnor(a, b) → {Logic.state}
-
Logic XNOR
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state
-
static xor(a, b) → {Logic.state}
-
Logic XOR
Parameters:
Name Type Description a
Logic.state first input state
b
Logic.state second input state
Returns:
Logic.state -output state