logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

lut5 - Arbitrary 5-input logic function based on a look-up table

Author

       Jeff Epler

Description

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.  A wiki page has a calculator to assist in computing the proper value for function.

       https://wiki.linuxcnc.org/cgi-bin/wiki.pl?Lut5

       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.

   ExampleFunctions
       A 5-input and function is TRUE only when all the inputs are true, so the correct value  for  function  is
       0x80000000.

       A 2-input or function would be the sum of 0x2 + 0x4 + 0x8, so the correct value for function is 0xe.

       A  5-input  or function is TRUE whenever any of the inputs are true, so the correct value for function is
       0xfffffffe. Because every weight except 0x1 is true the function is the sum  of  every  line  except  the
       first one.

       A  2-input  xor  function  is  TRUE  whenever exactly one of the inputs is true, so the correct value for
       function is 0x6.  Only in-0 and in-1 should be connected to signals, because if any  other  bit  is  TRUE
       then the output will be FALSE.

       ┌────────────────────────────────────────────────────┐
       │        Weightsforeachlineoftruthtable        │
       ├───────────────────────────────────────┬────────────┤
       │ Bit4Bit3Bit2Bit1Bit0Weight   │
       ├───────────────────────────────────────┼────────────┤
       │   0       0       0       0       0   │        0x1 │
       │   0       0       0       0       1   │        0x2 │
       │   0       0       0       1       0   │        0x4 │
       │   0       0       0       1       1   │        0x8 │
       │   0       0       1       0       0   │       0x10 │
       │   0       0       1       0       1   │       0x20 │
       │   0       0       1       1       0   │       0x40 │
       │   0       0       1       1       1   │       0x80 │
       │   0       1       0       0       0   │      0x100 │
       │   0       1       0       0       1   │      0x200 │
       │   0       1       0       1       0   │      0x400 │
       │   0       1       0       1       1   │      0x800 │
       │   0       1       1       0       0   │     0x1000 │
       │   0       1       1       0       1   │     0x2000 │
       │   0       1       1       1       0   │     0x4000 │
       │   0       1       1       1       1   │     0x8000 │
       │   1       0       0       0       0   │    0x10000 │
       │   1       0       0       0       1   │    0x20000 │
       │   1       0       0       1       0   │    0x40000 │
       │   1       0       0       1       1   │    0x80000 │
       │   1       0       1       0       0   │   0x100000 │
       │   1       0       1       0       1   │   0x200000 │
       │   1       0       1       1       0   │   0x400000 │
       │   1       0       1       1       1   │   0x800000 │
       │   1       1       0       0       0   │  0x1000000 │
       │   1       1       0       0       1   │  0x2000000 │
       │   1       1       0       1       0   │  0x4000000 │
       │   1       1       0       1       1   │  0x8000000 │
       │   1       1       1       0       0   │ 0x10000000 │
       │   1       1       1       0       1   │ 0x20000000 │
       │   1       1       1       1       0   │ 0x40000000 │
       │   1       1       1       1       1   │ 0x80000000 │
       └───────────────────────────────────────┴────────────┘

Functions

lut5.N

License

       GPL

LinuxCNC Documentation                             2025-06-19                                            LUT5(9)

Name

       lut5 - Arbitrary 5-input logic function based on a look-up table

Parameters

lut5.N.function u32 rw

Pins

lut5.N.in-0 bit in
       lut5.N.in-1 bit in
       lut5.N.in-2 bit in
       lut5.N.in-3 bit in
       lut5.N.in-4 bit in
       lut5.N.out bit out

See Also

and(9), logic(9), not(9), or2(9), xor2(9).

Synopsis

loadrtlut5[count=N|names=name1[,name2...]]

See Also