summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/liblog.m4
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-01-02 03:04:28 +0000
committerNorbert Preining <norbert@preining.info>2024-01-02 03:04:28 +0000
commit6b10e9901a24325e837f0fdc2cbce8f43f18ccff (patch)
tree3c9f999691258a32058bf6b3e8353eadeda85f9b /graphics/circuit_macros/liblog.m4
parent094e5f512c4ea5981db967dd89c47363a603529b (diff)
CTAN sync 202401020304
Diffstat (limited to 'graphics/circuit_macros/liblog.m4')
-rw-r--r--graphics/circuit_macros/liblog.m4168
1 files changed, 104 insertions, 64 deletions
diff --git a/graphics/circuit_macros/liblog.m4 b/graphics/circuit_macros/liblog.m4
index 5f4693cd67..9c68aff0e2 100644
--- a/graphics/circuit_macros/liblog.m4
+++ b/graphics/circuit_macros/liblog.m4
@@ -1,7 +1,7 @@
divert(-1)
liblog.m4 Logic gates
-* Circuit_macros Version 10.4, copyright (c) 2023 J. D. Aplevich under *
+* Circuit_macros Version 10.5, copyright (c) 2024 J. D. Aplevich under *
* the LaTeX Project Public Licence in file Licence.txt. The files of *
* this distribution may be redistributed or modified provided that this *
* copyright notice is included and provided that modifications are clearly *
@@ -43,6 +43,7 @@ define(`XOR_off',1) `XOR and NXOR parameter'
define(`N_diam',(3/2)) `not-circle diameter'
define(`N_rad',`(N_diam/2)') `not-circle radius'
define(`NOT_rad',`(N_rad*L_unit)') `scaled radius eg line chop NOT_rad'
+define(`N_attr') `not-circle attribs eg shaded "green"'
define(`H_ht',2) `Hysteresis symbol dimen'
define(`Mx_pins',6) `max number of gate input pins without extensions
Possibly 4 is better for negated inputs'
@@ -50,6 +51,7 @@ define(`FF_wid',12) `Bistable (flipflop)'
define(`FF_ht',18)
define(`Mux_wid',8) `Multiplexer defaults'
define(`Mux_ht',18)
+define(`Lg_body') `Gate body attributes, e.g., shaded "color"'
define(`lg_plen',4) `Logic pin'
define(`lg_pinsep',`(3*L_unit)') `logic pin separation in logic units'
@@ -71,7 +73,7 @@ define(`rsvec_',`Here+svec_(`$1',`$2')')
`NOT_circle
convenience for drawing NOT circles'
-define(`NOT_circle',`circle diam N_diam*L_unit')
+define(`NOT_circle',`circle diam N_diam*L_unit N_attr')
`LH_symbol([U|D|L|R|degrees][I])
I=inverted
@@ -92,7 +94,8 @@ define(`LT_symbol', `[ setdir_(`$1',R)
then to svec_(0,-H_ht*5/8) then to Here
`$2'; resetdir_ ] ')
- `BOX_gate(inputs,output,swid,sht,label)
+ `BOX_gate(inputs,output,swid,sht,label,
+ attributes)
drawn in the current direction
args 3 and 4 are L_unit values
inputs=[P|N]* output=P|N'
@@ -101,30 +104,31 @@ define(`m4m',`ifelse(`$1',,2,len(`$1'))')define(`m4a',`$1')dnl
define(`m4h',`ifelse(`$3',,AND_wd,`$3')')dnl
define(`m4v',`ifelse(`$4',,AND_wd,`$4')')dnl
[ Box: [Outline: line to svec_(0,m4v/2) then to svec_(m4h,m4v/2) \
- then to svec_(m4h,-m4v/2) then to svec_(0,-m4v/2) then to (0,0) ] \
+ then to svec_(m4h,-m4v/2) then to svec_(0,-m4v/2) then to (0,0) \
+ Lg_body `$6'] \
with .Outline.start at (0,0)
ifelse(`$5',,,`{ move to Box.n+(0,-5pt__)
m4lstring($5,"ifsvg(`svg_small($5,75)',`{\scriptsize$ $5 $}')") }')
IOdefs(from svec_(0,m4v/2) to svec_(0,-m4v/2),In,`$1',R)
Out: svec_(m4h,0) ifelse(`$2',N,`+svec_(N_diam,0)
N_Out: NOT_circle \
- at Out-svec_(N_rad,0)'); `$6']')
+ at Out-svec_(N_rad,0)'); `$7']')
- `AND_gate(n,[N][B],wid,ht)
+ `AND_gate(n,[N][B],[wid,[ht]],attributes)
drawn in the current direction
0 <= n <= 16; N=negated inputs, B=box shape
or
- AND_gate(chars,[B],wid,ht)
+ AND_gate(chars,[B],wid,ht,attributes)
arg1 is one or more of N|P '
define(`AND_gate',`define(`m4arg1',ifelse(`$1',,2,`$1'))dnl
ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
`m4dupstr(ifinstr(`$2',N,N,P),m4arg1,`m4PN')',`define(`m4PN',m4arg1)')dnl
ifinstr(`$2',B,
`BOX_gate(m4PN,ifinstr(`$2',N,N,P),ifelse(`$3',,,`($3)/(L_unit)'),
- ifelse(`$4',,,`($4)/(L_unit)'),ifsvg(`&```amp''';',`\&'),`$5')',
-`AND_gen(m4PN,ifelse(`$2',N,N)IBAONESEC,`$3',`$4',`$5')')')
+ ifelse(`$4',,,`($4)/(L_unit)'),ifsvg(`&```amp''';',`\&'),Lg_body `$5',`$6')',
+`AND_gen(m4PN,ifelse(`$2',N,N)IBAONESEC,`$3',`$4',Lg_body `$5',`$6')')')
- `NAND_gate(n,[N][B],wid,ht)
+ `NAND_gate(n,[N][B],[wid,[ht]],attributes)
0 <= n <= 16; N=negated inputs, B=box shape
or
NAND_gate(chars,[B],wid,ht)
@@ -134,20 +138,21 @@ ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
`m4dupstr(ifinstr(`$2',N,N,P),m4arg1,`m4PN')',`define(`m4PN',m4arg1)')dnl
ifinstr(`$2',B,
`BOX_gate(m4PN,ifelse(`$2',N,N,P),ifelse(`$3',,,`($3)/(L_unit)'),
- ifelse(`$4',,,`($4)/(L_unit)'),ifsvg(`&```amp''';',`\&'),`$5')',
-`AND_gen(m4PN,ifelse(`$2',N,N)IBANONESEC,`$3',`$4',`$5')')')
+ ifelse(`$4',,,`($4)/(L_unit)'),ifsvg(`&```amp''';',`\&'),Lg_body `$5',`$6')',
+`AND_gen(m4PN,ifelse(`$2',N,N)IBANONESEC,`$3',`$4',Lg_body `$5',`$6')')')
- `AND_gen(n,chars,[wid,[ht]])
+ `AND_gen(n,chars,[wid,[ht]],attributes)
0 <= n <= 16
B=base and straight sides; A=Arc;
[N]NE,[N]SE,[N]I,[N]N,[N]S=inputs or circles,
[N]O=output; C=center location
or
- AND_gen(chars,chars,[wid,[ht]])
+ AND_gen(chars,chars,[wid,[ht]],attributes)
arg1 is one or more of N|P
eg PPPP defines 4 inputs,
NPNP negates the first and third;
- arg2 as above except [N]I is ignored '
+ arg2 as above except [N]I is ignored
+ arg5 contains body attributes '
define(`AND_gen',`define(`m4arg1',ifelse(`$1',,2,`$1'))dnl
ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
`m4dupstr(ifinstr(`$2',N,N,P),m4arg1,`m4PN')',`define(`m4PN',m4arg1)')dnl
@@ -157,11 +162,11 @@ ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
[ sc_draw(`dna_',B,`Bm: line from svec_(m4hor-m4ver/2,-m4ver/2) \
to svec_(0,-m4ver/2) \
then to svec_(0,m4ver/2) then \
- to svec_(m4hor-m4ver/2,m4ver/2)
+ to svec_(m4hor-m4ver/2,m4ver/2) Lg_body `$5'
')dnl
sc_draw(`dna_',A,`Arc: arc cw rad m4ver/2 \
to rsvec_(0,-m4ver) \
- with .c at rsvec_(0,-m4ver/2)
+ with .c at rsvec_(0,-m4ver/2) Lg_body `$5'
')dnl
sc_draw(`dna_',NNE,
`NNE: svec_(m4hor-m4ver/2,0)+svec_(Rect_(m4ver/2+N_diam,45))
@@ -202,7 +207,7 @@ ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
sc_draw(`dna_',S, `S: svec_(0,-m4ver/2)
')dnl
sc_draw(`dna_',C, `C: svec_(m4hor/2,0)')
- `$5']')
+ `$6']')
`Input locations, flat face
m4A_defs(n,[N]) or m4A_defs(string)
@@ -230,10 +235,10 @@ define(`m4A_defs',`define(`m4arg1',ifelse(`$1',,2,`$1'))dnl
`OR_gate or NOR_gate or XOR_gate or NXOR_gate
drawn in the current direction
- args = (n,[N][B],wid,ht)
+ args = (n,[N][B],wid,ht,attributes)
0 <= n <= 16; N=negated inputs, B=box shape
or
- args = (chars,[B],wid,ht)
+ args = (chars,[B],wid,ht,attributes)
arg1 is one or more of N|P '
define(`OR_gate',`m4_OR(OR,$@)')
define(`NOR_gate',`m4_OR(NOR,$@)')
@@ -244,49 +249,70 @@ define(`m4_OR',`define(`m4arg1',ifelse(`$2',,2,`$2'))dnl
ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
`m4dupstr(ifinstr(`$3',N,N,P),m4arg1,`m4PN')',`define(`m4PN',m4arg1)')dnl
ifinstr(`$3',B,
-`BOX_gate(m4PN,ifinstr(`$3',N,N,P),
+`BOX_gate(m4PN,ifinstr(`$3',N,N,P,`$6',`$7'),
ifelse(`$4',,,`($4)/(L_unit)'),ifelse(`$5',,,`($5)/(L_unit)'),
- ifinstr(`$1',XOR,`=',`ifsvg(`>=1',`\geq 1')'),`$6')',
+ ifinstr(`$1',XOR,`=',`ifsvg(`>=1',`\geq 1')'),Lg_body `$6',`$7',`$8')',
`OR_gen(m4PN,
ifinstr(`$1',XOR,P)`'ifelse(`$3',N,N)IBA`'ifelse(substr(`$1',0,1),N,N)ONESEC,
shift(shift(shift($@))))')')
- `OR_gen(n,chars,[wid,[ht]])
+ `OR_gen(n,chars,[wid,[ht]],attributes)
0 <= n <= 16
B=base and straight sides; A=Arc;
[N]NE,[N]SE,[N]I,[N]N,[N]S=inputs or circles,
[N]P=XOR arc; [N]O=output; C=center
or
- OR_gen(chars,chars,[wid,[ht]])
+ OR_gen(chars,chars,[wid,[ht]],attributes)
arg1 is one or more of N|P
eg PPPP defines 4 inputs,
NPNP negates the first and third;
- arg2 as above except [N]I is ignored '
+ arg2 as above except [N]I is ignored
+ If arg5 contains shaded rgbstring(...)
+ the arguments of rgbstring may not contain
+ parentheses'
define(`OR_gen',`[define(`m4arg1',ifelse(`$1',,2,`$1'))dnl
ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
`m4dupstr(ifinstr(`$2',N,N,P),m4arg1,`m4PN')',`define(`m4PN',m4arg1)')dnl
define(`m4hor',`ifelse(`$3',,AND_wd,`($3)/(L_unit)')')define(`m4o',0)dnl
define(`m4ver',`ifelse(`$4',,ifelse(`$3',,AND_ht,AND_ht/(AND_wd)*m4hor),
`($4)/(L_unit)')')define(`dna_',ifelse(`$2',,IBAONESEC,`$2'))dnl
+ define(`m4gfill',`Lg_body `$5'')dnl
+dnl concave fill, painful code:
+ ifelse(regexp(m4gfill,`^fill \|[^a-z]fill '),-1,
+ `ifelse(regexp(m4gfill,`shaded *"'),-1,
+ `define(`m4osh',`regexp(m4gfill,`.*shaded *\(sprintf([^)]*)\).*$',\1)')
+ define(`m4att',`patsubst(m4gfill,`shaded *sprintf([^)]*)')')',
+ `define(`m4osh',`regexp(m4gfill,`.*shaded *"\([^"]*\)".*$',"\1")')
+ define(`m4att',`patsubst(m4gfill,`shaded *"[^"]*"')')')',
+ `define(`m4osh',`regexp(m4gfill,`.*fill *\([^ ]*\) .*$',`graystring(\1)')')
+ define(`m4att',`patsubst(m4gfill,`fill *[^ ]*[ $]')')')
sc_draw(`dna_',P,`define(`m4o',XOR_off*m4ver/(AND_ht))dnl
Parc: arc cw from svec_(0,m4ver/2) \
to svec_(0,-m4ver/2) \
with .c at svec_(-sqrt((OR_rad*m4ver/(AND_ht))^2-(m4ver/2)^2),0)
')dnl
sc_draw(`dna_',B,dnl
- `Bt: line from svec_(m4o+m4hor/3,m4ver/2) \
- to svec_(m4o,m4ver/2) ifdpic(chop 0 chop -hlth)
- ArcB: arc cw to svec_(m4o,-m4ver/2) \
- with .c at svec_(m4o-sqrt((OR_rad*m4ver/(AND_ht))^2-(m4ver/2)^2),0)
- Bb: line to svec_(m4o+m4hor/3,-m4ver/2) ifdpic(chop -hlth chop 0)
+ `r = OR_rad*m4ver/(AND_ht)
+ rt = sqrt(r^2-(m4ver/2)^2)
+ ifelse(m4osh,,,`for i=0 to int((r-rt)*L_unit/lthick+1) do {
+ tx = i*lthick/L_unit
+ {arc cw from svec_(tx+m4o-hlth,m4ver/2) to svec_(tx+m4o-hlth,-m4ver/2) \
+ with .c at svec_(tx+m4o-rt,0) outlined m4osh} }
+ {rotbox(m4hor/3*L_unit,m4ver*L_unit,shaded m4osh invis) with .W \
+ at svec_(m4o+r-rt,0)} ')
+ Bt: line from svec_(m4o+m4hor/3,m4ver/2) \
+ to svec_(m4o,m4ver/2) ifdpic(chop 0 chop -hlth) m4att
+ ArcB: arc cw to svec_(m4o,-m4ver/2) with .c at svec_(m4o-rt,0) m4att
+ Bb: line to svec_(m4o+m4hor/3,-m4ver/2) ifdpic(chop -hlth chop 0) m4att
')dnl
sc_draw(`dna_',A,`define(`m4m',`((m4hor*2/3)^2-(m4ver/2)^2)/(m4ver)')dnl
+ ifelse(m4osh,,,`{line invis from svec_(m4o+m4hor,0) \
+ to svec_(m4o+m4hor/3, m4ver/2) then to svec_(m4o+m4hor/3,-m4ver/2) \
+ then to svec_(m4o+m4hor,0) shaded m4osh}')
ArcN: arc cw from svec_(m4o+m4hor/3, m4ver/2) \
- to svec_(m4o+m4hor,0) \
- with .c at svec_(m4o+m4hor/3,-m4m)
+ to svec_(m4o+m4hor,0) with .c at svec_(m4o+m4hor/3,-m4m) m4gfill
ArcS: arc ccw from svec_(m4o+m4hor/3,-m4ver/2) \
- to svec_(m4o+m4hor,0) \
- with .c at svec_(m4o+m4hor/3,m4m)
+ to svec_(m4o+m4hor,0) with .c at svec_(m4o+m4hor/3,m4m) m4gfill
')dnl
sc_draw(`dna_',NNE,
`N_NNE: NOT_circle \
@@ -327,7 +353,7 @@ ifelse(ifinstr(m4arg1,N,1)`'ifinstr(m4arg1,P,1),,
sc_draw(`dna_',S, `S: svec_(m4o+m4hor/6,-m4ver/2)
')dnl
sc_draw(`dna_',C, `C: svec_(m4o+m4hor/2,0)')
- `$5']')
+ `$6']')
`Input locations, curved face
m4O_defs(n,[N]) or m4O_defs(string)
@@ -385,7 +411,8 @@ define(`IOdefs',`define(`m4dm',`ifelse(`$3',,1,len(`$3'))')
at m4dv`'m4x ifelse(`$4',R,+,-)(M4PL.x*N_rad,M4PL.y*N_rad)}')
define(`m4da',substr(m4da,1))') ')
- `BUFFER_gen(chars,wd,ht,[N|P]*,[N|P]*,[N|P]*)
+ `BUFFER_gen(chars, wd, ht,
+ [N|P]*, [N|P]*, [N|P]*, attributes)
chars: T=triangle (default),
[N]O=output location Out (NO draws circle
N_Out);
@@ -400,7 +427,7 @@ define(`BUFFER_gen',
[sc_draw(`dna_',T,`Tm: line from svec_(m4h,0) \
to svec_(0,-m4v/2) \
then to svec_(0,m4v/2) \
- then to svec_(m4h,0)
+ then to svec_(m4h,0) Lg_body `$7'
Tc: svec_(m4h/2,0)
')dnl
sc_draw(`dna_',NNE,`N_NNE: NOT_circle \
@@ -444,10 +471,10 @@ define(`BUFFER_gen',
ifelse(`$4',,,`IOdefs(from svec_(0,m4v/2) to svec_(0,-m4v/2),In,`$4',R)')
ifelse(`$5',,,`IOdefs(from svec_(0,m4v/2) to svec_(m4h,0),NE,`$5')')
ifelse(`$6',,,`IOdefs(from svec_(0,-m4v/2) to svec_(m4h,0),SE,`$6',R)')
- `$7']')
+ `$8']')
- `BUFFER_gate(linespec,[N|B],wid,ht,
- [N|P]*,[N|P]*)
+ `BUFFER_gate(linespec, [N|B], wid, ht,
+ [N|P]*, [N|P]*, attributes)
When linespec is blank then the element is
composite and In1, Out, C, NE, and SE are
defined; otherwise the element is drawn as
@@ -457,16 +484,18 @@ define(`BUFFER_gen',
sequences'
define(`BUFFER_gate',`ifinstr(`$2',B,
`BOX_gate(ifinstr(`$2',N,N,P),P,ifelse(`$3',,,`($3)/(L_unit)'),
- ifelse(`$4',,,`($4)/(L_unit)'),1,`$5')',
+ ifelse(`$4',,,`($4)/(L_unit)'),1,`$5',Lg_body `$7')',
`ifelse(`$1',,
- `BUFFER_gen(ifelse(`$2',N,N)ITOCNESE,`$3',`$4',,`$5',`$6',`$7')',
+ `BUFFER_gen(ifelse(`$2',N,N)ITOCNESE,`$3',`$4',,`$5',`$6',
+ Lg_body `$7',`$8')',
`eleminit_(`$1')
- { BUFFER_gen(ifelse(`$2',N,N)ITOC,`$3',`$4',,`$5',`$6',`$7') \
+ { BUFFER_gen(ifelse(`$2',N,N)ITOC,`$3',`$4',,`$5',`$6',Lg_body `$7',`$8') \
with .Tc at last line.c }
{ line to last [].In1; line from last [].Out to 2nd last line.end }
line invis to rvec_(rp_len,0)')')')
- `NOT_gate(linespec,[B][N|n],wid,ht)
+ `NOT_gate(linespec, [B][N|n], wid, ht,
+ attributes)
When linespec is blank then the element is
composite and In1, Out, C, NE, and SE are
defined; otherwise the element is drawn as
@@ -475,17 +504,19 @@ define(`BUFFER_gate',`ifinstr(`$2',B,
output, n=negated input only'
define(`NOT_gate',`ifinstr(`$2',B,
`BOX_gate(ifinstr(`$2',N,N,`$2',n,N,P),ifinstr(`$2',n,P,N),
- ifelse(`$3',,,`($3)/(L_unit)'),ifelse(`$4',,,`($4)/(L_unit)'),1,`$5')',
+ ifelse(`$3',,,`($3)/(L_unit)'),ifelse(`$4',,,`($4)/(L_unit)'),1,
+ Lg_body `$5',`$6')',
`ifelse(`$1',,
`BUFFER_gen(ifinstr(`$2',N,N,`$2',n,N)IT`'ifinstr(`$2',n,,N)OCNESE,
- `$3',`$4',,,,`$5')',
+ `$3',`$4',,,,Lg_body `$5',`$6')',
`eleminit_(`$1')
{ BUFFER_gen(ifinstr(`$2',N,N,`$2',n,N)IT`'ifinstr(`$2',n,,N)OC,
- `$3',`$4',,,,`$5') \
+ `$3',`$4',,,,Lg_body `$5',`$6') \
with .C at last line.c }
{ line to last [].In1; line from last [].Out to 2nd last line.end }
line invis to rvec_(rp_len,0)')')')
+###############################
`The comprehensive logic pin:
lg_pin(location, label, Picname, n|e|s|w [L|M|I|O][N][E], pinno, optlen)
label=text (indicating logical pin function, usually)
@@ -527,7 +558,8 @@ define(`lg_pin',`ifelse(`$1',,,`move to $1')
define(`lp_xy',`vrot_(`$1',`$2',m4lph,m4lpv)')
`Mux(ni, label,
- [L][B|H|X][N[n]|S[n]][[N]OE],wid,ht)
+ [L][B|H|X][N[n]|S[n]][[N]OE],
+ wid, ht, attributes)
ni = number of inputs (default 2)
The input pins are lines named
In0, In1, ... In<ni-1>
@@ -552,7 +584,8 @@ define(`Mux',`[
SW: svec_(0,-m4Mht/2)
NE: svec_(m4Mwid,m4Mht/2-2)
SE: svec_(m4Mwid,-m4Mht/2+2)
- line from W to NW then to NE then to SE then to SW then to W
+ Line: line from W to NW then to NE then to SE then to SW then to W \
+ Lg_body`$6'
ifelse(`$2',,,`"ifsvg(`svg_small($2,75)',`\scriptsize $2')" at C')
lg_pin(E,,Out,e)
define(`m4Mdna',`$3')define(`m4MOE')dnl
@@ -584,10 +617,11 @@ define(`Mux',`[
`ifelse(m4MN,X,,`ifelse(m4MOE,N,lg_bartxt(OE),OE)')'),
ifelse(m4MNO,,In`'decr(m4x),ifelse(m4MOE,N,N)OE),
w`'ifelse(m4MNO,,,ifelse(m4MOE,N,N)))')
- `$6']')
+ `$7']')
`Demux(no, label,
- [L][B|H|X][N[n]|S[n]][[N]OE],wid,ht)
+ [L][B|H|X][N[n]|S[n]][[N]OE],
+ wid, ht, attributes)
no = number of outputs (default 2)
The output pins are lines named
Out0, Out1, ... Out<ni-1>
@@ -611,7 +645,8 @@ define(`Demux',`[
SW: svec_(0,-m4Dht/2+2)
NE: svec_(m4Dwid,m4Dht/2)
SE: svec_(m4Dwid,-m4Dht/2)
- line from W to NW then to NE then to SE then to SW then to W
+ Line: line from W to NW then to NE then to SE then to SW then to W \
+ Lg_body `$6'
ifelse(`$2',,,`"ifsvg(`svg_small($2,75)',`\scriptsize $2')" at C')
# lg pin(location, label, Picname, n|e|s|w [L|M|I|O][N][E], pinno, optlen)
lg_pin(W,,In,w)
@@ -645,7 +680,7 @@ define(`Demux',`[
ifelse(m4DOE,,,`ifelse(m4DOE,N,
`lg_pin(svec_(0,m4Dht*(0.5+(1-m4Dn)/m4Dn)),lg_bartxt(OE),NOE,wN)',
`lg_pin(svec_(0,m4Dht*(0.5+(1-m4Dn)/m4Dn)),OE,OE,w)')')
- `$6']')
+ `$7']')
###########################################################################
AutoGate allowable functions (plus the ~ operator)
@@ -677,6 +712,7 @@ define(`autovsep',`L_unit') # vertical separation between input gates
Draw the gate with input sublayer Sg containing
gates G1, G2, ...
+ Example: `AutoGate(AND,$@)'
define(`AutoGate',`[
lu = L_unit define(`m4dirt',m4_dir_)
dnl Count the arguments (inputs) (could use $# )
@@ -776,6 +812,7 @@ define(`DrawInNotIn',`
InNt`'$1: Here; m4xpand(m4dirt`'_)
')
+ifelse(0,1,`
dnl `Autologic(Boolean function, ****Obsolete
dnl [N[oconnect]][L[eftinputs]][R][V][;offset=val])'
@@ -786,6 +823,7 @@ dnl [N[oconnect]][L[eftinputs]][R][V][;offset=val])'
define(`Autologic',
`print `"*** Circuit_macros warning: Autologic is obsolete; use Autologix"'
Autologix($@)')
+')
############################
`Autologix(FunctionSpec;FunctionSpec;... ,
@@ -793,27 +831,28 @@ define(`Autologic',
[N[oconnect]]
[L[eftinputs]]
[R][V]
- [;offset=val])
+ [;offset=val],
+ fill spec)
FunctionSpec =
Boolean-fn(args) [@ location attribute]'
` e.g. HalfAdder: Autologix(Xor(x,y);And(x,y),LVR)
Drawing single gates is not enough; more general Boolean expressions
- in function notation can be drawn automatically. This macro draws
+ in function notation should be drawn automatically. This macro draws
one or more trees of gates with the output or outputs
(roots) to the right (on the left if the M[irror] option is used).
The predefined functions are And, Or, Not, Nand, Nor, Xor, Nxor,
and Buffer, and may be nested; e.g., Or(And(x,~y),And(~x,y)).
Function notation does not model internal connections such as
- feedback. However, internal nodes can be accessed.
+ feedback. However, internal nodes are labelled for later access.
The exact appearance of a tree depends on the order in which
terms and variables appear in the expressions. Gates can be placed
relative to previously drawn objects using the @ location construct;
e.g. @with .nw at last [].sw+(0,-dimen_).
- Autologix locates the distinct input variables (with NOT gates for
- variables preceded by ~) in a row or column and connects them to
+ Autologix locates the distinct input variables (with variables preceded
+ by ~ given NOT gates) in a row or column and connects them to
the internal gates. If x1 (for example) appears as a variable,
then the corresponding input location is Inx1.
@@ -826,10 +865,9 @@ define(`Autologic',
In1, In2, ...
Placing inputs in a column on the left using the L option introduces
- graphic complexity that is incompletely handled. Hand tuning
- may be required for complex expressions; putting offset=value in
- arg2 shifts the array of inputs. Time will tell whether this can
- be improved.
+ graphic complexity. Therefore, hand tuning may be required for
+ complex expressions; putting offset=value in arg2 shifts the array
+ of inputs. Time will tell whether this can be improved.
Arbitrary subcircuits with inputs In1, In2, ... on the left and at
least one output Out on the right can be included (see the example
@@ -858,6 +896,7 @@ dnl Separate functions from position attributes
`pushdef(`m4BooleanFn',substr(m4BooleanR,m4xi))dnl
pushdef(`m4posattr')')dnl
')dnl
+ pushdef(`Lg_body',`$3')
dnl Sublayer of functions, outputs Out1, Out2,..
pushdef(`m4Path',ifelse(m4Path,,,m4Path.)Fx)
Fx: [ define(`m4fno',0)dnl
@@ -956,10 +995,11 @@ dnl
`m4AutoConnex(Fx,`m4InNames',ifdef(`m4LI',`ifinstr(`$2',V,Top,Bot)',Bot))')
stackexec_(`m4TAL',,
`define(`m4bn',basename_(m4TAL))undefine(Bot`'m4bn)undefine(Top`'m4bn)')
+ popdef(`Lg_body')dnl
# Define the outputs
ifelse(m4nbf,1,`Out: Fx.Out')
for_(1,m4nbf,1,`Out`'m4x: Fx.Out`'m4x')
- `$3' `# End Autologix'
+ `$4' `# End Autologix'
] ')
define(`m4AutoConnex',`define(`m4cx',0)dnl
@@ -1025,7 +1065,7 @@ define(`FlipFlop',`ifelse(
N=pin with not circle; E=edge trigger
Optional arg7 is the length of pins'
define(`FlipFlopX',`[
- Chip: box wid_ FF_wid*L_unit ht_ FF_ht*L_unit `$1'
+ Chip: box wid_ FF_wid*L_unit ht_ FF_ht*L_unit Lg_body `$1'
dnl Center label
ifelse(`$2',,,"ifsvg(`svg_small($2,75)',`\scriptsize $2')" at Chip.c)
ifelse(`$7',,,`pushdef(`lg_plen',(`$7')/L_unit)')dnl