LUT5(9)
π LUT5(9) π
okay bestie, welcome to the lut5 page β it lives in the HAL Component section and it is genuinely one of my faves because it can be literally any logic gate you can dream of. grab a strawberry π and let's get into it.
πΈ NAME πΈ
lut5 β arbitrary 5-input logic function based on a look-up table. yes that's it, that's the whole name, and it is exactly what it says. iconic.
π¦ SYNOPSIS π¦
loadrt lut5 [count=N|names=name1[,name2...]]
π DESCRIPTION π
okay so here's the tea β β lut5 constructs a logic function with up to 5 inputs using a look-up table. The value for function can be determined by writing the truth table, and computing the sum of all the weights for which the output value would be TRUE. The weights are hexadecimal, not decimal, so hexadecimal math must be used to sum the weights (do not come at me with decimal, it's not giving). A wiki page has a calculator to assist in computing the proper value for function:
https://wiki.linuxcnc.org/cgi-bin/wiki.pl?Lut5
and like, the range on this thing? Note that LUT5 will generate any of the 4,294,967,296 logical functions of 5 inputs, so AND, OR, NAND, NOR, XOR and every other combinatorial function is possible. she really said "I contain multitudes" π
β¨ Example Functions β¨
- A 5-input
andfunction is TRUE only when all the inputs are true, so the correct value forfunctionis0x80000000. no crumbs. π - A 2-input
orfunction would be the sum of0x2 + 0x4 + 0x8, so the correct value forfunctionis0xe. - A 5-input
orfunction is TRUE whenever any of the inputs are true, so the correct value forfunctionis0xfffffffe. Because every weight except0x1is true, the function is the sum of every line except the first one. subtle but slay. - A 2-input
xorfunction is TRUE whenever exactly one of the inputs is true, so the correct value forfunctionis0x6. π¦ Onlyin-0andin-1should be connected to signals, because if any other bit is TRUE then the output will be FALSE. important bestie, don't skip that one!!
π and now the moment you've all been waiting for: the weights for each line of the truth table. left to right that'sBit 4,Bit 3,Bit 2,Bit 1,Bit 0, then the weight. all 32 lines, no skipping, i would never do you like that π
0 0 0 0 0β0x10 0 0 0 1β0x20 0 0 1 0β0x40 0 0 1 1β0x80 0 1 0 0β0x100 0 1 0 1β0x200 0 1 1 0β0x400 0 1 1 1β0x800 1 0 0 0β0x1000 1 0 0 1β0x2000 1 0 1 0β0x4000 1 0 1 1β0x8000 1 1 0 0β0x10000 1 1 0 1β0x20000 1 1 1 0β0x40000 1 1 1 1β0x80001 0 0 0 0β0x100001 0 0 0 1β0x200001 0 0 1 0β0x400001 0 0 1 1β0x800001 0 1 0 0β0x1000001 0 1 0 1β0x2000001 0 1 1 0β0x4000001 0 1 1 1β0x8000001 1 0 0 0β0x10000001 1 0 0 1β0x20000001 1 0 1 0β0x40000001 1 0 1 1β0x80000001 1 1 0 0β0x100000001 1 1 0 1β0x200000001 1 1 1 0β0x400000001 1 1 1 1β0x80000000
π FUNCTIONS π
lut5.N
β¨ PINS β¨
every pin, all six of them, look at her go:
lut5.N.in-0βbitinlut5.N.in-1βbitinlut5.N.in-2βbitinlut5.N.in-3βbitinlut5.N.in-4βbitinlut5.N.outβbitout
π₯ PARAMETERS π₯
just the one, and she's powerful:
lut5.N.functionβu32rw
π SEE ALSO π
and(9), logic(9), not(9), or2(9), xor2(9). the whole friend group fr fr π«Ά
π AUTHOR π
Jeff Epler
π LICENSE π
GPL
LinuxCNC Documentation β 2026-03-17 β and that's the whole page bestie, you ate, go build a truth table πβ¨π
π¦ where this page comes from
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms