There is a problem inside Tkgate version 2.0 and version 1.8: when mux, demux and decoder have the bit order reversed (right to
left), then the postscript rendition just ignores it, and print like the order has remained the standard one (left to right).
As these postscript functions do not have a parameter for the bit order, to solve the problem in a simple way, there might be two different
postscript functions for each type of object, like the following code. In the following snipet, /mux0 is like the original /mux, and /mux1 is the reversed bit version.
%
% x y r mux
%
/mux0 {
dup /mrot exch def
startgate
8 rfont
-29.5 15.5 moveto
29.5 15.5 lineto
16.5 -12.5 lineto
-16.5 -12.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
mrot -90 eq mrot -180 eq or {
3 -1 roll 1 sub 50 string cvs exch (0) exch % d1 (n) (0) dn
-29 add 7 rCT % d1
exch -29 add 7 rCT
} {
3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
-29 add 7 rCT % d1
(0) exch -29 add 7 rCT
} ifelse
grestore
} def
/mux1 {
dup /mrot exch def
startgate
8 rfont
-29.5 15.5 moveto
29.5 15.5 lineto
16.5 -12.5 lineto
-16.5 -12.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
mrot -90 eq mrot -180 eq or {
3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
-29 add 7 rCT % d1
(0) exch -29 add 7 rCT
} {
3 -1 roll 1 sub 50 string cvs exch (0) exch % d1 (n) (0) dn
-29 add 7 rCT % d1
exch -29 add 7 rCT
} ifelse
grestore
} def
%
% x y r decoder
%
/decoder0 {
startgate
8 rfont
(dec) 0 5 rCT
-16.5 12.5 moveto
16.5 12.5 lineto
29.5 -15.5 lineto
-29.5 -15.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
-29 add -12 rCT % d1
(0) exch -29 add -12 rCT
grestore
} def
%
% x y r decoder
%
/decoder1 {
startgate
8 rfont
(dec) 0 5 rCT
-16.5 12.5 moveto
16.5 12.5 lineto
29.5 -15.5 lineto
-29.5 -15.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
% 3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
% -29 add -12 rCT % d1
% (0) exch -29 add -12 rCT
3 -1 roll 1 sub 50 string cvs exch (0) exch % d1 (n) (0) dn
-29 add -12 rCT % d1
exch -29 add -12 rCT
grestore
} def
%
% x y r demux
%
/demux0 {
startgate
8 rfont
(demux) 0 5 rCT
-16.5 12.5 moveto
16.5 12.5 lineto
29.5 -15.5 lineto
-29.5 -15.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
-29 add -12 rCT % d1
(0) exch -29 add -12 rCT
grestore
} def
/demux1 {
startgate
8 rfont
(demux) 0 5 rCT
-16.5 12.5 moveto
16.5 12.5 lineto
29.5 -15.5 lineto
-29.5 -15.5 lineto
closepath stroke
dup % n n
1 add 58 exch div % n d1
2 copy mul % n d1 dn
% 3 -1 roll 1 sub 50 string cvs exch % d1 (n) dn
% -29 add -12 rCT % d1
% (0) exch -29 add -12 rCT
3 -1 roll 1 sub 50 string cvs exch (0) exch % d1 (n) (0) dn
-29 add -12 rCT % d1
exch -29 add -12 rCT
grestore
} def
I tryed to look inside the C code, but the Postscript generation code is too complex for me.
Thank you for the attention.
Alternative postscript functions to get normal and reversed bit order