Skip to content

Commit 7fe861d

Browse files
authored
Merge pull request #1795 from petterreinholdtsen/logic-example
Add example and more info on parameter to logic(9) manual page.
2 parents 3f6528c + dff4dd6 commit 7fe861d

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

src/hal/components/logic.comp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
component logic "LinuxCNC HAL component providing configurable logic functions";
1+
component logic """LinuxCNC HAL component providing configurable logic functions
2+
3+
.B loadrt logic
4+
.B [count=N|names=name1[,name2...]]
5+
.B personality=0xXXXX[,0xXXXX...]
6+
7+
.TP
8+
\\fBcount\\fR The number of logical gates.
9+
.TP
10+
\\fBnames\\fR The named logical gates to create.
11+
.TP
12+
\\fBpersonality\\fR Comma separated list of hexadecimal number.
13+
Each number defines the behaviour of the individual logic gate. The
14+
list must have the same number of personalities as the N count.
15+
16+
""";
217
pin in bit in-##[16 : personality & 0xff];
318
pin out bit and if personality & 0x100;
419
pin out bit or if personality & 0x200;
520
pin out bit xor if personality & 0x400;
621
pin out bit nand if personality & 0x800;
722
pin out bit nor if personality & 0x1000;
8-
function _ nofp;
23+
function _ nofp "Read the inputs and toggle the output bit.";
924
description """
1025
General `logic function' component. Can perform `and', `or',
1126
`nand', `nor' and `xor' of up to 16 inputs.
@@ -27,6 +42,33 @@ The number of input pins, usually from 2 to 16
2742
.LP
2843
Outputs can be combined, for example 2 + 256 + 1024 = 1282 converted to hex
2944
would be 0x502 and would have two inputs and have both `xor' and `and' outputs.
45+
""";
46+
examples """
47+
.PP
48+
This is an OR circuit connected to three different signals, two inputs
49+
named sig-in-0 and sig-in-1, and one output named sig-out. First the
50+
circuit is defined, then its function is connected to the servo real
51+
time thread, last, its pins are connected to the wanted signals.
52+
.IP
53+
.nf
54+
loadrt logic count=1 personality=0x202
55+
addf logic.0 servo-thread
56+
net sig-in-0 => logic.0.in-00
57+
net sig-in-1 => logic.0.in-01
58+
net sig-out <= logic.0.or
59+
.fi
60+
61+
.PP
62+
This is a named AND circuit with two inputs and one output.
63+
.IP
64+
.nf
65+
loadrt logic names=both personality=0x102
66+
addf both servo-thread
67+
net sig-in-0 => both.in-00
68+
net sig-in-1 => both.in-01
69+
net sig-out <= both.and
70+
.fi
71+
3072
""";
3173
see_also """
3274
\\fBand2\\fR(9),

0 commit comments

Comments
 (0)