逻辑电路

逻辑电路

我正在尝试使用 circuitikz 包重新创建一个逻辑电路。我画出了 nor 端口,并将其放置在它们应该在的位置。我在连接它时遇到了问题。我应该对 ABC 输入使用什么方法,我应该手动从上到下绘制它们吗?我的另一个问题是我应该如何连接特定输入,例如从 A 主线连接到门的输入,以及如何实现黑点分支连接器。最后一个问题是如何制作接受两个相同输入的门,例如从底部开始的第一个门(输入 1 和 2 都是 C)。我需要它看起来一样。

在此处输入图片描述

答案1

我不会为你画出整个电路,但我可以告诉你我该怎么做。要画出漂亮的电路,易于修改和适应,诀窍是:

  1. 使用尽可能少的绝对坐标(如数字),仅使用起点,仅此而已。

  2. 使用相对于固定起点的坐标构建电路,然后根据新定位的元件构建其余部分。诀窍是能够更改任何数字,同时仍能获得连贯的电路。

  3. 您需要熟悉垂直坐标符号。

详细信息见代码注释:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[siunitx, RPvoltages]{circuitikz}
\ctikzset{logic ports = ieee}
\begin{document}
\begin{tikzpicture}[]
    \node (A) at (0,0) {A};
    \node (B) at (1,0) {B};
    \node (C) at (2,0) {C};
    % draw vertical lines (adjust them at taste)
    \foreach \nod in {A, B, C} \draw (\nod.south) -- ++(0,-4);
    % let's add a 3-input nor. Start below A and then adjust the rest with the anchors
    % the `*-` in the `short` component takes care of the connection dot (although not
    % strictly needed here...)
    % once fixed the position at ++(3,0), we'll use only relative coordinates, so you can
    % just change this number and have the whole thing change coherently
    \draw (A) ++(0, -1) to[short, *-] ++(3,0)
        node[nor port, number inputs=3, anchor=in 1](N1){N1};
    % ok, now use the other input anchors and the perpendicular coordinate system
    % to place the other inputs
    \draw (N1.in 2) to[short, -*] (B|-N1.in 2);
    \draw (N1.in 3) to[short, -*] (C|-N1.in 3);
    % the notation you use for the "nor-based not" with both input connected together is not
    % really supported (you need a lot of tweaks to get the inputs so tight). I suggest:
    % 1) draw the nor port where you like, here below the N1
    \node [nor port, anchor=center](N2) at ([yshift=-2cm]N1.center) {N2};
    % join the two inputs and connect their center to one of the vertical bus (again, the
    % dots are not really necessary, but well, de gustibus...)
    % notice the trick to obtain the center of the line...
    \draw (N2.in 1) -- coordinate[pos=0.5] (N2 in center) (N2.in 2);
    \draw (N2 in center) to [short, *-*] (N2 in center -| B);
    % let's add another level just to show off...
    \draw (N1.out) -| ++(1,-1) -- ++(1,0)
        node[nor port, number inputs=5, anchor=in 1](NA){NA};
    % use the "kink" position to be nicely aligned...
    \draw (N2.out) -- ++(1,0) |- (NA.in 2);
    % ... I suppose you can continue on...
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

Circuit_macros 包有一个宏 Autologix(),它将绘制以函数符号定义的电路:

.PS
log_init
F: Autologix(Nor(
  Nor(A,B,C),
  Nor(A,C,Nor(B,B)),
  Nor(B,C,Nor(A,A)),
  Nor(Nor(B,B),A,Nor(C,C)),
  Nor(Nor(A,A),B,Nor(C,C))),R)
  "A" at F.InA above
  "B" at F.InB above
  "C" at F.InC above
.PE

相关内容