LOGIC(9)

πŸ“¦
version 2.9.4 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– LOGIC(9) β€” the hal component that's literally a little logic gate factory πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about logic, a LinuxCNC HAL component that hands you configurable logic functions like it's a vending machine and you've got exact change. this page lives in section 9 of the manual (kernel/HAL component territory, iykyk) and honestly? it ate. πŸŽ€


✨ NAME ✨

logic β€” a LinuxCNC HAL component providing configurable logic functions. that's the whole vibe. gates. you configure them. they logic. πŸ¦‹


🌸 SYNOPSIS 🌸

loadrt logic [count=N|names=name1[,name2...]]
personality=0xXXXX[,0xXXXX...]
  • count β€” the number of logical gates you want. just. so many gates.
  • names β€” the named logical gates you want to create. give them little names, they deserve it. 🫢
  • personality β€” a comma separated list of hexadecimal numbers. each number defines the behaviour of one individual logic gate. and listen: the list must have the same number of personalities as the N count. no mismatches. match the energy. πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

it's the general logic function'</lavender> component, bestie. it can do <mint>and', or'</mint>, <mint>nand', nor'</mint> and <mint>xor' of up to 16 inputs. sixteen!! the range!!

so how do you figure out the proper value for personality? you add the inputs and outputs together, then convert to hex. it's giving math class but make it cute:

  • the number of input pins, usually from 2 to 16
  • 256 (0x100) if the `and' output is desired
  • 512 (0x200) if the `or' output is desired
  • 1024 (0x400) if the `xor' (exclusive or) output is desired
  • 2048 (0x800) if the `nand' output is desired
  • 4096 (0x1000) if the `nor' output is desired

and here's the slay part: outputs can be combined. for example, 2 + 256 + 1024 = 1282 converted to hex would be 0x502, and that would have two inputs and have both xor'</mint> and <mint>and' outputs. two outputs. one gate. main character behaviour honestly. πŸ‘‘


πŸ”₯ FUNCTIONS πŸ”₯

  • logic.N β€” read the inputs and toggle the output bit. that's it. that's the function. no notes. πŸ’…

πŸ¦‹ PINS πŸ¦‹

  • logic.N.in-MM bit in (MM=00..personality & 0xff) β€” the inputs, and yeah there are a lot of them depending on your personality nibble
  • logic.N.and bit out [if personality & 0x100]
  • logic.N.or bit out [if personality & 0x200]
  • logic.N.xor bit out [if personality & 0x400]
  • logic.N.nand bit out [if personality & 0x800]
  • logic.N.nor bit out [if personality & 0x1000]

see how the output pins only show up if their bit is set in personality? conditional. iconic. ✨


πŸ“ EXAMPLES πŸ“

example one: the OR circuit 🧚

this is an OR circuit connected to three different signals β€” two inputs named sig-in-0 and sig-in-1, and one output named sig-out. first the circuit is defined, then its function is connected to the servo real time thread, last, its pins are connected to the wanted signals.

loadrt logic count=1 personality=0x202
addf logic.0 servo-thread
net sig-in-0 => logic.0.in-00
net sig-in-1 => logic.0.in-01
net sig-out  <= logic.0.or

example two: the named AND circuit πŸ’–

this is a named AND circuit with two inputs and one output.

loadrt logic names=both personality=0x102
addf both servo-thread
net sig-in-0 => both.in-00
net sig-in-1 => both.in-01
net sig-out  <= both.and

look at that. names=both and then everything is just both. instead of logic.0.. naming rights are real and they are powerful. πŸ’…


🌈 SEE ALSO 🌈

and2(9), lut5(9), not(9), or2(9), xor2(9)

go read those too, they're the rest of the friend group. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Jeff Epler


πŸ’€ LICENSE πŸ’€

GPL


okay and that's the whole manual page, bestie!! this was written up by the LinuxCNC Documentation crew, version dated 2026-03-17, and that date is the footer energy we're leaving you with. now go build a gate and slay. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from