I am trying to draw a circuit logic diagrams using circuit_macros and it is not straightforward for me. I just read the manual of circuit_macros and then some of the publicly available examples at CTAN.

Here is the circuit I wish to draw: capture

So far, here is what I have accomplished. But I don't know how to draw the vertical lines with the NOT gates.




jog = AND_ht/2*L_unit
lgt = L_unit*5

  X1: AND_gate
    line left 8*lgt from X1.In1
    line left 5.5*lgt from X1.In2
  X2: AND_gate at X1+svec_(0,-AND_ht*3/2)
    line left 5.5*lgt from X2.In1
    line left 4*lgt from X2.In2
  X3: AND_gate(3) at X2+svec_(0,-AND_ht*3/2)
    line left 9*lgt from X3.In1
    line left 6.5*lgt from X3.In2
    line left 3*lgt from X3.In3
  X4: OR_gate(3) at X2+svec_(AND_ht*3.5,0)
    line right jog from X4.Out; "\textsc{output}" ljust
    line left from X4.In2 to X2.Out
    line left jog*3 from X4.In1 then up X1.Out.y-X4.In1.y then right to X1.Out
    line left jog*3 from X4.In3 then down X4.In3.y-X3.Out.y then right to X3.Out


My first solution;

% `logic.cir'


#setrgb(0,0,1) # Blue Color


"A" at Here above;line down_ elen_/2;dot;{A:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LA:line down_ to (Here.x,A.end.y);

"B" at (elen_,0) above;line down_ elen_/2;dot;{B:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LB:line to (Here.x,B.end.y);

"C" at (2*elen_,0) above;line down_ elen_/2;dot;{C:line down_ 3.5*elen_};line right_ elen_/2;corner;
line down_ elen_/2;NOT_gate;LC:line to (Here.x,C.end.y);


X1:AND_gate(2) at (3*elen_,LC.y+15)
line from X1.In1 to (LA.x,X1.In1.y);dot
line from X1.In2 to (LB.x,X1.In2.y);dot

X2:AND_gate(2) at (X1.x,X1.y-15);
line from X2.In1 to (LB.x,X2.In1.y);dot
line from X2.In2 to (C.x,X2.In2.y);dot

X3:AND_gate(3) at (X1.x,X1.y-30);
line from X3.In1 to (A.x,X3.In1.y);dot
line from X3.In2 to (B.x,X3.In2.y);dot
line from X3.In3 to (LC.x,X3.In3.y);dot

line right_ elen_ from X2.Out;X4:OR_gate(3) with .In2 at Here;
line right_ elen_/2 from X1.Out;corner;line down_ to (Here.x,X4.In1.y);corner;line to X4.In1
line right_ elen_/2 from X3.Out;corner;line up_ to (Here.x,X4.In3.y);corner;line to X4.In3

line right_ elen_/2 from X4.Out; "X" ljust


And output

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.