.\"******************************************************************* .\" .\" This file was extracted from hal/components/logic.comp using halcompile.g. .\" Modify the source file. .\" .\"******************************************************************* .TH LOGIC "9" "2024-03-13" "LinuxCNC Documentation" "HAL Component" .SH NAME logic \- LinuxCNC HAL component providing configurable logic functions .SH SYNOPSIS .B loadrt logic .B [count=N|names=name1[,name2...]] .B personality=0xXXXX[,0xXXXX...] .TP \fBcount\fR The number of logical gates. .TP \fBnames\fR The named logical gates to create. .TP \fBpersonality\fR Comma separated list of hexadecimal number. Each number defines the behaviour of the individual logic gate. The list must have the same number of personalities as the N count. .SH DESCRIPTION General `logic function' component. Can perform `and', `or', `nand', `nor' and `xor' of up to 16 inputs. .LP Determine the proper value for `personality' by adding the inputs and outputs then convert to hex: .IP \(bu 4 The number of input pins, usually from 2 to 16 .IP \(bu 256 (0x100) if the `and' output is desired .IP \(bu 512 (0x200) if the `or' output is desired .IP \(bu 1024 (0x400) if the `xor' (exclusive or) output is desired .IP \(bu 2048 (0x800) if the `nand' output is desired .IP \(bu 4096 (0x1000) if the `nor' output is desired .LP Outputs can be combined, for example 2 + 256 + 1024 = 1282 converted to hex would be 0x502 and would have two inputs and have both `xor' and `and' outputs. .SH FUNCTIONS .TP \fBlogic.\fIN\fB\fR Read the inputs and toggle the output bit. .SH PINS .TP .B logic.\fIN\fB.in-\fIMM\fB\fR bit in (MM=00..personality & 0xff) \fR .br .ns .TP .B logic.\fIN\fB.and\fR bit out [if personality & 0x100] \fR .br .ns .TP .B logic.\fIN\fB.or\fR bit out [if personality & 0x200] \fR .br .ns .TP .B logic.\fIN\fB.xor\fR bit out [if personality & 0x400] \fR .br .ns .TP .B logic.\fIN\fB.nand\fR bit out [if personality & 0x800] \fR .br .ns .TP .B logic.\fIN\fB.nor\fR bit out [if personality & 0x1000] \fR .SH EXAMPLES .PP 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. .IP .nf 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 .fi .PP This is a named AND circuit with two inputs and one output. .IP .nf 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 .fi .SH SEE ALSO \fBand2\fR(9), \fBlut5\fR(9), \fBnot\fR(9), \fBor2\fR(9), \fBxor2\fR(9) .SH AUTHOR Jeff Epler .SH LICENSE GPL