.\"******************************************************************* .\" .\" This file was extracted from hal/components/lut5.comp using halcompile.g. .\" Modify the source file. .\" .\"******************************************************************* .TH LUT5 "9" "2024-03-13" "LinuxCNC Documentation" "HAL Component" .SH NAME lut5 \- Arbitrary 5-input logic function based on a look-up table .SH SYNOPSIS .HP .B loadrt lut5 [count=\fIN\fB|names=\fIname1\fB[,\fIname2...\fB]] .SH DESCRIPTION .B lut5 constructs a logic function with up to 5 inputs using a \fBl\fRook-\fBu\fRp \fBt\fRable. The value for \fBfunction\fR can be determined by writing the truth table, and computing the sum of \fBall\fR the \fBweights\fR for which the output value would be \fRTRUE\fR. 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. .PP https://wiki.linuxcnc.org/cgi-bin/wiki.pl?Lut5 .PP Note that LUT5 will generate any of the 4,294,967,296 logical functions of 5 inputs so \fBAND\fR, \fBOR\fR, \fBNAND\fR, \fBNOR\fR, \fBXOR\fR and every other combinatorial function is possible. .PP .SS Example Functions A 5-input \fIand\fR function is TRUE only when all the inputs are true, so the correct value for \fBfunction\fR is \fB0x80000000\fR. .PP A 2-input \fIor\fR function would be the sum of \fB0x2\fR + \fB0x4\fR + \fB0x8\fR, so the correct value for \fBfunction\fR is \fB0xe\fR. .PP A 5-input \fIor\fR function is TRUE whenever any of the inputs are true, so the correct value for \fBfunction\fR is \fB0xfffffffe\fR. Because every weight except \fB0x1\fR is true the function is the sum of every line except the first one. .PP A 2-input \fIxor\fR function is TRUE whenever exactly one of the inputs is true, so the correct value for \fBfunction\fR is \fB0x6\fR. Only \fBin-0\fR and \fBin-1\fR should be connected to signals, because if any other bit is \fBTRUE\fR then the output will be \fBFALSE\fR. .PP .ie '\*[.T]'html' \{\ .HTML \ \ \ \ \ \
Weights for each line of truth table \
Bit 4Bit 3Bit 2Bit 1Bit 0 Weight \
000000x1 \
000010x2 \
000100x4 \
000110x8 \
001000x10 \
001010x20 \
001100x40 \
001110x80 \
010000x100 \
010010x200 \
010100x400 \
010110x800 \
011000x1000 \
011010x2000 \
011100x4000 \
011110x8000 \
100000x10000 \
100010x20000 \
100100x40000 \
100110x80000 \
101000x100000 \
101010x200000 \
101100x400000 \
101110x800000 \
110000x1000000 \
110010x2000000 \
110100x4000000 \
110110x8000000 \
111000x10000000 \
111010x20000000 \
111100x40000000 \
111110x80000000 \
\} .el \{\ .TS box tab(;); cb s s s s s cb cb cb cb cb | cb c c c c c | r. Weights for each line of truth table _ Bit 4;Bit 3;Bit 2;Bit 1;Bit 0; Weight _ 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 .TE \} .SH FUNCTIONS .TP \fBlut5.\fIN\fB\fR .SH PINS .TP .B lut5.\fIN\fB.in-0\fR bit in \fR .br .ns .TP .B lut5.\fIN\fB.in-1\fR bit in \fR .br .ns .TP .B lut5.\fIN\fB.in-2\fR bit in \fR .br .ns .TP .B lut5.\fIN\fB.in-3\fR bit in \fR .br .ns .TP .B lut5.\fIN\fB.in-4\fR bit in \fR .br .ns .TP .B lut5.\fIN\fB.out\fR bit out \fR .SH PARAMETERS .TP .B lut5.\fIN\fB.function\fR u32 rw \fR .SH SEE ALSO \fBand\fR(9), \fBlogic\fR(9), \fBnot\fR(9), \fBor2\fR(9), \fBxor2\fR(9). .SH AUTHOR Jeff Epler .SH LICENSE GPL