Logical_OR Logical_OR Icon

LogicGates.Logical_OR

Logical_OR(; name, abs_tol=1e-3, target_value=0.0)

A logical OR operation component for two real-valued input signals.

Parameters

  • abs_tol: Absolute tolerance for comparing inputs to target value (default: 1e-3)
  • target_value: Reference value for comparison (default: 0.0)

Variables

  • u1(t): First input signal (placement: left side, upper)
  • u2(t): Second input signal (placement: left side, lower)
  • y(t): Output signal (placement: right side)

Description

Each input is first compared against the target_value with the specified absolute tolerance:

  • Input is considered false if it is approximately equal to the target value within tolerance.
  • Otherwise, it is considered true.

The OR operation is applied to the boolean results:

  • y = 1.0 if either u1 or u2 is true (not approximately equal to target_value)
  • y = 0.0 if both u1 and u2 are false (approximately equal to target_value)

Examples

With abstol = 0.001, targetvalue = 0.0:

  • u1 = 0.0, u2 = 0.0 → y = 0.0 (both false)
  • u1 = 0.1, u2 = 0.0 → y = 1.0 (u1 true)
  • u1 = 0.0, u2 = -0.002 → y = 1.0 (u2 true within tolerance)
  • u1 = 0.5, u2 = 0.8 → y = 1.0 (both true)

Usage

PrimitiveComponents.LogicGates.Logical_OR(abs_tol=1e-3, target_value=0.0)

Parameters:

NameDescriptionUnitsDefault value
abs_tol0.001
target_value0

Connectors

  • u1 - This connector represents a real signal as an input to a component (RealInput)
  • y - This connector represents a real signal as an output from a component (RealOutput)
  • u2 - This connector represents a real signal as an input to a component (RealInput)

Variables

NameDescriptionUnits
c1
c2

Behavior

\[ \begin{align} \mathtt{c1}\left( t \right) &= check\_with\_target\_value\left( \mathtt{u1}\left( t \right), \mathtt{target\_value}, \mathtt{abs\_tol} \right) \\ \mathtt{c2}\left( t \right) &= check\_with\_target\_value\left( \mathtt{u2}\left( t \right), \mathtt{target\_value}, \mathtt{abs\_tol} \right) \\ y\left( t \right) &= ifelse\left( \neg \mathtt{c1}\left( t \right) \vee \neg \mathtt{c2}\left( t \right), 1, 0 \right) \end{align} \]

Source

"""
    Logical_OR(; name, abs_tol=1e-3, target_value=0.0)

A logical OR operation component for two real-valued input signals.

# Parameters
- `abs_tol`: Absolute tolerance for comparing inputs to target value (default: 1e-3)
- `target_value`: Reference value for comparison (default: 0.0)

# Variables
- `u1(t)`: First input signal (placement: left side, upper)
- `u2(t)`: Second input signal (placement: left side, lower)
- `y(t)`: Output signal (placement: right side)

# Description
Each input is first compared against the target_value with the specified absolute tolerance:
- Input is considered false if it is approximately equal to the target value within tolerance.
- Otherwise, it is considered true.

The OR operation is applied to the boolean results:
- y = 1.0 if either u1 or u2 is true (not approximately equal to target_value)
- y = 0.0 if both u1 and u2 are false (approximately equal to target_value)

# Examples
With abs_tol = 0.001, target_value = 0.0:
- u1 = 0.0, u2 = 0.0 → y = 0.0  (both false)
- u1 = 0.1, u2 = 0.0 → y = 1.0  (u1 true)
- u1 = 0.0, u2 = -0.002 → y = 1.0  (u2 true within tolerance)
- u1 = 0.5, u2 = 0.8 → y = 1.0  (both true)
"""
component Logical_OR
  u1 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  y = Dyad.RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  u2 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  # Absolute tolerance — the maximum allowed difference |x - target_value| for them to be considered approximately equal. Defaults to 1e-3
  parameter abs_tol::Real() = 1e-3
  # The reference value against which x is compared for closeness. Defaults to 0.0.
  parameter target_value::Real() = 0.0
  variable c1::Boolean
  variable c2::Boolean
relations
  c1 = check_with_target_value(u1, target_value, abs_tol)
  c2 = check_with_target_value(u2, target_value, abs_tol)
  y = ifelse(!c1 or !c2, float_sym(1.0), float_sym(0.0))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/OR.svg"}}}
end
Flattened Source
"""
    Logical_OR(; name, abs_tol=1e-3, target_value=0.0)

A logical OR operation component for two real-valued input signals.

# Parameters
- `abs_tol`: Absolute tolerance for comparing inputs to target value (default: 1e-3)
- `target_value`: Reference value for comparison (default: 0.0)

# Variables
- `u1(t)`: First input signal (placement: left side, upper)
- `u2(t)`: Second input signal (placement: left side, lower)
- `y(t)`: Output signal (placement: right side)

# Description
Each input is first compared against the target_value with the specified absolute tolerance:
- Input is considered false if it is approximately equal to the target value within tolerance.
- Otherwise, it is considered true.

The OR operation is applied to the boolean results:
- y = 1.0 if either u1 or u2 is true (not approximately equal to target_value)
- y = 0.0 if both u1 and u2 are false (approximately equal to target_value)

# Examples
With abs_tol = 0.001, target_value = 0.0:
- u1 = 0.0, u2 = 0.0 → y = 0.0  (both false)
- u1 = 0.1, u2 = 0.0 → y = 1.0  (u1 true)
- u1 = 0.0, u2 = -0.002 → y = 1.0  (u2 true within tolerance)
- u1 = 0.5, u2 = 0.8 → y = 1.0  (both true)
"""
component Logical_OR
  u1 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  y = Dyad.RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  u2 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  # Absolute tolerance — the maximum allowed difference |x - target_value| for them to be considered approximately equal. Defaults to 1e-3
  parameter abs_tol::Real() = 1e-3
  # The reference value against which x is compared for closeness. Defaults to 0.0.
  parameter target_value::Real() = 0.0
  variable c1::Boolean
  variable c2::Boolean
relations
  c1 = check_with_target_value(u1, target_value, abs_tol)
  c2 = check_with_target_value(u2, target_value, abs_tol)
  y = ifelse(!c1 or !c2, float_sym(1.0), float_sym(0.0))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/OR.svg"}}}
end


Test Cases

No test cases defined.