From d019900647ba3553807f706a363362b4e4514add Mon Sep 17 00:00:00 2001 From: linuxcnc Date: Sat, 24 Oct 2026 21:39:07 +0000 Subject: [PATCH] Multi input AND/OR; much along the lines of logic(9) but with a controlled unconnected pin value that helps during machine conversation and an easier to read name. --- src/hal/components/and.comp | 36 ++++++++++++++++++++++++++++++++++++ src/hal/components/or.comp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/hal/components/and.comp create mode 100644 src/hal/components/or.comp diff --git a/src/hal/components/and.comp b/src/hal/components/and.comp new file mode 100644 index 00000000000..e39571171e0 --- /dev/null +++ b/src/hal/components/and.comp @@ -0,0 +1,36 @@ +component and "Multi input AND gate"; +pin in bool in##[128:personality] = 1 "input pins, up to personality-1"; +pin out bool out "output pin; the AND of all inputs"; + +description """ +The *out* pin is set to *TRUE* if all the inputs are all *TRUE*; or *FALSE* if one or more are *FALSE*. + +The value for a unconnected pin is TRUE; so it is fine to leave a pin unconnected. + +Set the number of pins via personality. The default value is a single *AND* with 8 inputs; so personality=8. The maximum number of inputs is 128 (hardcoded). If there are no inputs specified (personality=0); then the output value +is TRUE. +"""; + +function _ "Logical AND"; + +see_also """ +*or*(9), +and2(9) +and +or2(9). +"""; + +option period no; +option default_personality 8; +option default_count 1; + +license "ASLv2"; +author "Dirk-Willem van Gulik