LogicGate Block
Logic gate selector: AND, OR, NOT, XOR with configurable inputs
Open LogicGate in BlockWerk →# LogicGate Block Documentation
Overview
The LogicGate block provides 4 fundamental logic operations in a single configurable block:
- AND - All inputs must be true (non-zero)
- OR - Any input must be true (non-zero)
- NOT - Invert the input (single input)
- XOR - Odd number of inputs must be true
Inputs
- Input: Multiple numeric inputs (configurable count)
- Non-zero value = TRUE (1)
- Zero value = FALSE (0)
Outputs
- Output: 1 (true) or 0 (false), depending on the operation
Parameters
Operation
Type: Dropdown selector Default: AND Options:
AND- Output = 1 if ALL inputs are non-zero, else 0OR- Output = 1 if ANY input is non-zero, else 0NOT- Output = 1 if input is zero, else 0 (single input)XOR- Output = 1 if ODD NUMBER of inputs are non-zero, else 0
Number of Inputs
Type: Number Default: 2 Range: 1-10 Note: Only used for AND, OR, XOR. NOT always uses 1 input.
Operation Definitions
AND - Logical AND
Truth table (2 inputs): | A | B | Output | |---|---|--------| | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |
Definition: Output = 1 iff ALL inputs are non-zero
OR - Logical OR
Truth table (2 inputs): | A | B | Output | |---|---|--------| | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 1 |
Definition: Output = 1 iff ANY input is non-zero
NOT - Logical NOT
Truth table: | Input | Output | |-------|--------| | 0 | 1 | | ≠ 0 | 0 |
Definition: Output = 1 iff input = 0 (inverts signal)
XOR - Exclusive OR
Truth table (2 inputs): | A | B | Output | |---|---|--------| | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 0 |
Definition: Output = 1 iff ODD NUMBER of inputs are non-zero
- 3 inputs: Output = 1 if 1 or 3 inputs are true
- 4 inputs: Output = 1 if 1 or 3 inputs are true
Examples
Example 1: AND Gate (Dual Threshold)
Signal → Comparator(> 0.5) ⟶┐
├→ LogicGate(AND) → Action
Signal → Comparator(> -0.5) ⟶┘
Output triggers only when BOTH conditions met simultaneously.
Example 2: OR Gate (Fault Detection)
Sensor1_Error ⟶┐
Sensor2_Error ├→ LogicGate(OR) → Alarm
Sensor3_Error ⟶┘
Output triggers if ANY sensor reports an error.
Example 3: NOT Gate (Signal Inversion)
Enable_Signal → LogicGate(NOT) → Disable_Signal
Inverts boolean state.
Example 4: XOR Gate (Parity Check)
Bit1 ⟶┐
Bit2 ├→ LogicGate(XOR, 3 inputs) → Odd_Parity_Check
Bit3 ⟶┘
Output = 1 if odd number of bits are set (error detection).
Common Use Cases
1. Condition checking: AND for all conditions must be true 2. Fault detection: OR for any error triggers alarm 3. Signal inversion: NOT to flip boolean logic 4. Parity checking: XOR for error detection in data 5. State machines: Combine gates to build complex logic 6. Safety interlocks: AND gate for multiple safety conditions 7. Redundancy: OR gate for multiple independent triggers
Behavior Notes
Number of Inputs Configuration
- AND, OR, XOR: Configure via
numInputsparameter - NOT: Always uses first input (ignores
numInputs) - Default: 2 inputs
- Range: 1-10 inputs
Edge Cases
- No inputs: Output = 0
- Single input AND: Output = 1 if input ≠ 0
- Single input OR: Output = 1 if input ≠ 0
- Single input XOR: Output = 1 if input ≠ 0
De Morgan's Laws
Useful for logic simplification:
- NOT(AND(a, b)) = OR(NOT(a), NOT(b))
- NOT(OR(a, b)) = AND(NOT(a), NOT(b))
Can be implemented by combining LogicGate blocks.
Comparison with Comparator
- LogicGate: Works with boolean signals (0 or 1)
- Comparator: Creates boolean signals from analog values (e.g., > threshold)
- Use Comparator first to convert analog to boolean, then LogicGate for logic
Remarks
- Boolean convention: Non-zero = TRUE, zero = FALSE; use Comparator to convert analog signals to clean boolean values before logic gates
- Input count: AND, OR, and XOR support 1–10 inputs; NOT always uses exactly one input
- De Morgan's laws: NOT(AND(a,b)) = OR(NOT(a), NOT(b)) — useful for logic simplification and reducing gate count
- Cascading: Chain multiple LogicGate blocks to build complex combinatorial logic
- Single-input edge case: A single-input AND, OR, or XOR acts as a buffer (output = input ≠ 0)
See Also
Comparator- Convert analog signals to booleanSwitch- Conditional routing based on logicAND,OR,NOT,XOR- Individual gate blocks (if using simpler circuits)