2

I want to draw a circuit like this one using circuitikz: enter image description here

The red wires are the ones I don't know how to draw.

This is what I got so far:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}\draw
(0,4) node[and port] (A1) {A1}
(0,0) node[and port] (A2) {A2}
(6,4) node[and port] (A3) {A3}
(6,0) node[and port] (A4) {A4}
(4,2) node[and port] (A5) {A5}
(1,2) node[not port] (N) {}
(10,3) node[or port] (O1) {O1}
(10,1) node[or port] (O2) {O2}
(A1.out) -| (A3.in 1)
(A2.out) -| (A4.in 2)
(A3.out) -| (O1.in 1)
(A4.out) -| (O2.in 2)
(A5.out) -| (A3.in 2)
(A5.out) -| (A4.in 1)
(N.out)  -| (A5.in 1)
;
\end{circuitikz}

\end{document}

The name of the gates are on the photo only to provide some identification on what is what. But are unnecessary when drawing the circuit, also that hop the wire at Q does over the red one is to specify that is not connected to it, but again in the drawing does not to be like that.

5

I think it is important to learn to use relative coordinates and the anchors also to position elements, to avoid strange wires and to be able to change the circuit and re-use it with minimum effort. For example (but there are even more modular ways to do it, just no time now) this is one possibility; see the comments in the code.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[RPvoltages]{circuitikz}

\begin{document}

\begin{circuitikz}[scale=0.7]
\draw
% we position in an absolute way just these three ports
(0,5) node[and port] (A1) {A1}
(0,0) node[and port] (A2) {A2}
(4,2.5) node[and port] (A5) {A5}
% now is all relative
(A1.out) ++(5,0) node[and port, anchor=in 1] (A3) {A3}
(A2.out) ++(5,0) node[and port, anchor=in 2] (A4) {A4}
(A5.in 1) ++(-1,0) node[not port, circuitikz/logic ports/scale=0.6] (N) {}
(A3.out) ++(1,0) node[nor port, anchor=in 1] (O1) {O1}
(A4.out) ++(1,0) node[nor port, anchor=in 2] (O2) {O2}
(A1.out) -| (A3.in 1)
(A2.out) -| (A4.in 2)
(A3.out) -| (O1.in 1)
(A4.out) -| (O2.in 2)
(A5.out) -| (A3.in 2)
(A5.out) -| (A4.in 1)
(N.out)  -| (A5.in 1)
;
\draw [color=red]
% input leads
(A1.in 2) --++(-0.5,0) node[left]{J}
(A2.in 1) --++(-0.5,0) node[left]{K}
% N
(N.in) -- ++(-0.5, 0) coordinate(n1)
(A5.in 2) -| (n1)
(N.north) node[above]{N}
(n1) -- ++(-0.5,0) node[left]{CLK}
% output wires
(O1.out) --++(1,0) coordinate (o1) --++(1,0) coordinate(q1)
(O2.out) --++(1,0) coordinate (o2) --++(0.5,0) coordinate(q2) --++(0.5,0) coordinate(q3)
% crossing nors
(O1.in 2) -- ++(0,-1) coordinate(ao1) -- ++(1,0)  -- (o2)
(O2.in 1) -- ++(0,1) coordinate(ao2) -- ++(1,0)  -- (o1)
% long crossing
(q1) --++(0,-6) -| (A2.in 2)
(q2) --++(0,6) -| (A1.in 1)
% output leads 
(q1) to[short, -o] ++(0.5,0) node[right]{Q}
(q3) to [short, -o] ++(0.5,0) node[right]{/Q}
; 
% nodes
\foreach \cc in {n1, o1, o2, q1, q2} 
    \node [circ, color=red] at (\cc) {} ;
\end{circuitikz}

\end{document}

output for the MWE

6
  • 1
    I would add a node[circ]{} or to[short,*-] at every junction (n1, o1, o2, q1 and q2) to distinguish them from mere crossings. Dec 19 '19 at 16:21
  • Many thanks guys, you are awesome. Merry Christmas for you all.
    – ElSabio
    Dec 19 '19 at 17:15
  • @JohnKormylo you're definitely right.... I've been too lazy. :-)
    – Rmano
    Dec 19 '19 at 18:24
  • 1
    Also (A5.out -| A4.in 1). (I missed that one too.) Dec 21 '19 at 16:36
  • 1
    @JohnKormylo... yes, I imagine it would be coherent, although I feel it's a bit redundant there. Exercise let for the OP ;-).
    – Rmano
    Dec 21 '19 at 19:50

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.