學習指南與題庫 — 199 題Study Guide & Exercise Bank — 199 Problems学習ガイドと問題集 — 199 問

數位邏輯與
Verilog 設計
Digital Logic &
Verilog Design
デジタル論理と
Verilog 設計

依據 Based on 準拠 Fundamentals of Digital Logic with Verilog Design, 3rd Ed.
Brown & Vranesic

02 邏輯電路導論Introduction to Logic Circuits論理回路入門

這是全書的基礎章節。本章介紹邏輯變數、真值表,以及 AND、OR、NOT 三個基本運算。本章說明如何用閘建構邏輯網路,涵蓋布林代數及其所有重要定理(交換律、結合律、分配律、DeMorgan 定律、吸收律),並介紹文氏圖 (Venn diagram) 作為視覺化工具。書中提出積之和 (SOP) 與和之積 (POS) 標準式的合成技巧,以及僅用 NAND 或僅用 NOR 的實作方式。卡諾圖用於手工化簡至多 5 個變數的邏輯函數,包括 don't-care 條件與多輸出電路。本章也首次介紹 Verilog HDL,涵蓋結構式、行為式與階層式的撰寫風格。

This is the foundational chapter of the book. It introduces logic variables, truth tables, and the three fundamental operations: AND, OR, and NOT. The chapter shows how to build logic networks from gates, covers Boolean algebra and all its key theorems (commutative, associative, distributive, DeMorgan's, absorption), and introduces the Venn diagram as a visualization tool. Synthesis techniques are presented for sum-of-products (SOP) and product-of-sums (POS) canonical forms, along with NAND-only and NOR-only implementations. Karnaugh maps are introduced for manual minimization of logic functions up to 5 variables, including don't-care conditions and multiple-output circuits. The chapter also gives a first introduction to Verilog HDL with structural, behavioral, and hierarchical coding styles.

これは本書の基礎となる章である。論理変数、真理値表、そして AND、OR、NOT という 3 つの基本演算を導入する。ゲートから論理回路網を組み立てる方法を示し、ブール代数とその主要な定理(交換律、結合律、分配律、DeMorgan の定理、吸収律)をすべて扱い、可視化の道具としてベン図を導入する。積和形 (SOP) と和積形 (POS) の標準形に対する合成手法を、NAND のみ・NOR のみによる実装とあわせて示す。カルノー図は 5 変数までの論理関数を手で最小化するために導入され、don't-care 条件や多出力回路も扱う。さらに本章では Verilog HDL を初めて紹介し、構造記述・動作記述・階層記述のスタイルを取り上げる。

AND / OR / NOT 真值表 布林代數 迪摩根定理 SOP & POS 形式 NAND / NOR 邏輯 卡諾圖 無關項條件 Verilog 入門
AND / OR / NOT Truth Tables Boolean Algebra DeMorgan's Theorem SOP & POS Forms NAND / NOR Logic Karnaugh Maps Don't-Care Conditions Verilog Intro
AND / OR / NOT 真理値表 ブール代数 ド・モルガンの定理 SOP & POS 形式 NAND / NOR 論理 カルノー図 don't-care 条件 Verilog 入門
如何從 K-map 讀出 POS(把 0 格分組)How to read POS off a K-map (group the 0-cells)K-map から POS を読み取る方法(0 セルをグループ化する)

標準的 SOP 程序是在 K-map 上把 1 格分組,每一組寫出一個乘積項。若要改得到 POS(和之積),做法相同,只是改在 0 格上進行 — 並且把文字符號的極性規則反過來:

The standard SOP procedure groups 1-cells on a K-map and writes a product term per group. To get POS (product-of-sums) instead, do the same thing but on the 0-cells — and flip the literal polarity rule:

標準の SOP 手順では、K-map 上の 1 セルをグループ化し、グループごとに積項を書く。代わりに POS(和積形)を得るには、同じことを 0 セルに対して行い — リテラルの極性の規則を反転させる:

  1. 畫出卡諾圖。
  2. Plot the K-map.
  3. カルノー図を描く。
  4. 0 格以 2 的冪次(1、2、4、8…)分組,盡可能取最大;允許跨邊界環繞。
  5. Group the 0-cells in powers of 2 (1, 2, 4, 8…), maximally large; allow edge-wrap.
  6. 0 セルを 2 のべき乗(1、2、4、8…)の大きさで、できるだけ大きくグループ化する。端の回り込みも許す。
  7. For each group, write a sum (OR) term using the variables that stay constant within the group:
    • 恆為 1 的變數 → 取補數的文字符號
    • variable that is constantly 1complemented literal
    • 常に 1 の変数 → 補数形のリテラル
    • 恆為 0 的變數 → 不取補數的文字符號
    • variable that is constantly 0 → uncomplemented literal
    • 常に 0 の変数 → 非補数形のリテラル
    (Polarity flipped vs. SOP — this is the only thing that changes.)
  8. 把所有和項全部 AND 起來。
  9. AND all the sum terms together.
  10. すべての和項を AND でまとめる。

極性為何反過來:一個 0 格對應一個最大項,它對自己以外的所有輸入組合都為真。最大項是「為 1 者取補數、為 0 者不取補數」的文字符號做 OR — 極性與最小項恰好相反。把相鄰的 0 格分組會讓部分文字符號互相抵消,正如 SOP 中把相鄰的 1 格分組一樣。

Why polarities flip: a 0-cell corresponds to a maxterm, which is true for all input combinations except its own. A maxterm is the OR of complemented-where-1, uncomplemented-where-0 literals — the polarity opposite of a minterm. Grouping adjacent 0-cells lets some literals cancel, exactly as grouping adjacent 1-cells does for SOP.

極性が反転する理由:0 セルは最大項に対応し、それ自身以外のすべての入力組合せに対して真となる。最大項は、1 のところを補数形、0 のところを非補数形にしたリテラルの OR であり — 最小項とは極性が逆である。隣接する 0 セルをまとめるとリテラルの一部が消える。SOP で隣接する 1 セルをまとめるのとまったく同じである。

合法的 0 格分組長什麼樣

What a valid group of 0-cells looks like

正当な 0 セルのグループとはどういうものか

分組的大小必須是 2 的冪次(1、2、4、8、…),而且在 K-map 上必須是矩形。分組愈大,抵消掉的文字符號愈多,得到的和項也愈簡單。以下是 4 變數 K-map 上的三個例子:

Groups must be powers of 2 (1, 2, 4, 8, …) and rectangular on the K-map. A larger group cancels more literals, producing a simpler sum term. Three examples on a 4-variable K-map:

グループの大きさは 2 のべき乗(1、2、4、8、…)で、K-map 上で長方形でなければならない。グループが大きいほど多くのリテラルが消え、より簡単な和項になる。4 変数の K-map での例を 3 つ示す:

對 (pair) — 2 格,抵消 1 個變數,剩下 3 個文字符號。

Pair — 2 cells, cancels 1 variable, leaves 3 literals.

ペア — 2 セル。変数 1 個が消え、リテラルは 3 個残る。

x₃x₄00011110x₁x₂00011110m00m10m31m21m41m51m71m61m121m131m151m141m81m91m111m101Pair (3 literals): x₁ + x₂ + x₃

在這一對之中:$x_1=0, x_2=0, x_3=0$ 保持不變;$x_4$ 翻轉而被抵消。套用極性反轉:恆為 0 者維持不取補數 → 和項為 $x_1 + x_2 + x_3$。

Across the pair: $x_1=0, x_2=0, x_3=0$ stay constant; $x_4$ flips and cancels. Polarity flip: constant-0 stays uncomplemented → sum term $x_1 + x_2 + x_3$.

このペアでは $x_1=0, x_2=0, x_3=0$ が一定で、$x_4$ は反転して消える。極性の反転により、常に 0 の変数は非補数形のまま → 和項は $x_1 + x_2 + x_3$ となる。

四格組 (quad) — 2×2 共 4 格,抵消 2 個變數,剩下 2 個文字符號。

Quad — 2×2 block of 4 cells, cancels 2 variables, leaves 2 literals.

クワッド — 2×2 の 4 セル。変数 2 個が消え、リテラルは 2 個残る。

x₃x₄00011110x₁x₂00011110m01m10m30m21m41m50m70m61m121m131m151m141m81m91m111m101Quad (2 literals): x₁ + x̄₄

不變者:$x_1=0$(兩列皆是)、$x_4=1$(兩行皆是);$x_2, x_3$ 翻轉而被抵消。套用極性反轉:$x_1=0$ → $x_1$;$x_4=1$ → $\overline{x_4}$ → 和項為 $x_1 + \overline{x_4}$。

Constants: $x_1=0$ (both rows), $x_4=1$ (both columns); $x_2, x_3$ flip and cancel. Polarity flip: $x_1=0$ → $x_1$; $x_4=1$ → $\overline{x_4}$ → sum term $x_1 + \overline{x_4}$.

一定なのは $x_1=0$(両方の行)と $x_4=1$(両方の列)で、$x_2, x_3$ は反転して消える。極性の反転により $x_1=0$ → $x_1$、$x_4=1$ → $\overline{x_4}$ → 和項は $x_1 + \overline{x_4}$ となる。

八格組 (octet) — 2×4 共 8 格,抵消 3 個變數,剩下 1 個文字符號。

Octet — 2×4 block of 8 cells, cancels 3 variables, leaves 1 literal.

オクテット — 2×4 の 8 セル。変数 3 個が消え、リテラルは 1 個残る。

x₃x₄00011110x₁x₂00011110m00m10m30m20m40m50m70m60m121m131m151m141m81m91m111m101Octet (1 literal): x₁

只有 $x_1=0$ 保持不變;$x_2, x_3, x_4$ 在這 8 格中全都翻轉。和項為:$x_1$。

Only $x_1=0$ stays constant; $x_2, x_3, x_4$ all flip across the 8 cells. Sum term: $x_1$.

一定なのは $x_1=0$ だけで、$x_2, x_3, x_4$ は 8 セルの間ですべて反転する。和項は $x_1$ である。

總結 — 區塊越大,文字項越少

Summary — bigger groups, fewer literals:

まとめ — グループが大きいほどリテラルは少ない

群組大小 $k$Group size $k$グループの大きさ $k$被消去的變數Variables canceled消去される変数和項中的文字符號數(4 變數圖)Literals in sum term (4-var map)和項のリテラル数(4 変数マップ)
1 (single)04
2 (pair)13
4 (quad)22
8 (octet)31

永遠要圈出你能圈到的最大合法 0 格區塊 — 分組大小每加倍一次,剩下的文字符號數就減半。

Always group the largest legal block of 0-cells you can — each doubling of group size halves the number of remaining literals.

0 セルは、可能な限り最大の正当なブロックでグループ化すること — グループの大きさが 2 倍になるごとに、残るリテラルの数は半分になる。

範例演算 — 3 變數

Worked example — 3 variables

例題 — 3 変数

$f(A, B, C) = \sum m(0,1,2,5,6,7)$ — $m_3$ 與 $m_4$ 處為 0。

$f(A, B, C) = \sum m(0,1,2,5,6,7)$ — zeros at $m_3$ and $m_4$.

$f(A, B, C) = \sum m(0,1,2,5,6,7)$ — $m_3$ と $m_4$ が 0 である。

K-map(紅色格 = 0,也就是我們要為 POS 分組的那些):

K-map (red cells = 0, the ones we group for POS):

K-map(赤いセル = 0。POS のためにグループ化する対象である):

BC 00 01 11 10 A 0 1 1 1 0 m₃ 1 0 m₄ 1 1 1 0 1 3 2 4 5 7 6

兩個 0 格都是孤立的(沒有相鄰的 0),因此形成兩個單格分組。把每一個都轉成和項:

Both 0-cells are isolated (no adjacent 0), so two single-cell groups. Convert each to a sum term:

2 つの 0 セルはどちらも孤立している(隣に 0 がない)ので、1 セルのグループが 2 つできる。それぞれを和項に変換する:

群組GroupグループABC和項Sum term和項
m₃011$A + \overline{B} + \overline{C}$
m₄100$\overline{A} + B + C$

$f = (A + \overline{B} + \overline{C})(\overline{A} + B + C)$

SOP 與 POS 一覽對照

SOP vs POS at a glance

SOP と POS の早見比較

SOPPOS
圈選的格子值為Group cells with valueグループ化するセルの値10
每個區塊成為Each group becomes各グループがなるもの一個乘積 (AND) 項a product (AND) term積 (AND) 項一個和 (OR) 項a sum (OR) term和 (OR) 項
區塊中恆為 1 → 文字項為Constant 1 in group → literal isグループ内で常に 1 → リテラルはuncomplementedcomplemented
區塊中恆為 0 → 文字項為Constant 0 in group → literal isグループ内で常に 0 → リテラルはcomplementeduncomplemented
區塊之間以何結合Combine groups withグループどうしを結ぶ演算ORAND
當下列較少時最省Cheapest when there are fewer次が少ないときに最も安い1-cells0-cells

經驗法則:數一數 K-map 上 1 與 0 的個數。哪一種較少就圈哪一種 — 格子愈少,分組就愈少、愈小,式子的成本也愈低。SOP 與 POS 是同一張圖互補的兩種讀法。

Rule of thumb: count the 1s and 0s on the K-map. Whichever is fewer, group those — fewer cells means fewer / smaller groups, which means a cheaper expression. SOP and POS are the two complementary readings of the same map.

目安:K-map 上の 1 と 0 の個数を数える。少ないほうをグループ化する — セルが少なければグループも少なく小さくなり、式のコストも下がる。SOP と POS は同じマップの相補的な 2 通りの読み方である。

重要公式 — 布林代數 & 邏輯

Key Formulas — Boolean Algebra & Logic

重要公式 — ブール代数 & 論理

DeMorgan's Theorem 1 A · B = A + B
DeMorgan's Theorem 2 A + B = A · B
Absorption x + x · y = x
Distributive x · ( y + z ) = x·y + x·z
Identity x + 0 = x , x · 1 = x
Complement x + x = 1 , x · x = 0
Idempotent x + x = x , x · x = x
Involution x = x
Consensus  ★ Important xy + xz + yz = xy + xz

NAND / NOR 通用閘速查表

NAND / NOR Universal-Gate Cheat Sheet

NAND / NOR 万能ゲート早見表

NAND 與 NOR 都是功能完備的 — 每一種都能單獨建構出 NOT、AND 與 OR。把這六種作法記起來;其他所有閘(XOR、MUX、閂鎖、…)都由此組合而成。

Both NAND and NOR are functionally complete — each can build NOT, AND, and OR by itself. Memorize these six recipes; every other gate (XOR, MUX, latch, …) follows by composition.

NAND と NOR はどちらも機能的完全である — それぞれ単独で NOT、AND、OR を作れる。この 6 通りの作り方を覚えておくこと。ほかのゲート(XOR、MUX、ラッチ、…)はすべてその組合せで得られる。

函數Function関数 純 NAND 構成NAND-only constructionNAND のみの構成 純 NOR 構成NOR-only constructionNOR のみの構成
NOT $\overline{x}$ $\mathrm{NAND}(x,\, x)$  — 1 個閘$\mathrm{NAND}(x,\, x)$  — 1 gate$\mathrm{NAND}(x,\, x)$  — ゲート 1 個 $\mathrm{NOR}(x,\, x)$  — 1 個閘$\mathrm{NOR}(x,\, x)$  — 1 gate$\mathrm{NOR}(x,\, x)$  — ゲート 1 個
AND $x \cdot y$ $\mathrm{NAND}(\mathrm{NAND}(x,y),\, \mathrm{NAND}(x,y))$  — 2 個閘(NAND + 反相器)$\mathrm{NAND}(\mathrm{NAND}(x,y),\, \mathrm{NAND}(x,y))$  — 2 gates (NAND + inverter)$\mathrm{NAND}(\mathrm{NAND}(x,y),\, \mathrm{NAND}(x,y))$  — ゲート 2 個(NAND + インバータ) $\mathrm{NOR}(\mathrm{NOR}(x,x),\, \mathrm{NOR}(y,y))$  — 3 個閘(反相 + 反相 + NOR)$\mathrm{NOR}(\mathrm{NOR}(x,x),\, \mathrm{NOR}(y,y))$  — 3 gates (invert + invert + NOR)$\mathrm{NOR}(\mathrm{NOR}(x,x),\, \mathrm{NOR}(y,y))$  — ゲート 3 個(反転 + 反転 + NOR)
OR $x + y$ $\mathrm{NAND}(\mathrm{NAND}(x,x),\, \mathrm{NAND}(y,y))$  — 3 個閘(反相 + 反相 + NAND)$\mathrm{NAND}(\mathrm{NAND}(x,x),\, \mathrm{NAND}(y,y))$  — 3 gates (invert + invert + NAND)$\mathrm{NAND}(\mathrm{NAND}(x,x),\, \mathrm{NAND}(y,y))$  — ゲート 3 個(反転 + 反転 + NAND) $\mathrm{NOR}(\mathrm{NOR}(x,y),\, \mathrm{NOR}(x,y))$  — 2 個閘(NOR + 反相器)$\mathrm{NOR}(\mathrm{NOR}(x,y),\, \mathrm{NOR}(x,y))$  — 2 gates (NOR + inverter)$\mathrm{NOR}(\mathrm{NOR}(x,y),\, \mathrm{NOR}(x,y))$  — ゲート 2 個(NOR + インバータ)

對稱性:NAND「擅長 AND」(只要 2 個閘,較便宜),而「不擅長 OR」(要 3 個閘)。NOR 則是其對偶 — 擅長 OR,不擅長 AND。兩者都只要 1 個閘就能做出 NOT。挑選與函數主要運算相符的閘族,就能讓閘數最少。

Symmetry: NAND is "good at AND" (cheaper at 2 gates) and "expensive at OR" (3 gates). NOR is the dual — good at OR, expensive at AND. Both reach NOT in 1 gate. Choose the family that matches your function's dominant operation to minimize gate count.

対称性:NAND は「AND が得意」(2 ゲートで済み安い)で「OR が高くつく」(3 ゲート)。NOR はその双対で、OR が得意、AND が高くつく。どちらも NOT は 1 ゲートで作れる。関数の主要な演算に合うファミリを選べば、ゲート数を最小にできる。

兩者為何都行得通:把 DeMorgan 定律往兩個方向套用。從 NAND 出發:$\overline{xy} = \overline{x} + \overline{y}$ — 所以輸入先反相的 NAND 就是 OR。從 NOR 出發:$\overline{x+y} = \overline{x} \cdot \overline{y}$ — 所以輸入先反相的 NOR 就是 AND。「把每個輸入反相後再送進 NAND/NOR」這個作法,就是 DeMorgan 定律的直接應用。

Why both work: apply DeMorgan in two directions. From NAND: $\overline{xy} = \overline{x} + \overline{y}$ — so NAND with inverted inputs = OR. From NOR: $\overline{x+y} = \overline{x} \cdot \overline{y}$ — so NOR with inverted inputs = AND. The "invert each input then NAND/NOR" recipe is just DeMorgan applied directly.

どちらでも作れる理由:DeMorgan の定理を両方向に適用する。NAND から:$\overline{xy} = \overline{x} + \overline{y}$ — つまり入力を反転した NAND は OR である。NOR から:$\overline{x+y} = \overline{x} \cdot \overline{y}$ — つまり入力を反転した NOR は AND である。「各入力を反転してから NAND/NOR に通す」という作り方は、DeMorgan の定理をそのまま適用したものにすぎない。

兩層法則:任何最小成本的 SOP 都可對映成兩層的 NAND-NAND 電路(每個 AND 變成 NAND,最後的 OR 也變成 NAND)。任何最小成本的 POS 都可對映成兩層的 NOR-NOR 電路(每個 OR 變成 NOR,最後的 AND 也變成 NOR)。接線拓樸完全相同,只是把閘的種類換掉 — 這就是 NAND/NOR 成為 CMOS 閘庫標準建構元件的實務理由。

2-level rule: any minimum-cost SOP maps to a 2-level NAND-NAND circuit (each AND becomes a NAND, the final OR also becomes a NAND). Any minimum-cost POS maps to a 2-level NOR-NOR circuit (each OR becomes a NOR, the final AND also becomes a NOR). Same wiring topology, just swap the gate type — that's the practical reason NAND/NOR are the standard building blocks of CMOS gate libraries.

2 レベルの規則:最小コストの SOP はどれも 2 レベルの NAND-NAND 回路に写る(各 AND が NAND になり、最後の OR も NAND になる)。最小コストの POS はどれも 2 レベルの NOR-NOR 回路に写る(各 OR が NOR になり、最後の AND も NOR になる)。配線のトポロジは同じで、ゲートの種類を入れ替えるだけである — これが NAND/NOR が CMOS ゲートライブラリの標準的な構成要素となっている実務上の理由である。

2.1簡單Easy易しい第一階Tier 1ティア 1?R
寫出 $f = x_1 \cdot x_2 + \overline{x_1} \cdot x_3$ 的真值表。它共有多少列?
Write the truth table for $f = x_1 \cdot x_2 + \overline{x_1} \cdot x_3$. How many rows does it contain?
$f = x_1 \cdot x_2 + \overline{x_1} \cdot x_3$ の真理値表を書け。行数はいくつになるか。
2.2簡單Easy易しい第一階Tier 1ティア 1?R
用迪摩根定理求 $f = (a + b) \cdot (c + d)$ 的補數。
Apply DeMorgan's theorem to find the complement of $f = (a + b) \cdot (c + d)$.
ド・モルガンの定理を用いて $f = (a + b) \cdot (c + d)$ の補数を求めよ。
2.3中等Medium普通第一階Tier 1ティア 1?R
將函數 $f(x_1, x_2, x_3) = \sum m(1,2,5,6,7)$ 表示成標準 SOP 與 POS 形式。
Express the function $f(x_1, x_2, x_3) = \sum m(1,2,5,6,7)$ in canonical SOP and POS forms.
関数 $f(x_1, x_2, x_3) = \sum m(1,2,5,6,7)$ を標準形の SOP と POS で表せ。
2.4中等Medium普通第一階Tier 1ティア 1?R
用 3 變數卡諾圖化簡 $f(x_1, x_2, x_3) = \sum m(0,1,2,5,6,7)$。
Use a 3-variable Karnaugh map to minimize $f(x_1, x_2, x_3) = \sum m(0,1,2,5,6,7)$.
3 変数のカルノー図を用いて $f(x_1, x_2, x_3) = \sum m(0,1,2,5,6,7)$ を最小化せよ。
2.5中等Medium普通第一階Tier 1ティア 1?R
用 4 變數卡諾圖化簡 $f(x_1, x_2, x_3, x_4) = \sum m(0,2,5,7,8,10,13,15)$。
Use a 4-variable Karnaugh map to minimize $f(x_1, x_2, x_3, x_4) = \sum m(0,2,5,7,8,10,13,15)$.
4 変数のカルノー図を用いて $f(x_1, x_2, x_3, x_4) = \sum m(0,2,5,7,8,10,13,15)$ を最小化せよ。
2.6中等Medium普通第一階Tier 1ティア 1?R
化簡函數 $f(x_1, x_2, x_3, x_4) = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$,其中 $D$ 代表無關 (don't-care) 條件。
Minimize the function $f(x_1, x_2, x_3, x_4) = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$ where $D$ represents don't-care conditions.
関数 $f(x_1, x_2, x_3, x_4) = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$ を最小化せよ。ここで $D$ は don't-care 条件を表す。
2.7簡單Easy易しい第一階Tier 1ティア 1?R
證明 2 輸入 NAND 閘具有函數完備性(亦即任何布林函數都可以只用 NAND 閘實現)。
Show that a 2-input NAND gate is functionally complete (i.e., any Boolean function can be implemented using only NAND gates).
2 入力 NAND ゲートが関数完全であること(すなわち任意のブール関数が NAND ゲートだけで実現できること)を示せ。
2.8中等Medium普通第一階Tier 1ティア 1?R
設計一個三路電燈控制的邏輯電路:只要三個開關中的任何一個被切換,燈就改變狀態。請給出真值表與最小 SOP 表示式。
Design a logic circuit for a 3-way light control: the light changes state whenever any one of three switches is toggled. Give the truth table and a minimum SOP expression.
3 路の照明制御を行う論理回路を設計せよ。3 つのスイッチのいずれか 1 つが切り替わるたびに、照明の状態が変わるものとする。真理値表と最小 SOP 式を示せ。
2.9中等Medium普通第一階Tier 1ティア 1?R
撰寫一個 2 對 1 多工器的行為級 Verilog 模組,輸入為 w0w1,選擇線為 s,輸出為 f
Write a behavioral Verilog module for a 2-to-1 multiplexer with inputs w0, w1, select s, and output f.
入力 w0w1、選択入力 s、出力 f をもつ 2-to-1 マルチプレクサの動作記述 Verilog モジュールを書け。
2.10中等Medium普通第一階Tier 1ティア 1?R
多數決函數在其三個輸入中有兩個以上為 1 時輸出 1。請寫出真值表、導出最小 SOP 表示式,並畫出閘級電路。
A majority function outputs 1 when two or more of its three inputs are 1. Write the truth table, derive the minimum SOP expression, and draw the gate-level circuit.
多数決関数は、3 つの入力のうち 2 つ以上が 1 のとき 1 を出力する。真理値表を書き、最小 SOP 式を導き、ゲートレベル回路を描け。
2.11中等Medium普通第一階Tier 1ティア 1?R
定義下列名詞:最小項 (minterm)、最大項 (maxterm)、蘊涵項 (implicant)、質蘊涵項 (prime implicant)、必要質蘊涵項 (essential prime implicant)。並針對一個 3 變數函數各舉一例。
Define the terms: minterm, maxterm, implicant, prime implicant, essential prime implicant. Give an example of each for a 3-variable function.
次の用語を定義せよ:最小項 (minterm)、最大項 (maxterm)、内項 (implicant)、主項 (prime implicant)、必須主項 (essential prime implicant)。さらに 3 変数関数について、それぞれの例を挙げよ。
2.12簡單Easy易しい第一階Tier 1ティア 1E?R
電燈 $L$ 由兩個切換開關 $x$ 與 $y$ 控制。只有在恰好一個開關向上時燈才可以亮。請導出 $L$ 的真值表與邏輯表示式,並指出所得到的是哪一個函數。
A light $L$ is controlled by two toggle switches $x$ and $y$. The light must be on only when exactly one switch is up. Derive the truth table and a logic expression for $L$, and identify the resulting function.
照明 $L$ は 2 つのトグルスイッチ $x$ と $y$ で制御される。ちょうど 1 つのスイッチが上がっているときだけ点灯しなければならない。$L$ の真理値表と論理式を導き、得られる関数が何であるかを答えよ。
2.13簡單Easy易しい第一階Tier 1ティア 1E?R
設計一個 1 位元二進位加法器,輸入為 $a$ 與 $b$,產生 2 位元的和 $S = s_1 s_0 = a + b$。請給出真值表、導出 $s_1$ 與 $s_0$ 的表示式,並畫出閘級電路。
Design a 1-bit binary adder that takes inputs $a$ and $b$ and produces a 2-bit sum $S = s_1 s_0 = a + b$. Give the truth table, derive expressions for $s_1$ and $s_0$, and draw the gate-level circuit.
入力 $a$ と $b$ を受け取り、2 ビットの和 $S = s_1 s_0 = a + b$ を出力する 1 ビット 2 進加算器を設計せよ。真理値表を示し、$s_1$ と $s_0$ の式を導き、ゲートレベル回路を描け。
2.14簡單Easy易しい第一階Tier 1ティア 1E?R
以代數運算證明布林恆等式 $(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\cdot x_3 + \overline{x_1}\cdot\overline{x_3}$。
Prove the Boolean identity $(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\cdot x_3 + \overline{x_1}\cdot\overline{x_3}$ using algebraic manipulation.
代数的な変形により、ブール恒等式 $(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\cdot x_3 + \overline{x_1}\cdot\overline{x_3}$ を証明せよ。
2.15中等Medium普通第一階Tier 1ティア 1E?R
用代數運算證明 $\overline{x_1}\cdot\overline{x_3} + \overline{x_2}\cdot x_3 + x_1\cdot x_3 + x_2\cdot\overline{x_3} = x_1\cdot x_2 + \overline{x_1}\cdot\overline{x_2} + x_1\cdot\overline{x_2}$,並求出此函數的最簡表示式。
Use algebraic manipulation to prove that $\overline{x_1}\cdot\overline{x_3} + \overline{x_2}\cdot x_3 + x_1\cdot x_3 + x_2\cdot\overline{x_3} = x_1\cdot x_2 + \overline{x_1}\cdot\overline{x_2} + x_1\cdot\overline{x_2}$ and find the simplest expression for the function.
代数的変形により $\overline{x_1}\cdot\overline{x_3} + \overline{x_2}\cdot x_3 + x_1\cdot x_3 + x_2\cdot\overline{x_3} = x_1\cdot x_2 + \overline{x_1}\cdot\overline{x_2} + x_1\cdot\overline{x_2}$ を証明し、この関数の最も簡単な式を求めよ。
2.16簡單Easy易しい第一階Tier 1ティア 1E?R
Use a Venn diagram to prove the dual distributive property $x + y\cdot z = (x+y)\cdot(x+z)$.
什麼是文氏圖?What is a Venn diagram?ベン図とは何か?

文氏圖 (Venn diagram) 把布林變數畫成矩形(全集)內互相重疊的圓。每個區域對應真值表中的一個最小項:圓 $x$ 之內=「x 為 1」,之外=「x 為 0」。兩圓的交集=AND;聯集=OR;圓外的區域=NOT。

A Venn diagram represents Boolean variables as overlapping circles inside a rectangle (the universe). Each region corresponds to one minterm of the truth table: inside circle $x$ = "x is 1", outside = "x is 0". The intersection of two circles = AND; the union = OR; the area outside a circle = NOT.

ベン図はブール変数を、長方形(全体集合)の中で重なり合う円として表す。各領域は真理値表の 1 つの最小項に対応する:円 $x$ の内側=「x が 1」、外側=「x が 0」である。2 つの円の共通部分=AND、和集合=OR、円の外側の領域=NOT である。

兩變數文氏圖(4 個區域 = 真值表 4 列):

Two-variable Venn (4 regions = 4 truth-table rows):

2 変数のベン図(4 領域 = 真理値表の 4 行):

xyx·ȳx·yx̄·yx̄·ȳ

三變數文氏圖(8 個區域 = 真值表 8 列):

Three-variable Venn (8 regions = 8 truth-table rows):

3 変数のベン図(8 領域 = 真理値表の 8 行):

xyzx·y·z̄x·zy·zx·y·z

Operators visually:

運算Operation演算區域Region領域
$x \cdot y$ (AND)$x$ 與 $y$ 的交集intersection of $x$ and $y$$x$ と $y$ の共通部分
$x + y$ (OR)$x$ 與 $y$ 的聯集union of $x$ and $y$$x$ と $y$ の和集合
$\overline{x}$ (NOT)圓 $x$ 之外的全部everything outside circle $x$円 $x$ の外側すべて

用法:分別為左式與右式塗色 — 若兩者的陰影圖樣一致,該恆等式即獲證明。

Use: shade LHS and RHS separately — if the shaded patterns match, the identity is proven.

使い方:左辺と右辺を別々に網掛けする — 網掛けの模様が一致すれば、その恒等式は証明されたことになる。

2.17簡單Easy易しい第一階Tier 1ティア 1E?R
用文氏圖證明迪摩根定理 $\overline{x \cdot y} = \overline{x} + \overline{y}$。
Prove DeMorgan's theorem $\overline{x \cdot y} = \overline{x} + \overline{y}$ using Venn diagrams.
ベン図を用いてド・モルガンの定理 $\overline{x \cdot y} = \overline{x} + \overline{y}$ を証明せよ。
2.18中等Medium普通第一階Tier 1ティア 1E?R
A gumball-sorting conveyor has three sensors: $s_1$ (too light), $s_2$ (too small), $s_3$ (too large). A gumball is rejected ($f=1$) if it is too large, or if it is both too light and too small. Derive the truth table and the canonical SOP expression, then simplify $f$ to a minimum-cost form using Boolean algebra.
背景:例題 2.7 — 口香糖球工廠(圖 2.21)Context: Example 2.7 — gumball factory (Figure 2.21)背景:例題 2.7 — ガムボール工場(図 2.21)

情境設定:輸送帶把口香糖球送過三個感測器:

Setup: a conveyor moves gumballs past three sensors:

設定:ベルトコンベアがガムボールを 3 つのセンサの前に運ぶ:

  • 若口香糖球太輕則 $s_1 = 1$(重量感測器)
  • $s_1 = 1$ if the gumball is too light (weight sensor)
  • ガムボールが軽すぎるとき $s_1 = 1$(重量センサ)
  • 若口香糖球太小則 $s_2 = 1$(直徑感測器)
  • $s_2 = 1$ if the gumball is too small (diameter sensor)
  • ガムボールが小さすぎるとき $s_2 = 1$(直径センサ)
  • 若口香糖球太大則 $s_3 = 1$(直徑感測器)
  • $s_3 = 1$ if the gumball is too large (diameter sensor)
  • ガムボールが大きすぎるとき $s_3 = 1$(直径センサ)

當輸出 $f = 1$ 時,活門會把口香糖球剔除。剔除規則:太大時剔除,或(太小 AND 太輕)時剔除。

A trap door rejects the gumball when output $f = 1$. Reject rule: reject if it is too large, OR (too small AND too light).

出力 $f = 1$ のとき、落とし戸がガムボールを排除する。排除の規則:大きすぎる場合、または(小さすぎる AND 軽すぎる)場合に排除する。

圖 2.21a — 輸送帶示意圖:

Figure 2.21a — conveyor schematic:

図 2.21a — コンベヤの概略図:

conveyor →s₁ (weight)s₂ (diam ↓)s₃ (diam ↑)活門(f=1 時開啟)trap door (open if f=1)トラップドア(f=1 で開く)f = reject

圖 2.21b — 真值表:

Figure 2.21b — truth table:

図 2.21b — 真理値表:

$s_1$$s_2$$s_3$$f$
0000
0011
0100
0111
1000
1011
1101
1111

例題 2.7 的推導(課本原本的作法):

Example 2.7 derivation (the original textbook approach):

例題 2.7 の導出(教科書本来の方法):

由最小項寫出的 SOP:$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$

SOP from minterms: $f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$

最小項から得られる SOP:$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$

把 $s_1 s_2 s_3$ 這一項複製一份(規則 7b),再重新分組:

Replicate the $s_1 s_2 s_3$ term (rule 7b), then group:

$s_1 s_2 s_3$ の項を複製し(規則 7b)、まとめ直す:

$= \overline{s_1}s_3(\overline{s_2}+s_2) + s_1 s_3(\overline{s_2}+s_2) + s_1 s_2(\overline{s_3}+s_3) = \overline{s_1}s_3 + s_1 s_3 + s_1 s_2$

合併前兩項:$f = s_3 + s_1 s_2$

Combine the first two terms: $f = s_3 + s_1 s_2$

最初の 2 項をまとめる:$f = s_3 + s_1 s_2$

習題 2.19 要求什麼:給出一條不同的化簡路徑,卻得到相同的結果。把 $s_1 s_2\overline{s_3}$ 這一項重複一次,再以 $\overline{s_3}$ 提出因式:

What problem 2.19 asks: show a different simplification path that ends at the same result. Repeat the term $s_1 s_2\overline{s_3}$, then factor by $\overline{s_3}$:

問題 2.19 が求めていること:同じ結果に至る別の簡単化の道筋を示すこと。項 $s_1 s_2\overline{s_3}$ を繰り返し、$\overline{s_3}$ でくくる:

$f = s_3(\overline{s_1}\overline{s_2}+\overline{s_1}s_2+s_1\overline{s_2}+s_1 s_2) + s_1 s_2(\overline{s_3}+s_3) = s_3 \cdot 1 + s_1 s_2 = s_3 + s_1 s_2$

括號中的和涵蓋 $(s_1, s_2)$ 的每一種賦值,因此等於 1。結果相同、路徑不同 — 這說明代數化簡並不唯一。

The bracketed sum spans every valuation of $(s_1, s_2)$, so it equals 1. Same result, different route — illustrating that algebraic minimization isn't unique.

括弧の中の和は $(s_1, s_2)$ のあらゆる付値を尽くすので 1 に等しい。同じ結果に別の道筋で到達しており — 代数的な最小化が一通りではないことを示している。

2.19中等Medium普通第一階Tier 1ティア 1E?R
針對口香糖球剔除函數(範例 2.7),先複製 $s_1 s_2 \overline{s_3}$ 這一項再加以因式分解,以得到 $f = s_3 + s_1 s_2$,示範另一種代數化簡方式。
Show an alternative algebraic simplification of the gumball reject function (Example 2.7) by first replicating the term $s_1 s_2 \overline{s_3}$ and then factoring to obtain $f = s_3 + s_1 s_2$.
ガムボールの排除関数(例題 2.7)について、まず項 $s_1 s_2 \overline{s_3}$ を複製し、続いて因数分解して $f = s_3 + s_1 s_2$ を得る、別の代数的簡単化を示せ。
2.20中等Medium普通第一階Tier 1ティア 1E?R
改用一致性 (consensus) 與迪摩根恆等式,而非範例 2.7 與 2.8 所用的代數步驟,推導口香糖球剔除函數的同一個最小表示式 $f = s_3 + s_1 s_2$。— 範例 2.7
Derive the same minimum expression $f = s_3 + s_1 s_2$ for the gumball reject function using the consensus and DeMorgan identities, instead of the algebraic steps used in Examples 2.7 and 2.8.— example 2.7
例題 2.7 と 2.8 で用いた代数的手順の代わりに、合意 (consensus) 定理とド・モルガンの恒等式を用いて、ガムボールの排除関数について同じ最小式 $f = s_3 + s_1 s_2$ を導け。— 例題 2.7
2.21中等Medium普通第一階Tier 1ティア 1E?R
導出 $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ 的標準 SOP,並以代數化簡成最小成本表示式。
Derive the canonical SOP for $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ and simplify it algebraically to a minimum-cost expression.
$f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ の標準形 SOP を導き、代数的に最小コストの式まで簡単化せよ。
2.22中等Medium普通第一階Tier 1ティア 1E?R
寫出 $f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$ 的標準 SOP,再用布林代數導出較簡單的 SOP 表示式。
Write the canonical SOP for $f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$, then use Boolean algebra to derive a simpler SOP expression.
$f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$ の標準形 SOP を書き、続いてブール代数を用いてより簡単な SOP 式を導け。
2.23中等Medium普通第一階Tier 1ティア 1E?R
對 $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7) = \prod M(0,1,5)$,導出標準 POS 表示式,並化簡成最小成本的 POS 形式。
For $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7) = \prod M(0,1,5)$, derive the canonical POS expression and simplify it to a minimum-cost POS form.
$f(x_1,x_2,x_3) = \sum m(2,3,4,6,7) = \prod M(0,1,5)$ について、標準形 POS 式を導き、最小コストの POS 形式まで簡単化せよ。
2.24中等Medium普通第一階Tier 1ティア 1E?R
Implement $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ using only NOR gates by starting from its minimum POS form $f=(\overline{x_1}+x_2)(x_2+\overline{x_3})$.
背景:只用 NOR 能不能實作出 AND、NOT、OR?(可以 — 以及怎麼做)Context: can NOR alone implement AND, NOT, OR? (it can — and how)背景:NOR だけで AND、NOT、OR を実現できるか?(できる — その方法)

可以 — NOR 是功能完備的:任何布林函數都能只用 NOR 閘建構出來。三個基本作法:

Yes — NOR is functionally complete: every Boolean function can be built using only NOR gates. Three base recipes:

できる — NOR は機能的完全である:どんなブール関数も NOR ゲートだけで構成できる。基本となる作り方は 3 つある:

NOT — 一個 NOR,兩個輸入短接在一起:$\mathrm{NOR}(x, x) = \overline{x+x} = \overline{x}$。

NOT — one NOR with both inputs shorted: $\mathrm{NOR}(x, x) = \overline{x+x} = \overline{x}$.

NOT — NOR 1 個の入力どうしを短絡する:$\mathrm{NOR}(x, x) = \overline{x+x} = \overline{x}$。

xNOR

OR — 兩個 NOR(NOR 之後接一個反相器):$x + y = \overline{\overline{x+y}} = \mathrm{NOR}(\mathrm{NOR}(x, y), \mathrm{NOR}(x, y))$。

OR — two NORs (NOR followed by inverter): $x + y = \overline{\overline{x+y}} = \mathrm{NOR}(\mathrm{NOR}(x, y), \mathrm{NOR}(x, y))$.

OR — NOR 2 個(NOR のあとにインバータ):$x + y = \overline{\overline{x+y}} = \mathrm{NOR}(\mathrm{NOR}(x, y), \mathrm{NOR}(x, y))$。

xyNORx+y(inv.)NORx+y

AND — 三個 NOR(兩個反相器 + 一個 NOR),依 DeMorgan 定律:$x \cdot y = \overline{\overline{x} + \overline{y}} = \mathrm{NOR}(\overline{x}, \overline{y})$。

AND — three NORs (two inverters + one NOR), via DeMorgan: $x \cdot y = \overline{\overline{x} + \overline{y}} = \mathrm{NOR}(\overline{x}, \overline{y})$.

AND — NOR 3 個(インバータ 2 個 + NOR 1 個)。DeMorgan の定理による:$x \cdot y = \overline{\overline{x} + \overline{y}} = \mathrm{NOR}(\overline{x}, \overline{y})$。

xyNORNORȳNORx·y

總結 — 閘數:

Summary — gate counts:

まとめ — ゲート数:

函數Function関数所需 NOR 數NORs needed必要な NOR 数構成方式Construction構成法
NOT1$\mathrm{NOR}(x, x)$
OR2NOR 之後接反相器NOR followed by inverterNOR のあとにインバータ
AND3先把每個輸入反相,再做 NORinvert each input, then NOR各入力を反転してから NOR
NAND4AND 之後接反相器(3 + 1)AND followed by inverter (3 + 1)AND のあとにインバータ(3 + 1)
XOR5$x\oplus y = (x+y)(\overline{x}+\overline{y})$ — POS 轉 NOR-NOR$x\oplus y = (x+y)(\overline{x}+\overline{y})$ — POS-to-NOR-NOR$x\oplus y = (x+y)(\overline{x}+\overline{y})$ — POS から NOR-NOR へ

只要有了 NOR,其他所有閘(以及任何函數)都隨之而來。只用 NAND 也是一樣 — 兩者都是單一閘的萬用元件,這正是 CMOS 閘庫通常以它們為核心建構的原因。

Once you have NOR, every other gate (and any function whatsoever) follows. The same is true for NAND alone — both are single-gate universals, which is why CMOS gate libraries are typically built around them.

NOR さえあれば、ほかのすべてのゲート(そしてどんな関数でも)が得られる。NAND だけの場合も同様である — どちらも単一ゲートで万能であり、CMOS ゲートライブラリがふつうこの 2 つを軸に構築されているのはそのためである。

套用到習題 2.24: $f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$ — 已經是兩層 POS 形式,可直接對映成兩層的 NOR-NOR 網路:

Application to problem 2.24: $f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$ — already in 2-level POS form, which maps directly to a 2-level NOR-NOR network:

問題 2.24 への適用: $f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$ — すでに 2 レベル POS 形になっており、2 レベルの NOR-NOR 回路網へそのまま写せる:

  1. NORa:$\mathrm{NOR}(x_1, x_1) = \overline{x_1}$  (反相器)
  2. NORa: $\mathrm{NOR}(x_1, x_1) = \overline{x_1}$  (inverter)
  3. NORa:$\mathrm{NOR}(x_1, x_1) = \overline{x_1}$  (インバータ)
  4. NORb:$\mathrm{NOR}(x_3, x_3) = \overline{x_3}$  (反相器)
  5. NORb: $\mathrm{NOR}(x_3, x_3) = \overline{x_3}$  (inverter)
  6. NORb:$\mathrm{NOR}(x_3, x_3) = \overline{x_3}$  (インバータ)
  7. NOR1:$\mathrm{NOR}(\overline{x_1}, x_2) = \overline{\overline{x_1}+x_2}$  (第一個和項,取反)
  8. NOR1: $\mathrm{NOR}(\overline{x_1}, x_2) = \overline{\overline{x_1}+x_2}$  (first sum, inverted)
  9. NOR1:$\mathrm{NOR}(\overline{x_1}, x_2) = \overline{\overline{x_1}+x_2}$  (1 つ目の和項の反転)
  10. NOR2:$\mathrm{NOR}(x_2, \overline{x_3}) = \overline{x_2+\overline{x_3}}$  (第二個和項,取反)
  11. NOR2: $\mathrm{NOR}(x_2, \overline{x_3}) = \overline{x_2+\overline{x_3}}$  (second sum, inverted)
  12. NOR2:$\mathrm{NOR}(x_2, \overline{x_3}) = \overline{x_2+\overline{x_3}}$  (2 つ目の和項の反転)
  13. NOR3:$\mathrm{NOR}(\mathrm{NOR1}, \mathrm{NOR2}) = (\overline{x_1}+x_2)(x_2+\overline{x_3}) = f$  (依 DeMorgan 定律再次取反並做 AND)
  14. NOR3: $\mathrm{NOR}(\mathrm{NOR1}, \mathrm{NOR2}) = (\overline{x_1}+x_2)(x_2+\overline{x_3}) = f$  (re-inverts and ANDs by DeMorgan)
  15. NOR3:$\mathrm{NOR}(\mathrm{NOR1}, \mathrm{NOR2}) = (\overline{x_1}+x_2)(x_2+\overline{x_3}) = f$  (ド・モルガンにより再反転して AND をとる)

合計:5 個 NOR 閘

Total: 5 NOR gates.

合計:NOR ゲート 5 個

x₁x₂x₃NORx̄₁NORx̄₃NOR1NOR2NOR3f= (x̄₁+x₂)(x₂+x̄₃)
2.25中等Medium普通第一階Tier 1ティア 1E?R
從最小 SOP 形式 $f = x_2 + \overline{x_1}\cdot\overline{x_3}$ 出發,只用 NAND 閘實現 $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$。
Implement $f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ using only NAND gates by starting from its minimum SOP form $f = x_2 + \overline{x_1}\cdot\overline{x_3}$.
最小 SOP 形 $f = x_2 + \overline{x_1}\cdot\overline{x_3}$ から出発して、$f(x_1,x_2,x_3) = \sum m(2,3,4,6,7)$ を NAND ゲートだけで実現せよ。
2.26困難Hard難しい第一階Tier 1ティア 1E?R
設計一個 BCD 轉七段顯示解碼器。4 位元輸入 $X = x_3 x_2 x_1 x_0$ 代表十進位 0–9;編碼 1010–1111 為無關項。請用含無關項的卡諾圖,導出七個段輸出 $a$ 到 $g$ 的最小成本 SOP 表示式。
Design a BCD-to-7-segment decoder. The 4-bit input $X = x_3 x_2 x_1 x_0$ represents decimal 0–9; codes 1010–1111 are don't-cares. Derive minimum-cost SOP expressions for the seven segment outputs $a$ through $g$ using Karnaugh maps with don't-cares.
BCD-7 セグメントデコーダを設計せよ。4 ビット入力 $X = x_3 x_2 x_1 x_0$ は 10 進の 0–9 を表し、符号 1010–1111 は don't-care である。don't-care を含むカルノー図を用いて、7 つのセグメント出力 $a$ から $g$ までの最小コスト SOP 式を導け。
2.27困難Hard難しい第一階Tier 1ティア 1E?R
給定兩個 4 變數函數 $f_1 = \overline{x_1}\overline{x_3}+x_1 x_3+\overline{x_2}\overline{x_3}\overline{x_4}$ 與 $f_2 = \overline{x_1} x_3+x_1\overline{x_3}+\overline{x_2}\overline{x_3}\overline{x_4}$。請找出一個共用共同乘積項、使總閘成本最小的多輸出合併實現。
Two 4-variable functions are given by $f_1 = \overline{x_1}\overline{x_3}+x_1 x_3+\overline{x_2}\overline{x_3}\overline{x_4}$ and $f_2 = \overline{x_1} x_3+x_1\overline{x_3}+\overline{x_2}\overline{x_3}\overline{x_4}$. Find a combined multi-output realization that minimizes total gate cost by sharing common product terms.
2 つの 4 変数関数 $f_1 = \overline{x_1}\overline{x_3}+x_1 x_3+\overline{x_2}\overline{x_3}\overline{x_4}$ と $f_2 = \overline{x_1} x_3+x_1\overline{x_3}+\overline{x_2}\overline{x_3}\overline{x_4}$ が与えられている。共通の積項を共有することで総ゲートコストを最小にする、多出力の合成実現を求めよ。
2.28困難Hard難しい第一階Tier 1ティア 1E?R
對兩個 4 變數函數 $f_3$ 與 $f_4$,其各自最小成本的 SOP 並無共同乘積項;請說明如何一併使用非質蘊涵項,來得到成本更低的雙輸出合併電路。請以圖 2.65 的函數對為例說明。— 範例 2.19
For two 4-variable functions $f_3$ and $f_4$ whose individually minimum-cost SOPs share no common product terms, show how using non-prime implicants together can yield a lower-cost combined two-output circuit. Illustrate with the function pair from Figure 2.65.— example 2.19
個別に最小コストとなる SOP に共通の積項をもたない 2 つの 4 変数関数 $f_3$ と $f_4$ について、主項でない内項をあわせて用いることで、より低コストな 2 出力の合成回路が得られることを示せ。図 2.65 の関数対を用いて説明せよ。— 例題 2.19
2.29困難Hard難しい第一階Tier 1ティア 1E?R
Find the minimum-cost POS expressions for the functions $f_1$ and $f_2$ of Example 2.16, and show that their combined POS implementation is more expensive than the corresponding shared SOP realization.
背景:例題 2.16 / 2.18 — 圖 2.64(多輸出合成)Context: Example 2.16 / 2.18 — Figure 2.64 (multiple-output synthesis)背景:例題 2.16 / 2.18 — 図 2.64(多出力の合成)

題設。兩個 4 變數函數 $f_1$ 與 $f_2$ 要實作成單一的合併電路(可共用之處就共用閘)。

Setup. Two 4-variable functions $f_1$ and $f_2$ are to be implemented in a single combined circuit (shared gates where possible).

設定。4 変数の関数 $f_1$ と $f_2$ を 1 つの結合回路として実装する(可能なところではゲートを共有する)。

Figure 2.64a / 2.64b — K-maps:

$f_1$ K-map
$x_3x_4{=}00$011110
$x_1x_2{=}00$1··1
011··1
11·11·
10·111
$f_2$ K-map
$x_3x_4{=}00$011110
$x_1x_2{=}00$1··1
0111·1
11·11·
10·11·

例題 2.16 — 最小 SOP(含共用)

Example 2.16 — minimum SOP (with sharing)

例題 2.16 — 最小 SOP(共有あり)

$f_1 = \overline{x_1}\,\overline{x_3} + x_1 x_3 + \overline{x_2} x_3 x_4$

$f_2 = \overline{x_1}\,\overline{x_3} + x_1 x_3 + x_2 \overline{x_3} x_4$

前兩個乘積項完全相同 → 圖 2.64c 中那些 AND 閘是共用的。合併後的成本:6 gates / 16 inputs = 22(相對於兩個獨立電路的 28)。

The first two product terms are identical → those AND gates are shared in Figure 2.64c. Combined cost: 6 gates / 16 inputs = 22 (versus 28 for two separate circuits).

最初の 2 つの積項は同一である → 図 2.64c ではそれらの AND ゲートが共有されている。結合後のコストは 6 gates / 16 inputs = 22(別々の 2 回路なら 28)。

例題 2.18 — 最小 POS(習題 2.29 的題目)

Example 2.18 — minimum POS (problem 2.29's task)

例題 2.18 — 最小 POS(問題 2.29 の課題)

$f_1 = (x_1 + \overline{x_3})(\overline{x_1} + x_3)(\overline{x_1} + \overline{x_3} + x_4)$

$f_2 = (x_1 + \overline{x_3})(\overline{x_1} + x_3)(\overline{x_1} + \overline{x_3} + \overline{x_4})$

前兩個和項是共同的(可以共用),但 K-map 顯示沒有任何 0 格分組同時出現在兩個函數中 — 因此除了那兩個共用的 OR 閘之外,再沒有其他和項值得合併。每個函數仍需要三個 OR 閘 + 一個 AND 閘 + 11 個輸入 ≈ 30 total(若共用那兩個共同和項的 OR 閘,則約 26)。

The first two sum terms are common (could be shared), but the K-maps reveal no 0-cell grouping that simultaneously appears in both functions — so beyond those two shared OR gates, no additional sum terms can be merged advantageously. Each function still needs three OR gates + one AND gate + 11 inputs ≈ 30 total (or ~26 if you share the two common sum-term ORs).

最初の 2 つの和項は共通で(共有できる)、しかし K-map を見ると両方の関数に同時に現れる 0 セルのグループは存在しない — したがって、その 2 つの共有 OR ゲート以外に、有利に併合できる和項はない。各関数にはなお OR ゲート 3 個 + AND ゲート 1 個 + 入力 11 本 ≈ 30 total が必要である(共通の和項の OR を 2 つ共有すれば約 26)。

結論:22(SOP,有共用)< 26–30(POS) — 對這幾張特定的 K-map 而言,SOP 形式能容許較多共用,因為 1 格聚成的乘積項彼此重疊,而 0 格則無法相容地聚集。這高度取決於函數本身 — 範例 2.17(圖 2.65,$f_3, f_4$)就顯示相反的順序也可能發生。

Conclusion: 22 (SOP, shared) < 26–30 (POS) — for these particular K-maps, the SOP form admits more sharing because the 1-cells cluster into product terms that overlap, while the 0-cells don't cluster compatibly. This is highly function-dependent — Example 2.17 (Figure 2.65, $f_3, f_4$) shows the opposite ordering can occur.

結論:22(SOP、共有あり)< 26–30(POS) — これらの K-map に限っては、1 セルが重なり合う積項にまとまるのに対し 0 セルは都合よくまとまらないため、SOP 形のほうが共有の余地が大きい。これは関数に強く依存する — 例 2.17(図 2.65、$f_3, f_4$)では逆の順序が起こり得ることが示される。

關於圖 2.65:該圖以另一組 $f_3, f_4$ 說明同樣的取捨,課本在那裡比較「只用質蘊涵項」的實作與「刻意共用非質蘊涵項」的實作 — 見範例 2.17 / 2.19(那是學習指南裡的另一道題,不是本題)。

Note on Figure 2.65: that figure illustrates the same trade-off for a different pair $f_3, f_4$ where the textbook compares prime-implicant-only realizations against intentionally-shared non-prime implicants — see Example 2.17 / 2.19 (different problem in the study guide, not this one).

図 2.65 について:その図は別の組 $f_3, f_4$ について同じトレードオフを示しており、教科書はそこで主項のみによる実現と、意図的に共有した非主項による実現とを比較している — 例 2.17 / 2.19 を参照(学習ガイド中の別の問題であり、本問ではない)。

2.30困難Hard難しい第一階Tier 1ティア 1E?R
Find the minimum-cost combined POS implementation for the function pair $f_3, f_4$ of Example 2.17 by sharing common sum terms, and compare its cost to the SOP-based realization.
背景:範例 2.17 / 2.19 — 圖 2.65(共用蘊涵項的多輸出合成)Context: Example 2.17 / 2.19 — Figure 2.65 (multiple-output synthesis with shared implicants)背景:例 2.17 / 2.19 — 図 2.65(内項を共有する多出力合成)

題設。兩個 4 變數函數 $f_3$ 與 $f_4$ 要實作成單一的合併電路。範例 2.16 使用質蘊涵項,並共用其中明顯共同的部分;範例 2.17 則刻意採用一些非質蘊涵項,以挖出更多共用的機會。

Setup. Two 4-variable functions $f_3$ and $f_4$ are to be implemented as a single combined circuit. Whereas Example 2.16 used only prime implicants and shared the obviously-common ones, Example 2.17 deliberately uses some non-prime implicants to expose more sharing opportunities.

設定。4 変数の関数 $f_3$ と $f_4$ を 1 つの結合回路として実装する。例 2.16 が主項だけを用いて明らかに共通なものを共有したのに対し、例 2.17 ではあえて非主の内項をいくつか使い、共有の機会をさらに引き出す。

Figure 2.65a / 2.65b — K-maps:

$f_3$ K-map (minterms 1,3,5,7,13,14,15)
$x_1x_2{=}00$011110
$x_3x_4{=}00$····
01111·
11111·
10··1·
$f_4$ K-map
$x_1x_2{=}00$011110
$x_3x_4{=}00$··11
011·11
111·11
10··1·

範例 2.17 — 只用質蘊涵項的最小 SOP:

Example 2.17 — minimum SOP using only prime implicants:

例 2.17 — 主項のみを用いた最小 SOP:

$f_3 = \overline{x_1}x_4 + x_2 x_4 + x_1 x_2 x_3$

$f_4 = \overline{x_1}\overline{x_2}\overline{x_4} + x_1 \overline{x_2} \overline{x_3} + x_1\overline{x_4}$  (或等價形式 — 總共六個 AND 閘,沒有任何 AND 可以共用)

$f_4 = \overline{x_1}\overline{x_2}\overline{x_4} + x_1 \overline{x_2} \overline{x_3} + x_1\overline{x_4}$  (or equivalent — six AND gates total, no AND can be shared)

$f_4 = \overline{x_1}\overline{x_2}\overline{x_4} + x_1 \overline{x_2} \overline{x_3} + x_1\overline{x_4}$  (あるいは同等の形 — AND ゲートは合計 6 個で、共有できる AND はない)

不共用時的合併成本:6 ANDs + 2 ORs + 21 inputs = 29

Combined cost with no sharing: 6 ANDs + 2 ORs + 21 inputs = 29.

共有なしの結合コスト:6 ANDs + 2 ORs + 21 inputs = 29

範例 2.17 — 共用非質蘊涵項的較佳 SOP:

Example 2.17 — better SOP using shared non-prime implicants:

例 2.17 — 非主の内項を共有したより良い SOP:

$f_3 = \overline{x_1}x_2 x_4 + x_1 x_2 x_3 \overline{x_4} + \overline{x_1}x_4$

$f_4 = \overline{x_1}x_2 x_4 + x_1 x_2 x_3 \overline{x_4} + x_2\overline{x_4}$

此時兩式的前兩個乘積項完全相同,可以共用 AND 閘。合併成本:6 gates + 17 inputs = 23 — 比質蘊涵項的實作省下 6 個輸入。

Now the first two product terms are identical in both expressions and can share AND gates. Combined cost: 6 gates + 17 inputs = 23 — a 6-input saving over the prime-implicant realization.

いまや両式の最初の 2 つの積項は同一であり、AND ゲートを共有できる。結合コストは 6 gates + 17 inputs = 23 — 主項による実現より入力が 6 本少なくて済む。

範例 2.19 — 同一組函數的最小 POS(習題 2.30 問的就是這個):

Example 2.19 — minimum POS for the same pair (problem 2.30 asks this):

例 2.19 — 同じ組に対する最小 POS(問題 2.30 が問うているのはこれ):

$f_3 = (x_3 + x_4)(x_2 + x_4)(x_1 + x_4)(\overline{x_1} + x_2)$

$f_4 = (x_3 + x_4)(x_2 + x_4)(x_1 + x_4)(\overline{x_1} + x_2 + \overline{x_4})$

兩個函數的前個和項完全相同 — 三個共用的 OR 閘,共耗六個輸入。再加上 $f_3$ 的一個 2 輸入 OR 與一個 4 輸入 AND,以及 $f_4$ 的一個 3 輸入 OR 與一個 4 輸入 AND。合併成本:5 ORs + 2 ANDs + 19 inputs = 26。

The first three sum terms are identical in both functions — three shared OR gates costing six inputs. Plus one 2-input OR and one 4-input AND for $f_3$, and one 3-input OR and one 4-input AND for $f_4$. Combined cost: 5 ORs + 2 ANDs + 19 inputs = 26.

両関数で最初の3 つの和項が同一である — 共有できる OR ゲート 3 個で入力は 6 本。さらに $f_3$ 用に 2 入力 OR 1 個と 4 入力 AND 1 個、$f_4$ 用に 3 入力 OR 1 個と 4 入力 AND 1 個が要る。結合コスト:5 ORs + 2 ANDs + 19 inputs = 26。

Comparison:

實現方式Realization実現方法成本Costコスト
SOP — 僅用質蘊涵項(例 2.17,基準)SOP — prime-implicant only (Ex 2.17, baseline)SOP — 主項のみ(例 2.17、基準)29
SOP — 共用非質蘊涵項(範例 2.17,最佳化後)SOP — shared non-prime implicants (Ex 2.17, optimized)SOP — 非主の内項を共有(例 2.17、最適化後)23
POS — 共用和項(範例 2.19,本題)POS — shared sum terms (Ex 2.19, this problem)POS — 和項を共有(例 2.19、本問)26

心得:對這一組函數而言,刻意採用非最小(共用)蘊涵項的 SOP 勝過 POS。SOP 與 POS 之間、質蘊涵項與共用蘊涵項之間的取捨,取決於 K-map 的幾何形狀 — 現代的合成工具兩者都會探索。

Lesson: SOP with intentionally-non-minimum (shared) implicants beats POS for this pair. The choice of SOP vs POS, and prime-vs-shared implicants, depends on the K-map geometry — modern synthesis tools explore both.

教訓:この組では、あえて最小でない(共有した)内項を使う SOP のほうが POS より優れている。SOP か POS か、主項か共有内項かの選択は K-map の幾何に依存する — 現代の合成ツールは両方を探索する。

2.31中等Medium普通第一階Tier 1ティア 1E?R
分別導出等式兩邊的標準 SOP,判斷 $\overline{x_1} x_3 + x_2 \overline{x_3} + x_1 x_2 = x_1 \overline{x_2} + \overline{x_1} x_2 + \overline{x_2} \overline{x_3}$ 是否成立。
Determine whether the equation $\overline{x_1} x_3 + x_2 \overline{x_3} + x_1 x_2 = x_1 \overline{x_2} + \overline{x_1} x_2 + \overline{x_2} \overline{x_3}$ is valid by deriving the canonical SOP for each side.
両辺の標準形 SOP を導いて、等式 $\overline{x_1} x_3 + x_2 \overline{x_3} + x_1 x_2 = x_1 \overline{x_2} + \overline{x_1} x_2 + \overline{x_2} \overline{x_3}$ が成り立つかどうかを判定せよ。
2.32中等Medium普通第一階Tier 1ティア 1E?R
從最大項表示出發,設計 $f(x_1,x_2,x_3,x_4) = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ 的最小成本 POS 表示式。
Design the minimum-cost POS expression for $f(x_1,x_2,x_3,x_4) = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ by starting from its maxterm representation.
最大項による表現から出発して、$f(x_1,x_2,x_3,x_4) = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ の最小コスト POS 式を求めよ。
2.33中等Medium普通第一階Tier 1ティア 1E?R
某控制電路有三個輸入 $x_1,x_2,x_3$,並辨識三種條件:$A = x_3(x_1+\overline{x_2})$、$B = x_1(\overline{x_2}+\overline{x_3})$、$C = x_2(x_1+\overline{x_3})$。請設計最簡單的電路,使得 $A,B,C$ 中至少有兩個成立時輸出 $f=1$。
A control circuit has three inputs $x_1,x_2,x_3$ and recognizes three conditions: $A = x_3(x_1+\overline{x_2})$, $B = x_1(\overline{x_2}+\overline{x_3})$, $C = x_2(x_1+\overline{x_3})$. Design the simplest circuit whose output $f=1$ when at least two of $A,B,C$ are true.
ある制御回路は 3 つの入力 $x_1,x_2,x_3$ をもち、$A = x_3(x_1+\overline{x_2})$、$B = x_1(\overline{x_2}+\overline{x_3})$、$C = x_2(x_1+\overline{x_3})$ の 3 つの条件を識別する。$A,B,C$ のうち少なくとも 2 つが真のとき出力 $f=1$ となる、最も簡単な回路を設計せよ。
2.34中等Medium普通第一階Tier 1ティア 1E?R
用文氏圖而非代數運算,解出範例 2.22 的三條件多數決問題,並確認 $f = x_1(x_2+x_3)$。— 範例 2.22
Solve the majority-of-three-conditions problem from Example 2.22 using Venn diagrams instead of algebraic manipulation, and confirm that $f = x_1(x_2+x_3)$.— example 2.22
例題 2.22 の 3 条件の多数決問題を、代数的変形ではなくベン図を用いて解き、$f = x_1(x_2+x_3)$ となることを確かめよ。— 例題 2.22
2.35中等Medium普通第一階Tier 1ティア 1E?R
用代數運算(一致性、合併與吸收)導出 $f = \overline{x_2} x_3 \overline{x_4} + \overline{x_1} \overline{x_3} \overline{x_4} + x_1 x_2 \overline{x_4}$ 的最簡 SOP 表示式。
Use algebraic manipulation (consensus, combining, and absorption) to derive the simplest SOP expression for $f = \overline{x_2} x_3 \overline{x_4} + \overline{x_1} \overline{x_3} \overline{x_4} + x_1 x_2 \overline{x_4}$.
代数的変形(合意、結合、吸収)を用いて、$f = \overline{x_2} x_3 \overline{x_4} + \overline{x_1} \overline{x_3} \overline{x_4} + x_1 x_2 \overline{x_4}$ の最も簡単な SOP 式を導け。
2.36中等Medium普通第一階Tier 1ティア 1E?R
用代數運算導出 $f = (x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4})(\overline{x_1}+\overline{x_3}+x_4)$ 的最簡 POS 表示式。
Use algebraic manipulation to derive the simplest POS expression for $f = (x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4})(\overline{x_1}+\overline{x_3}+x_4)$.
代数的変形を用いて、$f = (x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4})(\overline{x_1}+\overline{x_3}+x_4)$ の最も簡単な POS 式を導け。
2.37困難Hard難しい第一階Tier 1ティア 1E?R
用卡諾圖求出 $f(x_1,x_2,x_3,x_4)=\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$ 的最小成本 SOP 與 POS 表示式。並討論對無關項採取不同指派時,SOP 與 POS 形式如何得到不同的函數。
Determine the minimum-cost SOP and POS expressions for $f(x_1,x_2,x_3,x_4)=\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$ using K-maps. Discuss how different assignments to the don't-cares yield different functions for the SOP and POS forms.
カルノー図を用いて $f(x_1,x_2,x_3,x_4)=\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$ の最小コスト SOP 式と POS 式を求めよ。また、don't-care への割当てを変えると SOP 形と POS 形で異なる関数になることを論ぜよ。
2.38困難Hard難しい第一階Tier 1ティア 1E?R
用卡諾圖求出 $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3} x_4 + x_1\overline{x_2} x_4 + x_1\overline{x_2}\overline{x_3} x_4$(其中 $D=(9,12,14)$)的最小成本 SOP 與 POS 表示式。
Use Karnaugh maps to find the minimum-cost SOP and POS expressions for $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3} x_4 + x_1\overline{x_2} x_4 + x_1\overline{x_2}\overline{x_3} x_4$ with $D=(9,12,14)$.
カルノー図を用いて、$D=(9,12,14)$ とした $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3} x_4 + x_1\overline{x_2} x_4 + x_1\overline{x_2}\overline{x_3} x_4$ の最小コスト SOP 式と POS 式を求めよ。
2.39中等Medium普通第一階Tier 1ティア 1E?R
先用分配律展開,再以 3 變數卡諾圖最小化,導出 $f = s_3(s_1+s_2)+\overline{s_1}\overline{s_2}$ 的最小成本 SOP 表示式。
Derive a minimum-cost SOP expression for $f = s_3(s_1+s_2)+\overline{s_1}\overline{s_2}$ by first expanding via the distributive law and then minimizing with a 3-variable K-map.
まず分配律で展開し、次に 3 変数カルノー図で最小化して、$f = s_3(s_1+s_2)+\overline{s_1}\overline{s_2}$ の最小コスト SOP 式を導け。
2.40中等Medium普通第一階Tier 1ティア 1E?R
撰寫只使用連續 assign 敘述的 Verilog 程式碼,描述一個輸入為 $x,y,z$、輸出為 $f = (\overline{y \oplus z})\cdot z + (y \oplus z)\cdot x$ 與 $g = (y \oplus z)\oplus x$ 的電路。
Write Verilog code that uses only continuous assign statements to describe a circuit with inputs $x,y,z$ and outputs $f = (\overline{y \oplus z})\cdot z + (y \oplus z)\cdot x$ and $g = (y \oplus z)\oplus x$.
連続代入文 assign だけを用いて、入力 $x,y,z$、出力 $f = (\overline{y \oplus z})\cdot z + (y \oplus z)\cdot x$ および $g = (y \oplus z)\oplus x$ をもつ回路を記述する Verilog コードを書け。
2.41中等Medium普通第一階Tier 1ティア 1E?R
撰寫階層式 Verilog 程式碼,描述一個電路:透過兩個由選擇輸入 $m$ 控制的 2 對 1 多工器,讓兩組運算元 $(a,b)$ 與 $(c,d)$ 共用同一個 1 位元加法器。多工器與加法器請使用各自獨立的 module
Write hierarchical Verilog code for a circuit that shares one 1-bit adder between two pairs of operands $(a,b)$ and $(c,d)$ via two 2-to-1 multiplexers controlled by a select input $m$. Use separate modules for the multiplexer and the adder.
選択入力 $m$ で制御される 2 つの 2-to-1 マルチプレクサを介して、2 組のオペランド $(a,b)$ と $(c,d)$ が 1 ビット加算器を 1 つ共有する回路を、階層的な Verilog コードで記述せよ。マルチプレクサと加算器にはそれぞれ別の module を用いること。
2.42困難Hard難しい第一階Tier 1ティア 1E*必了解何謂LUT*You must understand what a LUT is*LUT とは何かを必ず理解しておくこと?R
說明如何在邏輯區塊為 3 輸入查表 (3-LUT) 的 FPGA 上實現 $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + \overline{x_1}\overline{x_2}\overline{x_3}$。請給出直接的 LUT 對映,並討論分解是否能減少 LUT 的數量。
Show how to implement $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + \overline{x_1}\overline{x_2}\overline{x_3}$ in an FPGA whose logic blocks are 3-input lookup tables (3-LUTs). Give a straightforward LUT mapping and discuss whether decomposition could reduce the LUT count.
論理ブロックが 3 入力ルックアップテーブル(3-LUT)である FPGA 上で $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + \overline{x_1}\overline{x_2}\overline{x_3}$ を実現する方法を示せ。素直な LUT マッピングを与え、分解によって LUT 数を減らせるかどうかを論ぜよ。
03 數字表示法與算術電路Number Representation and Arithmetic Circuits数の表現と算術回路

本章討論數字在數位系統中如何儲存與運算。開頭是位置式數字表示法,包括無號整數、八進位與十六進位。接著推導半加器與全加器,並把它們組合成漣波進位加法器。再引入有號數系統:符號-數值表示法、1 的補數,以及 2 的補數(現代電腦的標準)。本章涵蓋加法、減法、算術溢位偵測,以及包含前瞻進位加法器在內的快速加法器設計。也介紹陣列乘法與 Booth 演算法的概念。此外還討論定點、浮點(IEEE 754)與 BCD 表示法。本章有相當篇幅示範如何以 Verilog 描述上述所有算術電路,包括向量化信號、通用化規格與算術指定敘述。

This chapter covers how numbers are stored and manipulated in digital systems. It begins with positional number representations including unsigned integers, octal, and hexadecimal. The half-adder and full-adder are derived and combined to build ripple-carry adders. Signed number systems are introduced: sign-and-magnitude, 1's complement, and 2's complement (the standard for modern computers). The chapter covers addition, subtraction, arithmetic overflow detection, and fast adder designs including the carry-lookahead adder. Array multiplication and Booth's algorithm concepts are presented. Fixed-point, floating-point (IEEE 754), and BCD representations are also discussed. A significant portion of the chapter demonstrates how to describe all of these arithmetic circuits in Verilog using vectored signals, generic specifications, and arithmetic assignment statements.

本章では、数がディジタルシステムの中でどのように格納され、操作されるかを扱う。まず、符号なし整数、8 進、16 進を含む位取り記数法から始まる。半加算器と全加算器を導き、それらを組み合わせて桁上げ伝播加算器(リプルキャリー加算器)を構成する。次に符号付き数体系 — 符号絶対値表現、1 の補数、2 の補数(現代の計算機の標準)— を導入する。加算、減算、算術オーバフローの検出、および桁上げ先見加算器を含む高速加算器の設計を扱う。アレイ乗算と Booth のアルゴリズムの考え方も示す。固定小数点、浮動小数点(IEEE 754)、BCD 表現についても述べる。本章のかなりの部分は、これらの算術回路をベクトル信号、汎用的な記述、算術代入文を用いて Verilog でどう記述するかを示すことに充てられている。

無號/有號整數 八進位/十六進位 2 的補數 半加器/全加器 漣波進位加法器 進位預看 溢位偵測 乘法 BCD IEEE 754 浮點數 Verilog 算術運算
Unsigned / Signed Integers Octal / Hex 2's Complement Half-Adder / Full-Adder Ripple-Carry Adder Carry-Lookahead Overflow Detection Multiplication BCD IEEE 754 Float Verilog Arithmetic
符号なし/符号付き整数 8 進/16 進 2 の補数 半加算器/全加算器 リプルキャリー加算器 キャリー先見 オーバフロー検出 乗算 BCD IEEE 754 浮動小数点 Verilog の算術演算
3.1簡單Easy易しい第一階Tier 1ティア 1?R
將十六進位數 $\text{3F7A}$ 轉換成二進位,再轉換成十進位。
Convert the hexadecimal number $\text{3F7A}$ to binary and then to decimal.
16 進数 $\text{3F7A}$ を 2 進数に、さらに 10 進数に変換せよ。
3.2簡單Easy易しい第一階Tier 1ティア 1?R
將十進位數 73、−95 與 −1630 轉換成 12 位元的帶號數,分別以符號-數值、1 的補數與 2 的補數表示。
Convert the decimal numbers 73, −95, and −1630 into signed 12-bit numbers in sign-and-magnitude, 1's complement, and 2's complement representations.
10 進数 73、−95、−1630 を、符号付き 12 ビットの符号絶対値表現、1 の補数表現、2 の補数表現に変換せよ。
3.3簡單Easy易しい第一階Tier 1ティア 1?R
畫出半加器的電路。標示所有訊號,並寫出真值表。
Draw the circuit for a half-adder. Label all signals and write the truth table.
半加算器の回路を描け。すべての信号にラベルを付け、真理値表を書け。
3.4中等Medium普通第一階Tier 1ティア 1?R
執行下列 8 位元 2 補數加法,並指出是否發生溢位:$00110110 + 01000101$、$01110101 + 11011110$、$11011111 + 10111000$。
Perform the following 8-bit 2's complement additions and indicate whether overflow occurs: $00110110 + 01000101$, $01110101 + 11011110$, $11011111 + 10111000$.
次の 8 ビット 2 の補数加算を行い、オーバフローが起こるかどうかを示せ:$00110110 + 01000101$、$01110101 + 11011110$、$11011111 + 10111000$。
3.5中等Medium普通第一階Tier 1ティア 1?R
證明兩個 n 位元 2 補數相加的溢位條件為 $\text{Overflow} = c_n \oplus c_{n-1}$,其中 c 代表進位訊號。
Show that the overflow condition for adding two n-bit 2's complement numbers is $\text{Overflow} = c_n \oplus c_{n-1}$, where c represents the carry signals.
2 つの n ビット 2 の補数の加算におけるオーバフロー条件が $\text{Overflow} = c_n \oplus c_{n-1}$ となることを示せ。ここで c は桁上げ信号を表す。
3.6中等Medium普通第一階Tier 1ティア 1?R
用全加器方塊設計一個 4 位元漣波進位加法器。畫出方塊圖,標示所有進位連線。
Design a 4-bit ripple-carry adder using full-adder blocks. Draw the block diagram showing all carry connections.
全加算器ブロックを用いて 4 ビットのリップルキャリー加算器を設計せよ。すべての桁上げ接続を示すブロック図を描け。
3.7中等Medium普通第一階Tier 1ティア 1?R
說明如何用 XOR 閘與控制訊號 Sub 把 4 位元加法器改成加法/減法器單元。
Show how a 4-bit adder can be modified into an adder/subtractor unit using XOR gates and a control signal Sub.
XOR ゲートと制御信号 Sub を用いて、4 ビット加算器を加減算器ユニットに変更する方法を示せ。
3.8中等Medium普通第一階Tier 1ティア 1?R
用陣列(部分積)法將 4 位元無號數 $1101$ 與 $1011$ 相乘。列出所有部分積。
Multiply the 4-bit unsigned numbers $1101$ and $1011$ using the array (partial product) method. Show all partial products.
配列(部分積)方式で 4 ビットの符号なし数 $1101$ と $1011$ を乗算せよ。すべての部分積を示せ。
3.9中等Medium普通第一階Tier 1ティア 1?R
以 IEEE 754 單精度浮點格式表示十進位數 $-6.5$。標出符號、指數與尾數欄位。
Represent the decimal number $-6.5$ in IEEE 754 single-precision floating-point format. Show the sign, exponent, and mantissa fields.
十進数 $-6.5$ を IEEE 754 単精度浮動小数点形式で表せ。符号部、指数部、仮数部を示せ。
3.10中等Medium普通第一階Tier 1ティア 1?R
撰寫參數化 n 位元漣波進位加法器的 Verilog 模組,使用 generate 敘述實體化 n 個全加器模組。
Write a Verilog module for a parameterized n-bit ripple-carry adder using a generate statement to instantiate n full-adder modules.
generate 文で n 個の全加算器モジュールをインスタンス化し、パラメータ化された n ビットのリップルキャリー加算器の Verilog モジュールを書け。
3.11中等Medium普通第一階Tier 1ティア 1?R
說明求 2 的補數的簡單規則為何成立:「由右往左掃描,照抄所有 0 與第一個 1,再把其餘位元全部取補數。」
Explain why the simple rule for finding the 2's complement works: "scanning right to left, copy all 0s and the first 1, then complement all remaining bits."
2 の補数を求める簡単な規則「右から左へ走査し、0 と最初の 1 はそのまま写し、残りのビットをすべて反転する」がなぜ成り立つのかを説明せよ。
3.12中等Medium普通第一階Tier 1ティア 1?R
8 位元數在符號數值表示法、1 的補數與 2 的補數下,可表示的數值範圍各是多少?各能表示多少個相異的值?
What is the range of representable values for an 8-bit number in sign-and-magnitude, 1's complement, and 2's complement? How many unique values does each represent?
8 ビットの数について、符号絶対値表現、1 の補数、2 の補数それぞれで表現できる値の範囲はどうなるか。それぞれいくつの相異なる値を表せるか。
3.13中等Medium普通第一階Tier 1ティア 1E?R
證明對 $n$ 位十進位數 $A$ 與 $B$,減法 $A-B$ 可以用 $A+(10^n-B)-10^n$ 完成。說明最高位的進位輸出如何對應到捨棄 $10^n$,以及當 $A < B$ 時會發生什麼。
Show that for $n$-digit decimal numbers $A$ and $B$, the subtraction $A-B$ can be done as $A+(10^n-B)-10^n$. Explain how the carry-out from the leading digit corresponds to discarding $10^n$, and what happens when $A < B$.
$n$ 桁の十進数 $A$ と $B$ について、減算 $A-B$ が $A+(10^n-B)-10^n$ として実行できることを示せ。最上位桁からの桁上げ出力が $10^n$ を捨てることに対応する理由と、$A < B$ のときに何が起こるかを説明せよ。
3.14中等Medium普通第一階Tier 1ティア 1E?R
使用 3 位有號十進位數(正數前導 0、負數前導 9),以 10 的補數「相加後捨棄進位」技巧計算 $045 - 027$ 與 $027 - 045$。驗證第二個結果是 $-18$ 的 10 的補數。
Using 3-digit signed decimal numbers (with leading 0 for positive and 9 for negative), compute $045 - 027$ and $027 - 045$ via the 10's-complement add-and-discard-carry technique. Verify that the second result is the 10's complement of $-18$.
3 桁の符号付き十進数(正なら先頭 0、負なら先頭 9)を用い、10 の補数による「加算して桁上げを捨てる」手法で $045 - 027$ と $027 - 045$ を計算せよ。2 番目の結果が $-18$ の 10 の補数になっていることを確かめよ。
3.15簡單Easy易しい第一階Tier 1ティア 1E?R
使用 4 位元 2 的補數與「相加後捨棄進位」法計算 $(+5)-(+2)$。確認第四個位元位置產生的進位代表 $2^4$,可以忽略。
Using 4-bit 2's complement and the add-and-discard-carry method, compute $(+5)-(+2)$. Confirm that the carry from the fourth bit position represents $2^4$ and can be ignored.
4 ビットの 2 の補数と「加算して桁上げを捨てる」方法で $(+5)-(+2)$ を計算せよ。第 4 ビット位置からの桁上げが $2^4$ を表しており、無視できることを確かめよ。
3.16簡單Easy易しい第一階Tier 1ティア 1E?R
使用 4 位元 2 的補數,以「相加後捨棄進位」法計算 $(+2)-(+5)$。驗證結果 $1101$ 就是 $-3$ 的 2 的補數表示。
Using 4-bit 2's complement, compute $(+2)-(+5)$ via the add-and-discard-carry method. Verify that the result $1101$ is the 2's complement representation of $-3$.
4 ビットの 2 の補数を用い、「加算して桁上げを捨てる」方法で $(+2)-(+5)$ を計算せよ。結果 $1101$ が $-3$ の 2 の補数表現であることを確かめよ。
3.17簡單Easy易しい第一階Tier 1ティア 1E?R
使用 4 位元 2 的補數,以「相加後捨棄進位」技巧計算 $(+5)-(-2)$。驗證結果為 $0111 = +7$。
Using 4-bit 2's complement, compute $(+5)-(-2)$ by the add-and-discard-carry technique. Verify the result is $0111 = +7$.
4 ビットの 2 の補数を用い、「加算して桁上げを捨てる」手法で $(+5)-(-2)$ を計算せよ。結果が $0111 = +7$ となることを確かめよ。
3.18簡單Easy易しい第一階Tier 1ティア 1E?R
以連續除以 16 的方式把十進位整數 $14959$ 轉換成十六進位,並把每次的餘數記為一個十六進位數字。
Convert the decimal integer $14959$ into hexadecimal by successive division by 16, recording each remainder as a hex digit.
十進整数 $14959$ を 16 で繰り返し割り、各回の剰余を 16 進数字として記録することで 16 進数に変換せよ。
3.19簡單Easy易しい第一階Tier 1ティア 1E?R
以連續乘以 2 的方式,把十進位小數 $0.8254$ 轉換成小數點後至少八位的二進位小數。
Convert the decimal fraction $0.8254$ into a binary fraction with at least eight bits after the radix point, using successive multiplication by 2.
十進小数 $0.8254$ を、2 を繰り返し掛ける方法で小数点以下 8 ビット以上の 2 進小数に変換せよ。
3.20中等Medium普通第一階Tier 1ティア 1E?R
把十進位定點數 $214.45$ 轉換成二進位定點數:整數部分連續除以 2,小數部分連續乘以 2。
Convert the decimal fixed-point number $214.45$ into a binary fixed-point number, performing successive division by 2 for the integer part and successive multiplication by 2 for the fractional part.
十進の固定小数点数 $214.45$ を 2 進の固定小数点数に変換せよ。整数部は 2 で繰り返し割り、小数部は 2 を繰り返し掛ける。
3.21中等Medium普通第一階Tier 1ティア 1E?R
一個 4 位元比較器由 2 的補數減法器構成,輸出 $S = X - Y$ 以及三個旗標:$S=0$ 時 $Z=1$、$S$ 為負時 $N=1$、溢位時 $V=1$。請以 $Z, N, V$ 導出 $X=Y$、$X \lt Y$、$X \le Y$、$X \gt Y$、$X \ge Y$ 各自的運算式。
A 4-bit comparator is built from a 2's-complement subtractor that outputs $S = X - Y$ along with three flags: $Z=1$ if $S=0$, $N=1$ if $S$ is negative, $V=1$ on overflow. Derive expressions in terms of $Z, N, V$ for each of $X=Y$, $X \lt Y$, $X \le Y$, $X \gt Y$, $X \ge Y$.
4 ビットの比較器を、$S = X - Y$ を出力する 2 の補数減算器と 3 つのフラグ($S=0$ なら $Z=1$、$S$ が負なら $N=1$、オーバーフローで $V=1$)で構成する。$X=Y$、$X \lt Y$、$X \le Y$、$X \gt Y$、$X \ge Y$ のそれぞれについて、$Z, N, V$ による式を導け。
3.22中等Medium普通第一階Tier 1ティア 1E?R
為範例 3.9 的4 位元有號比較器撰寫 Verilog 程式碼。請同時提供實體化四個全加器模組的結構化版本,以及使用參數 $n$ 與 for 迴圈的泛用版本。— 範例 3.9
Write Verilog code for the 4-bit signed comparator of Example 3.9. Provide both a structural version that instantiates four full-adder modules and a generic version using a parameter $n$ and a for loop.— example 3.9
例題 3.9 の4 ビット符号付き比較器の Verilog コードを書け。全加算器モジュールを 4 個インスタンス化する構造記述版と、パラメータ $n$ と for ループを用いた汎用版の両方を示せ。— 例題 3.9
3.23困難Hard難しい第一階Tier 1ティア 1E?R
Compare the critical-path delay of a 4-bit ripple-carry array multiplier (Figure 3.35) with that of a 4-bit carry-save array multiplier (Figure 3.48). Express each delay as a multiple of the full-adder delay plus the AND-gate delay.
背景:圖 3.35 & 3.48 — 漣波進位 vs 進位保留的 4 位元乘法器Context: Figures 3.35 & 3.48 — ripple-carry vs carry-save 4-bit multipliers背景:図 3.35 & 3.48 — リプルキャリー方式と桁上げ保存方式の 4 ビット乗算器

兩個電路都把兩個 4 位元無號數 $M = m_3 m_2 m_1 m_0$ 與 $Q = q_3 q_2 q_1 q_0$ 相乘,得到 8 位元的乘積 $P = p_7 \ldots p_0$。它們的部分積產生方式相同(16 個 AND 閘:$m_i q_j$),差別在於如何累加這些和。

Both circuits multiply two 4-bit unsigned numbers $M = m_3 m_2 m_1 m_0$ and $Q = q_3 q_2 q_1 q_0$ to produce an 8-bit product $P = p_7 \ldots p_0$. They use the same partial-product generation (16 AND gates: $m_i q_j$) but differ in how the sums are accumulated.

どちらの回路も、4 ビットの符号なし数 $M = m_3 m_2 m_1 m_0$ と $Q = q_3 q_2 q_1 q_0$ を掛けて 8 ビットの積 $P = p_7 \ldots p_0$ を得る。部分積の生成は同じ(16 個の AND ゲート:$m_i q_j$)だが、和の積み上げ方が異なる。

圖 3.35 — 漣波進位陣列(慢):每一列的 FA 由左至右串接,前一個的進位輸出接到下一個的進位輸入(漣波)。接著該列的和位元落到下一列,在那裡再次漣波。關鍵路徑就這樣蜿蜒穿過好幾列。

Figure 3.35 — ripple-carry array (slow): FAs in each row are chained left-to-right with the carry-out of one feeding the carry-in of the next (ripple). Then the row's sum bits drop into the next row, which again ripples. The critical path snakes through several rows.

図 3.35 — リプルキャリーアレイ(遅い):各行の FA は左から右へ数珠つなぎになっており、ある FA の桁上げ出力が次の FA の桁上げ入力に入る(リプル)。その行の和ビットは次の行へ落ち、そこでもまたリプルする。クリティカルパスは何行にもわたって蛇行する。

圖 3.35 — 漣波進位陣列(延遲 = 8·t_FA + t_AND)Figure 3.35 — ripple-carry array (delay = 8·t_FA + t_AND)図 3.35 — リップルキャリーアレイ(遅延 = 8·t_FA + t_AND) row 1 row 2 row 3 row 4 FA FA FA FA FA FA FA FA FA FA FA FA FA FA FA FA p₇ p₆ p₅ p₄ p₃, p₂, p₁, p₀ (from rows 1–3) 關鍵路徑 = 2 + 2 + 4 = 8 個 FA 延遲 + 1 個 AND 延遲Critical path = 2 + 2 + 4 = 8 FA delays + 1 AND delayクリティカルパス = 2 + 2 + 4 = FA 遅延 8 個 + AND 遅延 1 個

沿關鍵路徑由右至左走:第 1 列(2 個 FA)→ 第 2 列(2 個 FA)→ 第 3 列 → 第 4 列(整條底部漣波,4 個 FA)→ 從最左邊的乘積位元輸出。總共 8 個 FA 延遲 + 1 個 AND 延遲。

Walk the critical path right-to-left through row 1 (2 FAs) → row 2 (2 FAs) → row 3 → row 4 (whole bottom ripple, 4 FAs) → exit at the leftmost product bit. 8 FA delays + 1 AND delay total.

クリティカルパスを右から左へたどる:第 1 行(FA 2 個)→ 第 2 行(FA 2 個)→ 第 3 行 → 第 4 行(最下段のリプル全体、FA 4 個)→ 最左の積ビットから出る。合計 8 FA 遅延 + 1 AND 遅延。

圖 3.48 — 進位保留陣列(快):在前三列之中,進位不是漣波傳遞,而是被保留下來(以正確的位元位置送到下一列)。因此第 1–3 列的每個 FA 都看到三個獨立且已位移的部分積位元。最底下那列仍是一個由 4 個 FA 組成的漣波進位加法器,用來把最後保留下來的進位與累計和合併。

Figure 3.48 — carry-save array (fast): within each of the first three rows, carries are saved (sent to the next row at the correct bit position) instead of rippled. Each FA in rows 1–3 thus sees three independent shifted partial-product bits. The bottom row is still a 4-FA ripple-carry adder to merge the final saved carries with the running sum.

図 3.48 — 桁上げ保存アレイ(速い):最初の 3 行では、桁上げはリプルさせずに保存される(正しいビット位置で次の行へ送られる)。そのため第 1〜3 行の各 FA は、独立にシフトされた 3 本の部分積ビットを受け取る。最下段は依然として FA 4 個のリプルキャリー加算器で、最後に残った保存桁上げを走行和と合流させる。

圖 3.48 — 進位保留陣列(延遲 = 6·t_FA + t_AND)Figure 3.48 — carry-save array (delay = 6·t_FA + t_AND)図 3.48 — キャリーセーブアレイ(遅延 = 6·t_FA + t_AND) row 1 row 2 row 3 row 4 (ripple) FA FA FA FA FA FA FA FA FA FA FA FA FA FA FA FA p₇ p₆ p₅ p₄ p₃ – p₀ from rows 1–3 關鍵路徑 = 1 + 1 + 4 = 6 個 FA 延遲 + 1 個 AND 延遲Critical path = 1 + 1 + 4 = 6 FA delays + 1 AND delayクリティカルパス = 1 + 1 + 4 = FA 遅延 6 個 + AND 遅延 1 個

沿關鍵路徑走:第 1 列最右邊的 FA → 第 2 列最右邊的 FA → 直接往下到第 4 列(拜進位保留之賜,第 3 列沒有水平漣波)→ 底部漣波進位加法器的全部 4 個 FA。總共 6 個 FA 延遲 + 1 個 AND 延遲 — 省下 2 個 FA 延遲(快 25 %)。

Walk the critical path: rightmost FA in row 1 → rightmost FA in row 2 → straight down to row 4 (no horizontal ripple in row 3 thanks to carry-save) → all 4 FAs of the bottom ripple-carry adder. 6 FA delays + 1 AND delay total — a savings of 2 FA delays (25 % faster).

クリティカルパスをたどる:第 1 行の最右の FA → 第 2 行の最右の FA → そのまま真下の第 4 行へ(桁上げ保存のおかげで第 3 行に水平方向のリプルはない)→ 最下段のリプルキャリー加算器の FA 4 個すべて。合計 6 FA 遅延 + 1 AND 遅延 — FA 遅延 2 個分の節約(25 % 高速)。

Comparison:

架構Architectureアーキテクチャ關鍵路徑上的 FA 數Critical path FAsクリティカルパス上の FA 数總延遲Total delay総遅延
漣波進位陣列(圖 3.35)Ripple-carry array (Fig 3.35)リプルキャリー配列(図 3.35)2 + 2 + 4 = 8$8\,t_{FA} + t_{AND}$
進位保留陣列(圖 3.48)Carry-save array (Fig 3.48)キャリーセーブ配列(図 3.48)1 + 1 + 4 = 6$6\,t_{FA} + t_{AND}$

為什麼進位保留比較快:在第 1–3 列中,和與被保留的進位只往垂直方向傳遞,不往水平方向傳。每個 FA 不論位在哪一行,都只等一個延遲。只有最後那列加法器需要漣波。對 $n \times n$ 的乘法器而言,漣波進位陣列的延遲是 $\mathcal{O}(n)$ 列 × 每列 $\mathcal{O}(n)$ 的漣波 = 最壞情況下大致 $\mathcal{O}(n^2)$ 個 FA 延遲,而進位保留形式則是 $\mathcal{O}(n)$ — 這正是所有現代快速乘法器(Wallace tree、Dadda multiplier 等)的基礎。

Why carry-save is faster: in rows 1–3, sums and saved carries propagate only vertically, not horizontally. Each FA waits one delay regardless of which column it sits in. Only the final adder row needs to ripple. For an $n \times n$ multiplier the ripple-carry array delay is $\mathcal{O}(n)$ rows × $\mathcal{O}(n)$ ripple per row = $\mathcal{O}(n^2)$ FA-delays in the worst case (ish), while the carry-save form is $\mathcal{O}(n)$ — the basis of all modern fast multipliers (Wallace tree, Dadda multiplier, etc.).

桁上げ保存が速い理由:第 1〜3 行では、和と保存された桁上げは垂直方向にしか伝わらず、水平方向には伝わらない。各 FA はどの列にあっても 1 段分の遅延しか待たない。リプルが必要なのは最後の加算器の行だけである。$n \times n$ の乗算器では、リプルキャリーアレイの遅延は $\mathcal{O}(n)$ 行 × 1 行あたり $\mathcal{O}(n)$ のリプル = 最悪の場合おおよそ $\mathcal{O}(n^2)$ FA 遅延となるのに対し、桁上げ保存形は $\mathcal{O}(n)$ である — これが現代の高速乗算器(Wallace tree、Dadda multiplier など)すべての基礎である。

— example 3.11
04 組合電路基本模組Combinational-Circuit Building Blocks組合せ回路の基本ブロック

本章介紹數位設計中處處可見的標準組合電路構件。多工器有深入的討論,包括如何藉由 Shannon 展開定理用它實作任意邏輯函數。解碼器(含解多工器)與編碼器(二進位與優先權)則作為位址轉換與選擇電路的基本元件加以說明。此外也介紹碼轉換器(例如 BCD 轉七段顯示器)與算術比較電路(大小比較器)。主要的 Verilog 章節引入條件運算子(?:)、if-else 敘述、case 敘述、for 迴圈、完整的 Verilog 運算子集合、generate 結構,以及 task/function — 基本上就是描述組合電路所需的所有 Verilog 語法結構。

This chapter presents the standard combinational building blocks used everywhere in digital design. Multiplexers are covered in depth, including their use for implementing arbitrary logic functions via Shannon's expansion theorem. Decoders (including demultiplexers) and encoders (binary and priority) are discussed as fundamental address-translation and selection circuits. Code converters (e.g., BCD to 7-segment display) and arithmetic comparison circuits (magnitude comparators) are also presented. The major Verilog section introduces the conditional operator (?:), if-else statements, the case statement, for loops, the full set of Verilog operators, the generate construct, and tasks/functions — essentially all the Verilog constructs needed for combinational circuit description.

本章では、ディジタル設計のいたるところで使われる標準的な組合せ回路の構成要素を紹介する。マルチプレクサは、Shannon の展開定理を用いて任意の論理関数を実装する使い方も含め、詳しく扱う。デコーダ(デマルチプレクサを含む)とエンコーダ(2 進および優先順位)は、アドレス変換と選択の基本回路として説明する。コード変換器(たとえば BCD から 7 セグメント表示へ)や算術比較回路(大小比較器)も取り上げる。Verilog の主要な節では、条件演算子(?:)、if-else 文、case 文、for ループ、Verilog の演算子一式、generate 構文、および task/function を導入する — 要するに、組合せ回路を記述するのに必要な Verilog 構文のすべてである。

多工器 夏農展開 解碼器/解多工器 編碼器/優先編碼器 碼轉換器 比較器 Verilog if-else / case Verilog for / generate
Multiplexers Shannon's Expansion Decoders / Demux Encoders / Priority Code Converters Comparators Verilog if-else / case Verilog for / generate
マルチプレクサ シャノン展開 デコーダ/デマルチプレクサ エンコーダ/優先エンコーダ コード変換器 比較器 Verilog if-else / case Verilog for / generate
解碼器與解多工器 — 互動示範Decoder vs demultiplexer — interactive demoデコーダとデマルチプレクサ — インタラクティブなデモ

A decoder takes an $n$-bit input and asserts exactly one of its $2^n$ outputs. A demultiplexer (demux) takes one data line plus an $n$-bit select and routes the data to one of $2^n$ outputs (the others stay at 0). The two circuits share an internal structure — a demux is just a decoder whose data-line gates each output.

2-to-4 Decoder

Input $w_1 w_0$:
y₀ = 1 when 00 y₁ = 1 when 01 y₂ = 1 when 10 y₃ = 1 when 11

對應輸入二進位值的那條輸出為高,其餘皆為低。等價地說,$y_i = m_i$(第 $i$ 個最小項)。

The output corresponding to the binary value of the input is high; all others are low. Equivalently $y_i = m_i$ (minterm $i$).

入力の 2 進値に対応する出力が高レベルとなり、それ以外はすべて低レベルである。同じことだが $y_i = m_i$(最小項 $i$)である。

1-to-4 Demultiplexer

解多工器等於一個輸出被資料輸入閘控的解碼器:$y_i = D \cdot \text{(decode of select)}_i$。

A demux equals a decoder whose output is gated by a data input: $y_i = D \cdot \text{(decode of select)}_i$.

デマルチプレクサは、出力がデータ入力でゲートされたデコーダに等しい:$y_i = D \cdot \text{(decode of select)}_i$。

Data $D$: D = on
Select $s_1 s_0$:
y₀ ← D when 00 y₁ ← D when 01 y₂ ← D when 10 y₃ ← D when 11

D 切到關閉,看著被選中的輸出掉到 0 — 解多工器只是把資料位元繞送出去,並不會自己產生一個。當 $D=1$ 時,解多工器的行為與上面的解碼器完全相同。

Toggle D to off and watch the selected output drop to 0 — the demux only routes the data bit, it doesn't generate one. With $D=1$ the demux behaves identically to the decoder above.

D をオフに切り替えると、選ばれている出力が 0 に落ちるのが分かる — デマルチプレクサはデータビットを振り分けるだけで、自分で作り出すわけではない。$D=1$ のとき、デマルチプレクサは上のデコーダとまったく同じ動作をする。

4 對 1 多工器(解多工器的反向)

4-to-1 Multiplexer (the inverse of a demux)

4 対 1 マルチプレクサ(デマルチプレクサの逆)

多工器把解多工器反過來:它有 $2^n$ 條資料輸入 $D_0, D_1, D_2, D_3$、一個 $n$ 位元的選擇線,以及單一輸出 $y$,其值等於選擇線所指的那條資料線。$y = D_{(\text{select})}$。

A multiplexer reverses the demux: it has $2^n$ data inputs $D_0, D_1, D_2, D_3$, an $n$-bit select, and a single output $y$ which equals whichever data line the select points to. $y = D_{(\text{select})}$.

マルチプレクサはデマルチプレクサを逆にしたものである:$2^n$ 本のデータ入力 $D_0, D_1, D_2, D_3$、$n$ ビットの選択線、そして選択線が指すデータ線の値に等しくなる1 本だけの出力 $y$ をもつ。$y = D_{(\text{select})}$。

資料輸入(逐一切換):
Data inputs (toggle each):
データ入力(各々を切り替える):
Select $s_1 s_0$:
D₀ D₁ D₂ D₃
y = D(sel)

金色格 = 目前為 1 的資料輸入。有綠色外框的那一格就是目前被繞送出去的那一條。輸出 $y$ 取該格的值:外框那格若是金色(1),輸出就是 1;若是暗色(0),輸出就是 0。

Gold cells = data inputs currently 1. The cell with the green outline is the one currently routed through. The output $y$ takes that cell's value: if the outlined cell is gold (1) the output is 1; if dim (0) the output is 0.

金色のセル = 現在 1 になっているデータ入力。緑の枠が付いたセルが、いま通されているものである。出力 $y$ はそのセルの値をとる:枠付きのセルが金色(1)なら出力は 1、暗い(0)なら出力は 0 である。

三者比較(解碼器、解多工器、多工器):

Three-way comparison (decoder, demultiplexer, multiplexer):

3 者の比較(デコーダ、デマルチプレクサ、マルチプレクサ):

解碼器Decoderデコーダ解多工器Demultiplexerデマルチプレクサ多工器Multiplexerマルチプレクサ
Direction$n$ → $2^n$$1 + n$ → $2^n$ (fan-out)$2^n + n$ → 1 (fan-in)
Inputs$n$ select bits1 data + $n$ select$2^n$ data + $n$ select
Outputs$2^n$ minterm signals$2^n$(其中一條帶資料,其餘為 0)$2^n$ (one carries data, rest 0)$2^n$(1 本がデータを運び、残りは 0)1(帶著被選中的輸入)1 (carries selected input)1(選ばれた入力を運ぶ)
Behavior$y_i = 1$ iff input $= i$$y_i = D$ 若且唯若 sel $= i$,否則為 0$y_i = D$ iff sel $= i$, else 0sel $= i$ のときに限り $y_i = D$、それ以外は 0$y = D_{\text{sel}}$
Boolean form$y_i = m_i(s)$$y_i = D \cdot m_i(s)$$y = \sum_i D_i \cdot m_i(s)$
Use case位址解碼、最小項產生、ROM 列address decode, minterm generation, ROM rowsアドレスデコード、最小項の生成、ROM の行把一條信號繞送到多個目的地(時脈分配、寫入致能)routing one signal to many destinations (clock distribution, write-enable)1 本の信号を多数の宛先へ振り分ける(クロック分配、ライトイネーブル)從多個來源中選出一個(匯流排仲裁、ALU 運算元挑選、以 Shannon 展開實現函數)selecting one of many sources (bus arbitration, ALU operand pick, function realization via Shannon expansion)多数のソースから 1 つを選ぶ(バス調停、ALU オペランドの選択、Shannon 展開による関数の実現)

對偶性。解多工器與 MUX 是互逆的電路 — 用相同的選擇線把兩者背對背接起來,解多工器輸入端 $D_i$ 上的資料就會原封不動地重現在 MUX 的輸出。這正是分時多工的基礎:許多通道靠輪流切換選擇線共用一條線路。

Duality. A demux and a MUX are inverse circuits — connect them back-to-back with the same select, and the data on $D_i$ at the demux input reappears unchanged at the MUX output. This is the basis of time-division multiplexing: many channels share one wire by alternating selects.

双対性。デマルチプレクサと MUX は互いに逆の回路である — 同じ選択信号で背中合わせに接続すると、デマルチプレクサ入力の $D_i$ 上のデータが MUX の出力にそのまま現れる。これが時分割多重の基礎である:選択を交互に切り替えることで、多数のチャネルが 1 本の線を共有する。

解碼器 vs MUX。解碼器產生全部 $2^n$ 個最小項;MUX 則在內部使用最小項在各輸入之間做選擇。等價地說:MUX 是由解碼器 + AND 閘 + 一個大 OR 組成的。所以解碼器才是基本構件;MUX 與解多工器都是以解碼器為基礎的變形 — 讀取方向(MUX,$2^n$→1)對上寫入方向(解多工器,1→$2^n$)。

Decoder vs MUX. A decoder generates all $2^n$ minterms; a MUX uses minterms internally to select among inputs. Equivalently: a MUX is built from a decoder + AND gates + a big OR. So decoders are the building block; MUXes and demuxes are decoder-based variants — read-direction (MUX, $2^n$→1) vs. write-direction (demux, 1→$2^n$).

デコーダと MUX。デコーダは $2^n$ 個の最小項をすべて生成する。MUX は内部で最小項を使って入力の中から 1 つを選ぶ。同じことだが、MUX はデコーダ + AND ゲート + 大きな OR で構成される。つまりデコーダが構成要素であり、MUX とデマルチプレクサはデコーダに基づく派生形である — 読み出し方向(MUX、$2^n$→1)と書き込み方向(デマルチプレクサ、1→$2^n$)の違いである。

夏農展開 — 速查表Shannon's Expansion — cheat sheetシャノン展開 — 早見表

Shannon 展開定理把任意布林函數就選定的某個變數分解成兩塊較簡單的「餘因子」。它是以 MUX 為基礎的邏輯合成、BDD 以及遞迴式函數分析在代數上的根基。

Shannon's expansion theorem decomposes any Boolean function on a chosen variable into two simpler "cofactor" pieces. It's the algebraic foundation of MUX-based logic synthesis, BDDs, and recursive function analysis.

Shannon の展開定理は、任意のブール関数を、選んだ 1 つの変数について 2 つのより簡単な「コファクタ」に分解する。これは MUX に基づく論理合成、BDD、再帰的な関数解析の代数的な基礎である。

定理(SOP 形式):

Theorem (SOP form):

定理(SOP 形式):

$f(x_1, x_2, \ldots, x_n) \;=\; \overline{x_1}\cdot f(0, x_2, \ldots, x_n) \;+\; x_1 \cdot f(1, x_2, \ldots, x_n)$

定理(POS/對偶形式):

Theorem (POS / dual form):

定理(POS/双対形式):

$f(x_1, x_2, \ldots, x_n) \;=\; \bigl(x_1 + f(0, x_2, \ldots, x_n)\bigr) \cdot \bigl(\overline{x_1} + f(1, x_2, \ldots, x_n)\bigr)$

這兩塊稱為 $f$ 對 $x_1$ 的餘因子

The two pieces are called the cofactors of $f$ with respect to $x_1$:

この 2 つを、$x_1$ に関する $f$ のコファクタと呼ぶ:

記法Notation記法意義Meaning意味
$f_{x_1=0}$,   $f|_{x_1=0}$,   $f_0$在 $f$ 中處處代入 $x_1=0$ → 0-餘因子substitute $x_1=0$ everywhere in $f$ → 0-cofactor$f$ のあらゆる箇所に $x_1=0$ を代入する → 0-コファクタ
$f_{x_1=1}$,   $f|_{x_1=1}$,   $f_1$在 $f$ 中處處代入 $x_1=1$ → 1-餘因子substitute $x_1=1$ everywhere in $f$ → 1-cofactor$f$ のあらゆる箇所に $x_1=1$ を代入する → 1-コファクタ

$\boxed{\,f \;=\; \overline{x_1}\,f_0 \;+\; x_1\,f_1\,}$

與 2 對 1 MUX 的關聯 — 這根本就是選擇線 $= x_1$、資料輸入為 $f_0$ 與 $f_1$ 的 MUX2:

Connection to a 2-to-1 MUX — that's literally MUX2 with select $= x_1$, data inputs $f_0$ and $f_1$:

2 対 1 MUX との対応 — これはまさに、選択線 $= x_1$、データ入力が $f_0$ と $f_1$ の MUX2 である:

f₀ f₁ x₁ MUX2 0 1 f

遞迴應用 — 將函數拆解為 MUX 樹:Recursive application — decomposing a function into a MUX tree:再帰的な適用 — 関数を MUX ツリーへ分解する:

$f \;=\; \overline{x_1}\bigl[\overline{x_2} f_{00} + x_2 f_{01}\bigr] + x_1\bigl[\overline{x_2} f_{10} + x_2 f_{11}\bigr]$

每個 cofactor 接著對下一個變數展開,產生一棵具有 $2^n$ 個葉節點的二元樹(葉節點為常數 0 或 1,對應真值表的值)。這就一個尚未化簡的二元決策圖 (BDD)。

Each cofactor is then expanded on the next variable, producing a binary tree with $2^n$ leaves (the leaves are the constants 0 or 1, matching the truth-table entries). This is a binary decision diagram (BDD), just not yet reduced.

各 cofactor をさらに次の変数について展開すると、$2^n$ 個の葉をもつ二分木ができる(葉は定数 0 または 1 で、真理値表の値に対応する)。これはまさに二分決定図 (BDD) そのものであり、ただ簡約されていないだけである。

範例。 $f(w_1, w_2, w_3) = w_1 w_2 + \overline{w_1} w_3$。對 $w_1$ 展開:

Example. $f(w_1, w_2, w_3) = w_1 w_2 + \overline{w_1} w_3$. Expanding on $w_1$:

例。 $f(w_1, w_2, w_3) = w_1 w_2 + \overline{w_1} w_3$。$w_1$ について展開する:

  • $f_0 = f|_{w_1 = 0} = (0)\cdot w_2 + (1)\cdot w_3 = w_3$
  • $f_1 = f|_{w_1 = 1} = (1)\cdot w_2 + (0)\cdot w_3 = w_2$
  • 因此 $f = \overline{w_1}\,w_3 + w_1\,w_2$ — 可用一個 2-to-1 MUX 實作:select $= w_1$、$D_0 = w_3$、$D_1 = w_2$。原本的函數化簡為單一個 MUX,兩個資料輸入直接是原始 literal。
  • So $f = \overline{w_1}\,w_3 + w_1\,w_2$ — implementable with a single 2-to-1 MUX: select $= w_1$, $D_0 = w_3$, $D_1 = w_2$. The original function collapses to one MUX whose two data inputs are the raw literals.
  • したがって $f = \overline{w_1}\,w_3 + w_1\,w_2$ — 1 個の 2-to-1 MUX で実装できる:select $= w_1$、$D_0 = w_3$、$D_1 = w_2$。もとの関数は MUX 1 個にまで縮み、2 つのデータ入力はそのまま生の literal になる。

常用恆等式與性質:Common identities and properties:よく使う恒等式と性質:

恆等式Identity恒等式說明Meaning意味
$f = \overline{x}\,f_0 + x\,f_1$SOP 標準形式SOP canonical formSOP 標準形
$f = (x + f_0)(\overline{x} + f_1)$POS 標準形式(對偶)POS canonical form (dual)POS 標準形(双対)
$f_0 \cdot f_1 \neq 0 \Rightarrow$ Boolean 微分$f_0 \cdot f_1 \neq 0 \Rightarrow$ Boolean difference$f_0 \cdot f_1 \neq 0 \Rightarrow$ ブール微分$\partial f / \partial x = f_0 \oplus f_1$ (cofactor 的 XOR)$\partial f / \partial x = f_0 \oplus f_1$ (XOR of the cofactors)$\partial f / \partial x = f_0 \oplus f_1$(cofactor の XOR)
$f_0 = f_1 \iff f$ 與 $x$ 無關$f_0 = f_1 \iff f$ is independent of $x$$f_0 = f_1 \iff f$ は $x$ に依存しない用來偵測「冗餘」變數Used to detect “redundant” variables「冗長な」変数の検出に使う
$(f \cdot g)_{x=v} = f_{x=v} \cdot g_{x=v}$cofactor 對 AND、OR、NOT、XOR 具分配性Cofactoring distributes over AND, OR, NOT and XORcofactor は AND・OR・NOT・XOR に対して分配的

應用場景:Where it is used:使いどころ:

  • MUX-based 合成 — 透過遞迴 Shannon 展開,用一棵 2-to-1 MUX 樹實作任意 Boolean 函數。
  • MUX-based synthesis — implement any Boolean function with a tree of 2-to-1 MUXes via recursive Shannon expansion.
  • MUX ベースの合成 — Shannon 展開を再帰的に適用し、2-to-1 MUX のツリーで任意のブール関数を実装する。
  • BDD / ROBDD — BDD 的每個節點都是針對某個變數的 Shannon 展開。變數排序的選擇 = 每一層要對哪個變數展開。
  • BDD / ROBDD — every node of a BDD is a Shannon expansion on some variable. Choosing the variable order = choosing which variable to expand at each level.
  • BDD / ROBDD — BDD のすべてのノードは、ある変数についての Shannon 展開である。変数順序を選ぶこと = 各段でどの変数を展開するかを選ぶこと。
  • 函數分解 — 為了把 $f(x, y, \ldots)$ 分解成 $g(h(x, \ldots), y, \ldots)$,檢查 cofactor 並尋找重複出現的模式。
  • Functional decomposition — to decompose $f(x, y, \ldots)$ into $g(h(x, \ldots), y, \ldots)$, inspect the cofactors and look for repeated patterns.
  • 関数分解 — $f(x, y, \ldots)$ を $g(h(x, \ldots), y, \ldots)$ へ分解するために、cofactor を調べて繰り返し現れるパターンを探す。
  • Boolean 微分 — $\partial f / \partial x = f_0 \oplus f_1$。一個變數若使此式為真即被「敏化」;這是 DFT 中產生測試樣本的基礎。
  • Boolean difference — $\partial f / \partial x = f_0 \oplus f_1$. A variable is “sensitised” when this holds; it is the basis of test-pattern generation in DFT.
  • ブール微分 — $\partial f / \partial x = f_0 \oplus f_1$。この式が成り立つとき、その変数は「敏感化」されている。DFT におけるテストパターン生成の基礎である。
  • SAT solver — DPLL 搜尋演算法對選中的 literal 執行 Shannon 展開,分支搜尋樹。
  • SAT solvers — the DPLL search algorithm performs a Shannon expansion on the chosen literal, branching the search tree.
  • SAT ソルバ — DPLL 探索アルゴリズムは選んだ literal について Shannon 展開を行い、探索木を分岐させる。

快速做法: 若要用 $x_i$ 作為 select 的 2-to-1 MUX 表達 $f$ — 透過代入計算 $f_0$ 與 $f_1$,接到兩個資料輸入,$x_i$ 接 select。要繼續往下(MUX 樹),就把每個 cofactor 對下一個變數展開。遞迴在常數 0 和 1 處終止。

Quick recipe: to express $f$ as a 2-to-1 MUX selected by $x_i$ — compute $f_0$ and $f_1$ by substitution, wire them to the two data inputs and $x_i$ to select. To go deeper (a MUX tree), expand each cofactor on the next variable. The recursion terminates at the constants 0 and 1.

手早いやり方: $f$ を $x_i$ で select する 2-to-1 MUX で表すには — 代入によって $f_0$ と $f_1$ を求め、2 つのデータ入力へ、$x_i$ を select へつなぐ。さらに深くしたい(MUX ツリーにしたい)なら、各 cofactor を次の変数について展開する。再帰は定数 0 と 1 で終了する。

編碼器 ↔ 解碼器 — 互逆的一對(背對背串接運作)Encoder ↔ Decoder — the inverse pair (back-to-back co-working)エンコーダ ↔ デコーダ — 逆関係の対(背中合わせに接続して動かす)

編碼器把 $2^n$ 選 1 的 one-hot 訊號轉成 $n$ 位元的二進位索引。解碼器則做相反的事:把 $n$ 位元的二進位索引轉回 one-hot 訊號。兩者以相同寬度背對背相接時,對合法的 one-hot 輸入形成恆等關係 — 就像 demux/MUX 這一對,只是方向相反。

An encoder turns a one-of-$2^n$ one-hot signal into an $n$-bit binary index. A decoder does the reverse: it turns an $n$-bit binary index back into a one-hot signal. Connected back-to-back with the same width, they form an identity on valid one-hot inputs — exactly like a demux/MUX pair, but in the opposite direction.

エンコーダは $2^n$ 本のうち 1 本が立つ one-hot 信号を $n$ ビットの 2 進インデックスに変換する。デコーダはその逆で、$n$ ビットの 2 進インデックスを one-hot 信号に戻す。同じ幅どうしを背中合わせに接続すると、正当な one-hot 入力に対して恒等写像となる — demux/MUX の対とちょうど同じで、向きだけが逆である。

$\text{one-hot}\;\xrightarrow{\;\text{encoder}\;}\;\text{binary index}\;\xrightarrow{\;\text{decoder}\;}\;\text{one-hot}$

並列方塊圖(4 對 2 編碼器 → 2 對 4 解碼器):

Side-by-side block diagram (4-to-2 encoder → 2-to-4 decoder):

並べたブロック図(4-to-2 エンコーダ → 2-to-4 デコーダ):

W₃ W₂ W₁ W₀ 4-to-2 Encoder y₁ y₀ 2-bit binary 2-to-4 Decoder Y₃ Y₂ Y₁ Y₀ one-hot 輸入(壓縮)one-hot in (compress)one-hot 入力(圧縮) one-hot 輸出(展開)one-hot out (expand)one-hot 出力(展開) narrow link

真值表往返 — 編碼器把 4 條線壓成 2 條;解碼器再展開回來。對合法的 one-hot 輸入,這趟往返就是恆等:

Truth-table round-trip — encoder squeezes 4 wires into 2; decoder expands them back. On valid one-hot inputs the round-trip is identity:

真理値表での往復 — エンコーダは 4 本の線を 2 本に絞り、デコーダがそれを元に戻す。正当な one-hot 入力に対して、この往復は恒等である:

W₃W₂W₁W₀ (one-hot) y₁y₀ (encoded) Y₃Y₂Y₁Y₀ (decoded) 是否相符?match?一致するか?
0001000001
0010010010
0100100100
1000111000
0000 (invalid)000001 (wrong!)×

加上 valid 閘的背對背串接 — 紅色那一列顯示為何單純的編碼器輸出會有歧義:輸入 0001 與輸入 0000 都會得到 y = 00。為了區分兩者,編碼器多 assert 一個 valid 位元(= 所有 one-hot 輸入的 OR),解碼器則以它作為致能,於是沒有任何輸入被 assert 時,輸出維持 0000:

Back-to-back chain with a valid gate — the row in red shows why a plain encoder output is ambiguous: input 0001 and input 0000 both produce y = 00. To distinguish them, the encoder asserts an extra valid bit (= OR of all one-hot inputs), and the decoder uses it as enable so its outputs stay 0000 when no input was asserted:

valid のゲートを付けた背中合わせの接続 — 赤い行は、素のエンコーダ出力があいまいになる理由を示している:入力 0001 と入力 0000 のどちらも y = 00 になる。両者を区別するため、エンコーダは追加の valid ビット(= すべての one-hot 入力の OR)をアサートし、デコーダはそれをイネーブルとして使う。こうすれば、どの入力もアサートされていないとき出力は 0000 のままになる:

Encoder 4→2 W[3:0] /4 y[1:0] /2 valid Decoder 2→4 W En Y[3:0] /4 窄鏈路:用 2 + 1 條線取代 4 條narrow link: 2 + 1 wires instead of 4狭いリンク:4 本の代わりに 2 + 1 本

這組搭配會出現在哪裡:

Where this pair shows up:

この組合せが登場する場面:

  • 匯流排上的位址壓縮。把很寬的 one-hot 訊號(例如 16 條裝置請求線)編碼成 4 位元,經背板傳送,到目的端再解碼回來。可節省線數與繞線面積。
  • Address compression on a bus. A wide one-hot signal (say 16 device-request lines) is encoded to 4 bits, transmitted across a backplane, then decoded back at the destination. Saves wires and routing area.
  • バス上のアドレス圧縮。幅の広い one-hot 信号(たとえばデバイス要求線 16 本)を 4 ビットに符号化してバックプレーン越しに送り、受信側で復号して戻す。配線数と配線面積を節約できる。
  • 中斷向量。許多中斷請求線(one-hot)由優先編碼器編成一個數值向量索引;CPU 之後再解碼該索引以查出服務常式 — 同樣是編碼器/解碼器的一對,只是多了優先權仲裁。
  • Interrupt vector. Many interrupt-request lines (one-hot) are encoded into a numeric vector index by a priority encoder; the CPU later decodes that index to look up the service routine — same encoder/decoder pair, with priority resolution added.
  • 割込みベクタ。多数の割込み要求線(one-hot)を優先エンコーダが数値のベクタインデックスに符号化し、CPU は後でそのインデックスを復号してサービスルーチンを引く — 同じエンコーダ/デコーダの対に、優先順位の解決を加えたものである。
  • 記憶體映射 I/O。位址位元以二進位索引的形式傳送;晶片選擇解碼器再把它們變回 one-hot 致能訊號,分別對應各個周邊或記憶體區塊。
  • Memory-mapped I/O. Address bits travel as a binary index; a chip-select decoder turns them back into one-hot enables for individual peripherals or memory banks.
  • メモリマップド I/O。アドレスビットは 2 進インデックスとして伝わり、チップセレクトのデコーダがそれを個々の周辺回路やメモリバンク向けの one-hot イネーブルに戻す。
  • 匯流排仲裁。優先編碼器選出勝出的請求;解碼器再把對應的授權線 assert 回請求方。
  • Bus arbitration. A priority encoder picks the winning request; a decoder re-asserts the matching grant line back to the requester.
  • バス調停。優先エンコーダが勝った要求を選び、デコーダが対応する許可線を要求元へアサートし返す。

Verilog — 最精簡的背對背組合:

Verilog — minimal back-to-back pair:

Verilog — 最小限の背中合わせ構成:

module binary_encoder_4to2(input [3:0] W, output reg [1:0] y, output valid);
  assign valid = |W;            // 1 if any input is asserted
  always @(*) case (W)
    4'b0001: y = 2'b00;
    4'b0010: y = 2'b01;
    4'b0100: y = 2'b10;
    4'b1000: y = 2'b11;
    default: y = 2'b00;         // ambiguous without 'valid'
  endcase
endmodule

module dec2to4(input [1:0] W, input En, output reg [3:0] Y);
  always @(*) case ({En, W})
    3'b100: Y = 4'b0001;
    3'b101: Y = 4'b0010;
    3'b110: Y = 4'b0100;
    3'b111: Y = 4'b1000;
    default: Y = 4'b0000;
  endcase
endmodule

module enc_dec_link(input [3:0] W, output [3:0] Y);
  wire [1:0] y;
  wire       valid;
  binary_encoder_4to2 enc(.W(W), .y(y), .valid(valid));
  dec2to4             dec(.W(y), .En(valid), .Y(Y));
endmodule

關於 valid 輸出的註腳。單純(非優先)的編碼器無法分辨「沒有輸入被 assert」與「輸入 0 被 assert」 — 兩者都得到 y = 00。valid = 所有輸入的 OR 這個位元解決了問題:它閘控下游的解碼器,於是即使沒有任何來源線在作用,這趟往返仍然正確。對優先編碼器而言,valid 同時也是送給仲裁器的「有請求待處理」訊號。

Footnote on the valid output. A plain (non-priority) encoder cannot tell "no input asserted" from "input 0 asserted" — both produce y = 00. The valid = OR-of-all-inputs bit fixes this: it gates the downstream decoder so the round-trip is correct even when no source line is active. For a priority encoder, valid doubles as the "any request pending" signal feeding the arbiter.

valid 出力についての注。素の(優先順位なしの)エンコーダは「どの入力もアサートされていない」と「入力 0 がアサートされている」を区別できない — どちらも y = 00 になる。valid = 全入力の OR というビットがこれを解決する:後段のデコーダをゲートするので、どの入力線も活性でないときでも往復は正しくなる。優先エンコーダでは、valid は調停器へ送る「要求が保留中である」という信号も兼ねる。

多工器 ↔ 解多工器 — 互逆的一對(分時多工)Multiplexer ↔ Demultiplexer — the inverse pair (time-division multiplexing)マルチプレクサ ↔ デマルチプレクサ — 逆関係の対(時分割多重)

多工器 (MUX) 從 $2^n$ 個資料來源中挑一個,送到單一輸出。解多工器 (DEMUX) 做相反的事:接收一個資料輸入,把它導向 $2^n$ 個輸出中的其中一個(其餘維持 0)。兩者以共用的選擇訊號背對背相接時,MUX→DEMUX 就構成一條完美的分時多工 (TDM) 鏈路:許多通道分時輪流共用一條線。

A multiplexer (MUX) picks one of $2^n$ data sources and routes it to a single output. A demultiplexer (DEMUX) does the reverse: it takes one data input and steers it to one of $2^n$ outputs (the rest stay at 0). Connected back-to-back with a shared select, MUX→DEMUX makes a perfect time-division multiplexed (TDM) link: many channels share one wire, alternating in time.

マルチプレクサ (MUX) は $2^n$ 個のデータ源から 1 つを選び、単一の出力へ送る。デマルチプレクサ (DEMUX) はその逆で、1 本のデータ入力を $2^n$ 本の出力のうち 1 本へ振り分ける(残りは 0 のまま)。選択信号を共有して背中合わせに接続すると、MUX→DEMUX は完全な時分割多重 (TDM) リンクになる:多数のチャネルが 1 本の線を時間で交代しながら共有する。

$D_0 \ldots D_{2^n-1}\;\xrightarrow{\;\text{MUX}\;}\;\text{1 wire}\;\xrightarrow{\;\text{DEMUX}\;}\;Y_0 \ldots Y_{2^n-1}$

並列方塊圖(4 對 1 MUX → 1 對 4 DEMUX):

Side-by-side block diagram (4-to-1 MUX → 1-to-4 DEMUX):

並べたブロック図(4-to-1 MUX → 1-to-4 DEMUX):

D₃ D₂ D₁ D₀ MUX 4→1 共用的 1 位元線shared 1-bit wire共有する 1 ビット線 DEMUX 1→4 Y₃ Y₂ Y₁ Y₀ shared sel[1:0]

往返對照表 — 兩端使用相同的選擇訊號時,被選中的槽位滿足 $Y_i = D_i$,其餘 $Y_j = 0$(解多工器的 0 底值):

Round-trip table — with the same select on both sides, $Y_i = D_i$ for the selected slot, all other $Y_j = 0$ (the demux floor):

往復の表 — 両側で同じ選択信号を使うと、選ばれたスロットでは $Y_i = D_i$ となり、それ以外はすべて $Y_j = 0$ である(デマルチプレクサの 0 の下地):

sel MUX 輸出(= 共用線)MUX out (= shared wire)MUX 出力(= 共有線) DEMUX outputs Y₃Y₂Y₁Y₀ 作用中的通道live channel有効なチャネル
00D₀000 D₀channel 0
01D₁00 D₁ 0channel 1
10D₂0 D₂ 00channel 2
11D₃D₃ 000channel 3

TDM 時序 — 讓 sel 在連續的時槽中依序輪轉 00 → 01 → 10 → 11;每個來源 $D_i$ 在其中一個時槽獨占這條線,解多工器再把它落到對應的 $Y_i$ 上:

TDM timing — rotate sel through 00 → 01 → 10 → 11 in successive time slots; each source $D_i$ owns the wire for one slot, and the demux drops it onto the matching $Y_i$:

TDM のタイミングsel を連続するタイムスロットで 00 → 01 → 10 → 11 と巡回させる。各データ源 $D_i$ は 1 スロットのあいだ線を占有し、デマルチプレクサがそれを対応する $Y_i$ へ落とす:

time → sel 00 01 10 11 wire D₀ D₁ D₂ D₃ Y₀ D₀ Y₁ D₁ Y₂ D₂ Y₃ D₃

這組搭配會出現在哪裡:

Where this pair shows up:

この組合せが登場する場面:

  • 分時多工 (TDM)。多條低速通道共用一條高速線路。發送端做多工,接收端以相同輪轉的選擇訊號做解多工。用於 T1/E1 電話系統、UART 序列框訊、I²S 音訊。
  • Time-division multiplexing (TDM). Multiple low-rate channels share one high-rate wire. The transmitter MUXes; the receiver DEMUXes with the same rotating select. Used in T1/E1 telephony, serial UART framing, I²S audio.
  • 時分割多重 (TDM)。低速のチャネルを複数まとめて 1 本の高速な線で共有する。送信側が多重化し、受信側は同じように巡回する選択信号で分離する。T1/E1 の電話網、UART のシリアルフレーミング、I²S オーディオで使われる。
  • ADC 通道共用。單一顆實體 ADC 透過類比 MUX 取樣多條感測器線路;數位側再把樣本解多工到各通道的緩衝區。
  • ADC channel sharing. One physical ADC samples many sensor lines via an analog MUX; the digital side DEMUXes the samples into per-channel buffers.
  • ADC のチャネル共有。1 個の物理 ADC がアナログ MUX を介して多数のセンサ線をサンプリングし、デジタル側がそのサンプルをチャネルごとのバッファへ振り分ける。
  • 記憶體匯流排仲裁。數個主控端透過 MUX 共用一條記憶體資料匯流排;目的端的暫存器則像 DEMUX 一樣運作,在對應的週期把該字組擷取進正確的閂鎖。
  • Memory bus arbitration. Several masters share one memory data bus through a MUX; the destination registers behave as a DEMUX, capturing the word into the correct latch on the matching cycle.
  • メモリバスの調停。複数のマスタが MUX を介して 1 本のメモリデータバスを共有する。行き先のレジスタ群は DEMUX のようにふるまい、対応するサイクルでワードを正しいラッチへ取り込む。
  • 管線運算元繞送。ALU 以 MUX 挑選運算元的來源(暫存器檔、立即值、前遞值);再由一組 DEMUX 形狀的寫入致能網路,把結果導回正確的暫存器。
  • Pipeline operand routing. ALUs use a MUX to pick the operand source (register file, immediate, forwarded value); a DEMUX-shaped write-enable network steers the result back to the right register.
  • パイプラインのオペランド経路。ALU は MUX でオペランドの供給元(レジスタファイル、即値、フォワーディングされた値)を選ぶ。結果は DEMUX の形をした書込みイネーブル網によって正しいレジスタへ戻される。

Verilog — 最精簡的背對背組合:

Verilog — minimal back-to-back pair:

Verilog — 最小限の背中合わせ構成:

module mux4to1(input [3:0] D, input [1:0] sel, output reg out);
  always @(*) case (sel)
    2'b00: out = D[0];
    2'b01: out = D[1];
    2'b10: out = D[2];
    2'b11: out = D[3];
  endcase
endmodule

module demux1to4(input in, input [1:0] sel, output reg [3:0] Y);
  always @(*) begin
    Y = 4'b0000;
    case (sel)
      2'b00: Y[0] = in;
      2'b01: Y[1] = in;
      2'b10: Y[2] = in;
      2'b11: Y[3] = in;
    endcase
  end
endmodule

module tdm_link(input [3:0] D, input [1:0] sel, output [3:0] Y);
  wire bus;                              // the shared 1-bit wire
  mux4to1   tx(.D(D),  .sel(sel), .out(bus));
  demux1to4 rx(.in(bus), .sel(sel), .Y(Y));
endmodule

注意。MUX/DEMUX 這一對傳的是資料(一條線,帶著數值);編碼器/解碼器這一對傳的是索引(二進位數,帶著位置)。兩對都是互逆電路,但作用的抽象層次不同:一個是資料繞送,一個是位址轉換。

Note. The MUX/DEMUX pair carries data (one wire, value-bearing); the encoder/decoder pair carries an index (binary number, position-bearing). Both pairs are inverse circuits, but they operate on different abstractions: data routing vs. address translation.

注。MUX/DEMUX の対が運ぶのはデータ(1 本の線に載る値)であり、エンコーダ/デコーダの対が運ぶのはインデックス(位置を表す 2 進数)である。どちらの対も互いに逆の回路だが、扱う抽象が異なる:データの経路選択か、アドレスの変換かである。

4.1簡單Easy易しい第一階Tier 1ティア 1?R
說明如何用一個 3-to-8 解碼器與單一個 OR 閘實作 $f(w_1,w_2,w_3) = \sum m(0,2,3,4,5,7)$。
Show how $f(w_1,w_2,w_3) = \sum m(0,2,3,4,5,7)$ can be implemented using a 3-to-8 decoder and a single OR gate.
$f(w_1,w_2,w_3) = \sum m(0,2,3,4,5,7)$ を 3-to-8 デコーダと OR ゲート 1 個で実装する方法を示せ。
4.2中等Medium普通第一階Tier 1ティア 1?R
Use Shannon's expansion with respect to variable $w_1$ to implement $f(w_1,w_2,w_3) = \sum m(0,2,3,6)$ using a 2-to-1 multiplexer and any necessary gates.
背景 — 夏農展開:SOP 與 POS 的完整逐步演練Background — Shannon's expansion: full SOP and POS walk-through背景 — シャノン展開:SOP と POS の完全な手順解説

以下用一個 3 變數函數做具體的逐步演練。

Here's a concrete walk-through using a 3-variable function.

3 変数の関数を使って具体的にたどってみる。

Setup

取 $F(A, B, C) = A + BC$,共 3 個變數($n = 3$),因此有 $2^3 = 8$ 個最小項($m_0$ 到 $m_7$)。[cs.ucr]

Take $F(A, B, C) = A + BC$ with 3 variables ($n = 3$), so there are $2^3 = 8$ minterms ($m_0$ through $m_7$). [cs.ucr]

$F(A, B, C) = A + BC$ を取る。変数は 3 個($n = 3$)なので、最小項は $2^3 = 8$ 個($m_0$ から $m_7$ まで)ある。[cs.ucr]

Truth Table

對每一種輸入組合計算 $F$:[cs.ucr]

Evaluate $F$ for every input combination: [cs.ucr]

入力の各組合せについて $F$ を評価する:[cs.ucr]

$i$ABCMinterm $m_i$$F(A,B,C)$
0000$A'B'C'$0
1001$A'B'C$0
2010$A'BC'$0
3011$A'BC$1
4100$AB'C'$1
5101$AB'C$1
6110$ABC'$1
7111$ABC$1

套用公式

Applying the Formula

公式を適用する

$$F = \sum_{i=0}^{7} m_i \cdot F(\text{inputs for } m_i)$$

只有 $F = 1$ 的最小項會留下來(乘以 0 會把其餘消去):[caslab.ee.ncku.edu]

Only minterms where $F = 1$ survive (multiplying by 0 eliminates the rest): [caslab.ee.ncku.edu]

残るのは $F = 1$ の最小項だけである(0 を掛けることで残りは消える):[caslab.ee.ncku.edu]

$$F(A,B,C) = m_3 \cdot 1 + m_4 \cdot 1 + m_5 \cdot 1 + m_6 \cdot 1 + m_7 \cdot 1$$

代入實際的最小項乘積:[cs.ucr]

Substituting the actual minterm products: [cs.ucr]

実際の最小項の積を代入すると:[cs.ucr]

$$F(A,B,C) = A'BC + AB'C' + AB'C + ABC' + ABC$$

以簡記法寫出:[jazapka.people.ysu]

Written in shorthand notation: [jazapka.people.ysu]

略記法で書くと:[jazapka.people.ysu]

$$F(A,B,C) = \Sigma\, m(3, 4, 5, 6, 7)$$

這代表什麼

What This Means

これが意味すること

這個式子說的其實就是:把函數輸出為 1 的每一個最小項 OR 起來。每個最小項 $m_i$ 只在唯一一種輸入組合下為 1,因此這個和「挑出」真值表中 $F = 1$ 的那些列。這個標準 SOP 就是同時對所有變數完全展開的夏農分解。[cs.ucr]

The formula is simply saying: OR together every minterm for which the function outputs 1. Each minterm $m_i$ is exactly 1 for one and only one input combination, so the sum "selects" the rows in the truth table where $F = 1$. This canonical SOP is the fully expanded Shannon decomposition over all variables simultaneously. [cs.ucr]

この式が言っているのは要するに、関数が 1 を出力する最小項をすべて OR でつなぐということである。各最小項 $m_i$ はただ 1 通りの入力組合せに対してのみ 1 になるので、この和は真理値表のうち $F = 1$ の行を「選び出す」。この標準 SOP は、全変数について同時に完全展開したシャノン分解にほかならない。[cs.ucr]


以下是使用夏農展開之對偶 POS 形式的完整範例。

Here is a full worked example using the dual POS form of Shannon's expansion.

以下は、シャノン展開の双対な POS 形式を使った完全な例題である。

Setup

令 $F(A, B, C) = A + BC$,並對 $X_1 = A$ 展開:[en.wikipedia]

Let $F(A, B, C) = A + BC$, and expand on $X_1 = A$: [en.wikipedia]

$F(A, B, C) = A + BC$ とし、$X_1 = A$ について展開する:[en.wikipedia]

$$F = (A + F(0, B, C)) \cdot (A' + F(1, B, C))$$

步驟 1 — 計算兩個餘因子

Step 1 — Compute the Two Cofactors

ステップ 1 — 2 つのコファクタを計算する

負餘因子 — 令 $A = 0$:[en.wikipedia]

Negative cofactor — set $A = 0$: [en.wikipedia]

負のコファクタ — $A = 0$ とおく:[en.wikipedia]

$$F(0, B, C) = 0 + BC = BC$$

正餘因子 — 令 $A = 1$:[en.wikipedia]

Positive cofactor — set $A = 1$: [en.wikipedia]

正のコファクタ — $A = 1$ とおく:[en.wikipedia]

$$F(1, B, C) = 1 + BC = 1$$

步驟 2 — 代入 POS 公式

Step 2 — Plug into the POS Formula

ステップ 2 — POS の式に代入する

$$F(A, B, C) = (A + BC) \cdot (A' + 1)$$

因為 $A' + 1 = 1$(任何東西與 1 做 OR 都是 1):

Since $A' + 1 = 1$ (anything OR'd with 1 is 1):

$A' + 1 = 1$ だから(何と 1 を OR しても 1 になる):

$$F(A, B, C) = (A + BC) \cdot 1 = A + BC$$

函數確認無誤 $\checkmark$

The function is confirmed correctly $\checkmark$

関数が正しいことが確認できた $\checkmark$

步驟 3 — 進一步展開到標準 POS

Step 3 — Expand Further to Canonical POS

ステップ 3 — さらに展開して標準 POS にする

要得到完全標準的 POS(最大項形式),必須對每個剩下的子函數遞迴套用這個定理。對變數 $B$ 展開 $BC$:[eplauchu.files.wordpress]

To reach the fully canonical POS (maxterm form), apply the theorem recursively to each remaining sub-function. Expand $BC$ on variable $B$: [eplauchu.files.wordpress]

完全な標準 POS(最大項形式)に到達するには、残った各部分関数に定理を再帰的に適用する。$BC$ を変数 $B$ について展開する:[eplauchu.files.wordpress]

$$BC = (B + C \cdot 0)(B' + C \cdot 1) = (B + 0)(B' + C) = B(B' + C)$$

等一下 — 在 POS 中,對所有變數做標準展開,得到的是 $F = 0$ 之處的最大項。由前面的真值表可知,$F = 0$ 只出現在第 $i = 0, 1, 2$ 列(也就是 $A=0, BC=0$):

Wait — in POS, the canonical expansion over all variables yields maxterms where $F = 0$. From the earlier truth table, $F = 0$ only at rows $i = 0, 1, 2$ (i.e., $A=0, BC=0$):

ちょっと待とう — POS では、全変数にわたる標準展開が与えるのは $F = 0$ となる最大項である。先の真理値表から、$F = 0$ となるのは $i = 0, 1, 2$ の行だけである(すなわち $A=0, BC=0$):

$i$ABCMaxterm $M_i$$F$
0000$A+B+C$0
1001$A+B+C'$0
2010$A+B'+C$0
3–71

因此標準 POS 為:[eplauchu.files.wordpress]

So the canonical POS is: [eplauchu.files.wordpress]

したがって標準 POS は次のようになる:[eplauchu.files.wordpress]

$$F(A,B,C) = \Pi\, M(0, 1, 2) = (A+B+C)(A+B+C')(A+B'+C)$$

關鍵觀念:SOP 與 POS 的對偶性

Key Insight: SOP vs POS Duality

要点:SOP と POS の双対性

SOP(Shannon 直接式)SOP (Shannon direct)SOP(Shannon 直接形)POS(Shannon 對偶)POS (Shannon dual)POS(Shannon の双対)
Operator$x \cdot F_x + x' \cdot F_{x'}$$(x + F_{x=0})(x' + F_{x=1})$
Canonical form$F = 1$ 之處的最小項之和Sum of minterms where $F = 1$$F = 1$ となる最小項の和$F = 0$ 之處的最大項之積Product of maxterms where $F = 0$$F = 0$ となる最大項の積
Building blocksMinterms $m_i$Maxterms $M_i$

當函數在真值表中的 0 比 1 少時,對偶的 POS 形式特別有用 — 此時 POS 式子會比較精簡。[eplauchu.files.wordpress]

The dual POS form is particularly useful when a function has fewer 0s than 1s in the truth table — the POS expression will then be more compact. [eplauchu.files.wordpress]

双対な POS 形式が特に役立つのは、真理値表で関数の 0 が 1 より少ない場合である — そのとき POS の式のほうが簡潔になる。[eplauchu.files.wordpress]

4.3簡單Easy易しい第一階Tier 1ティア 1?R
畫出用 AND、OR、NOT 閘構成的 4-to-1 多工器電路圖。
Draw the circuit diagram for a 4-to-1 multiplexer using AND, OR, and NOT gates.
AND、OR、NOT ゲートを用いた 4-to-1 マルチプレクサの回路図を描け。
4.4中等Medium普通第一階Tier 1ティア 1?R
Design a 4-to-2 priority encoder where input 3 has the highest priority. Give the truth table and logic equations for the two outputs and a valid-output signal.
為什麼輸入 3 的優先權最高?Why does input 3 have the highest priority?なぜ入力 3 の優先順位が最も高いのか?

依慣例,索引最大的已 assert 輸入勝出:I₃ > I₂ > I₁ > I₀。編碼器在 (Y₁, Y₀) 上回報這個勝出輸入的索引,而只要有任一輸入為作用中,V=1。

By convention the highest-indexed asserted input wins: I₃ > I₂ > I₁ > I₀. The encoder reports the index of that winning input on (Y₁, Y₀), and V=1 whenever any input is active.

慣例として、アサートされた入力のうち添字が最大のものが勝つ:I₃ > I₂ > I₁ > I₀。エンコーダはその勝った入力の添字を (Y₁, Y₀) に出力し、いずれかの入力が活性なら V=1 となる。

if / else if 串接中,這就是最先被檢查的輸入:

In an if / else if chain this is the input checked first:

if / else if の連鎖では、これが最初に調べられる入力である:

if      (in[3]) out = 2'd3;   // highest priority
else if (in[2]) out = 2'd2;
else if (in[1]) out = 2'd1;
else if (in[0]) out = 2'd0;   // lowest priority

若想改成讓輸入 0 的優先權最高,只要把這串判斷的順序反過來即可。

To make input 0 the highest priority instead, just reverse the order of the chain.

代わりに入力 0 を最優先にしたければ、連鎖の順序を逆にするだけでよい。

如果改成輸入 0 的優先權最高呢?What if input 0 has the highest priority?入力 0 の優先順位が最も高い場合はどうなるか?

那就變成 I₀ > I₁ > I₂ > I₃。輸出 (Y₁,Y₀) 一樣回報勝出輸入的索引,但每一項都必須以優先權較高之輸入的補數來閘控。

Then I₀ > I₁ > I₂ > I₃. The output (Y₁,Y₀) still reports the index of the winning input, but every term must gate on the complements of the higher-priority inputs.

そのときは I₀ > I₁ > I₂ > I₃ となる。出力 (Y₁,Y₀) が勝った入力の添字を示すのは同じだが、各項は優先順位の高い入力の補数でゲートしなければならない。

I₃I₂I₁I₀Y₁Y₀V
0000xx0
xxx1001
xx10011
x100101
1000111

$Y_0 = I_1\overline{I_0} + I_3\overline{I_2}\,\overline{I_1}\,\overline{I_0}$

$Y_1 = \overline{I_0}\,\overline{I_1}(I_2 + I_3)$

$V = I_0 + I_1 + I_2 + I_3$

與 I₃ 最高的情形($Y_1 = I_3 + I_2$、$Y_0 = I_3 + I_1\overline{I_2}$)相比,把優先權翻轉成 I₀ 最高會讓式子變長,因為現在必須明確壓制優先權較高的輸入。

Compared to the I₃-highest case ($Y_1 = I_3 + I_2$, $Y_0 = I_3 + I_1\overline{I_2}$), flipping the priority to I₀ makes the equations longer because the higher-priority inputs now need to be explicitly suppressed.

I₃ を最優先とする場合($Y_1 = I_3 + I_2$、$Y_0 = I_3 + I_1\overline{I_2}$)と比べると、優先順位を I₀ 最優先へ反転させると式は長くなる。優先順位の高い入力を明示的に抑え込む必要があるからである。

如果改成輸入 1 的優先權最高呢?What if input 1 has the highest priority?入力 1 の優先順位が最も高い場合はどうなるか?

只把 I₁ 指定為最高優先權,並不能完全決定其餘三者的順序。慣例的讀法是循環移位(round-robin 式):I₁ > I₂ > I₃ > I₀。

Naming only I₁ as highest doesn't fully specify the order of the other three. The usual reading is a cyclic shift (round-robin style): I₁ > I₂ > I₃ > I₀.

I₁ だけを最上位と決めても、残り 3 つの順序は完全には定まらない。ふつうの読み方は巡回シフト(ラウンドロビン式)である:I₁ > I₂ > I₃ > I₀。

I₃I₂I₁I₀Y₁Y₀V
0000xx0
xx1x011
x10x101
100x111
0001001

$Y_0 = I_1 + I_3\overline{I_2}\,\overline{I_1}$

$Y_1 = \overline{I_1}(I_2 + I_3)$

$V = I_0 + I_1 + I_2 + I_3$

由於 I₀ 現在是最低優先權,而其索引為 00,兩個輸出中都不會出現 I₀ 項 — 只有當所有較高優先權的輸入都為 0 時它才會被「選中」,而這個選擇就由 Y₁Y₀ = 00 編碼。

Because I₀ is now the lowest priority and its index is 00, no I₀ term appears in either output — it's "selected" only when all higher-priority inputs are 0, and that selection is encoded by Y₁Y₀ = 00.

I₀ は今や最下位の優先度であり、その索引は 00 なので、どちらの出力にも I₀ の項は現れない — I₀ が「選ばれる」のは、より優先度の高い入力がすべて 0 のときだけであり、その選択は Y₁Y₀ = 00 で符号化される。

4.5中等Medium普通第一階Tier 1ティア 1?R
實作一個帶致能輸入的 2-to-4 解碼器。寫出真值表,並以 case 敘述撰寫 Verilog 程式碼。
Implement a 2-to-4 decoder with an enable input. Write the truth table and the Verilog code using a case statement.
イネーブル入力付きの 2-to-4 デコーダを実装せよ。真理値表を書き、case 文を用いた Verilog コードを示せ。
4.6中等Medium普通第一階Tier 1ティア 1?R
Derive minimum SOP expressions for outputs a, b, and c of a BCD-to-7-segment display decoder.
完整 0–9 真值表 (a–g, common cathode)Complete 0–9 truth table (a–g, common cathode)0–9 の完全な真理値表(a–g、common cathode)

段位示意:a = 上橫,b = 右上,c = 右下,d = 下橫,e = 左下,f = 左上,g = 中橫。BCD 用 ABCD = wxyz。

Segment layout: a = top bar, b = upper right, c = lower right, d = bottom bar, e = lower left, f = upper left, g = middle bar. BCD uses ABCD = wxyz.

セグメント配置:a = 上の横棒、b = 右上、c = 右下、d = 下の横棒、e = 左下、f = 左上、g = 中央の横棒。BCD は ABCD = wxyz を用いる。

十進位Decimal十進BCD (wxyz)BCD (wxyz)BCD (wxyz)abcdefg
000001111110
100010110000
200101101101
300111111001
401000110011
501011011011
601101011111
701111110000
810001111111
910011111011

特殊規律:Notable patterns:目につく規則性:

  • 數字 8:七段全亮 (1111111),是最完整的圖形。
  • Digit 8: all seven segments lit (1111111) — the most complete pattern.
  • 数字 8:7 セグメントすべてが点灯 (1111111) — もっとも完全なパターン。
  • 數字 1:只有 b、c 亮 (右側兩段)。
  • Digit 1: only b and c are lit (the two right-hand segments).
  • 数字 1:b と c だけが点灯(右側の 2 セグメント)。
  • 數字 7:比 1 多一條上橫 (a 段)。
  • Digit 7: digit 1 plus the top bar (segment a).
  • 数字 7:数字 1 に上の横棒(セグメント a)を足したもの。
  • g 段 (中橫):只有 0、1、7 不亮,其餘皆亮。
  • Segment g (middle bar): unlit only for 0, 1 and 7; lit for every other digit.
  • セグメント g(中央の横棒):0・1・7 のときだけ消灯し、それ以外の数字ではすべて点灯する。
  • BCD 1010–1111 (10–15) 為無效輸入,列為 Don't Care (X),可在 K-map 化簡時自由利用。
  • BCD 1010–1111 (10–15) are invalid inputs, treated as Don't Care (X), and can be exploited freely when simplifying the K-map.
  • BCD 1010–1111(10–15)は無効な入力なので Don't Care (X) として扱い、K-map の簡単化で自由に活用できる。
4.7中等Medium普通第一階Tier 1ティア 1?R
設計一個 2 位元大小比較器,產生三個輸出:AgtBAeqBAltB。寫出真值表與化簡後的方程式。關於相等偵測所用的 XNOR (≡),請參見複合閘
Design a 2-bit magnitude comparator that produces three outputs: AgtB, AeqB, AltB. Give the truth table and simplified equations. See Compound Gates for XNOR (≡) used in equality detection.
2 ビットの大小比較器を設計し、AgtBAeqBAltB の 3 出力を生成せよ。真理値表と簡単化した方程式を示せ。一致検出に使う XNOR (≡) については複合ゲートを参照。
4.8中等Medium普通第一階Tier 1ティア 1?R
用兩個 2-to-4 解碼器與額外的閘建構一個 3-to-8 解碼器。畫出方塊圖。
Use two 2-to-4 decoders and additional gates to build a 3-to-8 decoder. Draw the block diagram.
2-to-4 デコーダ 2 個と追加のゲートで 3-to-8 デコーダを構成せよ。ブロック図を描け。
4.9中等Medium普通第一階Tier 1ティア 1?R
always 區塊內使用 if-else 鏈,撰寫具 8 個輸入的優先編碼器的 Verilog 程式碼。
Write Verilog code for a priority encoder with 8 inputs using an if-else chain inside an always block.
always ブロック内の if-else 連鎖を用いて、入力 8 本の優先エンコーダの Verilog コードを書け。
4.10簡單Easy易しい第一階Tier 1ティア 1?R
若 Verilog 的 case 敘述沒有涵蓋所有可能的輸入組合,也沒有提供 default,會發生什麼事?會推導出什麼類型的硬體?
What happens if a case statement in Verilog doesn't cover all possible input combinations and no default is provided? What type of hardware is inferred?
Verilog の case 文がすべての入力組合せを網羅せず、default も与えられていない場合、何が起こるか。どのような種類のハードウェアが推論されるか。
4.11中等Medium普通第一階Tier 1ティア 1?R
Design a 4-bit binary-to-Gray code converter. Give the truth table and Verilog implementation.
什麼是格雷碼?What is Gray code?グレイ符号とは何か?

格雷碼(反射二進位碼)是一種二進位編碼系統,其中相鄰兩個數值恰好只差一個位元

Gray code (reflected binary code) is a binary numbering system where two consecutive values differ in exactly one bit.

グレイ符号(反射 2 進符号)とは、連続する 2 つの値がちょうど 1 ビットだけ異なる 2 進の数値表現である。

十進位Dec10 進二進位Binary2 進数格雷碼Grayグレイ符号十進位Dec10 進二進位Binary2 進数格雷碼Grayグレイ符号
000000000810001100
100010001910011101
2001000111010101111
3001100101110111110
4010001101211001010
5010101111311011011
6011001011411101001
7011101001511111000

每一列相對於上一列只變動一個位元。與二進位比較:0011 → 0100 一次就變了 3 個位元。

Each row changes only one bit from the row above. Compare with binary: 0011 → 0100 changes 3 bits at once.

各行は 1 つ上の行から 1 ビットしか変わらない。2 進と比べてみよ:0011 → 0100 では一度に 3 ビットが変わる。

為什麼重要:

Why it matters:

なぜ重要か:

  • 機械/光學編碼器(旋轉位置):位於位元邊界上的感測器無法全部同時切換。若用二進位,在轉換途中可能會短暫讀到完全錯誤的值(例如 011 → 100 可能會經過 000 或 111 的突波)。格雷碼保證只有一個感測器改變,因此最壞情況的誤讀也只差一。
  • Mechanical / optical encoders (rotary position): sensors at bit boundaries can't all switch simultaneously. With binary, mid-transition you might briefly read a wildly wrong value (e.g. 011 → 100 might glitch through 000 or 111). Gray guarantees only one sensor changes, so the worst-case mis-read is off by one.
  • 機械式/光学式エンコーダ(回転位置):ビット境界にあるセンサがすべて同時に切り替わることはあり得ない。2 進では、遷移の途中でまったく違う値を一瞬読んでしまうことがある(たとえば 011 → 100 が 000 や 111 を経由してグリッチする)。グレイ符号なら変化するセンサは必ず 1 つだけなので、最悪でも誤読は 1 つ違いにとどまる。
  • K-map:列與行都依格雷碼順序排列,因此在圈選最小項時,實體上的相鄰就等於邏輯上的相鄰。
  • K-maps: rows/columns are in Gray order so physical adjacency = logical adjacency for grouping minterms.
  • K-map:行と列がグレイ順に並んでいるので、最小項をまとめるとき物理的な隣接がそのまま論理的な隣接になる。
  • 非同步 FIFO/跨時脈域:計數器採用格雷碼,因此取樣到的值一定是「目前的計數」或「下一個計數」,絕不會是介於兩者之間的垃圾值。
  • Asynchronous FIFOs / clock-domain crossing: counters use Gray code so a sampled value is always either "this count" or "next count", never garbage in-between.
  • 非同期 FIFO/クロックドメイン交差:カウンタにグレイ符号を使うので、サンプルした値は必ず「今のカウント」か「次のカウント」のどちらかであり、その中間のゴミ値になることはない。
  • 功耗/EMI:每次遞增的位元轉換次數較少 → 切換雜訊也較低。
  • Power / EMI: fewer bit transitions per increment → less switching noise.
  • 電力/EMI:1 回の増加あたりのビット遷移が少ない → スイッチングノイズが減る。

Conversion formulas:

  • 二進位 → 格雷碼:$G_i = B_i \oplus B_{i+1}$,其中 $G_{MSB} = B_{MSB}$。等價地寫成 $G = B \oplus (B \gg 1)$
  • Binary → Gray: $G_i = B_i \oplus B_{i+1}$, with $G_{MSB} = B_{MSB}$. Equivalently $G = B \oplus (B \gg 1)$.
  • 2 進 → グレイ:$G_i = B_i \oplus B_{i+1}$、ただし $G_{MSB} = B_{MSB}$。同じことを $G = B \oplus (B \gg 1)$ とも書ける。
  • 格雷碼 → 二進位:$B_{MSB} = G_{MSB}$,接著 $B_i = G_i \oplus B_{i+1}$(由 MSB 往下的累積 XOR)。
  • Gray → Binary: $B_{MSB} = G_{MSB}$, then $B_i = G_i \oplus B_{i+1}$ (cumulative XOR from MSB down).
  • グレイ → 2 進:$B_{MSB} = G_{MSB}$、続いて $B_i = G_i \oplus B_{i+1}$(MSB から下へ向かう累積 XOR)。
4.12困難Hard難しい第一階Tier 1ティア 1?R
證明夏農展開定理:$f(x_1,\ldots,x_n) = x_1 \cdot f(1,x_2,\ldots,x_n) + \overline{x_1} \cdot f(0,x_2,\ldots,x_n)$。
Prove Shannon's expansion theorem: $f(x_1,\ldots,x_n) = x_1 \cdot f(1,x_2,\ldots,x_n) + \overline{x_1} \cdot f(0,x_2,\ldots,x_n)$.
シャノンの展開定理 $f(x_1,\ldots,x_n) = x_1 \cdot f(1,x_2,\ldots,x_n) + \overline{x_1} \cdot f(0,x_2,\ldots,x_n)$ を証明せよ。
4.13中等Medium普通第一階Tier 1ティア 1E?R
Design a $2\times 2$ crossbar switch using 2-to-1 multiplexers. The circuit has inputs $x_1,x_2$, outputs $y_1,y_2$, and a control signal $s$ such that $s=0$ connects $x_1\to y_1$, $x_2\to y_2$ and $s=1$ swaps the connections.
背景:什麼是 2×2 交叉開關?Context: what is a 2×2 crossbar switch?背景:2×2 クロスバスイッチとは何か?

交叉開關 (crossbar switch) 是一種網路元件,能把任一輸入繞送到任一輸出,就像數位版的「跳線盤」。最簡單而不平凡的情形是 2×2 交叉開關:兩個輸入($x_1, x_2$)、兩個輸出($y_1, y_2$),以及一個在兩種連接樣式之間做選擇的控制位元 $s$:

A crossbar switch is a network element that lets any input be routed to any output, like a digital "patch panel". The simplest non-trivial case is the 2×2 crossbar: two inputs ($x_1, x_2$), two outputs ($y_1, y_2$), and one control bit $s$ that picks between two connection patterns:

クロスバスイッチ (crossbar switch) は、任意の入力を任意の出力へ回せるネットワーク要素であり、デジタル版の「パッチパネル」のようなものである。最も簡単で自明でない場合が 2×2 クロスバである:入力 2 本($x_1, x_2$)、出力 2 本($y_1, y_2$)、そして 2 通りの接続パターンを選ぶ制御ビット $s$ が 1 本。

$s$繞線routing経路$y_1$$y_2$
0straight (pass-through)$x_1$$x_2$
1crossed (swap)$x_2$$x_1$

兩種繞送樣式的電路圖:

Schematic of the two routing patterns:

2 通りの経路パターンの回路図:

s = 0 (pass-through)x₁x₂y₁ = x₁y₂ = x₂s = 1 (swap / crossed)x₁x₂y₁ = x₂y₂ = x₁

Boolean expressions:

$y_1 = \overline{s}\,x_1 + s\,x_2 \;=\; \mathrm{MUX2}(s; x_1, x_2)$

$y_2 = \overline{s}\,x_2 + s\,x_1 \;=\; \mathrm{MUX2}(s; x_2, x_1)$

每個輸出都是一個 2-to-1 MUX:$s=0$ 時選「直通」的輸入,$s=1$ 時選「交叉」的輸入。總共兩個 MUX。

Each output is a 2-to-1 MUX: when $s=0$ pick the "straight" input, when $s=1$ pick the "crossed" input. Two MUXes total.

各出力は 2-to-1 MUX である:$s=0$ なら「ストレート」の入力を、$s=1$ なら「クロス」の入力を選ぶ。MUX は全部で 2 個である。

Block diagram:

x₁ s x₂ MUX2 y₁ MUX2 y₂

每個 MUX 的上方資料線直接接自 $x_i$,下方資料線則橫接自 $x_j$。單一控制訊號 $s$ 會同時翻轉兩個 MUX。

Each MUX has its top data line wired straight from $x_i$ and its bottom data line wired across from $x_j$. The single control $s$ flips both MUXes simultaneously.

各 MUX の上側のデータ線は $x_i$ から直結され、下側のデータ線は $x_j$ から横に渡される。制御信号 $s$ 1 本で両方の MUX が同時に切り替わる。

Verilog:

module crossbar_2x2 (
  input  x1, x2, s,
  output y1, y2
);
  assign y1 = s ? x2 : x1;
  assign y2 = s ? x1 : x2;
endmodule

為什麼重要。交叉開關可以擴充成 $n \times n$ 的網路(用於 CPU 暫存器檔案、多處理器記憶體網路、network-on-chip 路由器)。一個 $n \times n$ 交叉開關需要 $n$ 個並列的 $n$-to-1 MUX — 雖然是無阻塞的,但規模是 $O(n^2)$,因此較大的 $n$ 會改用多級網路(Clos、Beneš)。

Why it matters. Crossbar switches scale up to $n \times n$ networks (used in CPU register files, multiprocessor memory networks, network-on-chip routers). An $n \times n$ crossbar takes $n$ parallel $n$-to-1 MUXes — non-blocking but $O(n^2)$ in size, hence the use of multistage networks (Clos, Beneš) for larger $n$.

なぜ重要か。クロスバスイッチは $n \times n$ のネットワークへ拡張できる(CPU のレジスタファイル、マルチプロセッサのメモリネットワーク、network-on-chip のルータなどで使われる)。$n \times n$ クロスバには $n$ 並列の $n$-to-1 MUX が要る — ノンブロッキングだが規模は $O(n^2)$ なので、$n$ が大きい場合は多段ネットワーク(Clos、Beneš)が使われる。

4.14簡單Easy易しい第一階Tier 1ティア 1E?R
Implement the three-input majority function using a single 4-to-1 multiplexer. Choose $w_1$ and $w_2$ as the select inputs and determine the data inputs as functions of $w_3$.
背景:什麼是三輸入多數決函數?Context: what is the three-input majority function?背景:3 入力の多数決関数とは何か。

三輸入多數決函數 $M(w_1, w_2, w_3)$ 在三個輸入中至少有兩個為 1 時輸出 1,否則輸出 0。它是「多數表決」的布林版本:每個輸入是一張贊成/反對票,輸出就是勝出的那一方。

The three-input majority function $M(w_1, w_2, w_3)$ outputs 1 when at least two of the three inputs are 1, and 0 otherwise. It's the Boolean version of "majority vote": each input is a yes/no vote, the output is the winning side.

3 入力の多数決関数 $M(w_1, w_2, w_3)$ は、3 入力のうち少なくとも 2 つが 1 のとき 1 を、それ以外では 0 を出力する。「多数決」のブール版であり、各入力が賛成/反対の 1 票、出力が勝った側にあたる。

Truth table:

$w_1$$w_2$$w_3$$M$說明commentコメント
0000沒有票投給 1no votes for 11 への票がない
0010只有一票only one vote票が 1 つだけ
0100只有一票only one vote票が 1 つだけ
0111two votes
1000只有一票only one vote票が 1 つだけ
1011two votes
1101two votes
1111all three

布林表示式(最小 SOP):

Boolean expression (minimum SOP):

ブール式(最小 SOP):

$M = w_1 w_2 + w_1 w_3 + w_2 w_3$   必背$M = w_1 w_2 + w_1 w_3 + w_2 w_3$   memorise this$M = w_1 w_2 + w_1 w_3 + w_2 w_3$   要暗記

(任何一對 1 都會使 $M=1$ — 三個 2 輸入 AND 項再 OR 起來)。

(any pair of 1s makes $M=1$ — three 2-input AND terms ORed together).

(どの 1 の対でも $M=1$ になる — 2 入力の AND 項 3 つを OR で結んだ形である)。

4-to-1 MUX 的實作策略。把 $w_1, w_2$ 當作選擇輸入($s_1 s_0 = w_1 w_2$)。每一種選擇樣式下的 MUX 輸出就是真值表所要求的值,並以 $w_3$ 為參數:

4-to-1 MUX implementation strategy. Use $w_1, w_2$ as select inputs ($s_1 s_0 = w_1 w_2$). The MUX output for each select pattern is whatever the truth table dictates, parameterized by $w_3$:

4-to-1 MUX による実装の方針。$w_1, w_2$ を選択入力とする($s_1 s_0 = w_1 w_2$)。各選択パターンでの MUX 出力は真理値表が定めるとおりであり、$w_3$ をパラメータとして表される:

$w_1 w_2$MUX 線路MUX lineMUX の線$w_3{=}0$ 時的 $M$$M$ when $w_3{=}0$$w_3{=}0$ のときの $M$$w_3{=}1$ 時的 $M$$M$ when $w_3{=}1$$w_3{=}1$ のときの $M$資料輸入data inputデータ入力
00$I_0$000
01$I_1$01$w_3$
10$I_2$01$w_3$
11$I_3$111

結果:接上 $I_0 = 0$、$I_1 = I_2 = w_3$、$I_3 = 1$。無論輸入的 $(w_1, w_2, w_3)$ 為何,這個 4-to-1 MUX 都會自動產生多數決輸出。

Result: connect $I_0 = 0$, $I_1 = I_2 = w_3$, $I_3 = 1$. The 4-to-1 MUX automatically produces the majority output for whatever $(w_1, w_2, w_3)$ comes in.

結果:$I_0 = 0$、$I_1 = I_2 = w_3$、$I_3 = 1$ とつなぐ。$(w_1, w_2, w_3)$ がどう入ってきても、4-to-1 MUX が自動的に多数決の出力を作る。

多數決為何有趣:它是「投票」/「故障遮蔽」類函數的典型例子 — 用於三重模組冗餘 (TMR),把同一訊號的三份副本拿來表決,以遮蔽單一故障。它也是經典的 K-map 例題,因為其質蘊涵項 SOP 形式沒有靜態冒險。

Why majority is interesting: it's the canonical example of a "voting" / "fault-masking" function — used in triple-modular redundancy (TMR), where three copies of a signal are voted on to mask a single fault. Also a classic K-map example because its prime-implicant SOP form has no static hazards.

多数決が興味深い理由:「投票」「故障マスキング」型の関数の代表例だからである — 三重モジュール冗長 (TMR) で、同じ信号の 3 つの複製を多数決にかけて単一故障を隠すのに使われる。主項による SOP 形に静的ハザードがないことから、K-map の古典的な例題でもある。

4.15中等Medium普通第一階Tier 1ティア 1E?R
只用 2-to-1 多工器實作三輸入 XOR 函數 $f = w_1 \oplus w_2 \oplus w_3$,利用 $w_2 \oplus w_3$ 可由 $w_1$ 選擇這一點。這個概念非常重要
Implement the three-input XOR function $f = w_1 \oplus w_2 \oplus w_3$ using only 2-to-1 multiplexers, exploiting that $w_2 \oplus w_3$ can be selected by $w_1$. the concept is very important
$w_2 \oplus w_3$ を $w_1$ で選択できることを利用し、2-to-1 マルチプレクサだけで 3 入力 XOR 関数 $f = w_1 \oplus w_2 \oplus w_3$ を実装せよ。この概念は非常に重要である
4.16中等Medium普通第一階Tier 1ティア 1E?R
對 $f = \overline{w_1}\overline{w_3}+w_2 w_3$,依序針對 $w_1$、$w_2$、$w_3$ 各做一次夏農展開,並指出哪一個展開變數會產生成本最低的電路。
For $f = \overline{w_1}\overline{w_3}+w_2 w_3$, perform Shannon's expansion with respect to each of $w_1$, $w_2$, and $w_3$ in turn, and identify which expansion variable produces the lowest-cost circuit.
$f = \overline{w_1}\overline{w_3}+w_2 w_3$ について、$w_1$、$w_2$、$w_3$ のそれぞれを軸にシャノン展開を順に行い、どの展開変数が最もコストの低い回路を与えるかを示せ。
4.17中等Medium普通第一階Tier 1ティア 1E?R
用 (a) 單一個 2-to-1 多工器加上其他閘,以及 (b) 單一個 4-to-1 多工器,實作 $f = \overline{w_1}\overline{w_3} + w_1 w_2 + w_1 w_3$。兩個電路都以夏農展開推導。
Implement $f = \overline{w_1}\overline{w_3} + w_1 w_2 + w_1 w_3$ using (a) a single 2-to-1 multiplexer plus other gates and (b) a single 4-to-1 multiplexer. Use Shannon's expansion to derive both circuits.
$f = \overline{w_1}\overline{w_3} + w_1 w_2 + w_1 w_3$ を (a) 2-to-1 マルチプレクサ 1 個とその他のゲート、(b) 4-to-1 マルチプレクサ 1 個で実装せよ。どちらの回路もシャノン展開から導くこと。
4.18中等Medium普通第一階Tier 1ティア 1E?R
對三輸入多數決函數套用兩次夏農展開(先對 $w_1$,再在各個餘因子內對 $w_2$),只用 2-to-1 多工器實作。
Implement the three-input majority function using only 2-to-1 multiplexers by applying Shannon's expansion twice (first on $w_1$, then on $w_2$ within each cofactor).
3 入力の多数決関数にシャノン展開を 2 回(まず $w_1$、次に各コファクタ内で $w_2$)適用し、2-to-1 マルチプレクサだけで実装せよ。
4.19中等Medium普通第一階Tier 1ティア 1E?R
說明如何用一個 2-to-4 解碼器(致能固定為高)加上單一個 OR 閘建構 4-to-1 多工器;該 OR 閘結合各解碼器輸出與對應資料輸入的 AND。
Show how a 4-to-1 multiplexer can be built from a 2-to-4 decoder (with enable held high) plus a single OR gate combining the AND of each decoder output with the corresponding data input.
イネーブルを High に固定した 2-to-4 デコーダと、各デコーダ出力と対応するデータ入力の AND をまとめる OR ゲート 1 個から、4-to-1 マルチプレクサを構成する方法を示せ。
4.20簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫一個 Verilog 模組 mux2to1,輸入為 w0w1s,輸出為 f,使用連續指定 assign 搭配條件運算子 ?:
Write a Verilog module mux2to1 with inputs w0, w1, s and output f, using a continuous assign with the conditional operator ?:.
入力 w0w1s、出力 f をもつ Verilog モジュール mux2to1 を、条件演算子 ?: を用いた継続的代入 assign で書け。
4.21簡單Easy易しい第一階Tier 1ティア 1E?R
always 區塊內使用 if-else 敘述,撰寫 2-to-1 多工器的 Verilog 程式碼。
Write a Verilog module for a 2-to-1 multiplexer using an if-else statement inside an always block.
always ブロック内の if-else 文を用いて、2-to-1 マルチプレクサの Verilog コードを書け。
4.22中等Medium普通第一階Tier 1ティア 1E?R
撰寫 16-to-1 多工器的階層式 Verilog 程式碼,實體化五個 4-to-1 多工器模組。使用 16 位元資料向量 $W$ 與 4 位元選擇向量 $S$。
Write hierarchical Verilog code for a 16-to-1 multiplexer that instantiates five 4-to-1 multiplexer modules. Use a 16-bit data vector $W$ and a 4-bit select vector $S$.
4-to-1 マルチプレクサモジュールを 5 個インスタンス化する 16-to-1 マルチプレクサの階層的な Verilog コードを書け。16 ビットのデータベクタ $W$ と 4 ビットの選択ベクタ $S$ を用いること。
4.23簡單Easy易しい第一階Tier 1ティア 1E?R
always 區塊內使用 case 敘述,撰寫 4-to-1 多工器的 Verilog 程式碼,選擇向量 $S$ 為 2 位元。
Write Verilog code for a 4-to-1 multiplexer using a case statement inside an always block, with a 2-bit select vector $S$.
always ブロック内の case 文を用い、2 ビットの選択ベクタ $S$ をもつ 4-to-1 マルチプレクサの Verilog コードを書け。
4.24中等Medium普通第一階Tier 1ティア 1E?R
撰寫帶致能輸入 En 的 2-to-4 二進位解碼器的 Verilog 程式碼,對串接 {En, W} 使用 case 敘述。
Write Verilog code for a 2-to-4 binary decoder with an enable input En, using a case statement on the concatenation {En, W}.
イネーブル入力 En 付き 2-to-4 バイナリデコーダの Verilog コードを、連結 {En, W} に対する case 文で書け。
4.25中等Medium普通第一階Tier 1ティア 1E?R
結合 if-else(處理致能)與 case 敘述(處理輸入樣式),撰寫 2-to-4 二進位解碼器的 Verilog 程式碼。
Write Verilog code for a 2-to-4 binary decoder using a combination of if-else (for the enable) and a case statement (for the input pattern).
if-else(イネーブル用)と case 文(入力パターン用)を組み合わせて、2-to-4 バイナリデコーダの Verilog コードを書け。
4.26中等Medium普通第一階Tier 1ティア 1E?R
撰寫 4-to-16 解碼器的階層式 Verilog 程式碼,以五個 2-to-4 解碼器構成樹狀結構。重要技巧
Write hierarchical Verilog code for a 4-to-16 decoder built as a tree of five 2-to-4 decoders. important trick
2-to-4 デコーダ 5 個の木構造として構成した 4-to-16 デコーダの階層的な Verilog コードを書け。重要なテクニック
4.27中等Medium普通第一階Tier 1ティア 1E?R
撰寫一個 Verilog 模組 seg7,實作十六進位轉七段顯示器解碼器。4 位元輸入為 hex,7 位元輸出為 leds;使用 case 敘述列出全部 16 種樣式。
Write a Verilog module seg7 that implements a hexadecimal-to-7-segment display decoder. The 4-bit input is hex and the 7-bit output is leds; use a case statement listing all 16 patterns.
16 進数から 7 セグメント表示へのデコーダを実装する Verilog モジュール seg7 を書け。4 ビット入力は hex、7 ビット出力は leds とし、case 文で 16 通りのパターンをすべて列挙すること。
4.28困難Hard難しい第一階Tier 1ティア 1E?R
撰寫仿照 74381 晶片的 4 位元 ALU 的 Verilog 程式碼,具有 3 位元選擇 $S$、4 位元運算元 $A$ 與 $B$,以及 4 位元輸出 $F$。實作清除、$B-A$、$A-B$、$A+B$、$A\oplus B$、$A|B$、$A\&B$ 與預設為 1111。
Write Verilog code for a 4-bit ALU modeled on the 74381 chip, with 3-bit select $S$, 4-bit operands $A$ and $B$, and a 4-bit output $F$. Implement clear, $B-A$, $A-B$, $A+B$, $A\oplus B$, $A|B$, $A\&B$, and preset-to-1111.
74381 チップを模した 4 ビット ALU の Verilog コードを書け。3 ビットの選択 $S$、4 ビットのオペランド $A$ と $B$、4 ビット出力 $F$ をもつ。クリア、$B-A$、$A-B$、$A+B$、$A\oplus B$、$A|B$、$A\&B$、および 1111 へのプリセットを実装せよ。
4.29中等Medium普通第一階Tier 1ティア 1E?R
使用 casex 敘述撰寫 4 輸入優先權編碼器的 Verilog 程式碼,把較低優先權的位元視為 don't-care。並提供有效輸出旗標 $z$。
Write Verilog code for a 4-input priority encoder using a casex statement that treats lower-priority bits as don't-cares. Provide a valid output flag $z$.
casex 文を使い、優先度の低いビットを don't-care として扱う 4 入力プライオリティエンコーダの Verilog コードを書け。有効出力フラグ $z$ も設けること。
4.30中等Medium普通第一階Tier 1ティア 1E?R
以走訪四個輸出位置的 for 迴圈撰寫 2-to-4 解碼器的 Verilog 程式碼,當 $W=k$ 且 $\text{En}=1$ 時令 $Y[k]=1$。
Write Verilog code for a 2-to-4 decoder using a for loop that iterates over the four output positions, asserting $Y[k]=1$ when $W=k$ and $\text{En}=1$.
4 つの出力位置を走査する for ループを使って 2-to-4 デコーダの Verilog コードを書け。$W=k$ かつ $\text{En}=1$ のとき $Y[k]=1$ をアサートする。
4.31中等Medium普通第一階Tier 1ティア 1E?R
使用 for 迴圈撰寫 4 輸入優先權編碼器的 Verilog 程式碼。善用以下性質:在 always 區塊中,對同一變數的多次指定會保留最後一次指定,因此優先權最高的輸入勝出。
Write Verilog code for a 4-input priority encoder using a for loop. Exploit the fact that, in an always block, multiple assignments to the same variable retain the last assignment, so the highest priority input wins.
for ループを使って 4 入力プライオリティエンコーダの Verilog コードを書け。always ブロック内では同じ変数への複数回の代入のうち最後の代入が残るという性質を利用し、最も優先度の高い入力が勝つようにする。
4.32中等Medium普通第一階Tier 1ティア 1E?R
撰寫 4 位元大小比較器的 Verilog 程式碼,在 if-else 串鏈中使用關係運算子(==><)來驅動輸出 AeqBAgtBAltB
Write Verilog code for a 4-bit magnitude comparator that uses the relational operators (==, >, <) inside an if-else chain to drive outputs AeqB, AgtB, AltB.
if-else の連鎖の中で関係演算子(==><)を用いて出力 AeqBAgtBAltB を駆動する 4 ビット大小比較器の Verilog コードを書け。
4.33困難Hard難しい第一階Tier 1ティア 1E?R
使用 Verilog 的 generate 建構搭配 for 迴圈與閘級基本元件,描述一個 $n$ 位元漣波進位加法器。請使用 genvar 索引並將 $n$ 參數化。
Use the Verilog generate construct with a for loop and gate-level primitives to specify an $n$-bit ripple-carry adder. Use a genvar index and parameterize $n$.
Verilog の generate 構文と for ループ、そしてゲートレベルのプリミティブを使って $n$ ビットのリップルキャリー加算器を記述せよ。genvar の索引を用い、$n$ をパラメータ化すること。
4.34中等Medium普通第一階Tier 1ティア 1E?R
以 Verilog task 實作內層的 4-to-1 多工器,並從 always 區塊內的 case 敘述呼叫,重新實作範例 4.10 的階層式 16-to-1 多工器。— example 4.10
Re-implement the hierarchical 16-to-1 multiplexer of Example 4.10 using a Verilog task for the inner 4-to-1 multiplexer, called from a case statement inside an always block.— example 4.10
例題 4.10 の階層的な 16-to-1 マルチプレクサを、内側の 4-to-1 マルチプレクサを Verilog の task として書き、always ブロック内の case 文から呼び出す形で再実装せよ。— example 4.10
4.35中等Medium普通第一階Tier 1ティア 1E?R
改用 Verilog function(而非 task)重新實作這個 16-to-1 多工器。並說明它與 task 版本在語法與語意上的差異。
Re-implement the 16-to-1 multiplexer using a Verilog function rather than a task. Explain the syntactic and semantic differences from the task-based version.
この 16-to-1 マルチプレクサを、task ではなく Verilog の function を使って再実装せよ。task 版との構文上・意味上の違いを説明せよ。
4.36中等Medium普通第一階Tier 1ティア 1E?R
使用一個 3-to-8 二進位解碼器與單一個 OR 閘實作 $f(w_1,w_2,w_3) = \sum m(0,1,3,4,6,7)$。
Implement $f(w_1,w_2,w_3) = \sum m(0,1,3,4,6,7)$ using a 3-to-8 binary decoder and a single OR gate.
3-to-8 バイナリデコーダ 1 個と OR ゲート 1 個で $f(w_1,w_2,w_3) = \sum m(0,1,3,4,6,7)$ を実現せよ。
4.37中等Medium普通第一階Tier 1ティア 1E?R
設計一個 8-to-3 二進位編碼器。假設同一時間只有一個輸入被 assert,並寫出真值表以及 $y_2$、$y_1$、$y_0$ 的最簡 SOP 表示式。
Design an 8-to-3 binary encoder. Assume only one input is asserted at a time and write the truth table along with minimum SOP expressions for $y_2$, $y_1$, $y_0$.
8-to-3 バイナリエンコーダを設計せよ。同時にアサートされる入力は 1 本だけと仮定し、真理値表と $y_2$、$y_1$、$y_0$ の最簡 SOP 式を書け。
4.38困難Hard難しい第一階Tier 1ティア 1E?R
使用單一個 4-to-1 多工器(選擇線為 $w_1, w_4$)並盡可能少用額外的閘,實作 $f(w_1,\ldots,w_5) = \overline{w_1}\,\overline{w_2}\,w_4 w_5 + w_1\overline{w_2} + w_1 w_3 + w_1 w_4 + w_3 w_4 w_5$。假設只有未取補數的輸入可用。
Implement $f(w_1,\ldots,w_5) = \overline{w_1}\,\overline{w_2}\,w_4 w_5 + w_1\overline{w_2} + w_1 w_3 + w_1 w_4 + w_3 w_4 w_5$ using a single 4-to-1 multiplexer (selects $w_1, w_4$) and as few additional gates as possible. Assume only uncomplemented inputs are available.
4-to-1 マルチプレクサ 1 個(選択入力は $w_1, w_4$)と、できるだけ少ない追加ゲートで $f(w_1,\ldots,w_5) = \overline{w_1}\,\overline{w_2}\,w_4 w_5 + w_1\overline{w_2} + w_1 w_3 + w_1 w_4 + w_3 w_4 w_5$ を実現せよ。入力は非反転のものしか使えないものとする。
4.39中等Medium普通第一階Tier 1ティア 1E?R
依照表格 $b_2 b_1 b_0 \to g_2 g_1 g_0$ 設計一個 3 位元二進位轉格雷碼轉換器。證明 $g_2 = b_2$、$g_1 = b_1 \oplus b_2$、$g_0 = b_0 \oplus b_1$。
Design a 3-bit binary-to-Gray code converter according to the table $b_2 b_1 b_0 \to g_2 g_1 g_0$. Show that $g_2 = b_2$, $g_1 = b_1 \oplus b_2$, $g_0 = b_0 \oplus b_1$.
表 $b_2 b_1 b_0 \to g_2 g_1 g_0$ に従って 3 ビットの 2 進 - グレイ符号変換器を設計せよ。$g_2 = b_2$、$g_1 = b_1 \oplus b_2$、$g_0 = b_0 \oplus b_1$ となることを示せ。
4.40中等Medium普通第一階Tier 1ティア 1E?R
一個 4 輸入函數 $f$ 已對 $w_1$ 做 Shannon 展開,得到餘因子 $f_{w_1}$ 與 $f_{\overline{w_1}}$。證明在 (a) $f_{\overline{w_1}}=0$ 與 (b) $f_{\overline{w_1}}=1$ 兩種情況下,Shannon 展開電路中的多工器都可以用單一個邏輯閘取代。
A 4-input function $f$ has been Shannon-expanded with respect to $w_1$, giving cofactors $f_{w_1}$ and $f_{\overline{w_1}}$. Show that the multiplexer in the Shannon-expansion circuit can be replaced by a single logic gate (a) when $f_{\overline{w_1}}=0$ and (b) when $f_{\overline{w_1}}=1$.
4 入力関数 $f$ を $w_1$ について Shannon 展開し、コファクタ $f_{w_1}$ と $f_{\overline{w_1}}$ を得た。Shannon 展開回路のマルチプレクサが、(a) $f_{\overline{w_1}}=0$ のとき、および (b) $f_{\overline{w_1}}=1$ のときに、それぞれ 1 個の論理ゲートで置き換えられることを示せ。
4.41困難Hard難しい第一階Tier 1ティア 1E?R
A commercial FPGA uses 4-input lookup tables (4-LUTs). Determine the minimum number of 4-LUTs needed to construct a 4-to-1 multiplexer with select inputs $s_1, s_0$ and data inputs $w_3, w_2, w_1, w_0$. Show both a straightforward 3-LUT solution and an optimized 2-LUT solution.
LUT (Look-Up Table) — 查找表是什麼?LUT (Look-Up Table) — what is a look-up table?LUT (Look-Up Table) — ルックアップテーブルとは何か?

定義。一個 $k$-LUT 是 FPGA 的基本可程式邏輯單元,可以實作任何 $k$ 變數的 Boolean 函數。本質上就是一塊 $2^k$ 位元的小型 SRAM,把 $k$ 個輸入當成 address,讀出對應位置儲存的 1 bit 即為函數輸出。

Definition. A $k$-LUT is the basic programmable logic element of an FPGA and can implement any Boolean function of $k$ variables. It is essentially a small $2^k$-bit SRAM: the $k$ inputs act as an address, and the single bit read out of that location is the function output.

定義。$k$-LUT は FPGA の基本となるプログラマブル論理素子で、$k$ 変数の任意のブール関数を実装できる。実体は $2^k$ ビットの小さな SRAM であり、$k$ 本の入力をアドレスとして、その番地から読み出した 1 ビットがそのまま関数の出力になる。

結構 (3-LUT 為例):Structure (using a 3-LUT as the example):構造(3-LUT を例に):

SRAM (8 bits) b₀ b₁ b₂ b₃ b₄ b₅ b₆ b₇ 8-to-1 MUX f x₁ x₂ x₃ SRAM bits: b₀ = f(0,0,0) b₁ = f(1,0,0) b₂ = f(0,1,0) b₇ = f(1,1,1)

$k$ 個輸入接到 $2^k$-to-1 MUX 的 select,$2^k$ 個 SRAM 位元接到 MUX 的資料輸入。Programming 時把目標函數的真值表寫入 SRAM;runtime 時 MUX 依輸入位址選出對應位元當作輸出。

The $k$ inputs drive the select lines of a $2^k$-to-1 MUX, and $2^k$ SRAM bits drive its data inputs. At programming time the target function's truth table is written into the SRAM; at runtime the MUX selects the addressed bit as the output.

$k$ 本の入力が $2^k$-to-1 MUX の select を駆動し、$2^k$ 個の SRAM ビットがそのデータ入力につながる。プログラム時に目的の関数の真理値表を SRAM へ書き込み、実行時には MUX がアドレスされたビットを選んで出力する。

具體例子: 要實作 $g(x_1, x_2, x_3) = x_1 x_2 + \overline{x_3}$,真值表為:

Concrete example: to implement $g(x_1, x_2, x_3) = x_1 x_2 + \overline{x_3}$, the truth table is:

具体例:$g(x_1, x_2, x_3) = x_1 x_2 + \overline{x_3}$ を実装するとき、真理値表は次のようになる:

$x_3 x_2 x_1$$g$SRAM 位元SRAM bitSRAM ビット
0001b₀ = 1
0011b₁ = 1
0101b₂ = 1
0111b₃ = 1
1000b₄ = 0
1010b₅ = 0
1100b₆ = 0
1111b₇ = 1

把 8 個位元 1,1,1,1,0,0,0,1 寫入 SRAM,這顆 3-LUT 就「成為」函數 $g$。同一顆硬體要改實作別的函數,只需 reprogram SRAM 內容。

Write the eight bits 1,1,1,1,0,0,0,1 into the SRAM and this 3-LUT “becomes” the function $g$. To make the same hardware implement a different function, you only reprogram the SRAM contents.

8 ビット 1,1,1,1,0,0,0,1 を SRAM に書き込めば、この 3-LUT は関数 $g$ に「なる」。同じハードウェアで別の関数を実装したければ、SRAM の内容を書き換えるだけでよい。

關鍵特性:Key properties:重要な性質:

  • 通用性 (universality): 一個 $k$-LUT 可實作 $2^{2^k}$ 種不同的 $k$ 變數函數 — 真值表寫什麼,輸出就是什麼,跟函數的「複雜度」(SOP 字數、AND/OR 數量) 無關。
  • Universality: one $k$-LUT can implement all $2^{2^k}$ functions of $k$ variables — the output is whatever the truth table says, independent of how “complex” the function is (number of SOP terms, count of ANDs/ORs).
  • 万能性 (universality):1 個の $k$-LUT は $k$ 変数の関数 $2^{2^k}$ 種すべてを実装できる — 出力は真理値表に書いたとおりであり、関数の「複雑さ」(SOP の項数、AND/OR の個数)とは無関係である。
  • 固定面積: 不管函數複雜或簡單,LUT 都佔同樣 $2^k$ bits 的儲存 + 一個 $2^k$-to-1 MUX,硬體成本固定。
  • Fixed area: complex or simple, a LUT always costs the same $2^k$ bits of storage plus one $2^k$-to-1 MUX. The hardware cost is constant.
  • 面積が一定:関数が複雑でも単純でも、LUT は同じ $2^k$ ビットの記憶と $2^k$-to-1 MUX 1 個を消費する。ハードウェアコストは一定である。
  • 輸入數限制: 函數變數數 $> k$ 時,單顆 LUT 放不下,必須分解成多顆 LUT 接力 (cascading) — 這就是 functional decomposition 在 FPGA 設計上的直接應用。
  • Input-count limit: when a function has more than $k$ variables it will not fit in a single LUT and must be decomposed across cascaded LUTs — the direct application of functional decomposition to FPGA design.
  • 入力数の制限:関数の変数が $k$ 個を超えると 1 個の LUT には収まらず、複数の LUT へ分解して縦続接続 (cascading) しなければならない — 関数分解の FPGA 設計への直接的な応用である。

FPGA 中的角色:Role in an FPGA:FPGA における役割:

  • 現代商用 FPGA 通常用 4-LUT(早期)或 6-LUT(Xilinx Virtex/Zynq、Intel Cyclone V/Stratix 等)為基本邏輯區塊。
  • Modern commercial FPGAs use 4-LUTs (older parts) or 6-LUTs (Xilinx Virtex/Zynq, Intel Cyclone V/Stratix and so on) as the basic logic element.
  • 現在の商用 FPGA は基本論理素子として 4-LUT(旧世代)または 6-LUT(Xilinx Virtex/Zynq、Intel Cyclone V/Stratix など)を用いる。
  • 編譯流程: HDL → 邏輯合成 (gate-level netlist) → technology mapping (把通用 gate 改寫成 LUT 形式) → placement → routing。
  • Compilation flow: HDL → logic synthesis (gate-level netlist) → technology mapping (rewriting generic gates into LUT form) → placement → routing.
  • コンパイルの流れ:HDL → 論理合成(gate-level netlist)→ technology mapping(汎用ゲートを LUT の形へ書き換える)→ placement → routing。
  • 每個 LUT 通常配有一個 D flip-flop,合稱一個 logic cell;許多 logic cell 又組成一個 logic block (CLB / LAB / ALM 視廠商而定)。
  • Each LUT is usually paired with a D flip-flop, together forming a logic cell; many logic cells make up a logic block (CLB / LAB / ALM, depending on the vendor).
  • 各 LUT にはふつう D フリップフロップが 1 個組み合わされ、合わせて logic cell となる。多数の logic cell が集まって logic block(ベンダによって CLB / LAB / ALM)を構成する。

本題 (4.41) 的應用: 4-to-1 MUX 共有 6 個輸入 ($s_1, s_0$ + $w_3, w_2, w_1, w_0$),但每顆 4-LUT 只能容納 4 個輸入。直觀做法 — 把 MUX 看成 $f = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1 + s_1\overline{s_0}w_2 + s_1 s_0 w_3$:先用兩顆 4-LUT 各算一半 (例如一顆做 $\overline{s_1}$ 那半:輸入 $s_0, w_0, w_1$ 共 3 個,輸出半結果;另一顆做 $s_1$ 那半:輸入 $s_0, w_2, w_3$),再用第三顆 4-LUT 用 $s_1$ 選擇兩半。共 3 顆 LUT。優化做法:利用 LUT 結構直接實作 $\text{MUX}(s_1, h_0, h_1)$,其中 $h_0, h_1$ 由前一級 LUT 算好,合併共用變數,可降到 2 顆 4-LUT。

Application to this problem (4.41): a 4-to-1 MUX has six inputs in total ($s_1, s_0$ plus $w_3, w_2, w_1, w_0$), but each 4-LUT holds only four. The straightforward approach — viewing the MUX as $f = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1 + s_1\overline{s_0}w_2 + s_1 s_0 w_3$: use two 4-LUTs for the two halves (one computes the $\overline{s_1}$ half from inputs $s_0, w_0, w_1$ — three inputs — and outputs a partial result; the other computes the $s_1$ half from $s_0, w_2, w_3$), then a third 4-LUT selects between the halves with $s_1$. Three LUTs in total. The optimised approach exploits the LUT structure to implement $\text{MUX}(s_1, h_0, h_1)$ directly, where $h_0, h_1$ come from the previous stage; sharing the common variables brings this down to two 4-LUTs.

本問 (4.41) への応用:4-to-1 MUX の入力は合計 6 本($s_1, s_0$ と $w_3, w_2, w_1, w_0$)だが、4-LUT 1 個に入るのは 4 本までである。素直なやり方 — MUX を $f = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1 + s_1\overline{s_0}w_2 + s_1 s_0 w_3$ とみなし、2 個の 4-LUT で半分ずつ計算する(一方は $\overline{s_1}$ 側を入力 $s_0, w_0, w_1$ の 3 本から求めて中間結果を出し、もう一方は $s_1$ 側を $s_0, w_2, w_3$ から求める)。そのうえで 3 個目の 4-LUT が $s_1$ で両者を選択する。合計 3 個の LUT である。最適化したやり方では LUT の構造を活かして $\text{MUX}(s_1, h_0, h_1)$ を直接実装する。ここで $h_0, h_1$ は前段の LUT が出したもので、共通変数を共有することで 4-LUT 2 個まで減らせる。

跟 ROM 與 PLA 的差別: 三者都用 memory-like 結構儲存真值表,但 ROM 通常輸入較多 (大型解碼)、輸出多位元、address space 大;PLA 是固定 AND-OR plane 的可程式陣列;LUT 是細粒度單輸出單元 ($k$ 通常 4–6),由大量 LUT 組合構成 FPGA 的可程式邏輯。

How it differs from ROM and PLA: all three store a truth table in a memory-like structure, but a ROM typically has many inputs (large decoders), multi-bit outputs and a large address space; a PLA is a programmable array with fixed AND-OR planes; a LUT is a fine-grained single-output element ($k$ is usually 4–6), and an FPGA's programmable logic is built from a large number of them.

ROM や PLA との違い:3 つとも真理値表をメモリ的な構造に格納する点は同じだが、ROM は入力数が多く(大規模なデコーダ)、出力も多ビットでアドレス空間が広い。PLA は AND-OR プレーンが固定されたプログラマブルアレイである。LUT は細粒度の単一出力素子($k$ はふつう 4–6)で、FPGA のプログラマブル論理はこれを大量に並べて構成される。

4.42中等Medium普通第一階Tier 1ティア 1E?R
使用五個 2-to-1 多工器設計一個 4 位元右移電路。控制訊號 Shift 在下列兩者間選擇:(a) 直接通過,$Y=W$、$k=0$;(b) 右移一位,$y_3=0$、$y_2=w_3$、$y_1=w_2$、$y_0=w_1$、$k=w_0$。
Design a 4-bit right-shift circuit using five 2-to-1 multiplexers. The control signal Shift selects between (a) pass-through $Y=W$, $k=0$ and (b) right-shift by one with $y_3=0$, $y_2=w_3$, $y_1=w_2$, $y_0=w_1$, $k=w_0$.
2-to-1 マルチプレクサ 5 個を使って 4 ビットの右シフト回路を設計せよ。制御信号 Shift は (a) そのまま通す $Y=W$、$k=0$ と、(b) 1 ビット右シフトして $y_3=0$、$y_2=w_3$、$y_1=w_2$、$y_0=w_1$、$k=w_0$ とする動作とを選択する。
4.43困難Hard難しい第一階Tier 1ティア 1E?R
Design a 4-bit barrel shifter that rotates the input vector $W$ by 0, 1, 2, or 3 positions according to a 2-bit control $S$. Implement the circuit using four 4-to-1 multiplexers.
背景:什麼是桶形移位器?Context: what is a barrel shifter?背景:バレルシフタとは何か?

桶形移位器 (barrel shifter) 是一種組合電路,不論移位量多少,都能在一個時脈週期內把 $n$ 位元的向量移位(或旋轉)任意量。與每個時脈只移動一個位置的循序移位暫存器不同,桶形移位器完全以組合邏輯完成整個移位 — 靠的是平行的多工器。

A barrel shifter is a combinational circuit that shifts (or rotates) an $n$-bit vector by any amount in one clock cycle, regardless of how many bits the shift is. Unlike a sequential shift register, which moves one position per clock, a barrel shifter performs the entire shift through pure combinational logic — exploiting parallel multiplexers.

バレルシフタ (barrel shifter) は、シフト量がいくつであっても $n$ ビットのベクタを1 クロックサイクルで任意量シフト(または回転)する組合せ回路である。1 クロックに 1 位置ずつ動かす順序式のシフトレジスタとは違い、バレルシフタはシフト全体を純粋な組合せ論理で行う — 並列なマルチプレクサを活用するのである。

Two flavors:

  • 旋轉式桶形移位器 — 從一端掉出的位元會從另一端回到序列中。輸出位元是輸入位元的循環排列。
  • Rotating barrel shifter — bits that fall off one end re-enter the other. Output bits are a cyclic permutation of input bits.
  • 回転型バレルシフタ — 片端からあふれたビットが反対端から入り直す。出力ビットは入力ビットの巡回置換になる。
  • 邏輯/算術移位桶形移位器 — 掉出的位元被丟棄;空出的位置補 0(邏輯移位)或補符號延伸(算術移位)。
  • Logical/Arithmetic shift barrel shifter — bits that fall off are discarded; vacated positions get 0 (logical) or sign-extension (arithmetic).
  • 論理/算術シフトバレルシフタ — あふれたビットは捨てられ、空いた位置には 0(論理)または符号拡張(算術)が入る。

習題 4.43 要求的是一個旋轉式 4 位元移位器($n=4$),移位量 $\{0,1,2,3\}$ 由 2 位元控制訊號 $S = s_1 s_0$ 選擇。

Problem 4.43 asks for a rotating 4-bit shifter ($n=4$) with shift amounts $\{0,1,2,3\}$ selected by a 2-bit control $S = s_1 s_0$.

問題 4.43 が求めているのは回転型の 4 ビットシフタ($n=4$)で、シフト量 $\{0,1,2,3\}$ を 2 ビットの制御 $S = s_1 s_0$ で選ぶ。

功能表(輸入 $W = w_3 w_2 w_1 w_0$,輸出 $Y = y_3 y_2 y_1 y_0$):

Functional table (input $W = w_3 w_2 w_1 w_0$, output $Y = y_3 y_2 y_1 y_0$):

機能表(入力 $W = w_3 w_2 w_1 w_0$、出力 $Y = y_3 y_2 y_1 y_0$):

$S$移位shiftシフト$y_3$$y_2$$y_1$$y_0$
000$w_3$$w_2$$w_1$$w_0$
011 right$w_0$$w_3$$w_2$$w_1$
102 right$w_1$$w_0$$w_3$$w_2$
113 right$w_2$$w_1$$w_0$$w_3$

每個輸出位元都需要一個 4-to-1 MUX,其資料輸入是四個候選來源位元,選擇訊號為 $S$。從表中往下讀每一個 $y_i$ 欄,就知道 MUX$_i$ 的資料輸入是什麼:

Each output bit needs a 4-to-1 MUX whose data inputs are the four candidate source bits and whose select is $S$. From the table, reading down each $y_i$ column tells you the data inputs to MUX$_i$:

各出力ビットには 4-to-1 MUX が 1 個必要で、そのデータ入力は候補となる 4 本のソースビット、選択入力は $S$ である。表の各 $y_i$ 列を上から下へ読めば、MUX$_i$ のデータ入力が分かる:

  • $y_3$ 的 MUX:$S = (00, 01, 10, 11)$ 對應的資料線為 $(w_3, w_0, w_1, w_2)$
  • MUX for $y_3$: data lines $(w_3, w_0, w_1, w_2)$ for $S = (00, 01, 10, 11)$
  • $y_3$ 用の MUX:$S = (00, 01, 10, 11)$ に対するデータ線は $(w_3, w_0, w_1, w_2)$
  • $y_2$ 的 MUX:資料線 $(w_2, w_3, w_0, w_1)$
  • MUX for $y_2$: data lines $(w_2, w_3, w_0, w_1)$
  • $y_2$ 用の MUX:データ線 $(w_2, w_3, w_0, w_1)$
  • $y_1$ 的 MUX:資料線 $(w_1, w_2, w_3, w_0)$
  • MUX for $y_1$: data lines $(w_1, w_2, w_3, w_0)$
  • $y_1$ 用の MUX:データ線 $(w_1, w_2, w_3, w_0)$
  • $y_0$ 的 MUX:資料線 $(w_0, w_1, w_2, w_3)$
  • MUX for $y_0$: data lines $(w_0, w_1, w_2, w_3)$
  • $y_0$ 用の MUX:データ線 $(w_0, w_1, w_2, w_3)$

規律:每個 MUX$_i$ 的資料輸入為 $(w_i, w_{(i-1)\bmod 4}, w_{(i-2)\bmod 4}, w_{(i-3)\bmod 4})$ — 正好是 $W$ 從位置 $i$ 開始的循環移位。

Pattern: each MUX$_i$ has data inputs $(w_i, w_{(i-1)\bmod 4}, w_{(i-2)\bmod 4}, w_{(i-3)\bmod 4})$ — exactly the cyclic shift of $W$ starting at position $i$.

法則:各 MUX$_i$ のデータ入力は $(w_i, w_{(i-1)\bmod 4}, w_{(i-2)\bmod 4}, w_{(i-3)\bmod 4})$ である — ちょうど位置 $i$ から始まる $W$ の巡回シフトになっている。

電路圖(四個共用同一 $S$ 的並列 4-to-1 MUX):

Schematic (four parallel 4-to-1 MUXes sharing the same $S$):

回路図(同じ $S$ を共有する 4 個の並列 4-to-1 MUX):

w₃ w₂ w₁ w₀w₃w₂w₁w₀MUX₃y₃w₃,w₀,w₁,w₂MUX₂y₂w₂,w₃,w₀,w₁MUX₁y₁w₁,w₂,w₃,w₀MUX₀y₀w₀,w₁,w₂,w₃S = s₁s₀

Verilog(可對任意 2 的冪次 $n$ 參數化):

Verilog (parameterized for any $n$ that is a power of 2):

Verilog(2 のべき乗である任意の $n$ に対してパラメータ化):

module barrel_rot4 (
  input  [3:0] W,
  input  [1:0] S,
  output [3:0] Y
);
  // each output is the input rotated right by S
  assign Y = (W >> S) | (W << (4 - S));
endmodule

`(W >> S) | (W << (4-S))` 這個式子是右旋轉的標準寫法:從低位移出去的位元,會經由反向移位從高位回來。合成工具會把它變成上面那四個 4-to-1 MUX。

The expression `(W >> S) | (W << (4-S))` is the canonical right-rotate idiom: bits shifted off the bottom re-enter at the top via the inverted shift. The synthesis tool will turn this into the four 4-to-1 MUXes shown above.

`(W >> S) | (W << (4-S))` という式は右回転の定石である:下位からあふれたビットが、逆向きのシフトによって上位から入り直す。合成ツールはこれを上に示した 4 個の 4-to-1 MUX に変える。

成本 & 深度。由 $n$ 個並列 $n$-to-1 MUX 建成的 $n$ 位元桶形旋轉器使用 $O(n^2)$ 個閘,延遲為一個 MUX。當 $n$ 較大時,改用對數式的多級桶形移位器(每個位元 $\log_2 n$ 級的 2-to-1 MUX)可把成本降到 $O(n \log n)$,代價是 $\log_2 n$ 個 MUX 延遲 — 這就是現代 CPU 中 ALU 移位器的標準設計。

Cost & depth. An $n$-bit barrel rotator built from $n$ parallel $n$-to-1 MUXes uses $O(n^2)$ gates and one MUX-delay. For larger $n$, a logarithmic multi-stage barrel shifter ($\log_2 n$ stages of 2-to-1 MUXes per bit) cuts cost to $O(n \log n)$ at the price of $\log_2 n$ MUX delays — the standard ALU shifter design in modern CPUs.

コスト & 段数。$n$ 並列の $n$-to-1 MUX で作った $n$ ビットのバレル回転器は $O(n^2)$ 個のゲートを使い、遅延は MUX 1 段分である。$n$ が大きい場合、対数段の多段バレルシフタ(1 ビットあたり 2-to-1 MUX を $\log_2 n$ 段)にすればコストは $O(n \log n)$ に下がるが、代わりに $\log_2 n$ 段分の MUX 遅延がかかる — 現代の CPU における ALU シフタの標準的な設計である。

4.44中等Medium普通第一階Tier 1ティア 1E?R
撰寫 Verilog 程式碼,用一個 2-to-4 解碼器(以 dec2to4 模組實體化)以及對「解碼器輸出與資料向量做 AND」所取的單一個縮減 OR,組成一個 4-to-1 多工器。
Write Verilog code that builds a 4-to-1 multiplexer from a 2-to-4 decoder (instantiated as a dec2to4 module) and a single reduction-OR over the AND of decoder outputs with the data vector.
2-to-4 デコーダ(dec2to4 モジュールとしてインスタンス化する)と、デコーダ出力とデータベクタの AND に対する 1 つのリダクション OR とから 4-to-1 マルチプレクサを構成する Verilog コードを書け。
4.45簡單Easy易しい第一階Tier 1ティア 1E?R
Write Verilog code for the 4-bit right-shifter of Example 4.30 in two styles: one using an if-else with explicit bit assignments, and another using the Verilog shift operator >>.
為什麼要用 >> 而不是逐位元明確指派?Why use >> instead of explicit bit assignments?明示的なビット代入ではなく >> を使うのはなぜか。

寫法 1 — 逐位元明確指派:

Style 1 — explicit bit assignments:

スタイル 1 — ビットごとの明示的な代入:

module shifter_if (input [3:0] R, input shift, output reg [3:0] Q);
    always @* begin
        if (shift) begin
            Q[3] = 1'b0;       // fill MSB with 0
            Q[2] = R[3];
            Q[1] = R[2];
            Q[0] = R[1];       // R[0] discarded
        end else
            Q = R;
    end
endmodule

寫法 2 — 使用 >>

Style 2 — using >>:

スタイル 2 — >> を使う:

module shifter_op (input [3:0] R, input shift, output [3:0] Q);
    assign Q = shift ? (R >> 1) : R;
endmodule

為什麼偏好 >>

Why prefer >>?

なぜ >> のほうがよいのか?

面向Aspect観点明寫 if-elseExplicit if-else明示的な if-else>> 運算子>> operator>> 演算子
程式碼行數Lines of codeコード行数~101
Bug surface容易把兩個位元索引寫反而沒發現Easy to swap two bit indices and miss it2 つのビット添字を取り違えても気づきにくい由編譯器保證這個關係Compiler enforces the relationコンパイラが関係を保証する
可擴充到更寬的字組Scales to wider wordsより広いワードにも拡張できる每多一個位元就多一行One extra line per bit1 ビットにつき 1 行ずつ増える同一行程式碼適用於任何寬度Same line works for any width同じ 1 行がどの幅でも通用する
Parameterizable每一條指派都得套模板Need to template every assignment代入をすべてテンプレート化する必要があるassign Q = R >> 1; 適用於任何 [N-1:0]assign Q = R >> 1; works for any [N-1:0]assign Q = R >> 1; はどの [N-1:0] でも動く
Variable shift amountNeed a large case / mux networkR >> n — 由合成器建出桶形移位器R >> n — synthesizer builds the barrel shifterR >> n — 合成器がバレルシフタを組み立てる
Synthesized hardwareIdentical wire-renameIdentical wire-rename

結論:對固定 1 位元的移位而言,兩者在電氣上完全相同(都會合成成單純的接線改名 — 不含正反器)。但 >> 處在對的抽象層級:它陳述的是運算本身,而非其實作方式。面對參數化的寬度或可變的移位量時,>> 讓你不必手工寫出桶形多工器。課本兩種寫法都要求,是為了說清楚 HDL 運算子並不是魔法 — 它們只是你原本可以用結構化方式寫出來的東西的簡寫。

Bottom line: the two are electrically identical for a fixed 1-bit shift (both synthesize to a trivial wire-rename — no flip-flops). But >> is the right level of abstraction: it states the operation rather than its implementation. For parameterized widths or variable shift amounts, >> saves you from writing a barrel multiplexer by hand. The textbook asks for both styles to make clear that HDL operators are not magic — they're shorthand for what you could otherwise write structurally.

結論:1 ビット固定のシフトなら、両者は電気的に同一である(どちらも単なる配線の付け替えに合成され、フリップフロップは生じない)。しかし >> のほうが抽象度として適切である:実装ではなく演算そのものを述べているからである。幅をパラメータ化する場合や、シフト量が可変の場合、>> のおかげでバレルマルチプレクサを手書きせずに済む。教科書が両方の書き方を求めるのは、HDL の演算子が魔法ではないこと — 構造的に書こうと思えば書けるものの略記にすぎないこと — をはっきりさせるためである。

— example 4.30
4.46困難Hard難しい第一階Tier 1ティア 1E?R
撰寫 Verilog 程式碼定義一個 4 位元桶形移位器:把輸入向量 $W$ 串接兩份,將所得的 8 位元值右移 $S$ 個位元,再取其最低四個位元作為輸出。
Write Verilog code that defines a 4-bit barrel shifter by concatenating two copies of the input vector $W$ and shifting the resulting 8-bit value right by $S$ bits, then taking the four least-significant bits as the output.
入力ベクタ $W$ を 2 つ連結し、得られた 8 ビット値を $S$ ビット右シフトしたうえで、その下位 4 ビットを出力とする 4 ビットバレルシフタを定義する Verilog コードを書け。
4.47中等Medium普通第一階Tier 1ティア 1E?R
撰寫偶同位產生器的 Verilog 程式碼:輸入位元 $b_6\ldots b_0$ 為一個 7 位元 ASCII 字元,輸出為 8 位元,其中 $b_7$ 是偶同位位元,$b_6\ldots b_0$ 則原樣通過。
Write Verilog code for an even-parity generator that takes a 7-bit ASCII character on input bits $b_6\ldots b_0$ and produces an 8-bit output where $b_7$ is the even-parity bit and $b_6\ldots b_0$ pass through unchanged.
入力ビット $b_6\ldots b_0$ に 7 ビットの ASCII 文字を受け取り、$b_7$ を偶パリティビット、$b_6\ldots b_0$ をそのまま通した 8 ビットを出力する偶パリティ生成器の Verilog コードを書け。
05 正反器、暫存器與計數器Flip-Flops, Registers, and Countersフリップフロップ・レジスタ・カウンタ

本章由組合邏輯過渡到循序邏輯。先從交叉耦合的 NOR 或 NAND 閘所構成的基本 SR 閂鎖開始,接著介紹閘控 SR 閂鎖、閘控 D 閂鎖,以及關鍵的邊緣觸發 D 正反器(主從式架構)。T 正反器與 JK 正反器也一併涵蓋

This chapter transitions from combinational to sequential logic. It starts with the basic SR latch built from cross-coupled NOR or NAND gates, then introduces the gated SR latch, gated D latch, and the crucial edge-triggered D flip-flop (master-slave configuration). T flip-flops and JK flip-flops are also covered

本章は組合せ回路から順序回路へ移る。まず交差結合した NOR または NAND ゲートによる基本 SR ラッチから始め、続いてゲート付き SR ラッチ、ゲート付き D ラッチ、そして要となるエッジトリガ D フリップフロップ(マスタスレーブ構成)を導入する。T フリップフロップと JK フリップフロップも扱う

Visual tour: latches → flip-flops

1. 閘控 SR 閂鎖 — 在基本 SR 閂鎖上加入時脈/致能輸入。交叉耦合的 NOR 迴路只有在 CLK=1 時才會反應。S=R=1 的輸入仍然是禁止的。

1. Gated SR Latch — adds a clock/enable input to the basic SR latch. The cross-coupled NOR loop only responds when CLK=1. The S=R=1 input is still forbidden.

1. ゲート付き SR ラッチ — 基本 SR ラッチにクロック/イネーブル入力を加えたもの。交差結合した NOR ループは CLK=1 のときだけ応答する。S=R=1 の入力は依然として禁止である。

S R CLK AND AND NOR NOR Q

閘控 SR 閂鎖 — 只有在 CLK=1 期間 Q 才會 set/reset

Gated SR latch — Q sets/resets only while CLK=1

ゲート付き SR ラッチ — Q がセット/リセットされるのは CLK=1 の間だけ

t0t1t2t3t4t5t6t7t8t9t10CLKSRQ

2. 閘控 D 閂鎖 — 由 D̄ 導出 R,消除禁止狀態。只用一個 D 輸入,S = D·CLK、R = D̄·CLK,因此閂鎖被致能時 Q 永遠跟隨 D。它仍然是位準敏感的:CLK=1 期間,D 的每一次變化都會傳播過去。

2. Gated D Latch — eliminates the forbidden state by deriving R from D̄. With one D input, S = D·CLK and R = D̄·CLK, so Q always follows D when the latch is enabled. Still level-sensitive: while CLK=1, every change of D propagates through.

2. ゲート付き D ラッチ — R を D̄ から作ることで禁止状態をなくす。入力は D 1 本で、S = D·CLK、R = D̄·CLK となるため、ラッチがイネーブルの間 Q は常に D に追従する。依然としてレベル感知である:CLK=1 の間は D の変化がそのつど伝わる。

D CLK NOT AND AND NOR NOR Q

閘控 D 閂鎖 — CLK=1 時 Q 穿透地跟隨 D;CLK=0 時保持

Gated D latch — Q transparently follows D while CLK=1; holds when CLK=0

ゲート付き D ラッチ — CLK=1 の間 Q は D に透過的に追従し、CLK=0 で保持する

t0t1t2t3t4t5t6t7t8t9t10CLKDQ

3. 邊緣觸發 D 正反器(主從式) — 兩個 D 閂鎖串接,第二個的時脈反相。CLK=0 時主閂鎖追蹤 D(從閂鎖鎖住);CLK 上升時主閂鎖鎖住、從閂鎖打開 — 每個上升緣正好擷取 D 的一張快照。這才是真正的邊緣觸發:D 在兩個邊緣之間可以自由變化而不影響 Q。

3. Edge-Triggered D Flip-Flop (master-slave) — two D-latches in series with inverted clock to the second. While CLK=0 the master tracks D (slave is locked); when CLK rises, the master locks and the slave opens — capturing exactly one snapshot of D per rising edge. This is true edge-triggering: D can change freely between edges without affecting Q.

3. エッジトリガ D フリップフロップ(マスタスレーブ) — D ラッチを 2 段直列にし、2 段目のクロックを反転させたもの。CLK=0 の間はマスタが D を追い(スレーブは閉じている)、CLK が立ち上がるとマスタが閉じてスレーブが開く — 立上りごとに D のスナップショットをちょうど 1 枚取り込む。これが真のエッジトリガである:D はエッジとエッジの間で自由に変わっても Q に影響しない。

D CLK Master D-latch D EN Q Slave D-latch D EN Q Q NOT NOT

邊緣觸發 D 正反器 — Q 只在 CLK 上升緣取樣 D

Edge-triggered D FF — Q samples D only on rising edge of CLK

エッジトリガ D FF — Q は CLK の立上りでのみ D をサンプルする

t0t1t2t3t4t5t6t7t8t9t10CLKDQ

4. T 正反器 — 切換型正反器:T=1 時 Q 在每個時脈邊緣翻轉,T=0 時 Q 保持。由 D 正反器加上 D = T ⊕ Q 建成。它是二進位計數器的基本構件(每個正反器把時脈除以 2)。

4. T Flip-Flop — toggle FF: when T=1, Q flips on each clock edge; when T=0, Q holds. Built from a D-FF with D = T ⊕ Q. Used as the building block of binary counters (each FF divides clock by 2).

4. T フリップフロップ — トグル型の FF である:T=1 なら Q はクロックエッジごとに反転し、T=0 なら保持する。D-FF に D = T ⊕ Q を与えて作る。2 進カウンタの構成要素であり、FF 1 個ごとにクロックが 2 分周される。

T CLK XOR D D-FF posedge D CLK Q Q

T 正反器 — T=1 時 Q 在上升緣翻轉,T=0 時保持

T flip-flop — Q toggles on rising edge when T=1, holds when T=0

T フリップフロップ — T=1 のとき Q は立上りで反転し、T=0 では保持する

t0t1t2t3t4t5t6t7t8t9t10CLKTQ

5. JK 正反器 — 最一般化的單位元儲存元件:保持 (00)、重置 (01)、設定 (10)、翻轉 (11)。實際上結合了 SR 與 T 的行為。在早期的 TTL 設計中很常見;現代 FPGA 偏好 D 正反器,因為合成比較單純。

5. JK Flip-Flop — the most general single-bit storage element: hold (00), reset (01), set (10), and toggle (11). Effectively combines SR and T behavior. Historically common in TTL designs; modern FPGAs prefer D-FFs because synthesis is simpler.

5. JK フリップフロップ — 最も一般的な 1 ビット記憶素子である:保持 (00)、リセット (01)、セット (10)、トグル (11)。実質的に SR と T の動作を兼ね備える。かつての TTL 設計では一般的だったが、現代の FPGA は合成が簡単な D-FF を好む。

J K CLK JK FF edge-triggered Q Characteristic table: J K Q⁺ action 0 0 Q hold 0 1 0 reset 10 → Q⁺=1 set 11 → Q⁺=Q̄ toggle

JK 正反器 — JK = 00 保持、01 重置、10 設定、11 翻轉

JK flip-flop — JK = 00 hold, 01 reset, 10 set, 11 toggle

JK フリップフロップ — JK = 00 保持、01 リセット、10 セット、11 トグル

t0t1t2t3t4t5t6t7t8t9t10CLKJKQ

總結:閂鎖是位準敏感的(致能期間為穿透);正反器是邊緣敏感的(在時脈邊緣取樣,其餘時間保持)。主從式架構是兩者之間的橋樑 — 兩個時脈相位相反的閂鎖,把位準敏感轉換成邊緣敏感。

Summary: latches are level-sensitive (transparent while enabled); flip-flops are edge-sensitive (sample on a clock edge, hold otherwise). The master-slave construction is the bridge — two latches with opposite clock phases turn level-sensitivity into edge-sensitivity.

まとめ:ラッチはレベル感知(イネーブルの間は透過)、フリップフロップはエッジ感知(クロックエッジでサンプルし、それ以外は保持)である。マスタスレーブ構成が両者の橋渡しとなる — クロック位相が逆の 2 つのラッチが、レベル感知をエッジ感知に変えるのである。

. Timing parameters (setup time, hold time, propagation delay) are defined. The chapter then builds up to registers, shift registers (serial/parallel), and counters. Counter types include asynchronous (ripple) counters, synchronous counters, counters with parallel load, BCD counters, ring counters, and Johnson counters. The Verilog section introduces always @(posedge clk) for sequential logic, blocking vs. non-blocking assignments
What is blocking vs. non-blocking?

在 Verilog/SystemVerilog 裡,=(阻擋式)與 <=(非阻擋式)之間的選擇是最根本的。這個差別在 always @(posedge clk) 區塊裡最要緊 — 選錯了會無聲無息地改變你的硬體。

In Verilog/SystemVerilog, the choice between = (blocking) and <= (non-blocking) is fundamental. The difference matters most inside always @(posedge clk) blocks — getting it wrong silently changes your hardware.

Verilog/SystemVerilog では、=(ブロッキング)と <=(ノンブロッキング)のどちらを使うかが根本的な選択である。この違いがもっとも効いてくるのは always @(posedge clk) ブロックの中であり、間違えると何の警告もなくハードウェアが変わってしまう。

The core distinction:

  • 阻擋式(=):像軟體一樣循序執行。每一條敘述都在下一條開始之前完成。
  • Blocking (=): Executes sequentially, like software. Each statement finishes before the next begins.
  • ブロッキング(=):ソフトウェアのように逐次実行される。各文は次の文が始まる前に完了する。
  • 非阻擋式(<=):所有右側運算式會值求值,然後所有左側在該時間步結束時同時更新 — 這正是真實正反器運作方式的模型。
  • Non-blocking (<=): All right-hand sides are evaluated first using the old values, then all left-hand sides update simultaneously at the end of the time step — modeling how real flip-flops work.
  • ノンブロッキング(<=):まずすべての右辺が古い値を使って先に評価され、その後すべての左辺がタイムステップの終わりに同時に更新される — 実際のフリップフロップの動作をモデル化したものである。

經典的移位暫存器範例 — 同樣的程式碼,不同的硬體:

Classic shift-register example — same code, different hardware:

定番のシフトレジスタの例 — 同じコード、違うハードウェア:

非阻塞式(正確:3 級移位)Non-blocking (correct: 3-stage shift)ノンブロッキング(正解:3 段シフト)阻塞式(塌縮成 1 個正反器)Blocking (collapses to 1 flip-flop)ブロッキング(フリップフロップ 1 個に潰れる)
always @(posedge clk) begin
    b <= a;
    c <= b;
    d <= c;
end
// → a → [FF] → b → [FF] → c → [FF] → d
// Three flip-flops, true shift register
always @(posedge clk) begin
    b = a;
    c = b;
    d = c;
end
// b, c, d all = a after the edge
// Synthesizer collapses to one FF

為什麼阻擋式版本會「塌縮」:合成器看到 bcd 在每個時脈邊緣結束時的值都相同,於是讓它們共用儲存元件。你得到的是一個正反器,不是三個。模擬結果取決於敘述的先後順序,而這正是真實硬體會做的事。

Why the blocking version "collapses": synthesizers see that b, c, d always end the clock edge with the same value, so they share storage. You get one flip-flop, not three. The simulation result depends on statement ordering, which is exactly what real hardware does not do.

なぜブロッキング版は「潰れる」のか:合成ツールは bcd がクロックエッジの終わりで常に同じ値になることを見抜き、記憶素子を共有させる。得られるフリップフロップは 3 個ではなく 1 個である。シミュレーション結果は文の順序に依存するが、それこそ実際のハードウェアがしないことである。

為什麼非阻擋式吻合硬體:實體正反器在時脈邊緣取樣 D 輸入,並在一小段延遲(Tco)後傳到 Q。在同一個邊緣之內,它們看不到彼此的輸出。非阻擋式的語意(先求值再更新)正好精確地抓住這一點。

Why non-blocking matches hardware: physical flip-flops sample their D input at the clock edge and propagate to Q after a small delay (Tco). They can't see each other's new outputs within the same edge. Non-blocking semantics (evaluate-then-update) capture this exactly.

なぜノンブロッキングがハードウェアと一致するのか:物理的なフリップフロップはクロックエッジで D 入力をサンプルし、わずかな遅延(Tco)ののち Q へ伝える。同じエッジの中では、互いの新しい出力を見ることはできない。ノンブロッキングの意味論(評価してから更新する)は、これをそのまま正確に表している。

能防住幾乎所有指定錯誤的兩條準則:

Two-rule guideline that prevents almost all assignment bugs:

代入まわりのバグをほぼすべて防げる 2 つの指針:

  • always @(posedge clk) — 一律使用 <=
  • always @(posedge clk) — always use <=
  • always @(posedge clk) — 必ず <= を使う
  • always @* (combinational) — always use =

在同一個 always 區塊裡混用兩者,正是模擬與合成不一致悄悄鑽進來的地方。如果你的測試平台通過了,合成後的網表在 FPGA 上卻表現不同,通常就是這個原因。

Mixing them in a single always block is where simulation/synthesis mismatches creep in. If your testbench passes but the synthesized netlist behaves differently on FPGA, this is usually the culprit.

1 つの always ブロックで両者を混ぜることこそ、シミュレーションと合成の食い違いが忍び込む原因である。テストベンチは通るのに合成後のネットリストが FPGA 上で違う動きをするなら、たいていこれが犯人である。

, and how to describe registers and counters in Verilog. A reaction-timer design example ties everything together, and timing analysis of flip-flop circuits is covered.

SR / D / T / JK 正反器 閂鎖 vs 正反器 主從式 建立 / 保持時間 移位暫存器 同步計數器 環形 / 強生計數器 阻擋式 vs 非阻擋式 時序分析
SR / D / T / JK Flip-Flops Latches vs Flip-Flops Master-Slave Setup / Hold Time Shift Registers Synchronous Counters Ring / Johnson Counters Blocking vs Non-Blocking Timing Analysis
SR / D / T / JK フリップフロップ ラッチ vs フリップフロップ マスタ・スレーブ セットアップ / ホールド時間 シフトレジスタ 同期カウンタ リング / ジョンソンカウンタ ブロッキング vs ノンブロッキング タイミング解析
5.1簡單Easy易しい第一階Tier 1ティア 1?R
畫出以 NOR 閘構成的基本 SR 閂鎖電路。寫出特性表,列出全部四種輸入組合,包含禁止狀態。
Draw the circuit for a basic SR latch using NOR gates. Write the characteristic table showing all four input combinations including the forbidden state.
NOR ゲートによる基本 SR ラッチの回路を描け。禁止状態を含む 4 通りの入力組合せすべてを示す特性表を書け。
5.2簡單Easy易しい第一階Tier 1ティア 1?R
說明閂鎖與正反器的差異。為什麼同步電路偏好使用邊緣觸發的正反器?
Explain the difference between a latch and a flip-flop. Why are edge-triggered flip-flops preferred in synchronous circuits?
ラッチとフリップフロップの違いを説明せよ。同期回路でエッジトリガのフリップフロップが好まれるのはなぜか。
5.3中等Medium普通第一階Tier 1ティア 1?R
針對下列 D 輸入序列 0,1,1,0,1,0,0,1(每個時脈週期一個值),畫出正緣觸發 D 正反器的時序圖。假設 Q 從 0 開始。
Draw the timing diagram for a positive-edge-triggered D flip-flop with the following D input sequence: 0,1,1,0,1,0,0,1 (one value per clock cycle). Assume Q starts at 0.
次の D 入力系列 0,1,1,0,1,0,0,1(1 クロック周期あたり 1 値)に対して、立上りエッジトリガ D フリップフロップのタイミング図を描け。Q の初期値は 0 とする。
5.4中等Medium普通第一階Tier 1ティア 1?R
說明如何用一個 D 正反器加上一個 XOR 閘構成 T 正反器。並寫出其特性方程式。
Show how a T flip-flop can be built from a D flip-flop with an XOR gate. Write the characteristic equation.
D フリップフロップと XOR ゲート 1 個から T フリップフロップを構成する方法を示せ。特性方程式も書け。
5.5中等Medium普通第一階Tier 1ティア 1?R
使用 T 正反器設計一個同步 3 位元上數計數器。推導每個 T 輸入的邏輯,並畫出完整電路。
Design a synchronous 3-bit up counter using T flip-flops. Derive the logic for each T input and draw the complete circuit.
T フリップフロップを使って同期式 3 ビットアップカウンタを設計せよ。各 T 入力の論理を導き、回路全体を描け。
5.6中等Medium普通第一階Tier 1ティア 1?R
比較 4 位元漣波計數器與 4 位元同步計數器的最高時脈頻率。假設每個正反器的傳播延遲為 5 ns。
Compare the maximum clock frequency of a 4-bit ripple counter versus a 4-bit synchronous counter. Assume each flip-flop has a propagation delay of 5 ns.
4 ビットのリップルカウンタと 4 ビットの同期カウンタの最大クロック周波数を比較せよ。各フリップフロップの伝搬遅延は 5 ns とする。
5.7中等Medium普通第一階Tier 1ティア 1?R
設計一個帶控制訊號 UpDown 的同步 4 位元上/下數計數器。UpDown=1 時計數器上數,為 0 時下數。請給出 Verilog 程式碼。
Design a synchronous 4-bit up/down counter with a control signal UpDown. When UpDown=1 the counter counts up; when 0 it counts down. Give the Verilog code.
制御信号 UpDown を持つ同期式 4 ビットアップ/ダウンカウンタを設計せよ。UpDown=1 のときカウンタはアップカウント、0 のときダウンカウントする。Verilog コードを示せ。
5.8中等Medium普通第一階Tier 1ティア 1?R
說明 Verilog 中阻擋式(=)與非阻擋式(<=)指定的差異。舉出一段程式碼為例,說明用錯種類會產生不正確的硬體。
Explain the difference between blocking (=) and non-blocking (<=) assignments in Verilog. Show a code example where using the wrong type produces incorrect hardware.
Verilog のブロッキング代入(=)とノンブロッキング代入(<=)の違いを説明せよ。誤った種類を使うと不正なハードウェアになるコード例を示せ。
5.9中等Medium普通第一階Tier 1ティア 1?R
撰寫具同步重置與致能訊號的 D 正反器 Verilog 程式碼。當 Enable=0 時,正反器保持目前的值。
Write Verilog code for a D flip-flop with synchronous reset and an enable signal. When Enable=0, the flip-flop holds its current value.
同期リセットとイネーブル信号を持つ D フリップフロップの Verilog コードを書け。Enable=0 のとき、フリップフロップは現在の値を保持する。
5.10簡單Easy易しい第一階Tier 1ティア 1?R
正反器的建立時間、保持時間與 clock-to-Q 延遲各是什麼?為什麼每一項對正確運作都很重要?
What are the setup time, hold time, and clock-to-Q delay of a flip-flop? Why does each matter for correct operation?
フリップフロップのセットアップ時間、ホールド時間、clock-to-Q 遅延とは何か。それぞれが正しい動作にとってなぜ重要なのか。
5.11中等Medium普通第一階Tier 1ティア 1?R
用兩個閘控 D 閂鎖畫出主從式 D 正反器電路。說明它為何是邊緣觸發而非位準感測。
Draw the master-slave D flip-flop circuit using two gated D latches. Explain why it is edge-triggered rather than level-sensitive.
ゲート付き D ラッチ 2 個を用いてマスタ・スレーブ D フリップフロップの回路を描け。それがレベル検知ではなくエッジトリガである理由を説明せよ。
5.12中等Medium普通第一階Tier 1ティア 1?R
說明什麼是亞穩態,以及它為何重要。同步器(兩個串接的正反器)的用途是什麼?
Explain what metastability is and why it matters. What is the purpose of a synchronizer (two flip-flops in series)?
メタスタビリティとは何か、そしてなぜ問題になるのかを説明せよ。同期化回路(フリップフロップ 2 段の直列)の目的は何か。
5.13簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫一個 Verilog 模組 D_latch,輸入為 DClk、輸出為 Q,其中使用對 DClk 敏感的 always 區塊搭配 if (Clk) 指定,使其推論出一個位準感測的閘控 D 閂鎖。
Write a Verilog module D_latch with inputs D and Clk and output Q that uses an always block sensitive to D and Clk with an if (Clk) assignment, so that a level-sensitive gated D latch is inferred.
入力 DClk、出力 Q を持つ Verilog モジュール D_latch を書け。DClk に感応する always ブロックの中で if (Clk) による代入を行い、レベル検知のゲート付き D ラッチが推論されるようにすること。
5.14簡單Easy易しい第一階Tier 1ティア 1E?R
使用 always @(posedge Clock) 撰寫一個正緣觸發 D 正反器的 Verilog 模組。
Write a Verilog module for a positive-edge-triggered D flip-flop using always @(posedge Clock).
always @(posedge Clock) を用いて立上りエッジトリガ D フリップフロップの Verilog モジュールを書け。
5.15中等Medium普通第一階Tier 1ティア 1E?R
always @(posedge Clock) 區塊中出現兩個阻擋式指定 Q1 = D; Q2 = Q1;。說明為什麼這並不會綜合出串接的正反器,並畫出實際被推論出來的電路。
Inside an always @(posedge Clock) block, two blocking assignments Q1 = D; Q2 = Q1; appear. Explain why this does NOT synthesize cascaded flip-flops, and draw the circuit that is actually inferred.
always @(posedge Clock) ブロックの中に、ブロッキング代入 Q1 = D; Q2 = Q1; の 2 つがある。これが縦続接続のフリップフロップとして合成されない理由を説明し、実際に推論される回路を描け。
5.16中等Medium普通第一階Tier 1ティア 1E?R
Show that replacing the blocking assignments in Example 5.3 with non-blocking assignments (Q1 <= D; Q2 <= Q1;) produces a two-stage shift register. Explain the semantic difference.
脈絡:範例 5.3 / 5.4 — 時脈驅動 always 區塊中的阻擋式與非阻擋式Context: Examples 5.3 / 5.4 — blocking vs non-blocking in clocked always blocks文脈:例 5.3 / 5.4 — クロック同期 always ブロックにおけるブロッキングとノンブロッキング

範例 5.3 回顧(阻擋式 — 用於串接是錯的)。課本從這段程式碼開始:

Recap of Example 5.3 (blocking — wrong for cascading). The textbook starts with this code:

例 5.3 の復習(ブロッキング — 縦続接続には不適)。教科書はこのコードから始まる:

module example5_3 (D, Clock, Q1, Q2);
  input D, Clock;
  output reg Q1, Q2;
  always @(posedge Clock) begin
    Q1 = D;     // blocking
    Q2 = Q1;    // blocking — Q1 already updated
  end
endmodule

阻擋式指定是循序求值的。在 Q1 = D; 之後,變數 Q1 已經持有新值 D,所以 Q2 = Q1; 讀到的也是 D。兩個 FF 在每個時脈邊緣都閂鎖同一個輸入:

Blocking assignments evaluate sequentially. After Q1 = D;, the variable Q1 already holds the new value D, so Q2 = Q1; reads D as well. Both FFs latch the same input on every clock edge:

ブロッキング代入は逐次に評価される。Q1 = D; のあと、変数 Q1 はすでに新しい値 D を保持しているので、Q2 = Q1;D を読む。両方の FF がクロックエッジごとに同じ入力を取り込む:

圖 5.37 — 阻塞式:兩個並聯的 D 正反器(其中一個沒作用)Figure 5.37 — blocking: two parallel D-FFs (one is dead)図 5.37 — ブロッキング:並列な D-FF 2 個(片方は無効) D D CLK FF1 Q Q1 D CLK FF2 Q Q2 Clock Q1 = Q2 = D (redundant)

習題 5.16 — 非阻擋式(正確):= 換成 <=

Problem 5.16 — non-blocking (right): swap = for <=:

問題 5.16 — ノンブロッキング(正解):=<= に置き換える:

always @(posedge Clock) begin
  Q1 <= D;     // non-blocking
  Q2 <= Q1;    // reads OLD Q1 (value at block entry)
end

非阻擋式指定全都在 always 區塊觸發的那一刻取樣各自的右側,然後在結尾一起提交新值。因此 Q2 <= Q1; 讀到的是 Q1前一個值 — 這正是真實串接 FF 的行為。合成出來的硬體是不折不扣的兩級移位暫存器:

Non-blocking assignments all sample their right-hand sides at the moment the always block fires, then commit new values together at the end. So Q2 <= Q1; reads the previous value of Q1 — exactly what a real cascaded FF does. The synthesized hardware is a true 2-stage shift register:

ノンブロッキング代入はいずれも always ブロックが起動した時点で右辺をサンプルし、最後に新しい値をまとめて確定する。したがって Q2 <= Q1;Q1直前の値を読む — 実際に縦続接続した FF の動作そのものである。合成されるハードウェアは正真正銘の 2 段シフトレジスタとなる:

圖 5.39 — 非阻塞式:串接的 D 正反器(真正的移位暫存器)Figure 5.39 — non-blocking: cascaded D-FFs (true shift register)図 5.39 — ノンブロッキング:縦続接続の D-FF(本物のシフトレジスタ) D FF1 D CLK Q Q1 FF2 D CLK Q Q2 Clock

單一上升緣的語意對照。假設邊緣之前為:$D=1, Q_1=0, Q_2=0$。

Side-by-side semantics for one rising edge. Suppose before the edge: $D=1, Q_1=0, Q_2=0$.

1 回の立上りエッジにおける意味論の対比。エッジの直前が $D=1, Q_1=0, Q_2=0$ だとする。

寫法Style書き方邊緣後的 $Q_1$$Q_1$ after edgeエッジ後の $Q_1$邊緣後的 $Q_2$$Q_2$ after edgeエッジ後の $Q_2$
Blocking =$D = 1$new $Q_1 = 1$
Non-blocking <=$D = 1$old $Q_1 = 0$

使用非阻擋式時,要到第二個時脈邊緣之後 $Q_2$ 才終於變成 1 — 輸入已經走過兩級,所以才叫「移位暫存器」。

After the second clock edge with non-blocking, $Q_2$ finally becomes 1 — the input has propagated through two stages, hence "shift register".

ノンブロッキングでは、2 回目のクロックエッジのあとにようやく $Q_2$ が 1 になる — 入力が 2 段を伝わったわけで、だから「シフトレジスタ」と呼ぶ。

經驗法則。 在時脈驅動的 always @(posedge clk) 區塊裡,一切都用非阻擋式(<=)。阻擋式(=)只用在組合邏輯的 always @(*) 區塊,那裡的循序求值恰好對應閘級的資料流。在同一個區塊裡混用兩者,是合成與模擬不一致最常見的來源。

Rule of thumb. Use non-blocking (<=) for everything inside a clocked always @(posedge clk) block. Use blocking (=) only in combinational always @(*) blocks where sequential evaluation matches gate-level dataflow. Mixing the two in the same block is the most common source of synthesis-vs-simulation mismatches.

経験則。 クロック同期の always @(posedge clk) ブロックの中では、すべてノンブロッキング(<=)を使う。ブロッキング(=)は、逐次評価がゲートレベルのデータフローと一致する組合せ用の always @(*) ブロックでのみ使う。同じブロックで両者を混ぜることが、合成とシミュレーションの食い違いのもっとも多い原因である。

— example 5.3
5.17中等Medium普通第一階Tier 1ティア 1E?R
always @(posedge Clock) 區塊中使用阻擋式指定 f = x1 & x2; g = f | x3;,畫出所綜合出的電路。說明為什麼在輸入與饋入 g 正反器的 OR 閘之間會出現一個 AND 閘。
In an always @(posedge Clock) block with blocking assignments f = x1 & x2; g = f | x3;, draw the circuit that is synthesized. Explain why an AND gate appears between the input and the OR gate that feeds the g flip-flop.
always @(posedge Clock) ブロックでブロッキング代入 f = x1 & x2; g = f | x3; を用いたとき、合成される回路を描け。入力と、g のフリップフロップに入る OR ゲートとの間に AND ゲートが現れる理由を説明せよ。
5.18中等Medium普通第一階Tier 1ティア 1E?R
改用非阻擋式指定重做範例 5.5,並說明綜合出的電路為何改變:饋入 g 的 OR 閘現在由 f 正反器前一個週期的輸出所驅動,而不是由 AND 閘的輸出驅動。— example 5.5
Repeat Example 5.5 with non-blocking assignments and explain why the synthesized circuit changes: the OR gate that feeds g is now driven by the previous-cycle output of the f flip-flop instead of the AND-gate output.— example 5.5
例題 5.5 をノンブロッキング代入で繰り返し、合成される回路が変わる理由を説明せよ。g に入る OR ゲートは、AND ゲートの出力ではなく f のフリップフロップの前サイクルの出力で駆動されるようになる。— example 5.5
5.19簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫具非同步低準位有效重置(Resetn)的 D 正反器 Verilog 程式碼,敏感度列表使用 negedge Resetn, posedge Clock
Write Verilog for a D flip-flop with an asynchronous active-low reset (Resetn) using a sensitivity list of negedge Resetn, posedge Clock.
非同期の負論理リセット(Resetn)を持つ D フリップフロップの Verilog コードを、感応リストに negedge Resetn, posedge Clock を用いて書け。
5.20簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫具同步低準位有效重置的 D 正反器 Verilog 程式碼,敏感度列表只使用 posedge Clock
Write Verilog for a D flip-flop with a synchronous active-low reset, using a sensitivity list of posedge Clock only.
同期の負論理リセットを持つ D フリップフロップの Verilog コードを、感応リストに posedge Clock だけを用いて書け。
5.21簡單Easy易しい第一階Tier 1ティア 1E?R
Write a parameterized Verilog module regn for an $n$-bit register with asynchronous clear, where $n$ is a parameter with a default value.
這道題到底在問什麼?What is this problem asking for?この問題は何を求めているのか?

Four requirements:

1. 參數化的 Verilog 模組 regn — 模組名稱為 regn(「register,參數化的 n」)。必須使用 Verilog 的 parameter 機制,讓位元寬度不被寫死 — 同一份模組檔案,只要在實例化時傳入不同的值,就能適用於任意寬度。

1. parameterized Verilog module regn — module name is regn ("register, parameterized n"). Must use Verilog's parameter mechanism so the bit width is not hard-coded — the same module file works for any width by passing a different value at instantiation.

1. パラメータ化された Verilog モジュール regn — モジュール名は regn(「register、パラメータ化された n」)である。ビット幅をハードコードしないよう Verilog の parameter 機構を使わなければならない — 同じモジュールファイルが、インスタンス化時に違う値を渡すだけでどの幅にも使える。

2. 用於 $n$ 位元暫存器 — 也就是 $n$ 個 D 正反器並聯成的一組:輸入匯流排 D[n-1:0]、輸出匯流排 Q[n-1:0],共用一個時脈。每個時脈上升緣,$n$ 個輸入同時閂鎖到 $n$ 個輸出。

2. for an $n$-bit register — a bank of $n$ D flip-flops in parallel: input bus D[n-1:0], output bus Q[n-1:0], one shared clock. On each rising clock edge, the $n$ inputs latch into the $n$ outputs simultaneously.

2. $n$ ビットレジスタ用 — $n$ 個の D フリップフロップを並列に並べたものである:入力バス D[n-1:0]、出力バス Q[n-1:0]、クロックは 1 本を共有する。クロックの立上りごとに、$n$ 本の入力が $n$ 本の出力へ同時に取り込まれる。

3. 具備非同步清除 — 一個重置訊號,在 assert 時立刻把全部 $n$ 個位元清為 0,而不等待下一個時脈邊緣。實作上,重置訊號會和時脈一起放進 always 區塊的敏感度列表(always @(posedge Clock or negedge Resetn)),因此重置一 assert,該區塊就觸發。對照之下,同步清除要到下一個時脈上升緣才會生效。

3. with asynchronous clear — a reset signal that clears all $n$ bits to 0 immediately when asserted, not waiting for the next clock edge. Implementation-wise, the reset signal goes into the always-block sensitivity list along with the clock (always @(posedge Clock or negedge Resetn)), so the block fires the moment reset asserts. Contrast: a synchronous clear would only take effect on the next rising clock edge.

3. 非同期クリア付き — アサートされた瞬間に $n$ ビットすべてをただちに 0 にするリセット信号であり、次のクロックエッジを待たない。実装上は、リセット信号をクロックとともに always ブロックの感度リストに入れる(always @(posedge Clock or negedge Resetn))ので、リセットがアサートされた瞬間にブロックが起動する。対して同期クリアは、次のクロック立上りではじめて効く。

4. 其中 $n$ 是帶有預設值的 parameter

4. where $n$ is a parameter with a default value:

4. ただし $n$ は既定値をもつ parameter である

  • n 要用 parameter 宣告(不是 localparam,也不是寫死的數字)。
  • n declared with parameter (not localparam, not a hard-coded number).
  • nparameter で宣言する(localparam でも、直書きの数値でもない)。
  • 要提供預設值,讓實例化時不指定寬度也能得到合理的預設(例如 8 位元)。
  • Default value provided so instantiating without specifying width gets a sensible fallback (e.g., 8 bits).
  • 既定値を与えておき、幅を指定せずにインスタンス化しても妥当な既定(たとえば 8 ビット)になるようにする。

評分時會檢查的重點:單一模組檔案就支援 regn r1();(預設)、regn #(.n(16)) r2();(16 位元)、regn #(32) r3();(32 位元) — 全都不必改動原始碼。assert Resetn 會讓 Q 在時脈邊緣之間就掉到 0(波形上看得見)。Resetn 未作用時,全部 $n$ 個位元都在時脈上升緣載入 D。

What the grader checks: one module file that supports regn r1(); (default), regn #(.n(16)) r2(); (16-bit), regn #(32) r3(); (32-bit) — all without editing the source. Asserting Resetn drops Q to 0 between clock edges (visible in waveform). All $n$ bits load D on the rising clock edge when Resetn is inactive.

採点で見られる点:1 つのモジュールファイルで regn r1();(既定)、regn #(.n(16)) r2();(16 ビット)、regn #(32) r3();(32 ビット)をすべてサポートし、しかもソースを書き換えずに済むこと。Resetn をアサートすると、クロックエッジので Q が 0 に落ちる(波形で確認できる)。Resetn が非アクティブなら、クロックの立上りで $n$ ビットすべてが D を取り込む。

5.22中等Medium普通第一階Tier 1ティア 1E?R
Write hierarchical Verilog code for a 4-bit parallel-load shift register, instantiating four copies of a muxdff subcircuit (a D flip-flop with a 2-to-1 multiplexer on its D input). Inputs: R (parallel data), L (load), w (serial in), Clock; output Q.
Context: what is a muxdff?

muxdff 是並列載入/移位暫存器裡的主力單元:一個 D 正反器,前面接一個 2 對 1 多工器,用來在兩個下一狀態值之間做選擇。這個 MUX 的選擇線通常叫做 L(load):

A muxdff is the workhorse cell of a parallel-load / shift register: a single D flip-flop preceded by a 2-to-1 multiplexer that selects between two next-state values. The MUX's select line is usually called L (load):

muxdff は、並列ロード/シフトレジスタの主力セルである。D フリップフロップ 1 個の手前に 2-to-1 マルチプレクサを置き、2 つの次状態値のどちらかを選ぶ。この MUX の選択線はふつう L(load)と呼ばれる:

  • L = 0 — MUX 選擇「移位」輸入 w;FF 把來自鄰接單元的位元打進去。整條鏈就移位。
  • L = 0 — MUX picks the "shift" input w; the FF clocks in the bit coming from a neighbour cell. The chain shifts.
  • L = 0 — MUX は「シフト」入力 w を選ぶ。FF は隣のセルから来たビットを取り込む。チェーンはシフトする。
  • L = 1 — MUX 選擇「並列」輸入 R;FF 把外部來的新資料位元打進去。暫存器就完成載入。
  • L = 1 — MUX picks the "parallel" input R; the FF clocks in a fresh data bit from outside. The register loads.
  • L = 1 — MUX は「並列」入力 R を選ぶ。FF は外部から来た新しいデータビットを取り込む。レジスタはロードする。

它是能讓暫存器在單一控制位元之下兼做兩件事(移位或載入)的最小積木。

It's the smallest building block that lets a register do both jobs (shift OR load) under a single control bit.

1 本の制御ビットだけでレジスタに 2 つの仕事(シフトまたはロード)をさせられる、最小の構成要素である。

R w L MUX2 1 0 D D-FF Q Q Clock

Verilog for the muxdff cell:

module muxdff (
  input  R, w, L, Clock,
  output reg Q
);
  always @(posedge Clock)
    Q <= L ? R : w;   // L=1 → load R; L=0 → shift in w
endmodule

用四個 muxdff 單元串接,做出 4 位元並列載入移位暫存器

Building a 4-bit parallel-load shift register by chaining four muxdff cells:

4 個の muxdff セルを縦続接続して 4 ビット並列ロードシフトレジスタを作る

w muxdff[3] R[3] / w Q[3] muxdff[2] R[2] / Q[3] muxdff[1] R[1] / Q[2] muxdff[0] R[0] / Q[1]

每個單元的 MUX 下方輸入接到前一個單元的 QL=0 時,位元沿著鏈一路傳遞(移位)。L=1 時,每個單元並列載入各自對應的 R[i]

Each cell's MUX bottom input is wired to the previous cell's Q. With L=0, bits ripple through the chain (shift). With L=1, every cell loads its corresponding R[i] in parallel.

各セルの MUX の下側入力は、前段セルの Q に配線される。L=0 ならビットはチェーンを伝わっていく(シフト)。L=1 なら各セルが対応する R[i] を並列に取り込む。

Hierarchical Verilog (problem 5.22's task):

module shift_load_4 (
  input  [3:0] R,
  input        L, w, Clock,
  output [3:0] Q
);
  muxdff bit3 (.R(R[3]), .w(w),    .L(L), .Clock(Clock), .Q(Q[3]));
  muxdff bit2 (.R(R[2]), .w(Q[3]), .L(L), .Clock(Clock), .Q(Q[2]));
  muxdff bit1 (.R(R[1]), .w(Q[2]), .L(L), .Clock(Clock), .Q(Q[1]));
  muxdff bit0 (.R(R[0]), .w(Q[1]), .L(L), .Clock(Clock), .Q(Q[0]));
endmodule

為什麼 muxdff 這層抽象很重要:真實設計裡幾乎每個暫存器都不只要「每個邊緣把 D 打進 Q」而已。加上載入、移位、保持與重置的能力,if 和邊角情況會愈堆愈多。把每種組合收成一個有名字的小單元(muxdff,再加上 enable/reset 變體),然後為 n 位元暫存器實例化 n 份,是擴展規模最乾淨的做法 — 單元驗證一次,到處重用。

Why the muxdff abstraction matters: almost every register in a real design needs more than just "clock D into Q on each edge". Adding load, shift, hold, and reset capabilities can pile up ifs and edge cases. Capturing each combination as a tiny named cell (muxdff, plus enable/reset variants) and instantiating n copies for an n-bit register is the cleanest way to scale — verify the cell once, reuse everywhere.

muxdff という抽象がなぜ効くのか:実際の設計では、ほとんどのレジスタが「エッジごとに D を Q へ取り込む」だけでは足りない。ロード、シフト、ホールド、リセットを足していくと、if と例外ケースが積み上がる。組合せごとに名前を付けた小さなセル(muxdff と、enable/reset 版)としてまとめ、n ビットレジスタには n 個インスタンス化する — これが規模を広げるいちばんきれいなやり方である。セルを一度検証すれば、あとはどこでも再利用できる。

5.23中等Medium普通第一階Tier 1ティア 1E?R
為 4 位元並列載入移位暫存器另寫一個非階層式的 Verilog 描述,只用單一個 always @(posedge Clock) 區塊,以非阻擋式指定完成載入或移位的動作。
Write an alternative non-hierarchical Verilog description of the 4-bit parallel-load shift register, using a single always @(posedge Clock) block with non-blocking assignments to perform the load or shift action.
4 ビットの並列ロード付きシフトレジスタについて、階層を用いない別の Verilog 記述を書け。単一の always @(posedge Clock) ブロックの中で、ノンブロッキング代入によりロードまたはシフトの動作を行うこと。
5.24中等Medium普通第一階Tier 1ティア 1E?R
撰寫一個參數化的 Verilog 模組,實作具並列載入與串列輸入的 $n$ 位元移位暫存器。在 else 分支中以 for 迴圈逐位元表達移位動作。
Write a parameterized Verilog module for an $n$-bit shift register with parallel-load and serial-input. Use a for loop to express the bit-by-bit shift in the else branch.
並列ロードと直列入力を持つ $n$ ビットシフトレジスタの、パラメータ化された Verilog モジュールを書け。else 側の分岐では for ループでビットごとのシフトを表現すること。
5.25簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫一個 4 位元同步上數計數器的 Verilog 程式碼,具非同步重置 Resetn 與致能輸入 E。當 E=1 時,計數值在 Clock 的正緣遞增。
Write Verilog for a 4-bit synchronous up-counter with asynchronous reset Resetn and enable input E. The count increments on the positive edge of Clock when E=1.
非同期リセット Resetn とイネーブル入力 E を持つ 4 ビット同期アップカウンタの Verilog コードを書け。E=1 のとき、Clock の立上りエッジでカウントが増加する。
5.26簡單Easy易しい第一階Tier 1ティア 1E?R
為範例 5.13 的上數計數器加上並列載入輸入 L 與 4 位元資料輸入 R,使得 $L=1$ 時計數器會在下一個時脈邊緣載入 $R$。— example 5.13
Extend the up-counter of Example 5.13 with a parallel-load input L and a 4-bit data input R, so that the counter loads $R$ on the next clock edge when $L=1$.— example 5.13
例題 5.13 のアップカウンタに、並列ロード入力 L と 4 ビットのデータ入力 R を追加し、$L=1$ のとき次のクロックエッジで $R$ をロードするようにせよ。— example 5.13
5.27簡單Easy易しい第一階Tier 1ティア 1E?R
撰寫一個具並列載入的參數化下數計數器 Verilog 程式碼。在每個時脈正緣,若 L=1 則載入 R;否則若 E=1 則遞減。
Write Verilog for a parameterized down-counter with parallel load. On each positive clock edge, if L=1 load R; otherwise if E=1 decrement.
並列ロード付きの、パラメータ化されたダウンカウンタの Verilog コードを書け。クロックの立上りエッジごとに、L=1 なら R をロードし、そうでなく E=1 ならデクリメントする。
5.28中等Medium普通第一階Tier 1ティア 1E?R
撰寫一個具並列載入與方向控制 up_down 的參數化上/下數計數器 Verilog 程式碼,由 up_down 選擇計數器要遞增還是遞減。
Write Verilog for a parameterized up/down counter with parallel load and a direction control up_down that selects whether the counter increments or decrements.
並列ロードと、カウンタを増加させるか減少させるかを選ぶ方向制御 up_down を持つ、パラメータ化されたアップ/ダウンカウンタの Verilog コードを書け。
5.29困難Hard難しい第一階Tier 1ティア 1E?R
兩個正反器 $Q_1$ 與 $Q_2$ 之間以組合邏輯相連,各正反器上的時脈訊號延遲分別為 $\delta_1$ 與 $\delta_2$。定義 $t_{skew}=\delta_2-\delta_1$,並推導 (a) 最小時脈週期 $T_{min}=t_{cQ}+t_L+t_{su}-t_{skew}$,以及 (b) 對最短路徑延遲 $t_l$ 的保持時間條件 $t_{cQ}+t_l \ge t_h+t_{skew}$。
Two flip-flops $Q_1$ and $Q_2$ are connected through combinational logic, with clock-signal delays $\delta_1$ and $\delta_2$ at each flip-flop. Define $t_{skew}=\delta_2-\delta_1$ and derive (a) the minimum clock period $T_{min}=t_{cQ}+t_L+t_{su}-t_{skew}$ and (b) the hold-time condition $t_{cQ}+t_l \ge t_h+t_{skew}$ for the shortest path delay $t_l$.
2 つのフリップフロップ $Q_1$ と $Q_2$ が組合せ回路を介して接続され、各フリップフロップでのクロック信号の遅延を $\delta_1$、$\delta_2$ とする。$t_{skew}=\delta_2-\delta_1$ と定義し、(a) 最小クロック周期 $T_{min}=t_{cQ}+t_L+t_{su}-t_{skew}$ と、(b) 最短経路遅延 $t_l$ に対するホールド時間条件 $t_{cQ}+t_l \ge t_h+t_{skew}$ を導け。
5.30中等Medium普通第一階Tier 1ティア 1E?R
For a small combinational circuit driven by a square-wave input $C$ with 50% duty cycle (Figure 5.70a), draw a timing diagram showing the waveforms at internal nodes $A$ and $B$, assuming each gate has propagation delay $\Delta$.
Figure 5.70a — circuit reference

圖 5.70a — 兩個串接的反相器,從內部節點 A 與 B 拉出訊號

Figure 5.70a — two cascaded inverters tap-off internal nodes A and B

図 5.70a — 縦続接続した 2 個のインバータから内部ノード A と B を取り出す

C A B (open) INV (Δ delay) INV (Δ delay)

因此 $A = \overline{C}$ 是延遲 $\Delta$ 後的結果,而 $B = C$ 是延遲 $2\Delta$ 後的結果(也就是 $A$ 再反相一次)。

So $A = \overline{C}$ delayed by $\Delta$, and $B = C$ delayed by $2\Delta$ (i.e. $A$ further inverted).

したがって $A = \overline{C}$ は $\Delta$ だけ遅れたもの、$B = C$ は $2\Delta$ だけ遅れたもの(すなわち $A$ をさらに反転したもの)である。

— example 5.18
5.31中等Medium普通第一階Tier 1ティア 1E?R
Determine the functional behavior of the two-JK-flip-flop circuit in Figure 5.71, in which input $w$ is driven by a square-wave signal. Show that successive values of $Q_1 Q_0$ form the sequence $00,01,10,00,\ldots$ and conclude that the circuit is a modulo-3 counter.
脈絡:範例 5.19 — 圖 5.71 的模 3 計數器(兩個 JK FF)Context: Example 5.19 — Figure 5.71 mod-3 counter (two JK FFs)文脈:例 5.19 — 図 5.71 のモジュロ 3 カウンタ(JK FF 2 個)

電路。兩個邊緣觸發的 JK 正反器共用時脈輸入 $w$ 與一個共同的非同步 Clear。兩個 K 輸入都綁在邏輯 1,所以每個 FF 不是保持($J=0$ 時)就是翻轉($J=1$ 時)。組合邏輯的接線如下:

The circuit. Two edge-triggered JK flip-flops share clock input $w$ and a common asynchronous Clear. Both K inputs are tied to logic 1, so each FF either holds (when $J=0$) or toggles (when $J=1$). The combinational wiring is:

回路。エッジトリガの JK フリップフロップ 2 個が、クロック入力 $w$ と共通の非同期 Clear を共有する。K 入力はどちらも論理 1 に固定されているので、各 FF は保持($J=0$ のとき)かトグル($J=1$ のとき)のいずれかになる。組合せ回路の配線は次のとおりである:

  • $J_0 = \overline{Q_1}$、$K_0 = 1$  (FF0 會翻轉,除非 $Q_1=1$,此時它會被重置)
  • $J_0 = \overline{Q_1}$, $K_0 = 1$  (FF0 toggles unless $Q_1=1$, in which case it resets)
  • $J_0 = \overline{Q_1}$、$K_0 = 1$  (FF0 はトグルするが、$Q_1=1$ のときはリセットされる)
  • $J_1 = Q_0$、 $K_1 = 1$  (FF1 在 $Q_0=1$ 時翻轉,否則被重置)
  • $J_1 = Q_0$,  $K_1 = 1$  (FF1 toggles when $Q_0=1$, otherwise resets)
  • $J_1 = Q_0$、 $K_1 = 1$  (FF1 は $Q_0=1$ のときトグルし、そうでなければリセットされる)
FF0 J K Q FF1 J K Q Q0 Q1 w 1 1 Q̄1 共用的非同步 Clear → 兩個正反器都重設為 0(圖中未畫)Common async Clear → both FFs reset to 0 (not drawn)共通の非同期 Clear → どちらの FF も 0 にリセット(図では省略)

JK 行為回顧。在 $w$ 的每個上升緣:

JK behavior recap. On each rising edge of $w$:

JK の動作の復習。$w$ の立上りごとに:

$J$$K$$Q^{+}$名稱name名称
00$Q$hold
010reset
101set
11$\overline{Q}$toggle

逐狀態走一遍。Clear $\Rightarrow Q_1Q_0=00$ 開始:

State walk-through. Start from Clear $\Rightarrow Q_1Q_0=00$:

状態を順に追う。Clear $\Rightarrow Q_1Q_0=00$ から始める:

之前before$J_1K_1$$J_0K_0$FF1 的動作FF1 actionFF1 の動作FF0 的動作FF0 actionFF0 の動作之後after
$Q_1Q_0=00$$0,1$$1,1$reset → 0toggle → 1$01$
$Q_1Q_0=01$$1,1$$1,1$toggle → 1toggle → 0$10$
$Q_1Q_0=10$$0,1$$0,1$reset → 0reset → 0$00$

循環在三個脈衝之後閉合:$00 \to 01 \to 10 \to 00 \to \ldots$ — 正是 0, 1, 2, 0, 1, 2, … 這串計數序列,所以這個電路是模 3(除以 3)計數器

The cycle closes after three pulses: $00 \to 01 \to 10 \to 00 \to \ldots$ — exactly the count sequence 0, 1, 2, 0, 1, 2, … so the circuit is a modulo-3 (divide-by-3) counter.

3 パルスで循環が閉じる:$00 \to 01 \to 10 \to 00 \to \ldots$ — まさに 0, 1, 2, 0, 1, 2, … という計数列であり、この回路はモジュロ 3(3 分周)カウンタである。

時序圖(對應圖 5.72;兩個 FF 都在 $w$ 的正緣觸發):

Timing diagram (matches Figure 5.72; both FFs are positive-edge-triggered on $w$):

タイミング図(図 5.72 に対応。FF はどちらも $w$ の正エッジでトリガされる):

w Q0 Q1 Q1Q0: 00 01 10 00 01 10

為什麼這樣接線行得通。狀態 $11$ 在結構上就被排除了:從狀態 $10$ 出發,$J_0=\overline{Q_1}=0$ 使 $Q_0$ 維持在 0,所以下一狀態不可能是 $11$。可達狀態只有三個,三個時脈脈衝就回到起點 — 這正是模 3 計數器的定義性質。

Why this wiring works. State $11$ is excluded by construction: from state $10$, $J_0=\overline{Q_1}=0$ keeps $Q_0$ at 0, so the next state can never be $11$. With only three reachable states, three clock pulses return to the start — the defining property of a mod-3 counter.

この配線がうまくいく理由。状態 $11$ は構成上排除されている:状態 $10$ では $J_0=\overline{Q_1}=0$ が $Q_0$ を 0 に保つので、次状態が $11$ になることはない。到達可能な状態が 3 つしかないため、3 個のクロックパルスで出発点へ戻る — モジュロ 3 カウンタを定義づける性質である。

與第 6 章的連結。這是手工做出來的 FSM。在 §6.7 中,同一個模 3 計數器會以系統化的方式重新推導:選定狀態指派,建立 JK FF 的激勵表(使用 JK 特性表的反向對照),再從卡諾圖讀出 $J_i$、$K_i$。上面那組接線正是該程序得到的最佳結果。

Connection to Chapter 6. This is a hand-crafted FSM. In §6.7 the same mod-3 counter is re-derived systematically: pick a state assignment, build the excitation table for JK FFs (using the inverse of the JK characteristic table), and read $J_i$, $K_i$ off K-maps. The wiring above is the optimal result of that procedure.

第 6 章とのつながり。これは手作りの FSM である。§6.7 では同じモジュロ 3 カウンタを体系的に導き直す:状態割当てを選び、JK FF の励振表を(JK の特性表を逆に使って)作り、カルノー図から $J_i$、$K_i$ を読み取る。上の配線は、その手続きが与える最適な結果である。

— example 5.19
5.32困難Hard難しい第一階Tier 1ティア 1E?R
設計一個販賣機控制器,輸入為 $Q$(25 分)、$D$(10 分)、$N$(5 分)、$\text{Coin}$ 脈衝與 $\overline{\text{Resetn}}$。當累計投入金額達到至少 30 分時,輸出 $Z$ 被 assert(不找零)。只能使用一個 6 位元加法器、一個 6 位元暫存器與若干邏輯閘。
Design a vending-machine controller with inputs $Q$ (quarter), $D$ (dime), $N$ (nickel), $\text{Coin}$ pulse, and $\overline{\text{Resetn}}$. The output $Z$ is asserted when the cumulative deposit reaches at least 30 cents (no change is given). Use a 6-bit adder, a 6-bit register, and gates only.
入力を $Q$(25 セント)、$D$(10 セント)、$N$(5 セント)、$\text{Coin}$ パルス、$\overline{\text{Resetn}}$ とする自動販売機コントローラを設計せよ。投入金額の累計が 30 セント以上になったとき出力 $Z$ がアサートされる(釣り銭は出さない)。6 ビット加算器 1 個、6 ビットレジスタ 1 個、およびゲートのみを用いること。
5.33困難Hard難しい第一階Tier 1ティア 1E?R
撰寫 Verilog 程式碼實作範例 5.20 的 30 分販賣機控制器,包含把 $N$、$D$、$Q$ 編碼成 5 位元增量、以 Coin 的負緣觸發的 6 位元累加暫存器,以及輸出式 $Z = s_5 + s_4 s_3 s_2 s_1$。— example 5.20
Write Verilog code that implements the 30-cent vending-machine controller of Example 5.20, including the encoding of $N$, $D$, $Q$ into a 5-bit increment, the 6-bit accumulator register clocked on the negative edge of Coin, and the output expression $Z = s_5 + s_4 s_3 s_2 s_1$.— example 5.20
例題 5.20 の 30 セント自動販売機コントローラを実装する Verilog コードを書け。$N$、$D$、$Q$ を 5 ビットの増分に符号化する部分、Coin の立下りエッジで動作する 6 ビットのアキュムレータレジスタ、そして出力式 $Z = s_5 + s_4 s_3 s_2 s_1$ を含めること。— example 5.20
5.34困難Hard難しい第一階Tier 1ティア 1E?R
重新設計一個 4 位元同步計數器,以縮短正反器之間串接 AND 閘的延遲。重新安排閘控邏輯,使最長路徑變成 $T_{min}=t_{cQ}+t_{AND}+t_{XOR}+t_{su}$,並在 $t_{cQ}=1.0$ ns、$t_{AND}=1.4$ ns、$t_{XOR}=1.2$ ns、$t_{su}=0.6$ ns 之下計算 $F_{max}$。
Redesign a 4-bit synchronous counter to reduce the cascaded AND-gate delay between flip-flops. Refactor the gating so that the longest path becomes $T_{min}=t_{cQ}+t_{AND}+t_{XOR}+t_{su}$, and compute $F_{max}$ given $t_{cQ}=1.0$ ns, $t_{AND}=1.4$ ns, $t_{XOR}=1.2$ ns, $t_{su}=0.6$ ns.
4 ビット同期カウンタを再設計し、フリップフロップ間で縦続接続された AND ゲートの遅延を減らせ。ゲーティングを組み替えて最長経路が $T_{min}=t_{cQ}+t_{AND}+t_{XOR}+t_{su}$ となるようにし、$t_{cQ}=1.0$ ns、$t_{AND}=1.4$ ns、$t_{XOR}=1.2$ ns、$t_{su}=0.6$ ns のときの $F_{max}$ を求めよ。
5.35困難Hard難しい第一階Tier 1ティア 1E?R
某電路含三個正反器 $Q_1, Q_2, Q_3$,其時脈延遲分別為 $\delta_1, \delta_2, \delta_3$。已知 $t_{su}=0.6$ ns、$t_h=0.4$ ns、$0.8 \le t_{cQ} \le 1.0$ ns,且 $k$ 輸入閘的閘延遲為 $1+0.1k$ ns,請針對下列各組時脈偏斜計算 $F_{max}$:(i) $\delta_1=\delta_2=\delta_3=0$,(ii) $\delta_1=\delta_3=0$、$\delta_2=0.7$ ns,(iii) $\delta_1=1$、$\delta_2=0$、$\delta_3=0.5$ ns。並檢查每一種情況是否有 hold-time 違規。
A circuit has three flip-flops $Q_1, Q_2, Q_3$ with corresponding clock delays $\delta_1, \delta_2, \delta_3$. Given $t_{su}=0.6$ ns, $t_h=0.4$ ns, $0.8 \le t_{cQ} \le 1.0$ ns, and gate delay $1+0.1k$ ns for $k$-input gates, compute $F_{max}$ for the clock-skew sets (i) $\delta_1=\delta_2=\delta_3=0$, (ii) $\delta_1=\delta_3=0$, $\delta_2=0.7$ ns, and (iii) $\delta_1=1$, $\delta_2=0$, $\delta_3=0.5$ ns. Check for hold-time violations in each case.
ある回路にはフリップフロップ $Q_1, Q_2, Q_3$ の 3 個があり、それぞれのクロック遅延は $\delta_1, \delta_2, \delta_3$ である。$t_{su}=0.6$ ns、$t_h=0.4$ ns、$0.8 \le t_{cQ} \le 1.0$ ns、$k$ 入力ゲートのゲート遅延を $1+0.1k$ ns として、次のクロックスキューの各組について $F_{max}$ を求めよ:(i) $\delta_1=\delta_2=\delta_3=0$、(ii) $\delta_1=\delta_3=0$、$\delta_2=0.7$ ns、(iii) $\delta_1=1$、$\delta_2=0$、$\delta_3=0.5$ ns。またそれぞれの場合について hold-time 違反の有無を確かめよ。
06 同步循序電路Synchronous Sequential Circuits同期順序回路

這是有限狀態機(FSM)設計的核心章節。書中提出系統化的設計程序:從狀態圖到狀態表、狀態指派、正反器的選擇、下一狀態與輸出邏輯的推導,一直到時序驗證。Moore 機(輸出只取決於狀態)與 Mealy 機(輸出取決於狀態與目前的輸入)都以清楚的範例涵蓋。狀態指派策略包含二進位編碼與 one-hot 編碼。本章也完整處理了以分割程序進行的狀態最小化。書中以 Moore 與 Mealy 兩種風格各設計一次串列加法器,用以說明其間的取捨。仲裁器電路、以循序電路方法設計計數器、既有循序電路的分析,以及 ASM(Algorithmic State Machine)圖也都涵蓋在內。Verilog 程式範例使用 parametercase 以及多區塊的 FSM 撰寫風格。

This is the core chapter on finite state machine (FSM) design. The systematic design procedure is presented: from state diagram to state table, state assignment, choice of flip-flops, derivation of next-state and output logic, to timing verification. Both Moore machines (output depends only on state) and Mealy machines (output depends on state and current inputs) are covered with clear examples. State assignment strategies include binary encoding and one-hot encoding. The chapter includes a thorough treatment of state minimization using the partitioning procedure. A serial adder is designed in both Moore and Mealy styles to illustrate the tradeoffs. Arbiter circuits, counter design using the sequential-circuit approach, analysis of existing sequential circuits, and ASM (Algorithmic State Machine) charts are also covered. Verilog code examples use parameter, case, and multi-block FSM coding styles.

有限状態機械(FSM)設計の中核となる章である。体系的な設計手順が示される:状態遷移図から状態表、状態割当て、フリップフロップの選択、次状態論理と出力論理の導出、そしてタイミング検証まで。Moore 機械(出力が状態のみで決まる)と Mealy 機械(出力が状態と現在の入力で決まる)の双方を、明快な例とともに扱う。状態割当ての方針には 2 進符号化と one-hot 符号化がある。分割手続きによる状態最小化も本章で徹底的に扱われる。トレードオフを示すため、直列加算器を Moore 形式と Mealy 形式の両方で設計する。アービタ回路、順序回路的手法によるカウンタ設計、既存の順序回路の解析、そして ASM(Algorithmic State Machine)チャートも扱う。Verilog のコード例では parametercase、および複数ブロックに分ける FSM 記述スタイルを用いる。

Moore 與 Mealy FSM 狀態圖/狀態表 狀態指派 one-hot 編碼 狀態極小化 串列加法器 ASM 圖 仲裁器電路 Verilog FSM 寫法
Moore vs Mealy FSMs State Diagrams / Tables State Assignment One-Hot Encoding State Minimization Serial Adder ASM Charts Arbiter Circuits Verilog FSM Styles
Moore と Mealy の FSM 状態遷移図/状態表 状態割当て one-hot 符号化 状態最小化 直列加算器 ASM チャート アービタ回路 Verilog の FSM 記述スタイル
Moore 對 Mealy:兩種狀態圖在畫法上的差異Moore vs Mealy: how the two state diagrams differ visuallyMoore と Mealy:2 つの状態遷移図は見た目でどう違うか

兩種風格描述的是同一類 FSM,只是輸出畫在不同的位置。這一點在流程表(第 9 章)中呈現的方式,和在同步狀態圖(第 6 章)中是一樣的。

Both styles describe the same kind of FSM, but the output is drawn in different places. This shows up in flow tables (ch 9) the same way it shows up in synchronous state diagrams (ch 6).

どちらの形式も同じ種類の FSM を記述するが、出力を描く場所が違う。この違いは、同期式の状態遷移図(第 6 章)と同じかたちでフロー表(第 9 章)にも現れる。

對照範例 — 兩者都偵測輸入序列「11」並 assert $z=1$。行為相同,畫法慣例不同:

Side-by-side example — both detect the input sequence "11" and assert $z=1$. Same behavior, different drawing convention:

並べて比べる例 — どちらも入力系列「11」を検出して $z=1$ をアサートする。動作は同じで、作図の流儀が違うだけである:

Moore輸出寫在狀態內部output written inside the state出力は状態の中に書くAz=0Bz=0Cz=1w=0w=1w=1w=0w=0w=1Mealy輸出寫在轉移上(輸入/輸出)output written on the transition (input/output)出力は遷移の上に書く(入力/出力)ABw=0/0w=1/0w=1/1w=0/0

Reading the labels:

寫法style書き方狀態圓圈state circle状態の円箭頭標籤arrow label矢印のラベル輸出規則output rule出力規則
Moorename + output value (e.g. A/0, C/1)just the input value (w=1)$z = f(\text{state})$ — 已暫存,整個週期都穩定$z = f(\text{state})$ — registered, stable for full cycle$z = f(\text{state})$ — レジスタ出力であり、1 サイクルを通じて安定
Mealy只有狀態名稱(沒有輸出)just the state name (no output)状態名だけ(出力なし)input/output (w=1/1)$z = f(\text{state}, \text{input})$ — 組合邏輯,可能在週期中途改變$z = f(\text{state}, \text{input})$ — combinational, may change mid-cycle$z = f(\text{state}, \text{input})$ — 組合せ回路であり、サイクルの途中で変化しうる

同樣的工作,狀態數不同。上面的 Moore 版本需要 3 個狀態(A、B、C — 其中 C 專門用來表示「看到 11」,好讓 $z=1$ 能寄存在一個狀態裡)。Mealy 版本只需要 2 個狀態(A、B),因為「$z=1$」這個事件是在 B→B 這條轉移上發出的,不需要額外的狀態。

Same job, different state count. The Moore version above needs 3 states (A, B, C — with C dedicated to "saw 11" so $z=1$ can live in a state). The Mealy version needs only 2 states (A, B) because the "$z=1$" event is fired on the B→B transition itself, no extra state required.

同じ仕事でも状態数は違う。上の Moore 版は 3 状態(A、B、C — 「11 を見た」専用の C を置くことで $z=1$ を状態に持たせられる)を必要とする。Mealy 版は 2 状態(A、B)で済む。「$z=1$」という事象は B→B の遷移そのもので発火するので、余分な状態が要らないからである。

一眼分辨兩者的快速視覺線索:

Quick visual cues to tell them apart at a glance:

ひと目で見分けるための視覚的な手がかり:

  • 若看到圓圈裡有斜線A/0),而箭頭標籤只有輸入 → Moore
  • If you see a slash inside a circle (A/0) and arrow labels are just inputs → Moore.
  • 円の中にスラッシュA/0)があり、矢印のラベルが入力だけなら → Moore である。
  • 若看到箭頭上有斜線w=1/1),而圓圈裡只有狀態名稱 → Mealy
  • If you see a slash on an arrow (w=1/1) and circles only contain state names → Mealy.
  • 矢印にスラッシュw=1/1)があり、円の中が状態名だけなら → Mealy である。
  • Moore 的「接受」狀態有時會畫成雙圓圈(同心圓)— Mealy 沒有這種慣例。
  • Sometimes a Moore "accepting" state is drawn with a double circle (concentric rings) — Mealy has no such convention.
  • Moore の「受理」状態は二重丸(同心円)で描かれることがある — Mealy にそのような習慣はない。
  • 在同步狀態表中(本章):Moore 把輸出列成以現態為索引的獨立欄位;Mealy 則把輸出寫在每一個(狀態,輸入)格中,與次態項目並列。
  • In synchronous state tables (this chapter): Moore lists outputs as a separate column keyed on present state; Mealy lists outputs per (state, input) cell, alongside the next-state entry.
  • 同期式の状態表(本章)では:Moore は現状態をキーとする独立した列に出力を並べ、Mealy は(状態、入力)のセルごとに次状態の項目と並べて出力を書く。
6.1中等Medium普通第一階Tier 1ティア 1?R
請推導一個 FSM 的狀態圖,其輸入為 w、輸出為 z,每當偵測到輸入序列 101 時輸出 z=1。重疊的序列也必須被偵測到。
Derive the state diagram for an FSM with input w and output z that outputs z=1 whenever the input sequence 101 is detected. Overlapping sequences should be detected.
入力 w、出力 z をもち、入力系列 101 を検出するたびに z=1 を出力する FSM の状態遷移図を導け。重なり合う系列も検出すること。
6.2中等Medium普通第一階Tier 1ティア 1?R
For the FSM in exercise 6.1, derive the state table, assign binary state codes, and determine the next-state and output equations using D flip-flops.
背景:習題 6.1 的 FSM — 允許重疊的「101」序列偵測器Context: the FSM from exercise 6.1 — "101" sequence detector with overlap背景:演習 6.1 の FSM — 重なりを許す「101」系列検出器

習題 6.1 回顧。此 FSM 在輸入 $w$ 上偵測序列 101,並在序列完成時使 $z=1$。允許重疊 — 例如在 $w = 1,0,1,0,1$ 時,偵測器應該觸發兩次:在第 3 位(第一個「101」)與第 5 位(第二個「101」,重複使用第 3 位的那個「1」)。

Recap of exercise 6.1. The FSM detects the input sequence 101 on input $w$ and asserts $z=1$ when the sequence completes. Overlapping is allowed — e.g., on $w = 1,0,1,0,1$ the detector should fire twice: at position 3 (first "101") and at position 5 (second "101", reusing the "1" at position 3).

演習 6.1 の復習。この FSM は入力 $w$ 上の系列 101 を検出し、系列が完成したときに $z=1$ をアサートする。重なりは許される — たとえば $w = 1,0,1,0,1$ のとき、検出器は2 回発火するはずである:3 番目(1 つ目の「101」)と 5 番目(2 つ目の「101」。3 番目の「1」を再利用する)である。

Moore state diagram (4 states):

  • A — 初始/沒有有用的前綴。$w=0 \to A$,$w=1 \to B$。$z=0$。
  • A — initial / no useful prefix. $w=0 \to A$, $w=1 \to B$. $z=0$.
  • A — 初期状態/有用な接頭辞なし。$w=0 \to A$、$w=1 \to B$。$z=0$。
  • B — last input was 1. $w=0 \to C$, $w=1 \to B$. $z=0$.
  • C — 最後兩個輸入是「10」。$w=0 \to A$,$w=1 \to D$(序列完成)。$z=0$。
  • C — last two inputs were "10". $w=0 \to A$, $w=1 \to D$ (sequence complete). $z=0$.
  • C — 直前の 2 入力が「10」。$w=0 \to A$、$w=1 \to D$(系列が完成)。$z=0$。
  • D — 剛偵測到序列「101」。$w=0 \to C$(新的「0」加上 D 尾端的「1」構成「10」),$w=1 \to B$(重疊 — D 尾端的「1」加上新的「1」形成 B)。$z=1$。
  • D — sequence "101" just detected. $w=0 \to C$ (the new "0" plus the trailing "1" from D forms "10"), $w=1 \to B$ (overlap — the trailing "1" of D plus the new "1" makes B). $z=1$.
  • D — 系列「101」を検出した直後。$w=0 \to C$(新しい「0」と D の末尾の「1」で「10」になる)、$w=1 \to B$(重なり — D の末尾の「1」と新しい「1」で B になる)。$z=1$。

重疊來自 D 的轉移:完成序列的那個「1」被重複用作下一次嘗試的前綴。

Overlapping comes from D\'s transitions: the "1" that completed the sequence is reused as the prefix of the next attempt.

重なりは D の遷移から生じる:系列を完成させた「1」が、次の試行の接頭辞として再利用されるのである。

狀態表,採用 2 位元格雷碼式的二進位指派 $A=00, B=01, C=10, D=11$:

State table with 2-bit Gray-style binary assignment $A=00, B=01, C=10, D=11$:

状態表。2 ビットのグレイ符号風の 2 進割当て $A=00, B=01, C=10, D=11$ を用いる:

目前的 $y_2 y_1$Present $y_2 y_1$現在の $y_2 y_1$$w=0$ 的下一個 $Y_2 Y_1$$w=0$ next $Y_2 Y_1$$w=0$ のときの次の $Y_2 Y_1$$w=1$ 的下一個 $Y_2 Y_1$$w=1$ next $Y_2 Y_1$$w=1$ のときの次の $Y_2 Y_1$$z$
A=0000 (A)01 (B)0
B=0110 (C)01 (B)0
C=1000 (A)11 (D)0
D=1110 (C)01 (B)1

Next-state equations (D flip-flops):

$Y_1$ 的卡諾圖一望即知 — 只有在 $w=1$ 的格子裡 $Y_1 = 1$(與現態無關):

$Y_1$ K-map by inspection — $Y_1 = 1$ only in cells where $w=1$ (regardless of present state):

$Y_1$ のカルノー図は一目で分かる — $Y_1 = 1$ となるのは $w=1$ のセルだけである(現状態によらない):

$$Y_1 = w$$

$Y_2$ 的卡諾圖 — $Y_2 = 1$ 的格子為:$(w=0, y_2 y_1 = 01)$、$(w=0, y_2 y_1 = 11)$、$(w=1, y_2 y_1 = 10)$。分組:前兩格共有 $\overline{w}\,y_1$;第三格則是 $w\,y_2\,\overline{y_1}$。

$Y_2$ K-map — $Y_2 = 1$ in cells: $(w=0, y_2 y_1 = 01)$, $(w=0, y_2 y_1 = 11)$, $(w=1, y_2 y_1 = 10)$. Group: the first two cells share $\overline{w}\,y_1$; the third is $w\,y_2\,\overline{y_1}$.

$Y_2$ のカルノー図 — $Y_2 = 1$ となるセルは $(w=0, y_2 y_1 = 01)$、$(w=0, y_2 y_1 = 11)$、$(w=1, y_2 y_1 = 10)$ である。グループ化:前の 2 セルは $\overline{w}\,y_1$ を共有し、3 つ目は $w\,y_2\,\overline{y_1}$ となる。

$$Y_2 = \overline{w}\,y_1 + w\,y_2\,\overline{y_1}$$

Output: $z = 1$ only in state D = 11.

$$z = y_2 \cdot y_1$$

實作:2 個 D 正反器加上幾個閘。總成本:1 個緩衝器($Y_1 = w$ — 不需邏輯)、1 個 AND2 + 1 個 AND3 + 1 個 OR2($Y_2$)、1 個 AND2($z$)≈ 5 個閘/9 個輸入。現代合成工具推導出來的結果正是如此。

Implementation: 2 D flip-flops + a few gates. Total cost: 1 buffer ($Y_1 = w$ — no logic), 1 AND2 + 1 AND3 + 1 OR2 ($Y_2$), 1 AND2 ($z$) ≈ 5 gates / 9 inputs. Modern synthesis tools would derive this exactly.

実装:D フリップフロップ 2 個といくつかのゲート。総コストは、バッファ 1 個($Y_1 = w$ — 論理は不要)、AND2 1 個 + AND3 1 個 + OR2 1 個($Y_2$)、AND2 1 個($z$)で、ゲート約 5 個/入力 9 本である。現代の合成ツールもちょうどこれを導く。

Verification. Trace input $w = 1,0,1,0,1$ starting in A:

週期cycleサイクル進入狀態state in入り状態$w$離開狀態state out出状態$z$
0A1B0
1B0C0
2C1D0 → 1
3D0C1 → 0
4C1D0 → 1

在第 2 與第 4 週期各偵測到一次「101」— 重疊被正確偵測出來。

Two "101" detections at cycles 2 and 4 — overlap correctly detected.

サイクル 2 と 4 で「101」を 2 回検出 — 重なりが正しく検出されている。

6.3中等Medium普通第一階Tier 1ティア 1?R
請推導一個 Moore 型 FSM 的狀態圖,當輸入 w 上收到至少連續三個 1 時輸出 z=1
Derive the state diagram for a Moore-type FSM that outputs z=1 when it has received at least three consecutive 1s on input w.
入力 w に 1 が少なくとも 3 個連続して現れたとき z=1 を出力する Moore 型 FSM の状態遷移図を導け。
6.4中等Medium普通第一階Tier 1ティア 1?R
Repeat exercise 6.3 as a Mealy-type FSM. Compare the number of states needed.
背景:習題 6.3 的 FSM — 「連續三個 1」偵測器Context: the FSM from exercise 6.3 — "three consecutive 1s" detector背景:演習 6.3 の FSM — 「1 が 3 回連続」検出器

習題 6.3 回顧(Moore 版)。此 FSM 在輸入 $w$ 上收到至少三個連續的 1 之後輸出 $z=1$。一旦出現 0,連續就中斷,計數歸零。

Recap of exercise 6.3 (Moore version). The FSM outputs $z=1$ once it has received at least three consecutive 1s on input $w$. As soon as a 0 arrives, the run breaks and the count resets.

演習 6.3 の復習(Moore 版)。この FSM は入力 $w$ 上で 1 を少なくとも 3 回連続して受け取ると $z=1$ を出力する。0 が来た時点で連続は途切れ、カウントはリセットされる。

Moore state diagram — 4 states:

  • A — no 1s pending. $w=0 \to A$, $w=1 \to B$. $z = 0$.
  • B — saw one 1. $w=0 \to A$, $w=1 \to C$. $z = 0$.
  • C — saw two consecutive 1s. $w=0 \to A$, $w=1 \to D$. $z = 0$.
  • D — 已看到三個以上連續的 1。$w=0 \to A$,$w=1 \to D$(停留)。$z = 1$。
  • D — saw three or more consecutive 1s. $w=0 \to A$, $w=1 \to D$ (stay). $z = 1$.
  • D — 1 が 3 回以上連続したのを見た。$w=0 \to A$、$w=1 \to D$(とどまる)。$z = 1$。

Moore 的輸出只是狀態的函數,因此要區分「看到 3 個」與「看到 ≥3 個」,就必須有一個專門的「偵測」狀態 D 來寄存 $z=1$。

The Moore output is a function of state alone, so distinguishing "saw 3" from "saw ≥3" requires a separate "detection" state D where $z=1$ is registered.

Moore の出力は状態だけの関数なので、「3 個見た」と「3 個以上見た」を区別するには、$z=1$ を持たせる専用の「検出」状態 D が必要になる。

Mealy version — 3 states:

  • A — no 1s. $w=0/0 \to A$, $w=1/0 \to B$.
  • B — saw one 1. $w=0/0 \to A$, $w=1/0 \to C$.
  • C — 已看到兩個連續的 1。$w=0/0 \to A$,$w=1/\mathbf{1} \to C$(在第三個 1 上輸出 1;只要 1 持續就留在 C,並在之後每一個 1 上都發出 $z=1$)。
  • C — saw two consecutive 1s. $w=0/0 \to A$, $w=1/\mathbf{1} \to C$ (output 1 on the third 1; stay in C as long as 1s continue, firing $z=1$ on every additional 1).
  • C — 1 が 2 回連続したのを見た。$w=0/0 \to A$、$w=1/\mathbf{1} \to C$(3 個目の 1 で出力 1。1 が続く限り C にとどまり、以降の 1 ごとに $z=1$ を出す)。

記法 $w/z$ 表示轉移上的輸入/輸出。Mealy 形式在 $w=1$ 時於 C 到自身的轉移上發出 $z=1$,因此不需要另設一個「看到三個」的狀態 — 第三個 1 的效果就寄存在觀察到它的那一次轉移的輸出上。

Notation $w/z$ means input/output on the transition. The Mealy form fires $z=1$ on the transition from C to itself when $w=1$, so we don\'t need a separate "saw three" state — the third 1\'s effect is registered as the output of the very transition that observes it.

記法 $w/z$ は遷移上の入力/出力を表す。Mealy 形式では $w=1$ のとき C から C への遷移そのもので $z=1$ を出すので、「3 個見た」専用の状態は要らない — 3 個目の 1 の効果は、それを観測したまさにその遷移の出力として現れる。

Mealy 狀態圖(從 B 與 C 回到 A 的箭頭安排在不同深度,因此不會互相重疊):

Mealy state diagram (return arrows from B and C to A are routed at distinct depths so they never overlap):

Mealy 状態遷移図(B と C から A へ戻る矢印は互いに重ならないよう別々の深さに配置してある):

ABC0/01/11/01/00/00/0

Verilog(Mealy,3 個狀態) — 組合邏輯輸出在 C→C 轉移上同時用到狀態與輸入 $w$:

Verilog (Mealy, 3 states) — combinational output uses both state and input $w$ on the C→C transition:

Verilog(Mealy、3 状態) — 組合せ出力は C→C の遷移で状態と入力 $w$ の両方を使う:

module mealy_three_ones (
  input  clock, resetn, w,
  output reg z
);
  reg [1:0] y;
  parameter A = 2'b00, B = 2'b01, C = 2'b10;

  // single always block: state register + registered Mealy output
  always @(posedge clock or negedge resetn) begin
    if (!resetn) begin
      y <= A;
      z <= 1'b0;
    end else begin
      case (y)
        A:       begin y <= (w ? B : A); z <= 1'b0; end
        B:       begin y <= (w ? C : A); z <= 1'b0; end
        C:       begin y <= (w ? C : A); z <= w;    end  // z=1 on C&&w=1
        default: begin y <= A;         z <= 1'b0; end
      endcase
    end
  end
endmodule

Comparison:

性質Property性質Moore(範例 6.3)Moore (ex 6.3)Moore(例 6.3)Mealy(範例 6.4)Mealy (ex 6.4)Mealy(例 6.4)
States4  (A, B, C, D)3  (A, B, C)
Flip-flops22
Output$z = f(\text{state})$$z = f(\text{state}, w)$
Output timingsynchronous (clock edge)combinational (input-driven)

Key takeaways:

  • Mealy 把「我剛偵測到事件」摺進轉移輸出而不是專用狀態,因而減少狀態數。本例正好省下一個狀態(4 → 3)。
  • Mealy reduces state count by folding "I just detected the event" into the transition output rather than into a dedicated state. Saves exactly one state in this case (4 → 3).
  • Mealy は「いま事象を検出した」を専用の状態ではなく遷移出力に畳み込むことで状態数を減らす。この例ではちょうど 1 状態(4 → 3)節約できる。
  • 正反器數量不見得會隨狀態數一起下降 — 兩個版本都需要 2 個正反器,因為 $\lceil \log_2 3 \rceil = \lceil \log_2 4 \rceil = 2$。
  • Flip-flop count doesn\'t always go down with state count — both versions need 2 flip-flops because $\lceil \log_2 3 \rceil = \lceil \log_2 4 \rceil = 2$.
  • フリップフロップ数は状態数と一緒に必ず減るわけではない — $\lceil \log_2 3 \rceil = \lceil \log_2 4 \rceil = 2$ なので、どちらの版も 2 個必要である。
  • Mealy 的輸出 $z$ 會在 $w$ 改變時於時脈週期中途變化 — Moore 的 $z$ 只在時脈邊緣改變。若要求輸出無突波,Moore 較安全;若在意從輸入到輸出的延遲最小,則 Mealy 勝出。
  • Mealy output $z$ can change in the middle of a clock cycle when $w$ changes — Moore $z$ only changes at clock edges. If glitch-free output is required, Moore is safer; if minimum latency from input to output matters, Mealy wins.
  • Mealy の出力 $z$ は $w$ が変わるとクロックサイクルの途中でも変化しうる — Moore の $z$ はクロックエッジでしか変化しない。グリッチのない出力が要るなら Moore が安全であり、入力から出力までの遅延を最小にしたいなら Mealy が有利である。
6.5中等Medium普通第一階Tier 1ティア 1?R
說明 Moore 型與 Mealy 型 FSM 的差異。並各舉出一項優點。
Explain the difference between Moore and Mealy FSMs. Give one advantage of each type.
Moore 型と Mealy 型の FSM の違いを説明せよ。それぞれの利点を 1 つずつ挙げよ。
6.6中等Medium普通第一階Tier 1ティア 1?R
什麼是 one-hot 狀態編碼?對於一個有 5 個狀態的 FSM,二進位編碼與 one-hot 編碼各需要多少個正反器?請討論兩者的取捨。
What is one-hot state encoding? For an FSM with 5 states, how many flip-flops are needed for binary encoding versus one-hot? Discuss the tradeoffs.
one-hot 状態符号化とは何か。状態が 5 個の FSM では、2 進符号化と one-hot でフリップフロップはそれぞれ何個必要か。両者のトレードオフを論ぜよ。
6.7中等Medium普通第一階Tier 1ティア 1?R
請為習題 6.1 的 Moore 型序列偵測器撰寫 Verilog 程式碼,使用 case 敘述,並以 parameter 宣告各狀態。
Write Verilog code for the Moore-type sequence detector in exercise 6.1 using a case statement and parameter declarations for the states.
演習 6.1 の Moore 型系列検出器の Verilog コードを、case 文と状態の parameter 宣言を用いて書け。
6.8中等Medium普通第一階Tier 1ティア 1?R
Write Verilog code for a Mealy FSM that outputs 1 whenever the last two inputs were 01. Use a three-block coding style (state register, next-state logic, output logic).
背景:三區塊 FSM 撰寫風格Context: the three-block FSM coding style背景:3 ブロック方式の FSM 記述スタイル

三區塊風格把 FSM 拆成三個各司其職的 always 區塊。它清楚對映到 FSM 在概念上的分解:狀態暫存器、次態函數與輸出函數:

The three-block style separates an FSM into three distinct always blocks, each with one focused responsibility. It cleanly mirrors the FSM's conceptual decomposition into a state register, a next-state function, and an output function:

3 ブロック方式は、FSM をそれぞれ責務を 1 つだけ持つ 3 つの always ブロックに分ける。状態レジスタ、次状態関数、出力関数という FSM の概念的な分解をそのまま写し取るものである:

Block 2next-state logicalways @(*)Block 1state registeralways @(posedge clk)Block 3output logicalways @(*) or assignYyy 回授到下一狀態邏輯(以及輸出邏輯)y feeds back to next-state logic (and to output logic)y は次状態論理(および出力論理)へ帰還するwz

The three blocks at a glance:

區塊blockブロック敏感度列表sensitivityセンシティビティ指派方式assignment代入角色role役割
1. State register@(posedge clk)non-blocking <=在每個時脈邊緣把次態寫入正反器commits next-state to FFs on every clock edgeクロックエッジごとに次状態をフリップフロップへ書き込む
2. Next-state logic@(*)blocking =combinational: $Y = \delta(y, w)$
3. Output logic@(*) or assignblocking = / assigncombinational: Moore $z = f(y)$ or Mealy $z = f(y, w)$

「最後兩個輸入 = 01」Mealy 偵測器(2 個狀態)的骨架:

Skeleton for the "last two inputs = 01" Mealy detector (2 states):

「直前の 2 入力 = 01」Mealy 検出器(2 状態)の骨組み:

module detect_01_mealy (
  input  clk, resetn, w,
  output reg z
);
  reg y, Y;
  parameter A = 1'b0,   // have not just seen a 0
            B = 1'b1;   // last input was 0

  // ── Block 1: state register ─────────────────────────────
  always @(posedge clk or negedge resetn) begin
    if (!resetn) y <= A;
    else         y <= Y;
  end

  // ── Block 2: next-state logic (combinational) ───────────
  always @(*) begin
    case (y)
      A: Y = (w == 1'b0) ? B : A;   // saw a 0 → go to B
      B: Y = (w == 1'b0) ? B : A;   // saw 0 again → stay; saw 1 → done, return to A
      default: Y = A;
    endcase
  end

  // ── Block 3: output logic (Mealy — uses state AND input) ──
  always @(*) z = (y == B) && (w == 1'b1);
endmodule

Why split it up:

  • 每個區塊都能各自讀懂。區塊 1 是樣板;區塊 2 是狀態轉移表;區塊 3 放輸出規則。
  • Each block is locally readable. Block 1 is boilerplate; Block 2 is the state-transition table; Block 3 holds the output rule.
  • 各ブロックが局所的に読める。ブロック 1 は定型、ブロック 2 は状態遷移表、ブロック 3 は出力規則である。
  • 阻塞與非阻塞指定不再含糊。區塊 1 一律用 <=;區塊 2 & 3 一律用 =。把兩者混在同一個區塊裡,是最常見的合成與模擬不一致來源。
  • Blocking vs non-blocking is unambiguous. Block 1 always uses <=; Blocks 2 & 3 always use =. Mixing them in a single block is the most common synthesis-vs-simulation mismatch.
  • ブロッキングと非ブロッキングの区別が曖昧にならない。ブロック 1 は必ず <= を、ブロック 2 & 3 は必ず = を使う。両者を 1 つのブロックに混ぜることが、合成とシミュレーションの不一致で最も多い原因である。
  • Moore ↔ Mealy 切換容易。只需改動區塊 3;暫存器與轉移都不用動。
  • Easy Moore ↔ Mealy switch. Only Block 3 changes; the register and transitions stay put.
  • Moore ↔ Mealy の切り替えが容易。変えるのはブロック 3 だけで、レジスタと遷移はそのままでよい。
  • 對合成友善。工具能立刻辨認出這個樣式,乾淨地推論出正反器與組合邏輯錐。
  • Synthesis-friendly. Tools immediately recognize the pattern and infer flip-flops + combinational cones cleanly.
  • 合成に優しい。ツールがこのパターンをすぐ認識し、フリップフロップと組合せ回路のコーンをきれいに推論する。

變體:有些作者把區塊 2 & 3 合併成單一個組合邏輯 always @(*)(「兩區塊」風格)。也有人在輸出是單一狀態的 Moore 解碼時,把區塊 3 縮成一行 assign。不變的原則是:狀態暫存器保持循序且獨立;其餘一切都是組合邏輯並明確標示

Variants: some authors merge Blocks 2 & 3 into one combinational always @(*) (a "two-block" style). Others reduce Block 3 to a single assign when the output is a one-state Moore decode. The invariant: state register stays sequential and isolated; everything else is combinational and explicitly labeled.

変種:ブロック 2 & 3 を 1 つの組合せ always @(*) にまとめる著者もいる(「2 ブロック」方式)。出力が 1 状態の Moore デコードなら、ブロック 3 を assign 1 本に縮める流儀もある。不変なのは、状態レジスタは順序回路として隔離し、それ以外はすべて組合せ回路として明示するという点である。

6.9中等Medium普通第一階Tier 1ティア 1?R
Given the state-assigned table: Present State y₂y₁, Next State (w=0 / w=1), Output z: {00→10/11, 0}, {01→01/00, 0}, {10→11/00, 0}, {11→10/01, 1}. Derive the next-state and output equations using D flip-flops.
What is this problem asking?

題目給你一張已指派狀態的狀態表 — 也就是每個抽象狀態都已經換成具體位元樣式的狀態表。任務是把這份抽象描述轉成三個布林運算式,讓你能用邏輯閘與正反器把電路接出來。

You are given a state-assigned table — a state table where each abstract state has already been replaced by a concrete bit pattern. The job is to convert that abstract description into three Boolean expressions that you could wire up with logic gates and flip-flops.

与えられるのは状態割当て済みの状態表、すなわち抽象的な状態がすでに具体的なビットパターンに置き換えられた状態表である。仕事は、この抽象的な記述を、論理ゲートとフリップフロップで配線できる3 つのブール式に変換することである。

How to read the table:

  • $y_2 y_1$ = 兩個狀態正反器的現值(此 FSM 有 4 個狀態,故 $\lceil\log_2 4\rceil = 2$ 個正反器)。
  • $y_2 y_1$ = the current values of two state flip-flops (the FSM has 4 states, so $\lceil\log_2 4\rceil = 2$ flip-flops).
  • $y_2 y_1$ = 2 個の状態フリップフロップの現在値(この FSM は 4 状態なので $\lceil\log_2 4\rceil = 2$ 個)。
  • 次態($Y_2 Y_1$) = 下一個時脈邊緣應載入正反器的位元樣式,對 $w=0$ 與 $w=1$ 兩種輸入條件分別列出。
  • Next state ($Y_2 Y_1$) = the bit pattern that should be loaded into the flip-flops on the next clock edge, listed for each input condition $w=0$ and $w=1$.
  • 次状態($Y_2 Y_1$) = 次のクロックエッジでフリップフロップに読み込むべきビットパターン。入力条件 $w=0$ と $w=1$ のそれぞれについて示される。
  • $z$ = 輸出,此處為 Moore 型 — 只取決於現態,與 $w$ 無關。
  • $z$ = the output, here Moore-style — depends only on present state, not on $w$.
  • $z$ = 出力。ここでは Moore 型であり、現状態だけに依存し $w$ には依存しない。

「$00 \to 10/11$」這樣的記法讀作:現態為 00 時,$w=0$ 的次態是 10,$w=1$ 的次態是 11。

Notation like "$00 \to 10/11$" reads: when present state is 00, next state is 10 if $w=0$, or 11 if $w=1$.

「$00 \to 10/11$」という記法は、現状態が 00 のとき、$w=0$ なら次状態は 10、$w=1$ なら 11 と読む。

為什麼「使用 D 正反器」很重要:D 正反器具有 $Q^+ = D$ 的性質 — 送到 D 輸入的值會在下一個時脈邊緣之後成為輸出。所以若希望次態的第 $i$ 個位元等於 $Y_i$,只要把組合邏輯訊號 $Y_i$ 接到第 $i$ 個正反器的 D 輸入即可。不需要經過激勵表轉換(不像 JK 或 T 正反器還要多一道轉換手續)。

Why "using D flip-flops" matters: a D flip-flop has the property $Q^+ = D$ — whatever you put on the D input becomes the output after the next clock edge. So if you want next-state bit $i$ to equal $Y_i$, you simply connect the combinational signal $Y_i$ to the D input of flip-flop $i$. No conversion through excitation tables is needed (unlike JK or T flip-flops, which require an extra translation step).

「D フリップフロップを使う」ことがなぜ効くのか:D フリップフロップは $Q^+ = D$ という性質を持つ — D 入力に与えた値が、次のクロックエッジのあとそのまま出力になる。したがって次状態の第 $i$ ビットを $Y_i$ にしたいなら、組合せ信号 $Y_i$ をフリップフロップ $i$ の D 入力につなぐだけでよい。励振表を介した変換は不要である(JK や T フリップフロップのように余分な変換段が要らない)。

你必須產出的東西 — 三個布林運算式:

What you must produce — three Boolean expressions:

作るべきもの — 3 つのブール式:

  1. $Y_2 = D_2 = f(w, y_2, y_1)$ — the combinational logic feeding flip-flop 2.
  2. $Y_1 = D_1 = f(w, y_2, y_1)$ — likewise for flip-flop 1.
  3. $z = f(y_2, y_1)$ — 輸出解碼(因為是 Moore,所以不含 $w$)。
  4. $z = f(y_2, y_1)$ — the output decode (no $w$ since this is Moore).
  5. $z = f(y_2, y_1)$ — 出力デコード(Moore なので $w$ は入らない)。

Recommended procedure:

  1. 把這張 4 列的表展開成以 $(w, y_2, y_1)$ 為索引的 8 列真值表。
  2. Expand the 4-row table into an 8-row truth table indexed by $(w, y_2, y_1)$.
  3. 4 行の表を、$(w, y_2, y_1)$ を索引とする 8 行の真理値表に展開する。
  4. 為 $Y_2$、$Y_1$、$z$ 這三個輸出欄位各畫一張 3 變數卡諾圖
  5. Build a 3-variable K-map for each output column $Y_2$, $Y_1$, $z$.
  6. 出力の各列 $Y_2$、$Y_1$、$z$ について3 変数のカルノー図を作る
  7. 從每張 K-map 讀出最小 SOP(或 POS)。
  8. Read off minimum SOP (or POS) from each K-map.
  9. 各 K-map から最小 SOP を読み取る(または POS)。
  10. 畫出電路:兩個 D 型正反器,以組合閘實作各個 $Y_i$ 並接到對應的 $D_i$,另加一個產生 $z$ 的小型輸出解碼器。
  11. Sketch the circuit: two D flip-flops, with combinational gates implementing each $Y_i$ feeding into the corresponding $D_i$, and a small output decoder for $z$.
  12. 回路を描く:D フリップフロップ 2 個、各 $Y_i$ を実現して対応する $D_i$ に入れる組合せゲート、そして $z$ 用の小さな出力デコーダである。

最後做合理性檢查:把原始表格的每一列代入你的方程式 — 每一列的 $Y_2 Y_1$ 與 $z$ 都應該吻合。若全部吻合,方程式就是正確的(不論是否為最小式)。接著確認你的 K-map 分組已經是最大的可能,以驗證最小性。

Sanity-check at the end: plug each row of the original table into your equations — every row's $Y_2 Y_1$ and $z$ should match. If they all match, the equations are correct (whether or not they're minimum). Then verify your K-map groupings are the largest possible to confirm minimality.

最後に健全性を確認する:元の表の各行を自分の方程式に代入する — どの行でも $Y_2 Y_1$ と $z$ が一致するはずである。すべて一致すれば、方程式は正しい(最小かどうかは別として)。次に K-map のグループが可能な限り最大であることを確かめ、最小性を確認する。

6.10中等Medium普通第一階Tier 1ティア 1?R
請套用狀態極小化的分割程序,把下列狀態表(狀態 A–F)化簡為最簡形式。請同時給出原始表與化簡後的表。
Apply the state minimization partitioning procedure to reduce the following state table (states A–F) to a minimal form. Provide the original and reduced tables.
状態最小化の分割手続きを適用し、次の状態表(状態 A–F)を最小形に縮小せよ。もとの表と縮小後の表の両方を示せ。
6.11中等Medium普通第一階Tier 1ティア 1?R
請為控制販賣機的電路畫出 ASM 圖:接受 5 分與 10 分硬幣,收滿 15 分以上時出貨,若溢付則找零。
Draw an ASM chart for a circuit that controls a vending machine: accepts nickels and dimes, dispenses a product when 15 cents or more is collected, and returns change if overpaid.
自動販売機を制御する回路の ASM チャートを描け。5 セント硬貨と 10 セント硬貨を受け付け、15 セント以上集まったら商品を払い出し、払い過ぎなら釣り銭を返す。
6.12中等Medium普通第一階Tier 1ティア 1?R
請撰寫交通號誌控制器 FSM 的 Verilog 程式碼,狀態為 Green (30s)、Yellow (5s)、Red (30s)。以計數器計時,並以 FSM 控制狀態。
Write Verilog code for a traffic light controller FSM with states: Green (30s), Yellow (5s), Red (30s). Use a counter for timing and an FSM for state control.
状態が Green (30s)、Yellow (5s)、Red (30s) の交通信号制御 FSM の Verilog コードを書け。計時にはカウンタを、状態制御には FSM を用いよ。
6.13困難Hard難しい第一階Tier 1ティア 1E?R
請設計一個 Moore 型 FSM,在輸入 $w$ 上出現一個週期的脈衝時,透過暫時暫存器 $R_3$ 交換兩個暫存器 $R_1$ 與 $R_2$ 的內容。該 FSM 必須依正確的順序產生控制訊號 $R1_{out}, R1_{in}, R2_{out}, R2_{in}, R3_{out}, R3_{in},$ 與 Done。請推導狀態圖、狀態表,以及完成狀態指派的實作。
Design a Moore-type FSM that swaps the contents of two registers $R_1$ and $R_2$ via a temporary register $R_3$, in response to a one-cycle pulse on input $w$. The FSM must generate the control signals $R1_{out}, R1_{in}, R2_{out}, R2_{in}, R3_{out}, R3_{in},$ and Done in the proper sequence. Derive the state diagram, state table, and a state-assigned implementation.
入力 $w$ に 1 クロック幅のパルスが与えられたとき、一時レジスタ $R_3$ を介して 2 つのレジスタ $R_1$ と $R_2$ の内容を入れ替える Moore 型 FSM を設計せよ。この FSM は制御信号 $R1_{out}, R1_{in}, R2_{out}, R2_{in}, R3_{out}, R3_{in},$ と Done を正しい順序で生成しなければならない。状態遷移図、状態表、および状態割当てを行った実装を導け。
6.14中等Medium普通第一階Tier 1ティア 1E?R
For the four-state register-swap FSM of Example 6.1, try the alternative state assignment in which states $C$ and $D$ are swapped. Derive the next-state and output expressions and compare the resulting cost to the straightforward assignment.
Context: Example 6.1 — 4-state register-swap FSM

交換運算:以 R3 作為暫存,交換暫存器 R1 與 R2 的內容。依序進行三次傳送:R3 ← R2,接著 R2 ← R1,再來 R1 ← R3。

The swap operation: swap contents of registers R1 and R2 using R3 as temp storage. Three transfers in sequence: R3 ← R2, then R2 ← R1, then R1 ← R3.

スワップ動作:R3 を一時退避に使って、レジスタ R1 と R2 の内容を入れ替える。転送は 3 回を順に行う:R3 ← R2、次に R2 ← R1、そして R1 ← R3。

FSM:Moore 型,4 個狀態,由輸入 w 上的單一週期脈衝啟動:

FSM: Moore-type, 4 states, started by a one-cycle pulse on input w:

FSM:Moore 型、状態 4 個、入力 w の 1 サイクル幅パルスで起動する:

  • A — 閒置,所有輸出為 0;w=0 期間停留在 A,w=1 時轉移到 B
  • A — idle, all outputs 0; stays in A while w=0, transitions to B when w=1
  • A — 待機。出力はすべて 0。w=0 の間は A に留まり、w=1 で B へ遷移する
  • B — assert R2out=1、R3in=1(於是 R3 在下一個邊緣鎖存 R2);必定前進到 C
  • B — assert R2out=1, R3in=1 (so R3 latches R2 on next edge); always advances to C
  • B — R2out=1、R3in=1 をアサートする(次のエッジで R3 が R2 を取り込む)。必ず C へ進む
  • C — assert R1out=1、R2in=1(R2 鎖存 R1);必定前進到 D
  • C — assert R1out=1, R2in=1 (R2 latches R1); always advances to D
  • C — R1out=1、R2in=1 をアサートする(R2 が R1 を取り込む)。必ず D へ進む
  • D — assert R3out=1、R1in=1、Done=1(R1 鎖存舊的 R2);必定回到 A
  • D — assert R3out=1, R1in=1, Done=1 (R1 latches old R2); always returns to A
  • D — R3out=1、R1in=1、Done=1 をアサートする(R1 が元の R2 を取り込む)。必ず A へ戻る

State diagram:

A idle B R2out=1 R3in=1 C R1out=1 R2in=1 D R3out=1, R1in=1 Done=1 w=0 w=1 w=0/1 w=0/1 w=0/1 Reset

直觀的狀態指派(課本慣例):在 $(y_2, y_1)$ 上取 $A=00$、$B=01$、$C=10$、$D=11$。使用 D 型正反器時,課本推導出:

Straightforward state assignment (book convention): $A=00$, $B=01$, $C=10$, $D=11$ on $(y_2, y_1)$. With D flip-flops, the textbook derives:

素直な状態割当て(教科書の流儀):$(y_2, y_1)$ に対して $A=00$、$B=01$、$C=10$、$D=11$ とする。D フリップフロップを使うと、教科書は次を導く:

$$Y_1 = w\,\overline{y_1}\,\overline{y_2} + \overline{y_1}\,y_2 \qquad Y_2 = y_1\,\overline{y_2} + \overline{y_1}\,y_2$$

習題 6.14 要求什麼:把指派中的 C 與 D 對調($A=00$、$B=01$、$C=11$、$D=10$),重新推導下一狀態與輸出的運算式。再與原本指派的閘數比較 — 不同的狀態指派會產生代數上不同的方程式,成本往往也不同。課本要傳達的重點:狀態指派是一個不容小覷的最佳化旋鈕。

What problem 6.14 asks: redo the next-state and output expressions with C and D swapped in the assignment ($A=00$, $B=01$, $C=11$, $D=10$). Compare the gate count to the original assignment — different state assignments produce algebraically different equations, often with different costs. The textbook lesson: state assignment is a non-trivial optimization knob.

問題 6.14 が問うていること:割当てで C と D を入れ替えて($A=00$、$B=01$、$C=11$、$D=10$)、次状態と出力の式を導き直す。もとの割当てとゲート数を比べる — 状態割当てが違えば代数的に異なる方程式が得られ、コストもしばしば変わる。教科書の教訓:状態割当ては軽視できない最適化のつまみである。

— example 6.1
6.15中等Medium普通第一階Tier 1ティア 1E?R
Apply one-hot state encoding to the four-state register-swap FSM. Use four flip-flops $y_1\ldots y_4$ and derive the next-state expressions directly by inspection of the state diagram.
背景:什麼是 one-hot 狀態編碼?Context: what is one-hot state encoding?背景:one-hot 状態符号化とは何か?

One-hot 編碼 = 每個狀態各自擁有一個專屬的正反器,而任一時刻恰好有一個1(「hot」)。

One-hot encoding = each state gets its own dedicated flip-flop, and exactly one is 1 ("hot") at any moment.

One-hot 符号化 = 各状態が専用のフリップフロップを 1 個ずつ持ち、任意の時点でちょうど1 個だけが 1(「hot」)である。

Comparison for a 4-state FSM (A, B, C, D):

編碼Encoding符号化ABCD正反器數量# of flip-flopsフリップフロップ数
Binary00011011$\lceil\log_2 4\rceil = 2$
One-hot0001001001001000$N = 4$

Trade-off:

二進位Binary2 進数One-hotOne-hotOne-hot
Flip-flops$\lceil\log_2 N\rceil$$N$
Next-state logicdecoded from binary state每一次轉移就是一個乘積項each transition is one product term遷移 1 つが積項 1 つになる
State-output decodeequality check (e.g. y2 && y1)a single wire — assign R1out = y3;
Speedslower (deeper logic)faster (one AND/OR layer)
FF costminimumlinear in $N$

Applied to the swap FSM ($y_1{=}A, y_2{=}B, y_3{=}C, y_4{=}D$):

Y1 = (y1 & ~w) | y4    // stay in A while w=0; come back from D
Y2 = y1 & w            // A→B when w=1
Y3 = y2                // B→C  (unconditional)
Y4 = y3                // C→D  (unconditional)
R2out = R3in = y2      // outputs come "for free"
R1out = R2in = y3
R3out = R1in = Done = y4

每個下一狀態運算式都只是一個極小的乘積項 — 這就是它的好處。代價是要用 4 個正反器而不是 2 個。

Each next-state expression is one tiny product term — that's the win. The cost is using 4 flip-flops instead of 2.

各次状態式がごく小さな積項 1 つで済む — そこが利点である。代償はフリップフロップを 2 個ではなく 4 個使うことである。

何時該用哪一種:面積/正反器數量是瓶頸時用二進位。想要更簡單的邏輯、更快的組合路徑,以及「免費」的狀態輸出解碼時用 one-hot — 在正反器充裕、但受限於繞線與深度的 FPGA 上,這是標準選擇。

When to use which: Binary when area / FF count is the bottleneck. One-hot when you want simpler logic, faster combinational paths, and "free" state-output decoding — the standard choice on FPGAs where flip-flops are plentiful but routing/depth is the limit.

どちらを使うか:面積やフリップフロップ数がボトルネックなら2 進。論理を簡単にし、組合せ経路を速くし、状態出力のデコードを「ただ」で済ませたいなら one-hot — フリップフロップが潤沢で、配線や段数が制約になる FPGA では標準的な選択である。

6.16困難Hard難しい第一階Tier 1ティア 1E?R
請把範例 6.1 的暫存器交換控制器改設計為 Mealy 型 FSM。證明只需三個狀態,且交換可在三個時脈週期而非四個週期內完成。請推導狀態圖,並討論輸出訊號的時序。— 範例 6.1
Redesign the register-swap controller of Example 6.1 as a Mealy-type FSM. Show that only three states are needed and that the swap completes in three clock cycles instead of four. Derive a state diagram and discuss the timing of the output signals.— example 6.1
例題 6.1 のレジスタ交換コントローラを Mealy 型 FSM として再設計せよ。状態が 3 つで足りること、および入れ替えが 4 クロックではなく 3 クロックで完了することを示せ。状態遷移図を導き、出力信号のタイミングについて論ぜよ。— 例題 6.1
6.17中等Medium普通第一階Tier 1ティア 1E?R
請以雙 always 區塊的寫法,為範例 6.1 中四個狀態的暫存器交換 FSM 撰寫 Verilog 程式碼:一個組合邏輯的 always 負責次態邏輯,一個時序的 always 負責狀態暫存器,輸出則以現態的 assign 運算式導出。— 範例 6.1
Write Verilog code for the four-state register-swap FSM of Example 6.1 using the two-always-block style: one combinational always for the next-state logic and one sequential always for the state register, with the outputs derived as assign expressions of the present state.— example 6.1
例題 6.1 の 4 状態のレジスタ交換 FSM の Verilog コードを、always ブロックを 2 つ使う書き方で書け:次状態論理は組合せの always、状態レジスタは順序の always で記述し、出力は現状態の assign 式として導く。— 例題 6.1
6.18中等Medium普通第一階Tier 1ティア 1E?R
Apply the partitioning state-minimization procedure to a 7-state Moore FSM whose state table is given (Figure 6.51). Show each successive partition $P_1, P_2, \ldots$ and reduce the FSM to a 4-state equivalent.
背景:圖 6.51 — 7 狀態的 Moore FSM(範例 6.6)Context: Figure 6.51 — 7-state Moore FSM (Example 6.6)背景:図 6.51 — 7 状態の Moore FSM(例 6.6)

圖 6.51 — 原始狀態表(7 個狀態,Moore 輸出 $z$ 只取決於目前狀態):

Figure 6.51 — original state table (7 states, Moore output $z$ depends only on present state):

図 6.51 — もとの状態表(7 状態、Moore 出力 $z$ は現在状態のみに依存する):

目前狀態Present現状態$w=0$$w=1$$z$
ABC1
BDF1
CFE0
DBG1
EFC0
FED0
GFG0

分割程序(每個 $P_k$ 把 $k$ 步後繼仍落在同一區塊的狀態歸為一組):

Partitioning procedure (each $P_k$ groups states whose $k$-step successors stay in the same block):

分割手続き(各 $P_k$ は、$k$ 段先の後継が同じブロックに留まる状態どうしをまとめる):

  • $P_1 = (ABCDEFG)$ — 一開始把全部放在同一個區塊。
  • $P_1 = (ABCDEFG)$ — start with everything in one block.
  • $P_1 = (ABCDEFG)$ — 最初はすべてを 1 つのブロックに入れる。
  • $P_2 = (ABD)(CEFG)$ — 依輸出分割:$\{A,B,D\}$ 為 $z=1$,$\{C,E,F,G\}$ 為 $z=0$。
  • $P_2 = (ABD)(CEFG)$ — split by output: $z=1$ in $\{A,B,D\}$, $z=0$ in $\{C,E,F,G\}$.
  • $P_2 = (ABD)(CEFG)$ — 出力で分ける:$\{A,B,D\}$ が $z=1$、$\{C,E,F,G\}$ が $z=0$ である。
  • $P_3 = (ABD)(CEG)(F)$ — 在 $(CEFG)$ 之中:1-後繼為 $(E,C,D,G)$。$D$ 屬於不同的區塊(它在 $\{A,B,D\}$ 裡),因此 1-後繼為 $D$ 的 $F$ 被分了出來。
  • $P_3 = (ABD)(CEG)(F)$ — within $(CEFG)$: 1-successors are $(E,C,D,G)$. $D$ is in a different block (it's in $\{A,B,D\}$), so $F$ (whose 1-successor is $D$) splits off.
  • $P_3 = (ABD)(CEG)(F)$ — $(CEFG)$ の中では、1-後継が $(E,C,D,G)$ である。$D$ は別のブロック($\{A,B,D\}$)に属するので、1-後継が $D$ である $F$ が分離する。
  • $P_4 = (AD)(B)(CEG)(F)$ — 在 $(ABD)$ 之中:1-後繼為 $(C,F,G)$。$F$ 自成一個區塊,因此 1-後繼為 $F$ 的 $B$ 被分了出來。
  • $P_4 = (AD)(B)(CEG)(F)$ — within $(ABD)$: 1-successors are $(C,F,G)$. $F$ is in its own block, so $B$ (whose 1-successor is $F$) splits off.
  • $P_4 = (AD)(B)(CEG)(F)$ — $(ABD)$ の中では、1-後継が $(C,F,G)$ である。$F$ は単独のブロックなので、1-後継が $F$ である $B$ が分離する。
  • $P_5 = P_4$ — 不再有新的分割,分割程序到此結束。
  • $P_5 = P_4$ — no further splits, partitioning is done.
  • $P_5 = P_4$ — これ以上は分かれず、分割は完了である。

等價類:$\{A,D\}, \{B\}, \{C,E,G\}, \{F\}$ — 共四類,因此最小化後的 FSM 有 4 個狀態。把 $\{A,D\} \to A$、$\{C,E,G\} \to C$ 重新命名,即得圖 6.52:

Equivalence classes: $\{A,D\}, \{B\}, \{C,E,G\}, \{F\}$ — four classes, so the minimized FSM has 4 states. Rename $\{A,D\} \to A$ and $\{C,E,G\} \to C$ to obtain Figure 6.52:

等価類:$\{A,D\}, \{B\}, \{C,E,G\}, \{F\}$ — 4 類なので、最小化した FSM は 4 状態となる。$\{A,D\} \to A$、$\{C,E,G\} \to C$ と改名すると図 6.52 が得られる:

目前狀態Present現状態$w=0$$w=1$$z$
ABC1
BAF1
CFC0
FCA0

實作上的節省:$\lceil\log_2 7\rceil = 3$ 個正反器縮減為 $\lceil\log_2 4\rceil = 2$ 個。被合併的狀態行為無法區分 — 不論從 $A$ 或 $D$ 出發,或從 $C, E, G$ 中任一個出發,任何輸入序列都會產生相同的輸出序列。

Implementation savings: $\lceil\log_2 7\rceil = 3$ flip-flops shrink to $\lceil\log_2 4\rceil = 2$. The merged states have indistinguishable behavior — any input sequence produces the same output sequence whether you start in $A$ or $D$, or in any of $C, E, G$.

実装上の節約:$\lceil\log_2 7\rceil = 3$ 個のフリップフロップが $\lceil\log_2 4\rceil = 2$ 個に減る。併合された状態は振る舞いが区別できない — $A$ から始めても $D$ から始めても、あるいは $C, E, G$ のどれから始めても、どんな入力系列に対しても同じ出力系列が得られる。

— example 6.6
6.19困難Hard難しい第一階Tier 1ティア 1E?R
Design a candy-vending machine controller that accepts nickels and dimes, dispenses candy when 15 cents has been deposited, and credits a buyer with 5 cents if 20 cents is deposited (no change is given). Derive an initial state diagram and use the partitioning procedure to obtain a minimum-state Moore FSM.
說明:什麼是分割程序 (partitioning procedure)?Explanation: what is the partitioning procedure?解説:分割手続き (partitioning procedure) とは何か?

分割程序是一種系統化方法,用來找出等價狀態——也就是對所有可能的未來輸入序列都表現相同的狀態,並將它們合併。兩個狀態等價的條件是:(1) 它們有相同的輸出,且 (2) 對每一種輸入,它們的下個狀態也彼此等價。此程序逐步精煉分割,直到達到不動點 (fixed point)。

The partitioning procedure is a systematic method for finding equivalent states — states that behave identically for every possible future input sequence — and merging them. Two states are equivalent when (1) they produce the same output and (2) for every input their next states are also equivalent. The procedure refines the partition step by step until it reaches a fixed point.

分割手続き等価状態——あり得るすべての将来の入力系列に対して同じ振る舞いをする状態——を見つけ出して併合するための系統的な方法である。2 つの状態が等価であるのは、(1) 出力が同じで、かつ (2) どの入力に対しても次状態どうしがまた等価であるときに限る。この手続きは不動点 (fixed point) に達するまで分割を段階的に細かくしていく。

演算法:Algorithm:アルゴリズム:

  1. $P_1$:把所有狀態放進同一個區塊 (block)。
  2. $P_1$: place every state in a single block.
  3. $P_1$:すべての状態を 1 つのブロックに入れる。
  4. $P_2$:依照輸出把狀態分組。輸出 $z$ 不同的狀態不可能等價。
  5. $P_2$: group the states by output. States with different $z$ cannot be equivalent.
  6. $P_2$:状態を出力で分類する。$z$ が異なる状態どうしは等価になり得ない。
  7. $P_{k+1}$:對 $P_k$ 中的每個區塊,檢查所有輸入下的下個狀態。若同一區塊內兩個狀態的下個狀態落在 $P_k$ 的不同區塊,則它們等價,必須再拆成更小的子區塊。
  8. $P_{k+1}$: for each block of $P_k$, examine the next states under every input. If two states in the same block have next states lying in different blocks of $P_k$, they are not equivalent and the block must be split further.
  9. $P_{k+1}$:$P_k$ の各ブロックについて、すべての入力に対する次状態を調べる。同じブロック内の 2 状態の次状態が $P_k$ の異なるブロックに落ちるなら、その 2 状態は等価ではなく、ブロックをさらに分割しなければならない。
  10. 停止條件:當 $P_{k+1} = P_k$(不再有新的分割)時停止。最終分割中的每個區塊就是一組等價類別——把同一區塊的狀態合併為單一狀態即可。
  11. Stopping condition: stop when $P_{k+1} = P_k$ (no new splits). Each block of the final partition is an equivalence class — merge the states of a block into a single state.
  12. 停止条件:$P_{k+1} = P_k$(新たな分割が起こらない)となったら停止する。最終的な分割の各ブロックが 1 つの等価類であり、同じブロックの状態を 1 つの状態に併合すればよい。

為什麼有效(非正式證明):若兩個狀態 $X$ 和 $Y$ 等價,必定存在某個輸入序列能區分它們——也就是經過若干步後抵達輸出不同的狀態。分割程序在第 $k$ 步追蹤的是:「只看前 $k$ 個輸入時,哪些狀態仍無法被區分」。當不再有新的區別出現時,精煉就停止;此時的分割恰好等於行為等價類。

Why it works (informal proof): if two states $X$ and $Y$ are not equivalent, some input sequence must distinguish them — that is, after some number of steps they reach states with different outputs. At step $k$ the partitioning procedure tracks exactly “which states are still indistinguishable using only the first $k$ inputs”. Refinement stops when no new distinction appears, and the partition at that point is precisely the set of behavioural equivalence classes.

なぜうまくいくのか(略証):2 つの状態 $X$ と $Y$ が等価でないなら、それらを区別する入力系列が必ず存在する——すなわち何ステップか後に出力の異なる状態へ到達する。分割手続きが第 $k$ 段で追跡しているのは、まさに「最初の $k$ 個の入力だけではまだ区別できない状態はどれか」である。新たな区別が現れなくなった時点で細分化は止まり、そのときの分割がちょうど振る舞い上の等価類となる。

小範例:假設:

Small example: suppose:

小さな例:次のような場合を考える:

狀態State状態$w=0$$w=1$$z$
AAB0
BAC0
CAC1
  • $P_1 = (ABC)$
  • $P_2 = (AB)(C)$——依輸出分割(C 的 $z$ 不同)。
  • $P_2 = (AB)(C)$ — split by output ($C$ has a different $z$).
  • $P_2 = (AB)(C)$ — 出力で分割する($C$ だけ $z$ が異なる)。
  • $P_3$:在 $(AB)$ 中,$w=1$ 的後繼狀態為 $(B,C)$,分別落在 $P_2$ 的不同區塊——所以 $A$ 與 $B$ 必須分開。$P_3 = (A)(B)(C)$。
  • $P_3$: within $(AB)$, the successors under $w=1$ are $(B,C)$, which fall in different blocks of $P_2$ — so $A$ and $B$ must be separated. $P_3 = (A)(B)(C)$.
  • $P_3$:$(AB)$ の中で $w=1$ のときの後継は $(B,C)$ であり、$P_2$ の異なるブロックに落ちる——したがって $A$ と $B$ は分けなければならない。$P_3 = (A)(B)(C)$。
  • $P_4 = P_3$——完成。三個區塊各自獨立 → 無法再合併;此 FSM 本身已經最小化。
  • $P_4 = P_3$ — done. All three blocks are singletons → nothing can be merged; this FSM is already minimal.
  • $P_4 = P_3$ — 完了。3 つのブロックはいずれも単元集合 → 併合できるものはない。この FSM はすでに最小化されている。

為什麼要做?每減少一個狀態通常能省下一個或多個正反器(因為 FF 數量為 $\lceil\log_2 N\rceil$),而且推導出來的下一狀態方程式與輸出方程式會有更少的最小項——電路更小、更快。對於手工設計的 FSM 來說,這個程序也能找出設計者誤以為不同、但其實重複的多餘狀態。

Why bother? Every state removed typically saves one or more flip-flops (the FF count is $\lceil\log_2 N\rceil$), and the resulting next-state and output equations have fewer minterms — a smaller, faster circuit. For hand-designed FSMs the procedure also exposes redundant states the designer believed were distinct.

なぜやるのか?状態が 1 つ減るごとにふつうフリップフロップが 1 個以上節約でき(FF 数は $\lceil\log_2 N\rceil$)、導かれる次状態方程式と出力方程式の最小項も減る——回路は小さく速くなる。手作業で設計した FSM では、設計者が別物と思い込んでいた冗長な状態をこの手続きが暴き出してくれる。

套用至問題 6.19:先畫出販賣機 FSM 的初始狀態圖(包含 "0¢", "5¢", "10¢", "15¢", "20¢",若允許兩個一角硬幣連續投入則還有 "25¢"),再以此程序合併行為相同的狀態(例如「20¢——找零 5¢」狀態,若機器在下一輪投幣時會重置找零紀錄,可能等價於「5¢」狀態)。

Applying it to Problem 6.19: first draw the initial state diagram of the vending machine FSM (with "0¢", "5¢", "10¢", "15¢", "20¢", plus "25¢" if two dimes may be inserted in succession), then use this procedure to merge states that behave identically (for instance the “20¢ — return 5¢ change” state may be equivalent to the “5¢” state if the machine resets its change record on the next coin).

問題 6.19 への適用:まず自動販売機 FSM の初期状態図を描き("0¢", "5¢", "10¢", "15¢", "20¢"、10 セント硬貨を続けて 2 枚入れられるなら "25¢" も)、次にこの手続きで同じ振る舞いをする状態を併合する(たとえば「20¢——5¢ を釣り銭として返す」状態は、次のコイン投入で釣り銭の記録がリセットされるなら「5¢」状態と等価になり得る)。

6.20中等Medium普通第一階Tier 1ティア 1E?R
對於一個有四個未指定項目、共 7 個狀態的不完全指定 Mealy FSM,請套用分割程序兩次:先假設兩個未指定輸出皆為 0,再假設皆為 1。比較兩者所得的狀態數。
For an incompletely specified 7-state Mealy FSM with four unspecified entries, apply the partitioning procedure twice: first assuming both unspecified outputs are 0 and then assuming both are 1. Compare the resulting state counts.
未指定の欄が 4 つある、状態 7 個の不完全指定 Mealy FSM について、分割手続きを 2 回適用せよ:まず未指定の出力を両方 0 と仮定し、次に両方 1 と仮定する。得られる状態数を比較せよ。
6.21中等Medium普通第一階Tier 1ティア 1E?R
請分析一個由兩個 D 正反器構成的同步循序電路,其中 $Y_1 = w\overline{y_1}+wy_2$、$Y_2 = w\overline{y_1}+\overline{w}y_2$,輸出為 $z=y_1 y_2$。請推導狀態指派表,並說明此 FSM 會偵測輸入 $w$ 上連續三個 1。
Analyze a synchronous sequential circuit built from two D flip-flops with $Y_1 = w\overline{y_1}+wy_2$, $Y_2 = w\overline{y_1}+\overline{w}y_2$, and output $z=y_1 y_2$. Derive the state-assigned table and show the FSM detects three consecutive 1s on input $w$.
$Y_1 = w\overline{y_1}+wy_2$、$Y_2 = w\overline{y_1}+\overline{w}y_2$、出力 $z=y_1 y_2$ をもつ、D フリップフロップ 2 個で構成された同期順序回路を解析せよ。状態割当て表を導き、この FSM が入力 $w$ 上の 3 個連続する 1 を検出することを示せ。
6.22中等Medium普通第一階Tier 1ティア 1E?R
請分析一個由兩個 JK 正反器構成的同步循序電路,其中 $J_1=w$、$K_1=\overline{w}+y_2$、$J_2=wy_1$、$K_2=\overline{w}$,輸出為 $z=y_1 y_2$。請推導激勵表與狀態指派表,並指出此 FSM 的行為。
Analyze a synchronous sequential circuit built from two JK flip-flops with $J_1=w$, $K_1=\overline{w}+y_2$, $J_2=wy_1$, $K_2=\overline{w}$ and output $z=y_1 y_2$. Derive the excitation and state-assigned tables and identify the FSM behavior.
$J_1=w$、$K_1=\overline{w}+y_2$、$J_2=wy_1$、$K_2=\overline{w}$、出力 $z=y_1 y_2$ をもつ、JK フリップフロップ 2 個で構成された同期順序回路を解析せよ。励振表と状態割当て表を導き、この FSM の動作を明らかにせよ。
6.23中等Medium普通第一階Tier 1ティア 1E?R
請分析一個混用一個 D 正反器與一個 T 正反器的同步電路,其中 $D_1=w(y_1+y_2)$、$T_2=\overline{w}y_2+wy_1\overline{y_2}$,且 $z=y_1 y_2$。請推導激勵表,並說明此電路實現的 FSM 與範例 6.9 及 6.10 中的相同。— 範例 6.9
Analyze a synchronous circuit using a mixture of one D and one T flip-flop with $D_1=w(y_1+y_2)$, $T_2=\overline{w}y_2+wy_1\overline{y_2}$, and $z=y_1 y_2$. Derive the excitation table and show that this circuit implements the same FSM as those in Examples 6.9 and 6.10.— example 6.9
D フリップフロップ 1 個と T フリップフロップ 1 個を混用し、$D_1=w(y_1+y_2)$、$T_2=\overline{w}y_2+wy_1\overline{y_2}$、$z=y_1 y_2$ である同期回路を解析せよ。励振表を導き、この回路が例題 6.9 および 6.10 と同じ FSM を実現していることを示せ。— 例題 6.9
6.24困難Hard難しい第一階Tier 1ティア 1E?R
請設計一個 Moore 型序列偵測器,輸入為 $w$、輸出為 $z$,當 $w$ 的前兩個值同為 00 或同為 11 時使 $z=1$。請推導狀態圖、狀態表,以及完成狀態指派的實作。
Design a Moore-type sequence detector with input $w$ and output $z$ that asserts $z=1$ when the previous two values of $w$ were both 00 or both 11. Derive the state diagram, state table, and a state-assigned implementation.
入力 $w$、出力 $z$ をもち、$w$ の直前 2 つの値がともに 00 またはともに 11 のときに $z=1$ をアサートする Moore 型系列検出器を設計せよ。状態遷移図、状態表、および状態割当てを行った実装を導け。
6.25困難Hard難しい第一階Tier 1ティア 1E?R
Implement the sequence detector of Example 6.12 as the parallel combination of two simpler FSMs: one that detects two consecutive 1s and one that detects two consecutive 0s. Combine the outputs with an OR gate.
背景:範例 6.12 — 5 狀態的「00 或 11」序列偵測器Context: Example 6.12 — 5-state "00 or 11" sequence detector背景:例 6.12 — 5 状態の「00 または 11」系列検出器

規格:只要輸入 $w$ 的前兩個值同為 0 或同為 1,輸出就 $z=1$;否則 $z=0$。

Specification: output $z=1$ whenever the previous two values of input $w$ were both 0 or both 1; otherwise $z=0$.

仕様:入力 $w$ の直前 2 つの値がともに 0、またはともに 1 のとき出力 $z=1$ とし、それ以外では $z=0$ とする。

FSM:Moore 型,5 個狀態(A 為重置,B/D =「看到一個 0/1」,C/E =「看到 00/11」):

FSM: Moore-type, 5 states (A reset, B/D = "saw a 0/1", C/E = "saw 00/11"):

FSM:Moore 型、状態 5 個(A はリセット、B/D =「0/1 を 1 つ見た」、C/E =「00/11 を見た」):

狀態State状態意義Meaning意味$z$$w$=0 時的下一狀態Next on $w$=0$w$=0 のときの次状態$w$=1 時的下一狀態Next on $w$=1$w$=1 のときの次状態
Aafter reset0BD
Blast input was 00CD
Clast two were 001CD
Dlast input was 10BE
Elast two were 111BE

狀態圖(斜線後的數字為輸出):

State diagram (output is the digit after the slash):

状態遷移図(スラッシュの後の数字が出力である):

A/0 reset B/0 saw "0" C/1 saw "00" D/0 saw "1" E/1 saw "11" Reset w=0 w=1 w=0 w=1 w=0 w=1 w=0 w=1 w=1 w=0

為什麼剛好是 5 個狀態?這台機器必須記住三件事:剛重置、剛看到 0、剛看到 1,再加上「00」/「11」的連續偵測狀態。只追蹤「上一個輸入」(3 個狀態:A、B、D)並不夠 — 你必須區分「第一次出現的 0」(B)與「連續的第二個 0」(C),才能決定 $z$ 是否要拉高。

Why exactly 5 states? The machine must remember three things: just-reset, just-saw-0, just-saw-1, plus the "00" / "11" run-detection states. Tracking only "last input" (3 states: A, B, D) isn't enough — you need to distinguish "first 0 ever" (B) from "second 0 in a row" (C) to decide whether $z$ goes high.

なぜちょうど 5 状態なのか?この機械は 3 つのこと — リセット直後、0 を見た直後、1 を見た直後 — に加えて、「00」/「11」の連続を検出する状態も覚えていなければならない。「直前の入力」だけを追う(A、B、D の 3 状態)のでは足りない — $z$ を上げるかどうかを決めるには、「初めて現れた 0」(B)と「続けて 2 つ目の 0」(C)を区別する必要がある。

習題 6.25 要求什麼:不要用單一的 5 狀態機器,改建兩台並行的 FSM — 一台偵測「連續兩個 0」(3 個狀態),另一台偵測「連續兩個 1」(3 個狀態)。把兩者的輸出做 OR,就得到合併後的 $z$。要學到的是:並行分解往往比單一龐大的機器產生更簡單的 FSM(兩台機器合計 6 個正反器,相較於 5 狀態版本的 3 個正反器,但每台機器的下一狀態邏輯都比較簡單)。

What problem 6.25 asks: instead of the single 5-state machine, build two parallel FSMs — one detects "two consecutive 0s" (3 states), the other detects "two consecutive 1s" (3 states). OR their outputs to get the combined $z$. The lesson: parallel decomposition often produces simpler FSMs than a single monolithic one (6 flip-flops total split between two machines vs. 3 flip-flops for the 5-state version, but with simpler next-state logic per machine).

問題 6.25 が問うていること:5 状態の機械 1 台ではなく、並列に 2 台の FSM を作る — 一方は「0 が 2 つ連続」を検出し(3 状態)、他方は「1 が 2 つ連続」を検出する(3 状態)。両者の出力を OR して、まとめた $z$ を得る。教訓:並列分解は、一枚岩の機械 1 台よりも簡単な FSM を生むことが多い(2 台合わせてフリップフロップ 6 個に対し、5 状態版は 3 個だが、機械ごとの次状態論理は並列版のほうが簡単である)。

到底是什麼事件觸發了狀態轉移?What event actually triggers a state transition?状態遷移を実際に引き起こす事象は何か?

狀態圖上標示 w=0w=1 的箭頭是條件,不是事件。在同步 FSM 中,真正改變狀態的事件是時脈的上升緣

The arrows labeled w=0 / w=1 in any state diagram are conditions, not events. The actual event that changes the state in a synchronous FSM is the rising edge of the clock.

状態遷移図で w=0w=1 と付いた矢印は条件であって、事象ではない。同期 FSM で実際に状態を変える事象はクロックの立上りエッジである。

一個時脈週期之中會發生什麼:

What happens during one clock cycle:

1 クロックサイクルの間に起こること:

  • 邊緣之間:組合式的下一狀態邏輯持續計算 $Q' = \delta(Q, w)$ — 但狀態暫存器維持它目前的值 $Q$。箭頭上的標示是說:「若本週期內 $w=$0,下一狀態就是 C;若 $w=$1,下一狀態就是 D」。
  • Between edges: the combinational next-state logic continuously evaluates $Q' = \delta(Q, w)$ — but the state register holds its current value $Q$. The arrow labels say "if $w=$0 during this cycle, the next state will be C; if $w=$1, the next state will be D".
  • エッジとエッジの間:組合せの次状態論理は $Q' = \delta(Q, w)$ を絶えず計算している — が、状態レジスタは現在値 $Q$ を保持したままである。矢印のラベルは「このサイクル中に $w=$0 なら次状態は C、$w=$1 なら次状態は D」と言っている。
  • 在上升緣:狀態暫存器的正反器取樣 $Q'$(也就是剛結束的那個週期中,下一狀態邏輯所產生的值)並載入。$Q$ 隨即跳到 $Q'$。
  • At the rising edge: the state-register flip-flops sample $Q'$ (whatever the next-state logic was producing in the cycle just ending) and load it. $Q$ jumps to $Q'$.
  • 立上りエッジで:状態レジスタのフリップフロップが $Q'$(いま終わろうとしているサイクルで次状態論理が出していた値)を取り込んでロードする。$Q$ は $Q'$ へ飛ぶ。

所以「$w=$0 時 B → C」這個箭頭真正的意思是:「若 FSM 處於狀態 B,且某個時脈週期內 $w=$0,那麼在結束該週期的上升緣,狀態暫存器就會載入 C。」

So an arrow "B → C on $w=$0" really means: "if the FSM is in state B and $w=$0 during a clock cycle, then at the rising edge that ends that cycle, the state register loads C."

つまり「$w=$0 で B → C」という矢印が本当に意味するのは、「FSM が状態 B にあり、あるクロックサイクル中に $w=$0 であれば、そのサイクルを終える立上りエッジで状態レジスタが C をロードする」ということである。

輸入的作用:$w$ 並不造成轉移 — 它選擇下一個時脈邊緣要發生哪一個轉移。$w$ 在邊緣之間的變化,只有在邊緣觸發那一刻 $w$ 處於正確準位時才有意義(必須滿足 setup/hold 時間)。

What the input does: $w$ doesn't cause the transition — it selects which transition will happen at the next clock edge. Changes to $w$ between edges only matter if $w$ is at the right level when the edge fires (must satisfy setup/hold times).

入力の役割:$w$ は遷移を引き起こすのではなく、次のクロックエッジでどの遷移が起こるかを選ぶ。エッジとエッジの間の $w$ の変化が効くのは、エッジが立つ時点で $w$ が正しいレベルにある場合だけである(setup/hold 時間を満たす必要がある)。

Consequences:

  • 比一個時脈週期還短的輸入脈衝可能會被漏掉 — 到了下一個邊緣時,$w$ 可能已經回到 0。
  • An input pulse shorter than a clock cycle may be missed — $w$ could be back to 0 by the next edge.
  • 1 クロックサイクルより短い入力パルスは見逃されることがある — 次のエッジまでに $w$ が 0 に戻っているかもしれない。
  • 在 Moore 型 FSM 中,$z = f(Q)$ — 輸出只在 $Q$ 改變時才變,也就是只在時脈邊緣改變(同步輸出)。
  • In a Moore FSM, $z = f(Q)$ — output changes only when $Q$ changes, i.e. only at clock edges (synchronous output).
  • Moore 型 FSM では $z = f(Q)$ である — 出力が変わるのは $Q$ が変わるときだけ、すなわちクロックエッジでのみである(同期出力)。
  • 在 Mealy 型 FSM 中,$z = f(Q, w)$ — 當 $w$ 改變時,輸出可能在週期中途就變化(看起來像非同步的輸出)。
  • In a Mealy FSM, $z = f(Q, w)$ — output can change mid-cycle when $w$ changes (asynchronous-looking output).
  • Mealy 型 FSM では $z = f(Q, w)$ である — $w$ が変わるとサイクルの途中でも出力が変わりうる(非同期に見える出力)。

口訣:狀態圖是一本規則書,不是一部電影。它說的是「在狀態 X,若下一個時脈邊緣時輸入為 Y,就前往狀態 Z」。時脈則是那個隱含的節拍器,把規則變成實際的轉移。

Mnemonic: the state diagram is a rulebook, not a movie. It says "in state X, if input is Y at the next clock edge, go to state Z." The clock is the implicit metronome that turns rules into transitions.

覚え方:状態遷移図はルールブックであって、映画ではない。それが言っているのは「状態 X で、次のクロックエッジに入力が Y なら、状態 Z へ行け」である。クロックは、規則を遷移に変える暗黙のメトロノームである。

— example 6.12
6.26困難Hard難しい第一階Tier 1ティア 1E?R
請推導一個 Mealy 型 FSM,偵測與範例 6.12 相同的序列(連續兩個 0 或連續兩個 1)。證明只需三個狀態,並寫出次態與輸出的運算式。— 範例 6.12
Derive a Mealy-type FSM that detects the same sequences as in Example 6.12 (two consecutive 0s or two consecutive 1s). Show that only three states are required and write the next-state and output expressions.— example 6.12
例題 6.12 と同じ系列(0 が 2 個連続、または 1 が 2 個連続)を検出する Mealy 型 FSM を導け。状態が 3 つで足りることを示し、次状態と出力の式を書け。— 例題 6.12
6.27困難Hard難しい第一階Tier 1ティア 1E?R
Implement the state-assigned table of Figure 6.89 using JK-type flip-flops. Construct the excitation table for the J and K inputs and derive minimum expressions for $J_1, K_1, J_2, K_2, J_3, K_3$.
背景:圖 6.89 — 範例 6.12 的改良狀態指派Context: Figure 6.89 — improved state assignment for Example 6.12背景:図 6.89 — 例 6.12 の改良した状態割当て

圖 6.89 是範例 6.12 所用那台 5 狀態「00 或 11」偵測器的改良狀態指派。圖 6.88 中直觀的指派浪費了天生的 don't-care;改良版所給的編碼讓 $y_3$ 扮演「我們離開重置了嗎?」的旗標 — 機器一旦離開狀態 A,$y_3$ 就永遠維持 1。

Figure 6.89 is an improved state assignment for the same 5-state "00 or 11" detector that Example 6.12 uses. The straightforward assignment in Figure 6.88 wastes the natural don't-cares; the improved one assigns codes so that $y_3$ acts as a "have we left reset?" flag — once the machine leaves state A, $y_3$ stays 1 forever.

図 6.89 は、例 6.12 が使うのと同じ 5 状態の「00 または 11」検出器に対する改良された状態割当てである。図 6.88 の素直な割当ては、自然に生じる don't-care を無駄にしている。改良版は、$y_3$ が「リセットを離れたか?」のフラグとして働くように符号を割り当てる — 機械がいったん状態 A を離れると、$y_3$ はずっと 1 のままになる。

Improved state assignment:

狀態State状態$y_3 y_2 y_1$$w=0$ 時的下一狀態Next on $w=0$$w=0$ のときの次状態$w=1$ 時的下一狀態Next on $w=1$$w=1$ のときの次状態$z$
A (reset)000100 (B)110 (D)0
B (saw 0)100101 (C)110 (D)0
C (saw 00)101101 (C)110 (D)1
D (saw 1)110100 (B)111 (E)0
E (saw 11)111100 (B)111 (E)1

With D flip-flops, the textbook derives:

$$Y_1 = w\,\overline{y_2} + \overline{w}\,y_3\,y_2 \qquad Y_2 = w \qquad Y_3 = 1 \qquad z = y_1$$

既然(離開重置之後)$Y_3 = 1$ 恆成立,$y_3$ 就塌縮成一個常數,FSM 於是縮減為兩個正反器加上那個平凡的 $y_3$ — 比圖 6.88 的指派便宜得多。

Since $Y_3 = 1$ always (after leaving reset), $y_3$ collapses to a constant and the FSM reduces to two flip-flops + the trivial $y_3$ — much cheaper than the Figure 6.88 assignment.

(リセットを離れたあとは)$Y_3 = 1$ が常に成り立つので、$y_3$ は定数に潰れ、FSM はフリップフロップ 2 個と自明な $y_3$ にまで減る — 図 6.88 の割当てよりはるかに安い。

習題 6.27 要求什麼:改用 JK 型正反器(而非 D 型)重做這個實作。對每個狀態位元 $y_i$,推導出能讓下一狀態吻合的 $J_i$ 與 $K_i$。

What problem 6.27 asks: redo the implementation using JK flip-flops instead of D. For each state bit $y_i$, derive $J_i$ and $K_i$ such that the next state matches.

問題 6.27 が問うていること:D ではなく JK フリップフロップを使って実装をやり直す。各状態ビット $y_i$ について、次状態が一致するような $J_i$ と $K_i$ を導く。

JK 激勵表(把「現態→次態」轉換成 $J,K$ 的作法):

JK excitation table (the recipe for converting present→next into $J,K$):

JK 励振表(現状態→次状態を $J,K$ に変換する手順):

目前的 $y_i$Present $y_i$現在の $y_i$下一個 $Y_i$Next $Y_i$次の $Y_i$$J_i$$K_i$
000d
011d
10d1
11d0

把這個規則逐列套用到上表中每一組(現態, $w$)的組合,就得到一張 10 列的激勵表;接著用 K-map 分別最小化 $J_1, K_1, J_2, K_2, J_3, K_3$。don't-care 項(未使用的編碼 001、010、011,以及 JK 規則帶來的 don't-care)讓 K-map 非常寬鬆 — 對同一台 FSM 而言,最小成本的 JK 運算式通常比對應的 D 運算式更簡單。

Apply this row-by-row to every (present-state, $w$) combination in the table above to get a 10-row excitation table; then K-map-minimize each of $J_1, K_1, J_2, K_2, J_3, K_3$. Don't-care entries (the unused codes 001, 010, 011 and the don't-cares from the JK recipe) make the K-maps very loose — minimum-cost JK expressions are typically simpler than the corresponding D expressions for the same FSM.

上の表にある(現状態, $w$)のすべての組合せにこれを 1 行ずつ適用すると、10 行の励振表が得られる。次に $J_1, K_1, J_2, K_2, J_3, K_3$ のそれぞれを K-map で最小化する。don't-care の項(未使用の符号 001、010、011 と、JK の手順から生じる don't-care)によって K-map は非常に緩くなる — 同じ FSM に対して、最小コストの JK 式はふつう対応する D 式より簡単である。

— example 6.12
6.28中等Medium普通第一階Tier 1ティア 1E?R
請撰寫 Verilog 程式碼,實作範例 6.12 中五個狀態的 Moore 型序列偵測器(偵測 00 或 11)。請以 parameter 敘述為各狀態命名,並採用雙 always 區塊的寫法。— 範例 6.12
Write Verilog code that implements the 5-state Moore-type sequence detector of Example 6.12 (detects 00 or 11). Use a parameter statement to name the states and a two-always-block style.— example 6.12
例題 6.12 の 5 状態 Moore 型系列検出器(00 または 11 を検出)を実装する Verilog コードを書け。状態の命名には parameter 文を用い、always ブロックを 2 つ使う書き方とせよ。— 例題 6.12
6.29中等Medium普通第一階Tier 1ティア 1E?R
Write Verilog code for the Mealy-type sequence detector of Example 6.14 (detects 00 or 11) using the style where the output $z$ is set inside the combinational always block.
背景:範例 6.14 — 「00 或 11」偵測器的 3 狀態 Mealy 版本Context: Example 6.14 — 3-state Mealy version of the "00 or 11" detector背景:例題 6.14 — 「00 または 11」検出器の 3 状態 Mealy 版

規格與範例 6.12 相同(前兩個輸入同為 0 或同為 1 時輸出 1),但改以 Mealy FSM 實現。Mealy 形式只需 3 個狀態而非 5 個,因為輸出除了狀態之外還可以取決於當前輸入 — 所以不需要分開的「看到 00」/「看到 11」狀態;輸出就在轉移本身上發出。

Same specification as Example 6.12 (output 1 when previous two inputs were both 0 or both 1), but realized as a Mealy FSM. The Mealy form needs only 3 states instead of 5 because the output can depend on the current input as well as the state — so we don't need separate "saw 00" / "saw 11" states; the output fires on the transition itself.

仕様は例題 6.12 と同じ(直前 2 つの入力がともに 0 またはともに 1 のとき出力 1)だが、Mealy 形の FSM として実現する。Mealy 形なら状態は 5 個ではなく 3 状態で済む。出力が状態だけでなく現在の入力にも依存できるからである — 「00 を見た」「11 を見た」という専用の状態は不要で、出力は遷移そのもので発火する。

States and transitions:

  • A — 重置後,尚無相關的先前輸入。w=0 → B/z=0w=1 → C/z=0
  • A — after reset, no relevant prior input. w=0 → B / z=0; w=1 → C / z=0
  • A — リセット後で、関係する過去の入力がない。w=0 → B / z=0w=1 → C / z=0
  • B — last input was 0. w=0 → B / z=1 (00 detected); w=1 → C / z=0
  • C — last input was 1. w=0 → B / z=0; w=1 → C / z=1 (11 detected)

狀態表(轉移欄顯示次狀態/輸出):

State table (transitions show next-state / output):

状態表(遷移は次状態/出力を示す):

狀態State状態$w=0$ → 下一狀態/$z$$w=0$ → next/$z$$w=0$ → 次状態/$z$$w=1$ → 下一狀態/$z$$w=1$ → next/$z$$w=1$ → 次状態/$z$
AB / 0C / 0
B (saw 0)B / 1C / 0
C (saw 1)B / 0C / 1

課本的狀態指派($y_2 y_1$):A=00、B=01、C=11。編碼 10 未使用(don't-care)。巧妙之處:$y_1$ 成為「是否已離開重置?」的旗標 — 一旦離開 A,$y_1$ 就維持 1,所以次狀態方程式是 $Y_1 = 1$。實際上只需要一個真正的正反器($y_2$)。

Textbook state assignment ($y_2 y_1$): A=00, B=01, C=11. Code 10 is unused (don't-care). The clever bit: $y_1$ becomes a "have we left reset?" flag — once we leave A, $y_1$ stays 1, so $Y_1 = 1$ is the next-state equation. Effectively only one real flip-flop ($y_2$) is needed.

教科書の状態割当て($y_2 y_1$):A=00、B=01、C=11。符号 10 は未使用(don't-care)である。巧妙な点:$y_1$ が「リセットを抜けたか?」を表すフラグになる — いったん A を出れば $y_1$ は 1 のままなので、次状態方程式は $Y_1 = 1$ となる。実質的に本物のフリップフロップは 1 個($y_2$)で足りる。

為何這裡 Mealy 較精簡:Moore 版本(範例 6.12)需要分開的狀態 C 與 E 來記錄「已看到 00」/「已看到 11」,因為 Moore 輸出只是狀態的函數。Mealy 在合格輸入抵達的當下就送出輸出,所以不需要那些偵測連續樣式的狀態。

Why Mealy is more compact here: the Moore version (Example 6.12) needs separate states C and E to register "I've seen 00" / "I've seen 11" because Moore output is a function of state alone. Mealy fires its output the moment the qualifying input arrives, so the run-detection states aren't needed.

ここで Mealy のほうがコンパクトな理由:Moore 版(例題 6.12)は「00 を見た」「11 を見た」を記憶するために状態 C と E を別々に用意する必要がある。Moore の出力は状態だけの関数だからである。Mealy は条件を満たす入力が来た瞬間に出力を出すので、連続を検出するための状態は要らない。

習題 6.29 要求什麼:組合 always 區塊風格撰寫 Verilog — 次狀態與輸出都在 always @* 內設定,狀態暫存器則另用一個 always @(posedge clk) 區塊。由於是 Mealy,$z$ 同時取決於狀態與 $w$,所以 $z$ 的指派就寫在決定狀態轉移的那個組合區塊裡。

What problem 6.29 asks: write Verilog using the combinational always block style — both next-state and output are set inside always @*, with a separate always @(posedge clk) block for the state register. The Mealy nature means $z$ depends on both state and $w$, so $z$'s assignment lives in the same combinational block where state transitions are decided.

問題 6.29 が要求すること:組合せalways ブロック方式で Verilog を書く — 次状態も出力も always @* の中で決め、状態レジスタは別の always @(posedge clk) ブロックに置く。Mealy であるため $z$ は状態と $w$ の両方に依存し、$z$ の代入は状態遷移を決めるのと同じ組合せブロックの中に書く。

module mealy_seq (input w, clk, rst,
                  output reg z);
    parameter A = 2'b00, B = 2'b01, C = 2'b11;
    reg [1:0] state, next;

    always @(posedge clk or posedge rst)  // state register
        if (rst) state <= A;
        else     state <= next;

    always @* begin                        // next-state + output
        z = 1'b0;
        case (state)
            A: next = w ? C : B;
            B: begin next = w ? C : B; z = (w == 1'b0); end
            C: begin next = w ? C : B; z = (w == 1'b1); end
            default: next = A;
        endcase
    end
endmodule
— example 6.14
6.30困難Hard難しい第一階Tier 1ティア 1E?R
請設計一個串列資料傳送器 FSM,從並列輸入取得 7 位元 ASCII 字元,並在串列輸出線上每個時脈週期送出一個位元。請為此位元組加上適當的框架 (framing),並在傳送完成時給出指示。
Design a serial-data transmitter FSM that takes a 7-bit ASCII character on a parallel input and shifts it out one bit per clock cycle on a serial output line. Frame the byte appropriately and indicate when the transmission is complete.
並列入力から 7 ビットの ASCII 文字を受け取り、シリアル出力線に 1 クロックあたり 1 ビットずつシフト出力する直列データ送信 FSM を設計せよ。バイトに適切なフレーミングを施し、送信が完了したことを示すようにせよ。
07 數位系統設計Digital System Designディジタルシステム設計

本章說明如何把各種基本組件組合成完整的數位系統。核心概念是把系統分成資料路徑 (datapath) 與控制單元 (FSM)。匯流排結構以三態驅動器與多工器來說明。主要範例是一個簡單的處理器設計,包含暫存器檔案、ALU 與控制 FSM。書中還介紹了數個演算法式設計:位元計數電路、移位相加乘法器、回復式除法器、算術平均計算器,以及排序網路。每一個都以 ASM 圖描述控制、以資料路徑圖描述資料流。本章最後討論實務考量:時脈分佈網路、晶片層級的正反器時序、非同步輸入的處理(同步器),以及開關去彈跳電路。

This chapter shows how to combine building blocks into complete digital systems. The key concept of separating a system into a datapath and a control unit (FSM) is central. Bus structures are explained using tri-state drivers and multiplexers. A simple processor design serves as the main example, including a register file, ALU, and a control FSM. Several algorithmic designs are presented: a bit-counting circuit, a shift-and-add multiplier, a restoring divider, an arithmetic mean calculator, and a sorting network. Each is designed using ASM charts for control and datapath diagrams. The chapter concludes with practical considerations: clock distribution networks, flip-flop timing at the chip level, asynchronous input handling (synchronizers), and switch debouncing circuits.

本章では、基本ブロックを組み合わせて完全なディジタルシステムを構成する方法を示す。システムをデータパスと制御ユニット (FSM) に分けるという考え方が中心となる。バス構造はトライステートドライバとマルチプレクサを用いて説明する。主な例題は簡単なプロセッサ設計で、レジスタファイル、ALU、制御 FSM を含む。さらにいくつかのアルゴリズム的な設計を示す:ビット計数回路、シフト加算乗算器、復元型除算器、算術平均計算器、ソーティングネットワークである。いずれも制御は ASM チャートで、データの流れはデータパス図で設計する。章の終わりでは実際的な検討事項を扱う:クロック分配網、チップレベルでのフリップフロップのタイミング、非同期入力の扱い(同期化回路)、スイッチのチャタリング除去回路である。

本章說明如何將各個基礎元件組合成完整的數位系統。核心概念是把系統拆分為資料路徑 (datapath)控制單元 (control unit, FSM)。匯流排結構則以三態驅動器 (tri-state driver) 與多工器 (multiplexer) 來實現。本章的主要範例是一個簡單處理器,包含暫存器檔 (register file)、ALU 與控制 FSM。此外還介紹幾個演算法設計:位元計數電路、移位加法乘法器、還原除法器 (restoring divider)、算術平均計算器,以及排序網路。每個範例都以 ASM 圖描述控制流,搭配資料路徑圖。最後則討論實務考量:時脈分佈網路 (clock distribution)、晶片層級的正反器時序、非同步輸入處理 (同步器, synchronizer),以及開關彈跳消除 (switch debouncing) 電路。

This chapter shows how the individual building blocks combine into a complete digital system. The central idea is to split the system into a datapath and a control unit (FSM). Bus structures are realised with tri-state drivers and multiplexers. The chapter's main example is a simple processor containing a register file, an ALU and a control FSM. Several algorithmic designs are also introduced: a bit-counting circuit, a shift-and-add multiplier, a restoring divider, an arithmetic-mean calculator and a sorting network. Each example describes its control flow with an ASM chart alongside a datapath diagram. Practical concerns close the chapter: clock distribution networks, chip-level flip-flop timing, handling asynchronous inputs (synchronisers) and switch-debouncing circuits.

本章では、個々の基本要素をどのように組み合わせて完全なディジタルシステムを構成するかを示す。中心となる考え方は、システムをデータパス (datapath)制御ユニット (control unit, FSM) に分けることである。バス構造はトライステートドライバとマルチプレクサで実現する。本章の主要な例は、レジスタファイル・ALU・制御 FSM からなる簡単なプロセッサである。さらにいくつかのアルゴリズム設計も紹介する:ビット計数回路、シフト加算乗算器、引き戻し法除算器 (restoring divider)、算術平均計算器、そしてソーティングネットワークである。各例は制御の流れを ASM チャートで記述し、データパス図を併せて示す。最後に実務上の考慮事項を扱う:クロック分配網 (clock distribution)、チップレベルのフリップフロップタイミング、非同期入力の扱い(同期化回路、synchronizer)、およびスイッチのチャタリング除去 (switch debouncing) 回路である。

資料路徑+控制 匯流排結構 簡易處理器 移位相加乘法器 除法器 ASM 圖 時脈分佈 開關去彈跳
Datapath + Control Bus Structures Simple Processor Shift-and-Add Multiplier Divider ASM Charts Clock Distribution Switch Debouncing
データパスと制御 バス構成 簡易プロセッサ シフト加算乗算器 除算器 ASM チャート クロック分配 スイッチのチャタリング除去
What is an ASM chart?

ASM(Algorithmic State Machine)圖是一種流程圖式的記號,用來描述有限狀態機的控制流程。它的角色與狀態圖相同,但更接近演算法虛擬碼 — 對於依許多條件分支的複雜 FSM 更易讀,更容易直接轉成 Verilog 的 case 敘述,也更容易在視覺上與它所控制的資料路徑動作對齊。

An ASM (Algorithmic State Machine) chart is a flowchart-style notation for describing the control flow of a finite-state machine. It plays the same role as a state diagram, but is closer to algorithm pseudocode — easier to read for complex FSMs that branch on many conditions, easier to translate directly into Verilog case statements, and easier to align visually with the datapath actions it controls.

ASM(Algorithmic State Machine)チャートは、有限状態機械の制御の流れを記述するフローチャート形式の記法である。状態遷移図と同じ役割を果たすが、アルゴリズムの擬似コードに近い — 多くの条件で分岐する複雑な FSM でも読みやすく、Verilog の case 文へそのまま翻訳しやすく、制御対象のデータパス動作と視覚的に対応づけやすい。

ASM 圖的三種基本元件

The three building blocks of an ASM chart:

ASM チャートを構成する3 つの要素

State Box state name Moore outputs rectangle 「處於此狀態時…」"while in this state…"「この状態にいる間…」 Decision condition (e.g. $w$=1?) 0 1 rhombus 「檢查這個輸入」"check this input"「この入力を調べる」 Conditional Output oval 「這條分支上的 Mealy 輸出」"Mealy output on this branch"「この分岐での Mealy 出力」

Each box has a specific role:

  • 狀態框(矩形)。為狀態命名,並列出 FSM 停留在該狀態期間 assert 的 Moore 輸出。一個狀態框 = 一個時脈週期。
  • State box (rectangle). Names a state and lists the Moore outputs asserted while the FSM sits in that state. One state box = one clock cycle.
  • 状態ボックス(長方形)。状態に名前を付け、FSM がその状態にいる間にアサートされる Moore 出力を並べる。状態ボックス 1 個 = 1 クロックサイクルである。
  • 判斷框(菱形)。測試一個輸入或狀態訊號,把流程導向兩條分支之一。同一個 ASM 區塊內可以串接多個判斷框。
  • Decision box (rhombus / diamond). Tests an input or status signal and routes the flow to one of two branches. Multiple decision boxes can chain inside the same ASM block.
  • 判定ボックス(ひし形)。入力またはステータス信号を判定し、流れを 2 つの分岐のいずれかへ振り分ける。同じ ASM ブロックの中に判定ボックスを複数連ねることもできる。
  • 條件輸出框(橢圓)。內含只有在流程確實走到該分支時才 assert 的 Mealy 輸出 — 也就是同時取決於狀態與輸入。若沒有任何 Mealy 輸出,就不需要這個框。
  • Conditional output box (oval). Contains Mealy outputs that are only asserted when the flow actually reaches that branch — i.e., they depend on both the state and the input. If you don't have any Mealy outputs, you don't need this box.
  • 条件出力ボックス(楕円)。流れが実際にその分岐へ来たときにだけアサートされる Mealy 出力を入れる — つまり状態と入力の両方に依存する出力である。Mealy 出力がなければ、このボックスは不要である。

ASM 區塊是指一個狀態框,連同它之後、下一個狀態框之前的所有判斷框與條件輸出框。一個 ASM 區塊 = 一個時脈週期份的行為。

An ASM block is a state box together with all the decision and conditional-output boxes that follow it before the next state box. One ASM block = one clock cycle's worth of behavior.

ASM ブロックとは、1 つの状態ボックスと、その後ろから次の状態ボックスまでに現れるすべての判定ボックスおよび条件出力ボックスをまとめたものである。ASM ブロック 1 個 = 1 クロックサイクル分の動作である。

Tiny worked example — "01" detector (Moore):

Reset A z = 0 w 1 0 B (saw 0) z = 0 w 0 1 self-loop B C (saw 01) z = 1

三個狀態框(A、B、C — C 畫成雙框線,表示 Moore 的 z=1),兩個測試輸入 w 的判斷框;由於這個版本是純 Moore,不需要條件輸出。

Three state boxes (A, B, C — C drawn with a double border to mark Moore z=1), two decision boxes testing input w, no conditional outputs needed since this version is pure Moore.

状態ボックスが 3 つ(A、B、C — C は Moore の z=1 を示すため二重枠で描く)、入力 w を判定する判定ボックスが 2 つ。この版は純粋な Moore なので条件出力は要らない。

狀態 C (saw 01) 的讀法。 C 是這個 Moore FSM 的接受狀態,雙線外框是它的視覺標記:控制流走到此狀態,代表最近觀察到的兩個輸入 $w$ 依序為 01 — 即剛剛偵測到模式 "01"。(saw 01) 是給人看的助記註解,記錄輸入歷史的意義,不是狀態編碼的一部分(state assignment 換成 $y_1 y_0 = 10$ 之類後,這段註解就消失了)。

How to read state C (saw 01). C is the accepting state of this Moore FSM, and the double outline is its visual marker: reaching this state means the two most recent inputs $w$ were 0 then 1 — the pattern "01" has just been detected. (saw 01) is a human-readable annotation recording what the input history means; it is not part of the state encoding (once a state assignment such as $y_1 y_0 = 10$ is chosen, the annotation disappears).

状態 C (saw 01) の読み方。C はこの Moore FSM の受理状態であり、二重の枠線がその目印である。この状態に到達したということは、直近 2 回の入力 $w$ が 01 の順だったこと——すなわちパターン "01" をいま検出したことを意味する。(saw 01) は入力履歴の意味を人間向けに記した注記であって、状態符号化の一部ではない($y_1 y_0 = 10$ のような状態割当てを決めた時点で、この注記は消える)。

輸出 $z = 1$ 是 Moore output:只要 FSM 停留在 C,整個 clock cycle 都會 assert,跟當下的 $w$ 值無關。如果輸出要依賴 $w$,就改放在橢圓形 conditional-output box 中,變成 Mealy 輸出 — 這就是下方 Mealy variant 用一個 oval 取代額外狀態的原因。

The output $z = 1$ is a Moore output: it is asserted for the whole clock cycle whenever the FSM sits in C, independently of the current value of $w$. If the output had to depend on $w$ it would move into an oval conditional-output box and become a Mealy output — which is why the Mealy variant below replaces an extra state with a single oval.

出力 $z = 1$ は Moore 出力である:FSM が C にいる限り、そのクロックサイクル全体にわたってアサートされ、そのときの $w$ の値には依存しない。出力を $w$ に依存させたいなら、楕円形の conditional-output box に移して Mealy 出力にする——下の Mealy 版が状態を 1 つ増やす代わりに楕円 1 個で済ませているのはこのためである。

圖中 C 從上方接收一條進入箭頭(來自 B 的 $w=1$ 分支),下方應該有一條離開箭頭接到下一個 decision box,決定 C 在下個 clock edge 要回到 A(若收到 $w=1$)或回到 B(若收到 $w=0$ 重新開始累積)。本範例為了精簡只畫到「踏進 C」為止,完整的 FSM 還需要 C 的兩條離開 transition。

In the figure C receives one incoming arrow from above (the $w=1$ branch out of B), and below it there should be an outgoing arrow to the next decision box, deciding whether C returns to A on the next clock edge (if $w=1$) or back to B (if $w=0$, restarting the accumulation). For brevity the example only draws as far as “stepping into C”; the complete FSM also needs C's two outgoing transitions.

図では C に上から 1 本の入力矢印(B の $w=1$ 分岐)が入り、その下には次の decision box へ向かう出力矢印があるはずである。そこで、次のクロックエッジで C が A へ戻る($w=1$ のとき)のか、B へ戻って蓄積をやり直す($w=0$ のとき)のかが決まる。この例では簡潔さのため「C に入る」ところまでしか描いていない。完全な FSM には C から出る 2 本の遷移も必要である。

Mealy 變體 — 帶條件輸出橢圓的「01」偵測器:同樣的工作少用一個狀態。z 只在真正完成該樣式的那次轉移上 assert,所以它放在該分支的橢圓內(Mealy = 輸出同時取決於狀態輸入)。

Mealy variant — "01" detector with a conditional output oval: the same job done with one fewer state. z is asserted only on the transition that actually completes the pattern, so it lives inside an oval on that branch (Mealy = output depends on state and input).

Mealy 版 — 条件出力の楕円を持つ「01」検出器:同じ仕事を状態 1 つ少なく実現する。z はパターンを実際に完成させる遷移でのみアサートされるので、その分岐の楕円の中に置かれる(Mealy = 出力が状態入力に依存する)。

Reset A (沒有 Moore 輸出)(no Moore output)(Moore 出力なし) w 0 1 stay in A B (saw 0) w 0 1 stay in B z = 1 (Mealy output) back to A

兩個狀態框(A、B)、兩個針對輸入 w 的判斷框,以及一個位於 B → A 分支上的條件輸出橢圓,該分支上 w=1 完成「01」樣式。Mealy 只在那次轉移上讓 z 發出一個週期 — 狀態數確實比同一偵測器的 Moore 版本少,代價是輸出會以組合方式跟隨輸入。

Two state boxes (A, B), two decision boxes on input w, and one conditional output oval on the B → A branch where w=1 completes the "01" pattern. Mealy fires z for one cycle on that transition only — strictly fewer states than the Moore version of the same detector, at the cost of an output that follows the input combinationally.

状態ボックスが 2 つ(A、B)、入力 w の判定ボックスが 2 つ、そして w=1 が「01」パターンを完成させる B → A の分岐に条件出力の楕円が 1 つある。Mealy はその遷移でだけ z を 1 サイクル出す — 同じ検出器の Moore 版より状態数は確実に少ないが、出力が入力に組合せ的に追従するという代償を伴う。

如何對映到 Verilog:每個狀態框成為 FSM 組合 always 區塊中 case 的一個分支;每個判斷框成為一層巢狀的 if;每個條件輸出框成為該 if 分支內的一條輸出指派。

How it maps to Verilog: each state box becomes one branch of a case in the FSM's combinational always block; each decision box becomes a nested if; each conditional output box becomes an output assignment inside that if branch.

Verilog への対応:各状態ボックスは FSM の組合せ always ブロック内の case の 1 分岐になり、各判定ボックスは入れ子の if になり、各条件出力ボックスはその if 分岐の中の出力代入になる。

ASM chart vs. state diagram:

狀態圖State diagram状態遷移図ASM 圖ASM chartASM チャート
Visual stylecircles + arrows (graph)flowchart (boxes + flow lines)
Best forsmall FSMs, conceptual understanding輸入分支眾多的大型 FSM、需考慮資料路徑的設計large FSMs with many input branches, datapath-aware design入力分岐の多い大規模 FSM、データパスを意識した設計
Output placement在狀態圓圈內(Moore)或在箭頭上(Mealy)inside the state circle (Moore) or on the arrow (Mealy)状態の円の中(Moore)または矢印の上(Mealy)在狀態框內(Moore)或在條件輸出橢圓內(Mealy)inside the state box (Moore) or in a conditional output oval (Mealy)状態ボックスの中(Moore)または条件出力の楕円の中(Mealy)
Translation to Verilogmanual case + transitions直接對映:每個框 → 一個 Verilog 結構direct mapping: each box → one Verilog construct直接対応:各ボックス → Verilog の構文 1 つ
Datapath alignment分開(資料路徑另外畫)separate (you draw the datapath elsewhere)別々(データパスは別に描く)常與各狀態的資料路徑動作並列顯示often shown side-by-side with the datapath actions in each state各状態のデータパス動作と並べて示すことが多い

結論:ASM 圖 = 給工程師看的狀態圖。資訊完全相同,只是整理成流程圖形式,能與 Verilog 程式碼以及 FSM 所控制的資料路徑操作乾淨地對齊。課本第 7 章通篇使用 ASM 圖,因為每個例子都牽涉到必須逐週期編排暫存器傳送的資料路徑。

Bottom line: ASM chart = state diagram for engineers. Same information, organized as a flowchart that lines up cleanly with Verilog code and with the datapath operations the FSM is controlling. The textbook uses ASM charts throughout chapter 7 because every example involves a datapath whose register transfers must be choreographed cycle-by-cycle.

要点:ASM チャート = 技術者向けの状態遷移図である。情報は同じで、Verilog のコードや FSM が制御するデータパス操作ときれいに対応するフローチャートの形に整理されているだけである。教科書が第 7 章を通して ASM チャートを使うのは、どの例題もレジスタ転送をサイクルごとに組み立てねばならないデータパスを含むからである。

參考 Verilog:以歐幾里得減法求 GCD(習題 7.8)Reference Verilog: GCD via Euclidean subtraction (problem 7.8)参考 Verilog:ユークリッドの減算による GCD(問題 7.8)

一個典型的小型 FSM 範例:以反覆相減計算 $\gcd(a, b)$。3 狀態控制器(IDLE / RUN / DONE)驅動一個由兩個暫存器、一個減法器與一個比較器組成的小型資料路徑 — 正是本章通篇所談的那種模式。

A canonical small-FSM example: compute $\gcd(a, b)$ by repeated subtraction. The 3-state controller (IDLE / RUN / DONE) drives a tiny datapath of two registers, one subtractor, and one comparator — exactly the kind of pattern covered throughout this chapter.

小規模 FSM の典型例:繰り返し減算で $\gcd(a, b)$ を求める。3 状態のコントローラ(IDLE / RUN / DONE)が、レジスタ 2 個、減算器 1 個、比較器 1 個からなる小さなデータパスを駆動する — 本章を通して扱うパターンそのものである。

演算法。start 時載入 $A \leftarrow a$、$B \leftarrow b$。當 $A \neq B$ 時,從較大者減去較小者(若 $A>B$ 則 $A \leftarrow A-B$,否則 $B \leftarrow B-A$)。當 $A = B$ 時,這個共同的值就是 GCD。

Algorithm. Load $A \leftarrow a$, $B \leftarrow b$ on start. While $A \neq B$, subtract the smaller from the larger ($A \leftarrow A-B$ if $A>B$, else $B \leftarrow B-A$). When $A = B$ that common value is the GCD.

アルゴリズム。start で $A \leftarrow a$、$B \leftarrow b$ をロードする。$A \neq B$ の間、大きいほうから小さいほうを引く($A>B$ なら $A \leftarrow A-B$、そうでなければ $B \leftarrow B-A$)。$A = B$ になったとき、その共通の値が GCD である。

module gcd #(parameter N = 8) (
    input              clk, rst, start,
    input  [N-1:0]     a, b,
    output reg [N-1:0] gcd_out,
    output reg         done
);
    reg [N-1:0] A, B;
    reg [1:0]   state;
    parameter IDLE = 2'b00, RUN = 2'b01, DONE = 2'b10;

    always @(posedge clk or posedge rst) begin
        if (rst) begin
            state <= IDLE;
            done  <= 1'b0;
        end else case (state)
            IDLE: if (start) begin
                      A     <= a;
                      B     <= b;
                      done  <= 1'b0;
                      state <= RUN;
                  end
            RUN:  if (A == B) begin
                      gcd_out <= A;        // result
                      done    <= 1'b1;
                      state   <= DONE;
                  end else if (A > B) begin
                      A     <= A - B;
                      state <= RUN;        // explicit: stay in RUN
                  end else begin
                      B     <= B - A;
                      state <= RUN;        // explicit: stay in RUN
                  end
            DONE: if (!start) state <= IDLE;   // wait for start to deassert
        endcase
    end
endmodule

延遲 & 變體。以減法為基礎的 GCD 最壞情況需要 O(max(a, b)) 個週期 — 兩個運算元差距很大時很慢(例如 $\gcd(1, 2^{31})$)。取模的變體 $\gcd(A, B) = \gcd(B, A \bmod B)$ 只需 O(log min(a, b)) 個週期,但資料路徑中需要一個整數除法器。反覆相減的形式之所以是課本的標準範例,是因為它只需要一個減法器 + 比較器 + 2 個暫存器 + 一個 3 狀態的 FSM 控制器。

Latency & variants. Subtraction-based GCD is worst-case O(max(a, b)) cycles — slow for very different operands (e.g. $\gcd(1, 2^{31})$). The mod-based variant $\gcd(A, B) = \gcd(B, A \bmod B)$ reaches O(log min(a, b)) cycles but requires an integer divider in the datapath. The repeated-subtraction form is the standard textbook example because it needs only a subtractor + comparator + 2 registers + a 3-state FSM controller.

レイテンシ & 変種。減算に基づく GCD は最悪で O(max(a, b)) サイクルかかる — オペランドの差が大きいと遅い(たとえば $\gcd(1, 2^{31})$)。剰余を使う変種 $\gcd(A, B) = \gcd(B, A \bmod B)$ は O(log min(a, b)) サイクルで済むが、データパスに整数除算器が必要になる。繰り返し減算の形が教科書の標準例なのは、減算器 + 比較器 + レジスタ 2 個 + 3 状態の FSM コントローラだけで済むからである。

7.1中等Medium普通第一階Tier 1ティア 1?R
說明三態匯流排與以多工器為基礎的匯流排之間的差異。這兩種做法各有什麼優點?
Explain the difference between a tri-state bus and a multiplexer-based bus. What are the advantages of each approach?
トライステートバスとマルチプレクサ方式のバスの違いを説明せよ。それぞれの手法の利点は何か。
7.2中等Medium普通第一階Tier 1ティア 1?R
請畫出一個簡易處理器的資料路徑,包含四個 8 位元暫存器(R0–R3)、支援 ADD 與 SUB 的 ALU,以及以多工器為基礎的匯流排。
Draw the datapath for a simple processor with four 8-bit registers (R0–R3), an ALU supporting ADD and SUB, and a multiplexer-based bus.
8 ビットレジスタ 4 本(R0–R3)、ADD と SUB をサポートする ALU、およびマルチプレクサ方式のバスをもつ簡易プロセッサのデータパスを描け。
7.5中等Medium普通第一階Tier 1ティア 1?R
什麼是時脈偏斜 (clock skew)?請說明它為何會在同步電路中同時造成 setup time 違規與 hold time 違規。
What is clock skew? Explain how it can cause both setup time violations and hold time violations in a synchronous circuit.
クロックスキューとは何か。同期回路において、それが setup time 違反と hold time 違反の両方を引き起こしうる理由を説明せよ。
7.7中等Medium普通第一階Tier 1ティア 1?R
請說明暫存器轉移層級 (Register Transfer Level, RTL) 設計的概念。它與資料路徑/控制的切分有何關係?
Explain the concept of Register Transfer Level (RTL) design. How does it relate to the datapath/control partitioning?
レジスタ転送レベル (Register Transfer Level, RTL) 設計の概念を説明せよ。それはデータパスと制御の分割とどのように関係するか。
7.10簡單Easy易しい第一階Tier 1ティア 1?R
請描述 ASM 區塊的三個元素:狀態方塊、判斷方塊與條件輸出方塊。
Describe the three elements of an ASM block: state box, decision box, and conditional output box.
ASM ブロックを構成する 3 つの要素、すなわち状態ボックス、判定ボックス、条件付き出力ボックスについて述べよ。
7.12困難Hard難しい第一階Tier 1ティア 1?R
請為兩個 4 位元無號數設計一個移位相加乘法器。畫出控制電路的 ASM 圖與資料路徑電路。
Design a shift-and-add multiplier for two 4-bit unsigned numbers. Draw the ASM chart for the control circuit and the datapath circuit.
4 ビット符号なし数 2 つに対するシフト加算乗算器を設計せよ。制御回路の ASM チャートとデータパス回路を描け。
7.15困難Hard難しい第一階Tier 1ティア 1E?R
請設計一個無號的復原式除法器,以移位—相減—復原演算法計算兩個 $n$ 位元數的商與餘數。請提供資料路徑、控制器的 ASM 圖,以及能正確合成的 Verilog 程式碼。
Design an unsigned restoring divider that computes the quotient and remainder of two $n$-bit numbers using the shift-subtract-restore algorithm. Provide the datapath, an ASM chart for the controller, and Verilog code that synthesizes correctly.
シフト・減算・復元アルゴリズムを用いて $n$ ビットの数 2 つの商と剰余を求める、符号なし復元法の除算器を設計せよ。データパス、コントローラの ASM チャート、および正しく合成できる Verilog コードを示せ。
08 邏輯函數的最佳化實作Optimized Implementation of Logic Functions論理関数の最適化実装

本章從第 2 章的兩層 SOP/POS 化簡進一步走向多層邏輯合成,以及實際 CAD 工具所使用的進階最佳化技術。當有扇入或其他限制時,可用因式分解、函數分解與多層 NAND/NOR 電路合成來降低電路成本。書中也介紹邏輯函數的其他表示法:立方體表示法(使用 cube 與 cover),以及在現代 CAD 工具中廣泛用於驗證與最佳化的二元決策圖 (BDD)。Quine-McCluskey 表格化簡法在此作為卡諾圖的演算法式替代方案提出,能處理變數很多的函數。另外也介紹以立方體為基礎的化簡技巧。最後討論處理超大型函數的實務考量。

This chapter goes beyond the two-level SOP/POS minimization of Chapter 2 into multilevel logic synthesis and advanced optimization techniques used in real CAD tools. Factoring, functional decomposition, and multilevel NAND/NOR circuit synthesis are presented as methods to reduce circuit cost when fan-in or other constraints apply. Alternative representations of logic functions are introduced: the cubical representation (using cubes and covers), and binary decision diagrams (BDDs), which are used extensively in modern CAD tools for verification and optimization. The Quine-McCluskey tabular minimization method is presented as an algorithmic alternative to Karnaugh maps that can handle functions with many variables. A cubical technique for minimization is also covered. Practical considerations for dealing with very large functions are discussed.

本章は、第 2 章の 2 レベル SOP/POS 最小化を越えて、多段論理合成と実際の CAD ツールで使われる高度な最適化技法へ進む。ファンインなどの制約があるときに回路コストを下げる方法として、因数分解、関数分解、多段 NAND/NOR 回路合成を示す。論理関数の別の表現も導入する:キューブと被覆を用いる立方体表現と、現代の CAD ツールで検証・最適化に広く使われる 2 分決定グラフ (BDD) である。Quine-McCluskey の表による最小化法は、変数の多い関数も扱えるカルノー図のアルゴリズム的な代替として示される。立方体を用いた最小化手法も扱う。さらに、非常に大きな関数を扱う際の実際的な検討事項を論じる。

本章從第 2 章的兩層 SOP/POS 最小化進一步推廣到多層邏輯合成 (multilevel logic synthesis),介紹現代 CAD 工具實際使用的進階最佳化技術。因式分解 (factoring)功能分解 (functional decomposition),以及 NAND/NOR 多層電路合成被作為在扇入 (fan-in) 或其他限制下降低電路成本的方法。本章還介紹邏輯函式的替代表示法:立方體表示 (cubical representation) 使用 cube 與 cover 描述函式;二元決策圖 (BDD, binary decision diagram) 則在現代 CAD 工具中廣泛用於驗證與最佳化。Quine-McCluskey 表格化最小化法則是一種能處理多變數函式的演算法替代方案——當卡諾圖 (Karnaugh map) 變得不切實際時可改用。本章亦介紹立方體最小化技術,並討論處理超大型函式時的實務考量。

This chapter generalises the two-level SOP/POS minimisation of Chapter 2 to multilevel logic synthesis and introduces the advanced optimisation techniques that modern CAD tools actually use. Factoring, functional decomposition and NAND/NOR multilevel synthesis are presented as ways to reduce circuit cost under fan-in or other constraints. Alternative representations of logic functions also appear: cubical representation describes functions with cubes and covers, while binary decision diagrams (BDDs) are widely used in modern CAD tools for verification and optimisation. The Quine-McCluskey tabular minimisation method is an algorithmic alternative able to handle many-variable functions — usable when Karnaugh maps become impractical. The chapter also covers cube-minimisation techniques and discusses the practical issues of handling very large functions.

本章では、第 2 章の 2 レベル SOP/POS 最小化を多段論理合成 (multilevel logic synthesis) へ一般化し、現代の CAD ツールが実際に用いる高度な最適化手法を紹介する。因数分解 (factoring)関数分解 (functional decomposition)、および NAND/NOR による多段合成を、ファンイン制約などの下で回路コストを下げる手段として扱う。論理関数の別表現も登場する:キューブ表現 (cubical representation) は関数を cube と cover で記述し、二分決定図 (BDD, binary decision diagram) は現代の CAD ツールで検証と最適化に広く使われている。Quine-McCluskey の表形式最小化法は多変数関数も扱えるアルゴリズム的な代替手段であり、カルノー図が現実的でなくなったときに使える。本章ではさらにキューブ最小化の技法を扱い、非常に大きな関数を扱う際の実務上の問題にも触れる。

用一個小例子逐步走過 Quine-McCluskeyWalk through Quine-McCluskey on a small example小さな例で Quine-McCluskey をたどる

Q-M 以兩個階段化簡任意布林函數:

Q-M minimizes any Boolean function in two phases:

Q-M は任意のブール関数を 2 つの段階で最小化する:

  1. 反覆合併恰好差一個位元的相鄰項,以產生所有質蘊涵項
  2. Generate all prime implicants by repeatedly merging adjacent terms that differ in exactly one bit.
  3. ちょうど 1 ビットだけ異なる隣接項を繰り返し併合して、すべての主項を生成する
  4. 用質蘊涵項圖表從這些質蘊涵項中挑出最小覆蓋
  5. Pick a minimum cover from those primes using a prime-implicant chart.
  6. 主項表を使い、それらの主項から最小被覆を選ぶ

以下是 $f(A,B,C) = \sum m(0,1,3,7)$ 的完整範例。點擊各階段可展開。

Below is a worked example with $f(A,B,C) = \sum m(0,1,3,7)$. Click each phase to expand.

以下は $f(A,B,C) = \sum m(0,1,3,7)$ による実例である。各段階をクリックすると展開する。

階段 1a — 依漢明重量分組列出最小項Phase 1a — list minterms grouped by Hamming weight段階 1a — ハミング重みでグループ分けして最小項を列挙する
群組Groupグループ最小項Minterm最小項$ABC$
0$m_0$000
1$m_1$001
2$m_3$011
3$m_7$111

每一列都是 $f=1$ 的最小項。依 1 的個數分組,代表只有相鄰的組別才可能合併 — 跨越非相鄰組別的配對必定至少差 2 個位元。

Each row is a minterm where $f=1$. Grouping by 1-count means only adjacent groups can possibly merge — pairs across non-adjacent groups always differ in at least 2 bits.

各行は $f=1$ となる最小項である。1 の個数でグループ分けすると、併合し得るのは隣り合うグループどうしだけになる — 隣接しないグループにまたがる対は必ず 2 ビット以上異なる。

階段 1b — 合併差一個位元的配對(建出 2-cube)Phase 1b — combine pairs differing in one bit (build 2-cubes)段階 1b — 1 ビット異なる対を併合する(2-cube を作る)

把第 $k$ 組的每個最小項與第 $k+1$ 組的每個最小項比對。若兩個二進位樣式恰好在一個位置不同,就把該位元換成「−」:

Compare each minterm in group $k$ against each in group $k+1$. If the two binary patterns differ in exactly one position, replace that bit with "−":

グループ $k$ の各最小項を、グループ $k+1$ の各最小項と比較する。2 つの 2 進パターンがちょうど 1 か所だけ異なるなら、そのビットを「−」に置き換える:

$m_0$ (000) $m_1$ (001) $m_3$ (011) $m_7$ (111) 00− (0,1) 0−1 (1,3) −11 (3,7)

每個合併出的配對都是一個 2-cube — 消去一個字母,涵蓋兩個最小項。把來源的兩個最小項都標記為「已使用」。

Each merged pair is a 2-cube — covers two minterms with one literal eliminated. Mark both source minterms as "used".

併合してできた対はそれぞれ 2-cube であり、リテラルを 1 つ消して最小項 2 個を覆う。元の最小項 2 つには「使用済み」の印を付ける。

階段 1c — 嘗試把 2-cube 合併成 4-cubePhase 1c — try to combine 2-cubes into 4-cubes段階 1c — 2-cube どうしを 4-cube に併合できるか試す

兩個 2-cube 能合併的條件是:破折號位置相同,而且其餘位元中恰好有一個不同。

Two 2-cubes combine if they have the same dash position AND differ in exactly one of the remaining bits.

2 つの 2-cube が併合できるのは、ダッシュの位置が同じで、かつ残りのビットのちょうど 1 つだけが異なるときである。

  • $00{-}$ 對 $0{-}1$ — 破折號位置不同 → 無法合併
  • $00{-}$ vs $0{-}1$ — different dash positions → can't combine
  • $00{-}$ と $0{-}1$ — ダッシュの位置が違う → 併合できない
  • $00{-}$ 對 $-11$ — 破折號位置不同 → 無法合併
  • $00{-}$ vs $-11$ — different dash positions → can't combine
  • $00{-}$ と $-11$ — ダッシュの位置が違う → 併合できない
  • $0{-}1$ 對 $-11$ — 破折號位置不同 → 無法合併
  • $0{-}1$ vs $-11$ — different dash positions → can't combine
  • $0{-}1$ と $-11$ — ダッシュの位置が違う → 併合できない

無法再進一步合併。這三個 2-cube 都是質蘊涵項。若有任何 2-cube 還能再合併,就只有較大的結果才是質蘊涵項。

No further combination possible. All three 2-cubes are prime implicants. If any 2-cube had been combined further, only the larger result would be prime.

これ以上は併合できない。3 つの 2-cube はいずれも主項である。もしどれかの 2-cube がさらに併合できていたなら、主項になるのは大きいほうの結果だけである。

完整範例:2-cube 確實能成功合併的情形Worked example: when 2-cubes do combine successfully実例:2-cube が実際にうまく併合できる場合

取一個 4 變數函數 $f(x_1, x_2, x_3, x_4) = \sum m(0, 1, 4, 5)$。這四個最小項的二進位表示:

Take a 4-variable function $f(x_1, x_2, x_3, x_4) = \sum m(0, 1, 4, 5)$. The four minterms in binary:

4 変数関数 $f(x_1, x_2, x_3, x_4) = \sum m(0, 1, 4, 5)$ を考える。4 つの最小項を 2 進で表すと:

最小項Minterm最小項$x_1 x_2 x_3 x_4$
$m_0$0000
$m_1$0001
$m_4$0100
$m_5$0101

步驟 1 — 把最小項配對成 2-cube(每一對只變動一個位元):

Step 1 — pair minterms into 2-cubes (one bit changes per pair):

手順 1 — 最小項を対にして 2-cube を作る(各対で変わるビットは 1 つ):

  • $m_0 \,(0000)$ + $m_1 \,(0001)$ → 000−  (差在 $x_4$,破折號在第 4 位)
  • $m_0 \,(0000)$ + $m_1 \,(0001)$ → 000−  (differ in $x_4$, dash at position 4)
  • $m_0 \,(0000)$ + $m_1 \,(0001)$ → 000−  ($x_4$ が異なる。ダッシュは 4 桁目)
  • $m_4 \,(0100)$ + $m_5 \,(0101)$ → 010−  (差在 $x_4$,破折號在第 4 位)
  • $m_4 \,(0100)$ + $m_5 \,(0101)$ → 010−  (differ in $x_4$, dash at position 4)
  • $m_4 \,(0100)$ + $m_5 \,(0101)$ → 010−  ($x_4$ が異なる。ダッシュは 4 桁目)
  • $m_0 \,(0000)$ + $m_4 \,(0100)$ → 0−00  (差在 $x_2$,破折號在第 2 位)
  • $m_0 \,(0000)$ + $m_4 \,(0100)$ → 0−00  (differ in $x_2$, dash at position 2)
  • $m_0 \,(0000)$ + $m_4 \,(0100)$ → 0−00  ($x_2$ が異なる。ダッシュは 2 桁目)
  • $m_1 \,(0001)$ + $m_5 \,(0101)$ → 0−01  (差在 $x_2$,破折號在第 2 位)
  • $m_1 \,(0001)$ + $m_5 \,(0101)$ → 0−01  (differ in $x_2$, dash at position 2)
  • $m_1 \,(0001)$ + $m_5 \,(0101)$ → 0−01  ($x_2$ が異なる。ダッシュは 2 桁目)

步驟 2 — 試著把 2-cube 合併成 4-cube

Step 2 — try to combine the 2-cubes into 4-cubes:

ステップ 2 — 2-cube を 4-cube へ併合できるか試す

Attempt A: $000{-}$ + $010{-}$

  • 破折號位置相同嗎? — 兩者的破折號都在第 4 位。
  • Same dash position? YES — both have the dash at position 4.
  • ダッシュの位置は同じか?はい — どちらもダッシュは 4 桁目にある。
  • 其餘位元:$\mathbf{000}-$ 對 $\mathbf{010}-$ → 恰好一個位置不同($x_2$ 位元:0 對 1)。是。
  • Other bits: $\mathbf{000}-$ vs $\mathbf{010}-$ → differ in exactly one position (the $x_2$ bit: 0 vs 1). YES.
  • 残りのビット:$\mathbf{000}-$ と $\mathbf{010}-$ → ちょうど 1 か所だけ異なる($x_2$ のビット:0 と 1)。はい。
  • → 合併成 0−0−  (涵蓋 $m_0, m_1, m_4, m_5$ — 一個 4-cube)。$x_2$ 現在也成了破折號;$x_1=0$ 與 $x_3=0$ 保留。
  • → Combines to 0−0−  (covers $m_0, m_1, m_4, m_5$ — a 4-cube). $x_2$ now also a dash; $x_1=0$ and $x_3=0$ remain.
  • 0−0− に併合される  ($m_0, m_1, m_4, m_5$ を覆う 4-cube)。$x_2$ もダッシュになり、$x_1=0$ と $x_3=0$ が残る。

Attempt B: $0{-}00$ + $0{-}01$

  • 破折號位置相同嗎? — 兩者的破折號都在第 2 位。
  • Same dash position? YES — both have the dash at position 2.
  • ダッシュの位置は同じか?はい — どちらもダッシュは 2 桁目にある。
  • 其餘位元:$0{-}\mathbf{00}$ 對 $0{-}\mathbf{01}$ → 恰好一個位置不同($x_4$ 位元)。是。
  • Other bits: $0{-}\mathbf{00}$ vs $0{-}\mathbf{01}$ → differ in exactly one position (the $x_4$ bit). YES.
  • 残りのビット:$0{-}\mathbf{00}$ と $0{-}\mathbf{01}$ → ちょうど 1 か所だけ異なる($x_4$ のビット)。はい。
  • → 合併成 0−0−  (與嘗試 A 相同的 4-cube — 兩條路徑殊途同歸)。
  • → Combines to 0−0−  (same 4-cube as Attempt A — both routes converge).
  • 0−0− に併合される  (試み A と同じ 4-cube。どちらの経路も同じ結果に至る)。

Counter-attempt: $000{-}$ + $0{-}00$ — does this combine?

  • 破折號位置相同嗎? — 第一個在第 4 位,第二個在第 2 位。
  • Same dash position? NO — first dash at position 4, second at position 2.
  • ダッシュの位置は同じか?いいえ — 一方は 4 桁目、もう一方は 2 桁目にある。
  • 規則當場不成立 → 無法合併。(即使兩者有三個位元相同,破折號沒有對齊就是不行。)
  • Rule fails immediately → can't combine. (Even though they share three bits, the dashes don't align.)
  • 規則がその時点で満たされない → 併合できない。(3 ビットが共通でも、ダッシュが揃っていなければ駄目である。)

結果:4-cube $0{-}0{-}$ 對應到質蘊涵項 $\overline{x_1}\,\overline{x_3}$(只有 $x_1=0$ 與 $x_3=0$ 是固定的)。一個 4 輸入 AND 閘就取代了原本需要的四個 2 輸入 AND 閘加一個 4 輸入 OR — 這就是合併帶來的成本節省。

Result: the 4-cube $0{-}0{-}$ corresponds to the prime implicant $\overline{x_1}\,\overline{x_3}$ (only $x_1=0$ and $x_3=0$ are fixed). One 4-input AND gate replaces what would otherwise be four 2-input AND gates and a 4-input OR — that's the cost saving the merger produces.

結果:4-cube $0{-}0{-}$ は主項 $\overline{x_1}\,\overline{x_3}$ に対応する(固定されているのは $x_1=0$ と $x_3=0$ だけ)。4 入力 AND ゲート 1 個が、本来なら必要だった 2 入力 AND 4 個 + 4 入力 OR 1 個を置き換える — これが併合による節約である。

K-map 驗證。 在 4 變數 K-map 中,以 $x_1 x_2$ 為列、$x_3 x_4$ 為行,四個 minterm $m_0, m_1, m_4, m_5$ 全部落在 $x_3=0$ 的行對(column-pair)且 $x_1=0$ 的列對(row-pair)中 — 形成一個乾淨的 $2\times 2$ quad。cube $0{-}0{-}$ 正好編碼此 quad:$x_1=0$ 列、$x_3=0$ 行,$x_2$ 與 $x_4$ 皆為 free。

K-map check. On a 4-variable K-map with $x_1 x_2$ as rows and $x_3 x_4$ as columns, the four minterms $m_0, m_1, m_4, m_5$ all fall in the column-pair where $x_3=0$ and the row-pair where $x_1=0$ — forming a clean $2\times 2$ quad. The cube $0{-}0{-}$ encodes exactly that quad: row $x_1=0$, column $x_3=0$, with $x_2$ and $x_4$ both free.

K-map による確認。$x_1 x_2$ を行、$x_3 x_4$ を列とした 4 変数 K-map では、4 つの minterm $m_0, m_1, m_4, m_5$ はいずれも $x_3=0$ の列ペアと $x_1=0$ の行ペアに入り、きれいな $2\times 2$ の quad をつくる。cube $0{-}0{-}$ はまさにこの quad を符号化している:行 $x_1=0$、列 $x_3=0$、$x_2$ と $x_4$ はいずれも free である。

辨認樣式的訣竅:完成階段 1b 後,把 2-cube 依破折號位置排序。破折號位置不同的 cube 保證不可能合併,所以只需檢查同一破折號位置群組內的配對。這正是 Q-M 表格法比暴力兩兩比對更有效率的原因。

Pattern recognition tip: after Phase 1b, sort your 2-cubes by dash position. Cubes with different dash positions are guaranteed not to combine, so you only need to check pairs within each dash-position group. This is what makes Q-M's tabular approach efficient compared to brute-force pairwise checks.

パターンを見抜くこつ:フェーズ 1b が終わったら、2-cube をダッシュの位置で並べ替える。ダッシュの位置が違う cube は絶対に併合できないので、同じダッシュ位置のグループ内だけで対を調べればよい。Q-M の表形式が総当たりの対比較より効率的なのは、これが理由である。

階段 2 — 建立質蘊涵項圖表並挑出必要項Phase 2 — build the prime-implicant chart and pick essentialsフェーズ 2 — 主項チャートを作り、必須主項を選ぶ

列 = 質蘊涵項,行 = 原始最小項。✓ 標示該質蘊涵項涵蓋了該最小項。

Rows = prime implicants, columns = original minterms. ✓ marks where the prime covers that minterm.

行 = 主項、列 = もとの最小項。✓ はその主項がその最小項を覆うことを示す。

質蘊涵項Prime主項Term$m_0$$m_1$$m_3$$m_7$
$P_1$$00{-}$ = $\overline{A}\,\overline{B}$
$P_2$$0{-}1$ = $\overline{A}\,C$
$P_3$$-11$ = $B\,C$

$m_0$ 只有一個 ✓(在 $P_1$)→ $P_1$ 是必要質蘊涵項
$m_7$ 只有一個 ✓(在 $P_3$)→ $P_3$ 是必要質蘊涵項
選了 $P_1, P_3$ 之後:$m_0, m_1, m_3, m_7$ 全被涵蓋,$P_2$ 就成了多餘。

$m_0$ has only one ✓ (in $P_1$) → $P_1$ is essential.
$m_7$ has only one ✓ (in $P_3$) → $P_3$ is essential.
After picking $P_1, P_3$: $m_0, m_1, m_3, m_7$ all covered. $P_2$ is redundant.

$m_0$ の ✓ は 1 つだけ($P_1$)→ $P_1$ は必須主項
$m_7$ の ✓ も 1 つだけ($P_3$)→ $P_3$ は必須主項
$P_1, P_3$ を選べば $m_0, m_1, m_3, m_7$ がすべて覆われ、$P_2$ は不要になる。

Result

The minimum-cost SOP is:

$$f = \overline{A}\,\overline{B} + B\,C$$

2 個乘積項、共 4 個 literal,再加一個 2 輸入 OR。Q-M 保證這在所有 SOP 實現中是最佳的。

2 product terms, 4 literals total + one 2-input OR. Q-M guarantees this is optimal among SOP realizations.

積項 2 個、literal は合計 4 個、それに 2 入力 OR が 1 個。Q-M は、これが SOP による実現の中で最適であることを保証する。

Q-M 為何能擴展:卡諾圖需要 $2^n$ 格(5 變數 32 格、6 變數 64 格)。Q-M 的表格大小則以實際存在的最小項數為上限 — 通常遠小於 $2^n$。Q-M 也自然延伸到 don't-care(階段 1 把它們當成最小項,階段 2 再把它們排除在必須涵蓋的範圍外),以及多輸出最小化。CAD 工具內部使用 Q-M 的雜湊/位元遮罩變體(或其後繼者 Espresso)。

Why Q-M scales: a K-map needs $2^n$ cells (32 for 5 vars, 64 for 6). Q-M's table size is bounded by the number of actual minterms — typically far smaller than $2^n$. Q-M also generalizes naturally to don't-cares (treat them as minterms during Phase 1, then exclude them from the cover requirement in Phase 2) and to multi-output minimization. CAD tools use a hashed/bitmask variant of Q-M (or its successor Espresso) under the hood.

Q-M がスケールする理由:カルノー図には $2^n$ マスが要る(5 変数で 32、6 変数で 64)。Q-M の表の大きさは実際に存在する最小項の個数で抑えられ、ふつう $2^n$ よりはるかに小さい。Q-M は don't-care にも自然に拡張でき(フェーズ 1 では最小項として扱い、フェーズ 2 で被覆の要求から外す)、多出力の最小化にも対応する。CAD ツールは内部で Q-M のハッシュ/ビットマスク版(あるいはその後継の Espresso)を使っている。

多層合成 因式分解 函數分解 立方體表示法 BDD Quine-McCluskey 技術對映
Multilevel Synthesis Factoring Functional Decomposition Cubical Representation BDDs Quine-McCluskey Technology Mapping
多段合成 因数分解 関数分解 キューブ表現 BDD Quine-McCluskey テクノロジマッピング
8.1中等Medium普通第一階Tier 1ティア 1?R
請把運算式 f = x₁x₃ + x₁x₄ + x₂x₃ + x₂x₄ 因式分解,以得到多層實作。相較於 SOP 形式節省了多少成本?
Factor the expression f = x₁x₃ + x₁x₄ + x₂x₃ + x₂x₄ to produce a multilevel implementation. What is the cost saving over the SOP form?
f = x₁x₃ + x₁x₄ + x₂x₃ + x₂x₄ を因数分解して多段の実装を得よ。SOP 形式と比べてコストはどれだけ削減されるか。
8.3中等Medium普通第一階Tier 1ティア 1?R
請以 Quine-McCluskey 法找出 f(x₁,x₂,x₃,x₄) = Σm(0,1,2,5,6,7,8,9,14) 的所有質蘊涵項。
Use the Quine-McCluskey method to find all prime implicants of f(x₁,x₂,x₃,x₄) = Σm(0,1,2,5,6,7,8,9,14).
Quine-McCluskey 法を用いて f(x₁,x₂,x₃,x₄) = Σm(0,1,2,5,6,7,8,9,14) のすべての主項を求めよ。
8.4中等Medium普通第一階Tier 1ティア 1?R
Construct a BDD (Binary Decision Diagram) for the function f = x₁x₂ + x̄₁x₃ with variable ordering x₁ < x₂ < x₃.
BDD (Binary Decision Diagram) — 從 Shannon 展開建出決策圖BDD (Binary Decision Diagram) — building a decision graph from Shannon expansionBDD (Binary Decision Diagram) — Shannon 展開から決定グラフを組み立てる

定義。BDD 是一個有向無環圖 (DAG):每個非終端節點測試一個變數,有兩條出邊 (0-邊1-邊),葉節點是常數 $0$ 或 $1$。給輸入向量,從根節點依各變數值沿邊走,落到的葉即為 $f$ 的值。它本質上就是 Shannon 展開遞迴展開後的圖形化呈現。

Definition. A BDD is a directed acyclic graph (DAG): every non-terminal node tests one variable and has two outgoing edges (a 0-edge and a 1-edge), and the leaves are the constants $0$ and $1$. Given an input vector, follow the edges from the root according to each variable's value; the leaf you land on is the value of $f$. It is essentially a graphical rendering of a fully expanded Shannon recursion.

定義。BDD は有向非巡回グラフ (DAG) である:非終端ノードはそれぞれ 1 つの変数を判定し、出辺を 2 本(0-辺1-辺)もつ。葉は定数 $0$ または $1$ である。入力ベクトルが与えられたら、各変数の値に従って根から辺をたどり、行き着いた葉が $f$ の値になる。要するに Shannon 展開の再帰を完全に展開したものの図的表現である。

建構步驟 (給定變數順序 $x_1 < x_2 < \cdots < x_n$):Construction steps (for a given variable order $x_1 < x_2 < \cdots < x_n$):構成手順(変数順序 $x_1 < x_2 < \cdots < x_n$ が与えられたとき):

  1. 從根開始,對 $x_1$ 做 Shannon 展開 → 取得 $f_0 = f|_{x_1=0}$ 與 $f_1 = f|_{x_1=1}$。
  2. Starting at the root, apply Shannon expansion on $x_1$ → obtain $f_0 = f|_{x_1=0}$ and $f_1 = f|_{x_1=1}$.
  3. 根から始めて $x_1$ について Shannon 展開する → $f_0 = f|_{x_1=0}$ と $f_1 = f|_{x_1=1}$ が得られる。
  4. 各子節點再對 $x_2$ 展開,依序往下,直到所有路徑都走到常數 $0$ 或 $1$ — 此時得到完整二元決策樹,葉子數 $= 2^n$。
  5. Expand each child on $x_2$, and so on down the order, until every path reaches the constant $0$ or $1$ — giving the complete binary decision tree with $2^n$ leaves.
  6. 各子ノードを $x_2$ について展開し、順序に沿って下へ進む。すべての経路が定数 $0$ または $1$ に到達すれば、葉が $2^n$ 個の完全な二分決定木ができる。
  7. 化簡為 ROBDD (Reduced Ordered BDD): 套兩條規則直到收斂 — (a) 移除冗餘節點:若某節點的 0-子和 1-子指向同一目標,刪除此節點,父邊直接接到該目標;(b) 合併同形子圖:若兩節點測試同一變數且兩條子邊指向相同目標,合併成同一個節點。
  8. Reduce to an ROBDD (Reduced Ordered BDD): apply two rules until convergence — (a) remove redundant nodes: if a node's 0-child and 1-child point to the same target, delete the node and connect its parent edge straight to that target; (b) merge isomorphic subgraphs: if two nodes test the same variable and both of their child edges point to the same targets, merge them into one node.
  9. ROBDD (Reduced Ordered BDD) への簡約:収束するまで 2 つの規則を適用する — (a) 冗長ノードの除去:あるノードの 0-子と 1-子が同じ先を指しているなら、そのノードを削除して親の辺をその先へ直結する。(b) 同形部分グラフの併合:2 つのノードが同じ変数を判定し、2 本の子辺の行き先も同じなら、1 つのノードに併合する。

本題範例。 $f(x_1, x_2, x_3) = x_1 x_2 + \overline{x_1}\,x_3$,變數順序 $x_1, x_2, x_3$。

Worked example. $f(x_1, x_2, x_3) = x_1 x_2 + \overline{x_1}\,x_3$, with variable order $x_1, x_2, x_3$.

本問の例。$f(x_1, x_2, x_3) = x_1 x_2 + \overline{x_1}\,x_3$、変数順序は $x_1, x_2, x_3$。

對 $x_1$ 展開:

Expanding on $x_1$:

$x_1$ について展開する:

  • $f|_{x_1=0} = (0)\cdot x_2 + (1)\cdot x_3 = x_3$ — 此分支只剩 $x_3$ 在判斷。
  • $f|_{x_1=0} = (0)\cdot x_2 + (1)\cdot x_3 = x_3$ — only $x_3$ is still being tested on this branch.
  • $f|_{x_1=0} = (0)\cdot x_2 + (1)\cdot x_3 = x_3$ — この枝では $x_3$ しか判定に残らない。
  • $f|_{x_1=1} = (1)\cdot x_2 + (0)\cdot x_3 = x_2$ — 此分支只剩 $x_2$ 在判斷。
  • $f|_{x_1=1} = (1)\cdot x_2 + (0)\cdot x_3 = x_2$ — only $x_2$ is still being tested on this branch.
  • $f|_{x_1=1} = (1)\cdot x_2 + (0)\cdot x_3 = x_2$ — この枝では $x_2$ しか判定に残らない。

未化簡的二元決策樹會有 $2^3 = 8$ 個葉子;但化簡後,因為 $x_1=0$ 分支跟 $x_2$ 無關 (走任一 $x_2$ 邊都到同一個 $x_3$ 子節點),套規則 (a) 把那層 $x_2$ 節點消除;同理 $x_1=1$ 分支跟 $x_3$ 無關,把那層 $x_3$ 節點消除。再套規則 (b) 將底層的 $0$ 葉與 $1$ 葉各自合成一個共用葉子。最終 ROBDD 只有 $4$ 個節點:

The unreduced binary decision tree would have $2^3 = 8$ leaves; after reduction, because the $x_1=0$ branch is independent of $x_2$ (either $x_2$ edge leads to the same $x_3$ child), rule (a) eliminates that layer of $x_2$ nodes. Likewise the $x_1=1$ branch is independent of $x_3$, so that layer of $x_3$ nodes goes too. Rule (b) then merges the bottom $0$ leaves into one and the $1$ leaves into one. The final ROBDD has just $4$ nodes:

簡約前の二分決定木には葉が $2^3 = 8$ 個ある。しかし簡約すると、$x_1=0$ の枝は $x_2$ に依存しない(どちらの $x_2$ 辺も同じ $x_3$ 子ノードに至る)ので規則 (a) がその段の $x_2$ ノードを消す。同様に $x_1=1$ の枝は $x_3$ に依存しないので、その段の $x_3$ ノードも消える。続いて規則 (b) が最下段の $0$ 葉どうし、$1$ 葉どうしを 1 つずつに併合する。最終的な ROBDD はわずか $4$ ノードである:

x₁ x₃ x₂ 0 1 0 1 0 1 0 1 虛線 = 0 邊 (low),實線 = 1 邊 (high)dashed = 0-edge (low), solid = 1-edge (high)破線 = 0-辺 (low)、実線 = 1-辺 (high)

讀法驗證:Reading it back:読み方の確認:

  • $x_1=0, x_3=0$ → 走左邊 $x_3=0$ 邊到葉 $0$;$f = (0)(x_2) + (1)(0) = 0$ ✓
  • $x_1=0, x_3=0$ → take the left branch's $x_3=0$ edge to leaf $0$; $f = (0)(x_2) + (1)(0) = 0$ ✓
  • $x_1=0, x_3=0$ → 左の枝の $x_3=0$ 辺をたどって葉 $0$ へ。$f = (0)(x_2) + (1)(0) = 0$ ✓
  • $x_1=0, x_3=1$ → 走左邊 $x_3=1$ 邊到葉 $1$;$f = 1$ ✓
  • $x_1=0, x_3=1$ → take the left branch's $x_3=1$ edge to leaf $1$; $f = 1$ ✓
  • $x_1=0, x_3=1$ → 左の枝の $x_3=1$ 辺をたどって葉 $1$ へ。$f = 1$ ✓
  • $x_1=1, x_2=0$ → 走右邊 $x_2=0$ 邊到葉 $0$;$f = 0$ ✓
  • $x_1=1, x_2=0$ → take the right branch's $x_2=0$ edge to leaf $0$; $f = 0$ ✓
  • $x_1=1, x_2=0$ → 右の枝の $x_2=0$ 辺をたどって葉 $0$ へ。$f = 0$ ✓
  • $x_1=1, x_2=1$ → 走右邊 $x_2=1$ 邊到葉 $1$;$f = 1$ ✓
  • $x_1=1, x_2=1$ → take the right branch's $x_2=1$ edge to leaf $1$; $f = 1$ ✓
  • $x_1=1, x_2=1$ → 右の枝の $x_2=1$ 辺をたどって葉 $1$ へ。$f = 1$ ✓

為何重要:Why it matters:なぜ重要か:

  • 標準形式 (canonicity): 給定相同變數順序,兩個函數相等 $\iff$ 它們的 ROBDD 結構相同 — 等價檢查只需比結構。
  • Canonicity: for a fixed variable order, two functions are equal $\iff$ their ROBDDs are structurally identical — equivalence checking reduces to comparing structure.
  • 標準形性 (canonicity):変数順序を固定すれば、2 つの関数が等しい $\iff$ その ROBDD が構造的に一致する — 等価性検査は構造の比較に帰着する。
  • 大小視變數順序而定: 同一函數在不同變數順序下,ROBDD 大小可從 $O(n)$ 一路膨脹到 $O(2^n)$ (例如乘法器在最壞順序下指數爆炸)。實務上要找好的順序。
  • Size depends on variable order: for the same function the ROBDD can range from $O(n)$ to $O(2^n)$ depending on the order (multipliers, for instance, blow up exponentially under the worst order). In practice finding a good order matters.
  • 大きさは変数順序に左右される:同じ関数でも順序によって ROBDD の大きさは $O(n)$ から $O(2^n)$ まで変わり得る(たとえば乗算器は最悪順序で指数的に爆発する)。実務では良い順序を見つけることが重要になる。
  • 應用: 形式驗證 (equivalence checking、model checking)、SAT 預處理、自動化測試樣本產生 (ATPG)、邏輯合成中的函數表示。
  • Applications: formal verification (equivalence checking, model checking), SAT preprocessing, automatic test-pattern generation (ATPG), and function representation in logic synthesis.
  • 応用:形式検証(等価性検査、モデル検査)、SAT の前処理、自動テストパターン生成 (ATPG)、論理合成における関数表現。

跟 MUX 樹的關係: ROBDD 與 Shannon-expansion 的 MUX 樹是同一個東西的兩種畫法 — BDD 節點 $\equiv$ 2-to-1 MUX,$0$ 邊 $\equiv$ MUX 的 $D_0$,$1$ 邊 $\equiv$ MUX 的 $D_1$,變數本身為 select。化簡規則對應 MUX 樹中「兩個資料輸入相同 → 拿掉這顆 MUX」與「兩棵子樹同形 → 共用一份硬體」。

Relation to the MUX tree: an ROBDD and a Shannon-expansion MUX tree are two drawings of the same thing — a BDD node $\equiv$ a 2-to-1 MUX, the $0$ edge $\equiv$ the MUX's $D_0$, the $1$ edge $\equiv$ its $D_1$, and the variable itself is the select. The reduction rules correspond to “both data inputs identical → delete this MUX” and “two isomorphic subtrees → share one copy of the hardware”.

MUX ツリーとの関係:ROBDD と Shannon 展開による MUX ツリーは同じものの 2 通りの描き方である — BDD のノード $\equiv$ 2-to-1 MUX、$0$ 辺 $\equiv$ MUX の $D_0$、$1$ 辺 $\equiv$ その $D_1$、変数そのものが select である。簡約規則は MUX ツリーにおける「2 つのデータ入力が同じ → この MUX を取り除く」と「2 つの部分木が同形 → ハードウェアを 1 つ共有する」に対応する。

8.7簡單Easy易しい第一階Tier 1ティア 1?R
兩層與多層邏輯實作有什麼差異?請說明兩者各自的優缺點。
What is the difference between a two-level and a multilevel logic implementation? Give the advantages and disadvantages of each.
2 レベルと多段の論理実装の違いは何か。それぞれの長所と短所を挙げよ。
8.12困難Hard難しい第一階Tier 1ティア 1?R
Use functional decomposition to find an efficient implementation of f(x₁,...,x₅) = Σm(1,2,7,9,10,18,19,25,31) + D(0,15,20,26). Compare with the best SOP.
Functional Decomposition — 函數分解的概念與步驟Functional Decomposition — the idea and the procedureFunctional Decomposition — 関数分解の考え方と手順

定義。函數分解 (functional decomposition) 是把一個 $n$ 變數函數寫成「先算一個小子函數,再把它的結果跟其它變數一起餵到外層函數」的形式:

Definition. Functional decomposition rewrites an $n$-variable function as “compute a small subfunction first, then feed its result together with the remaining variables into an outer function”:

定義。関数分解 (functional decomposition) とは、$n$ 変数の関数を「まず小さな部分関数を計算し、その結果を残りの変数と一緒に外側の関数へ渡す」形に書き換えることである:

$f(x_1, \ldots, x_n) \;=\; g\bigl(h(x_1, \ldots, x_k),\; x_{k+1}, \ldots, x_n\bigr)$

$h$ 叫做子函數(subfunction),$\{x_1, \ldots, x_k\}$ 是bound set,剩下的 $\{x_{k+1}, \ldots, x_n\}$ 是free set。若 $h$ 只需要少數位元就能表達(例如 1 bit),就把 $k$ 個變數壓縮成 $\lceil \log_2 r \rceil$ 個訊號接到 $g$,大幅縮減外層函數的規模。

$h$ is the subfunction, $\{x_1, \ldots, x_k\}$ is the bound set and the remainder $\{x_{k+1}, \ldots, x_n\}$ is the free set. If $h$ needs only a few bits to express (one bit, say), the $k$ variables collapse into $\lceil \log_2 r \rceil$ signals feeding $g$, sharply reducing the size of the outer function.

$h$ を部分関数 (subfunction) と呼び、$\{x_1, \ldots, x_k\}$ が bound set、残りの $\{x_{k+1}, \ldots, x_n\}$ が free set である。$h$ が少ないビット数(たとえば 1 ビット)で表せるなら、$k$ 個の変数は $\lceil \log_2 r \rceil$ 本の信号に圧縮されて $g$ に入り、外側の関数の規模が大幅に縮む。

核心觀察 — K-map 的「行 = 子函數」。 把 K-map 用 bound 變數標欄、free 變數標列。掃過所有 bound 變數的組合 (共 $2^k$ 欄),看每一欄在 free 變數下呈現的 0/1 樣式 (column pattern)。如果這 $2^k$ 欄只出現 $r$ 種不同樣式,那麼:

The key observation — “a K-map column is the subfunction”. Label the K-map columns with the bound variables and the rows with the free variables. Sweep across all $2^k$ bound-variable combinations and look at the 0/1 column pattern each one produces over the free variables. If those $2^k$ columns show only $r$ distinct patterns, then:

肝心な着眼点 — 「K-map の列が部分関数」。K-map の列に bound 変数、行に free 変数を割り当てる。$2^k$ 通りの bound 変数の組合せを順に見ていき、各列が free 変数上に描く 0/1 のパターン (column pattern) を調べる。この $2^k$ 列に $r$ 種類のパターンしか現れないなら、次のようにできる:

  • 把每種樣式編碼成 $\lceil \log_2 r \rceil$ 個訊號 — 這就是 $h$ 的輸出。
  • Encode each distinct pattern in $\lceil \log_2 r \rceil$ signals — that is the output of $h$.
  • 各パターンを $\lceil \log_2 r \rceil$ 本の信号に符号化する — それが $h$ の出力である。
  • 外層 $g$ 接收 $h$ 的輸出 + free 變數,輸出 $f$。
  • The outer function $g$ takes $h$'s output plus the free variables and produces $f$.
  • 外側の $g$ は $h$ の出力と free 変数を受け取り、$f$ を出力する。
  • 常見好結果:$r = 2$ → $h$ 只需要 1 bit,整個 $f$ 可拆成「一個小 $h$ + 一個小 $g$」的兩層電路。
  • A common good outcome: $r = 2$ → $h$ needs just 1 bit, and the whole of $f$ splits into a two-level circuit of “a small $h$ plus a small $g$”.
  • よくある良い結果:$r = 2$ → $h$ は 1 ビットで済み、$f$ 全体が「小さな $h$ + 小さな $g$」という 2 段の回路に分かれる。

步驟:Procedure:手順:

  1. 選 bound / free 切法。 通常從 $k = 2$ 開始嘗試 (4 欄最容易看出重複)。多試幾種變數分組,挑使 $r$ 最小的那種。
  2. Choose the bound/free split. Usually start with $k = 2$ (four columns make repetition easiest to spot). Try several groupings and keep the one that minimises $r$.
  3. bound / free の分け方を選ぶ。ふつうは $k = 2$ から試す(4 列なら繰り返しが見つけやすい)。何通りかの変数分けを試し、$r$ が最小になるものを採る。
  4. 列出 column patterns。 對每個 bound 變數組合,記下對應的 free 變數樣式 (可寫成 minterm 集合或 0/1 字串)。
  5. List the column patterns. For each bound-variable combination, record the corresponding free-variable pattern (as a minterm set or a 0/1 string).
  6. column pattern を列挙する。bound 変数の各組合せについて、対応する free 変数側のパターンを(minterm の集合か 0/1 の文字列として)書き出す。
  7. 合併相同樣式。 唯一樣式數 $r$ 決定編碼寬度。寫下 $h$ 的真值表 (bound 變數 → $r$ 中哪一種樣式)。
  8. Merge identical patterns. The number of distinct patterns $r$ sets the encoding width. Write down the truth table of $h$ (bound variables → which of the $r$ patterns).
  9. 同じパターンを併合する。相異なるパターンの数 $r$ が符号化の幅を決める。$h$ の真理値表(bound 変数 → $r$ 種のどのパターンか)を書き下す。
  10. 建構 $g$。 用 $r$ 個編碼訊號加上 free 變數重建 $f$,通常透過 K-map 化簡 $g$ 即可。
  11. Construct $g$. Rebuild $f$ from the $r$ encoded signals plus the free variables, usually by simplifying $g$ on a K-map.
  12. $g$ を構成する。$r$ 個の符号化信号と free 変数から $f$ を組み直す。ふつうは K-map で $g$ を簡単化すればよい。
  13. 核算成本。 計算 $h$ 與 $g$ 各自的 gate-input 數,加總後與最佳 SOP 比較;若有 don't-care 條件,先把它們自由分派以降低成本。
  14. Cost it. Count the gate inputs of $h$ and $g$ separately, add them up and compare against the best SOP; if there are don't-care conditions, assign them freely first to lower the cost.
  15. コストを見積もる。$h$ と $g$ それぞれのゲート入力数を数えて合計し、最良の SOP と比べる。don't-care 条件があるなら、まずそれを自由に割り当ててコストを下げる。

小例子。 $f(x_1, x_2, x_3, x_4) = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\,\overline{x_3} x_4$。以 $\{x_3, x_4\}$ 為 bound 變數:

Small example. $f(x_1, x_2, x_3, x_4) = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\,\overline{x_3} x_4$. Taking $\{x_3, x_4\}$ as the bound variables:

小さな例。$f(x_1, x_2, x_3, x_4) = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\,\overline{x_3} x_4$。$\{x_3, x_4\}$ を bound 変数に取る:

$x_3 x_4$值 (在 $x_1, x_2$ 下)Value (over $x_1, x_2$)値($x_1, x_2$ 上)欄樣式column pattern列パターン
000α (恆 0)α (constant 0)α(恒等的に 0)
01$\overline{x_2}$ 或 $x_1$$\overline{x_2}$ or $x_1$$\overline{x_2}$ または $x_1$β
10$\overline{x_2}$ 或 $x_1$$\overline{x_2}$ or $x_1$$\overline{x_2}$ または $x_1$β
110α (恆 0)α (constant 0)α(恒等的に 0)

只有 $r = 2$ 種 pattern,正好 $h(x_3, x_4) = x_3 \oplus x_4$ (二者中間相異 → β,二者相同 → α)。再用 $h$ + free 變數重建:$f = h \cdot (x_1 + \overline{x_2})$ — 兩個 XOR + 一個 AND,遠優於原 SOP 的四個 3-input AND + 一個 4-input OR。

There are only $r = 2$ patterns, and indeed $h(x_3, x_4) = x_3 \oplus x_4$ (the two differ → β, the two agree → α). Rebuilding from $h$ plus the free variables: $f = h \cdot (x_1 + \overline{x_2})$ — two XORs and one AND, far better than the original SOP's four 3-input ANDs and one 4-input OR.

パターンは $r = 2$ 種類しかなく、実際 $h(x_3, x_4) = x_3 \oplus x_4$ である(両者が異なれば β、一致すれば α)。$h$ と free 変数から組み直すと $f = h \cdot (x_1 + \overline{x_2})$ — XOR 2 個と AND 1 個であり、もとの SOP の 3 入力 AND 4 個 + 4 入力 OR 1 個よりはるかに良い。

本題 (8.12) 提示: $f$ 是 5 變數函數 (29 個 minterm + don't-care 4 個);bound set 可試 $\{x_4, x_5\}$ 或 $\{x_1, x_2\}$。先把 $f$ 畫成兩張 4×4 K-map (或一張 32 格的 5 變數 K-map),按 bound 變數分欄並比對 column pattern。把 don't-care 自由指派以最大化重複欄,目標是讓不同 column pattern 數量降到 2 (理想) 或 3 (次佳)。最後與最佳 SOP 的 gate-input 總數比較。

Hint for this problem (8.12): $f$ is a 5-variable function (29 minterms plus 4 don't-cares); try $\{x_4, x_5\}$ or $\{x_1, x_2\}$ as the bound set. Draw $f$ as two 4×4 K-maps (or one 32-cell 5-variable K-map), split the columns by the bound variables and compare the column patterns. Assign the don't-cares freely to maximise repeated columns, aiming to reduce the number of distinct column patterns to 2 (ideal) or 3 (next best). Finally compare the total gate-input count against the best SOP.

本問 (8.12) のヒント:$f$ は 5 変数関数(minterm 29 個 + don't-care 4 個)で、bound set は $\{x_4, x_5\}$ か $\{x_1, x_2\}$ を試すとよい。まず $f$ を 4×4 の K-map 2 枚(あるいは 32 マスの 5 変数 K-map 1 枚)に描き、bound 変数で列を分けて column pattern を突き合わせる。don't-care は重複する列が最大になるよう自由に割り当て、相異なる column pattern の数を 2(理想)か 3(次善)まで減らすことを狙う。最後に最良の SOP とゲート入力総数を比較する。

為何重要 — 跟其它技術的關係:Why it matters — how it relates to other techniques:なぜ重要か — 他の技法との関係:

  • FPGA 技術對映: $k$-LUT 只能放下不超過 $k$ 變數的子函數 — 函數分解就是把大函數切成 LUT 容得下的小塊。
  • FPGA technology mapping: a $k$-LUT holds a subfunction of at most $k$ variables — functional decomposition is exactly how a large function is cut into LUT-sized pieces.
  • FPGA のテクノロジマッピング:$k$-LUT には高々 $k$ 変数の部分関数しか入らない — 関数分解こそが、大きな関数を LUT に収まる断片へ切り分ける方法そのものである。
  • 多輸出共享: 同一 $h$ 可被多個輸出函數共用 (8.13、8.15 即此類),整體成本進一步下降。
  • Multi-output sharing: one $h$ can be shared by several output functions (8.13 and 8.15 are of this kind), lowering the overall cost further.
  • 多出力での共有:1 つの $h$ を複数の出力関数で共有できる(8.13 や 8.15 がその類である)ため、全体のコストがさらに下がる。
  • BDD 觀點: 函數分解等價於在 BDD 找「同形子圖」並把它拉出來當共用節點。
  • BDD viewpoint: functional decomposition is equivalent to finding an isomorphic subgraph in a BDD and pulling it out as a shared node.
  • BDD から見ると:関数分解は、BDD の中に同形部分グラフを見つけ、それを共有ノードとして括り出すことと等価である。

Cofactor 公式角度: 對 bound 變數做 Shannon 展開可得 $f = \sum_{i=0}^{2^k-1} m_i(\text{bound}) \cdot f_{i}(\text{free})$,其中 $f_i$ 是 cofactor。若多個 cofactor 相同,就把它們合併為同一個 $h$ 輸出值;這正是函數分解的代數版本。

From the cofactor formula: a Shannon expansion on the bound variables gives $f = \sum_{i=0}^{2^k-1} m_i(\text{bound}) \cdot f_{i}(\text{free})$, where the $f_i$ are cofactors. When several cofactors coincide they merge into the same $h$ output value — the algebraic version of functional decomposition.

Cofactor の式から見ると:bound 変数について Shannon 展開すると $f = \sum_{i=0}^{2^k-1} m_i(\text{bound}) \cdot f_{i}(\text{free})$ となり、$f_i$ が cofactor である。複数の cofactor が一致すれば、それらは同じ $h$ の出力値へ併合される — これが関数分解の代数的な言い換えである。

8.31困難Hard難しい第一階Tier 1ティア 1E?R
請用 3 輸入查表 (3-LUT) 實作 4 變數函數 $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + x_1 x_2 x_3$。說明直接對映需要四個 3-LUT,並找出只用三個 3-LUT 的更巧妙分解。
Implement the 4-variable function $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + x_1 x_2 x_3$ using 3-input lookup tables (3-LUTs). Show that a straightforward mapping needs four 3-LUTs and find a smarter decomposition that uses only three 3-LUTs.
3 入力ルックアップテーブル (3-LUT) を用いて 4 変数関数 $f = x_1 x_2 \overline{x_4} + \overline{x_2} x_3 x_4 + x_1 x_2 x_3$ を実装せよ。素直にマッピングすると 3-LUT が 4 個必要になることを示し、3 個で済むより巧みな分解を求めよ。
09 非同步循序電路Asynchronous Sequential Circuits非同期順序回路

本章討論不需時脈訊號即可運作的循序電路 — 狀態改變由輸入變化直接觸發,而非由時脈邊緣引發。首先介紹基本操作模式:一次只能有一個輸入改變,且電路必須在下一次變化前抵達穩定狀態。分析使用流程表(狀態表的非同步對應物),含穩定與不穩定狀態。合成依循固定程序:原始流程表 → 合併流程表 → 狀態指派 → 下一狀態與輸出方程式。本章介紹非同步電路的狀態縮減技巧,並處理臨界競爭與狀態指派問題,包括作為無競爭替代方案的 one-hot 編碼。冒險也被徹底討論:靜態冒險(1 冒險與 0 冒險)、動態冒險,以及如何以冗餘項消除它們。最後以一個完整的販賣機控制器範例串起所有概念。

This chapter covers sequential circuits that operate without a clock signal — changes in state are triggered directly by input changes rather than clock edges. The fundamental mode of operation is introduced, where only one input may change at a time and the circuit must reach a stable state before the next change. Analysis involves flow tables (the asynchronous equivalent of state tables) with stable and unstable states. Synthesis follows a procedure: primitive flow table → merged flow table → state assignment → next-state and output equations. State reduction techniques for asynchronous circuits are presented. Critical races and state assignment problems are addressed, including one-hot encoding as a race-free alternative. The chapter thoroughly covers hazards: static hazards (1-hazards and 0-hazards), dynamic hazards, and their elimination through redundant terms. A complete vending machine controller example ties all concepts together.

本章では、クロック信号なしで動作する順序回路を扱う — 状態の変化はクロックエッジではなく入力の変化によって直接引き起こされる。まず基本モードを導入する:一度に変化してよい入力は 1 つだけで、回路は次の変化までに安定状態へ到達していなければならない。解析にはフロー表(状態表の非同期版)を用い、安定状態と不安定状態を扱う。合成は決まった手順に従う:原始フロー表 → 併合フロー表 → 状態割当て → 次状態方程式と出力方程式。非同期回路の状態縮小の手法も紹介する。臨界競合と状態割当ての問題も取り上げ、競合のない代替として one-hot 符号化を扱う。ハザードも徹底的に論じる:静的ハザード(1 ハザードと 0 ハザード)、動的ハザード、そして冗長項によるその除去である。最後に、完全な自動販売機コントローラの例がすべての概念を結びつける。

本章介紹不依靠時脈訊號運作的非同步循序電路 (asynchronous sequential circuit)——狀態的改變由輸入訊號直接觸發,而不是由時脈邊緣引發。首先介紹基本模式 (fundamental mode):每次只允許一個輸入改變,且電路必須在下一次輸入變化前先抵達穩定狀態。分析以流程表 (flow table)進行——它是狀態表 (state table) 的非同步對應物,含有穩定狀態與不穩定狀態。合成則依循固定流程:原始流程表 → 合併流程表 → 狀態指派 → 推導下一狀態與輸出方程式。本章亦說明非同步電路的狀態縮減技巧。臨界競爭 (critical race) 與狀態指派問題也被詳細討論,並介紹 one-hot 編碼作為避免競爭的替代方案。書中徹底剖析冒險 (hazards):靜態 1 冒險 (static 1-hazard)、靜態 0 冒險 (static 0-hazard)、動態冒險 (dynamic hazard),以及如何透過添加冗餘項加以消除。最後以一個完整的販賣機控制器範例貫穿所有概念。

This chapter covers asynchronous sequential circuits, which operate without a clock signal — state changes are triggered directly by the input signals rather than by a clock edge. It begins with fundamental mode: only one input may change at a time, and the circuit must reach a stable state before the next input change. Analysis proceeds with a flow table, the asynchronous counterpart of the state table, containing both stable and unstable states. Synthesis follows a fixed sequence: primitive flow table → merged flow table → state assignment → next-state and output equations. State-reduction techniques for asynchronous circuits are also covered. Critical races and the state-assignment problem are discussed in detail, with one-hot encoding presented as a race-free alternative. Hazards are dissected thoroughly: static 1-hazards, static 0-hazards and dynamic hazards, and how to remove them by adding redundant terms. A complete vending-machine controller example ties all the concepts together.

本章では、クロック信号によらずに動作する非同期順序回路 (asynchronous sequential circuit) を扱う——状態の変化はクロックエッジではなく、入力信号によって直接引き起こされる。まず基本モード (fundamental mode) を導入する:一度に変化してよい入力は 1 つだけで、回路は次の入力変化までに安定状態へ到達していなければならない。解析にはフロー表 (flow table) を用いる。これは状態表の非同期版であり、安定状態と不安定状態の両方を含む。合成は決まった順序で進む:原始フロー表 → 併合フロー表 → 状態割当て → 次状態方程式と出力方程式の導出。非同期回路の状態縮小の手法も扱う。臨界競合 (critical race) と状態割当ての問題も詳しく論じ、競合を避ける代替手段として one-hot 符号化を紹介する。ハザードについても徹底的に分解して説明する:静的 1 ハザード、静的 0 ハザード、動的ハザード、そして冗長項を加えて取り除く方法である。最後に、完全な自動販売機コントローラの例がすべての概念を結びつける。

基本模式 流程表 穩定/不穩定狀態 競爭 & 狀態指派 靜態/動態冒險 無冒險設計 one-hot 編碼 販賣機範例
Fundamental Mode Flow Tables Stable / Unstable States Races & State Assignment Static / Dynamic Hazards Hazard-Free Design One-Hot Encoding Vending Machine Example
基本モード フロー表 安定/不安定状態 競合 & 状態割当て 静的/動的ハザード ハザードフリー設計 one-hot 符号化 自動販売機の例
9.1簡單Easy易しい第一階Tier 1ティア 1?R
請定義非同步電路的基本模式 (fundamental mode) 操作。它對輸入施加了哪些限制?
Define the fundamental mode of operation for asynchronous circuits. What constraints are placed on the inputs?
非同期回路の基本モード動作を定義せよ。入力にはどのような制約が課されるか。
9.4中等Medium普通第一階Tier 1ティア 1?R
請說明什麼是關鍵競爭 (critical race)。舉出一個會造成關鍵競爭的狀態指派例子,並說明如何修正。
Explain what a critical race is. Give an example of a state assignment that causes a critical race and show how to fix it.
危険競合 (critical race) とは何かを説明せよ。危険競合を引き起こす状態割当ての例を挙げ、その直し方を示せ。
9.6簡單Easy易しい第一階Tier 1ティア 1?R
請定義靜態 1 冒險、靜態 0 冒險與動態冒險。在兩層 SOP 電路中,哪一種最常見?
Define static 1-hazard, static 0-hazard, and dynamic hazard. Which one is most common in two-level SOP circuits?
静的 1 ハザード、静的 0 ハザード、動的ハザードを定義せよ。2 レベル SOP 回路で最もよく現れるのはどれか。
9.12中等Medium普通第一階Tier 1ティア 1?R
請設計一個 Muller C 元件:兩個輸入皆為 1 時輸出變為 1,皆為 0 時輸出變為 0,其餘情況維持原狀態。請以非同步設計技巧推導。
Design a Muller C-element: output becomes 1 when both inputs are 1, becomes 0 when both are 0, and holds its state otherwise. Derive using asynchronous design techniques.
Muller の C 素子を設計せよ:両方の入力が 1 のとき出力は 1 になり、両方が 0 のとき 0 になり、それ以外では状態を保持する。非同期設計の手法を用いて導け。
9.20困難Hard難しい第一階Tier 1ティア 1E?R
Reduce a 12-row primitive flow table (Figure 9.32) by first applying the partitioning procedure, then constructing a merger diagram for the resulting flow table, and finally merging compatible rows. Show successive reductions until no further merging is possible.
背景:範例 9.8 — 12 列原始表的完整兩階段縮減Context: Example 9.8 — full two-step reduction of a 12-row primitive table背景:例 9.8 — 12 行の原始表を 2 段階で完全に縮小する

設定。圖 9.32 是一張原始流程表,共 11 列,標記為 $A, B, C, D, E, F, G, H, J, K, L$(跳過字母 $I$ 以免與數字 1 混淆)— 每列一個穩定狀態 — 由輸入 $w_2 w_1$ 驅動。每列的輸出為 0 或 1。

Setup. Figure 9.32 is a primitive flow table with 11 rows labeled $A, B, C, D, E, F, G, H, J, K, L$ (the letter $I$ is skipped to avoid confusion with the digit 1) — one stable state per row — driven by inputs $w_2 w_1$. Outputs are 0 or 1 per row.

設定。図 9.32 は原始フロー表で、$A, B, C, D, E, F, G, H, J, K, L$ とラベル付けされた 11 行からなる(文字 $I$ は数字の 1 と紛らわしいので飛ばしてある)— 各行に安定状態が 1 つ — 入力 $w_2 w_1$ で駆動される。出力は行ごとに 0 か 1 である。

重繪的圖 9.32(粗體 = 該列的穩定狀態,"—" = don't-care):

Reproduced Figure 9.32 (bold = stable state in that row, "—" = don't-care):

図 9.32 の再掲(太字 = その行の安定状態、"—" = don't-care):

狀態State状態$w_2 w_1$=00=01=10=11$z$
AAFC0
BABH1
CGCD0
DFD1
EGED1
FFH0
GGBJ0
HLEH1
JGJ0
KBEK1
LALK1

縮減分成兩個明確的階段:(i) 用分割程序找出可以改名而不影響 don't-care 的等價狀態,接著 (ii) 用合併圖把即使並非嚴格等價、但彼此相容的狀態合併起來。

The reduction proceeds in two distinct stages: (i) partitioning to find equivalent states that can be renamed without affecting don't-cares, then (ii) a merger diagram to combine compatible states even when they aren't strictly equivalent.

縮小ははっきり分かれた 2 段階で進む:(i) don't-care に影響を与えずに名前を付け替えられる等価状態を分割手続きで見つけ、続いて (ii) 厳密には等価でなくとも両立する状態をマージャ図で併合する。

Stage 1 — Partitioning procedure

  1. 初始分割 $P_1$:把輸出相同、且 don't-care 項落在相同欄位的列分成一組。課本找出三組候選等價對:$(A, G)$、$(B, L)$、$(H, K)$。其餘各列彼此相異,因此
  2. Initial partition $P_1$: group rows that have the same output AND their don't-care entries fall in the same columns. The textbook identifies three candidate equivalence pairs: $(A, G)$, $(B, L)$, $(H, K)$. All other rows are distinct, so
  3. 初期分割 $P_1$:出力が同じで、かつ don't-care の欄が同じ列に来る行をまとめる。教科書は等価候補の対を 3 組挙げている:$(A, G)$、$(B, L)$、$(H, K)$。ほかの行はすべて互いに異なるので
$$P_1 = (AG)(BL)(C)(D)(E)(F)(HK)(J)$$
  1. 依後繼狀態細分。對每一組候選對,檢查它們的下一狀態後繼在每個輸入欄位是否都落在 $P_1$ 的同一區塊。$(A, G)$ 的後繼分散到不同區塊 → $A$ 與 $G$ 並不等價 → 拆開。$(B, L)$ 與 $(H, K)$ 的後繼都落在單一區塊 → 保留為等價對。新的分割:
  2. Refine by successors. For each candidate pair, check whether their next-state successors land in the same blocks of $P_1$ for every input column. Successors of $(A, G)$ split across different blocks → $A$ and $G$ are NOT equivalent → split. Successors of $(B, L)$ and $(H, K)$ all stay in single blocks → keep as equivalent pairs. New partition:
  3. 後継で細分する。候補の各対について、次状態の後継がどの入力列でも $P_1$ の同じブロックに落ちるかを調べる。$(A, G)$ の後継は別々のブロックに分かれる → $A$ と $G$ は等価ではない → 分割する。$(B, L)$ と $(H, K)$ の後継はいずれも単一のブロックに収まる → 等価対として残す。新しい分割:
$$P_2 = (A)(G)(BL)(C)(D)(E)(F)(HK)(J)$$
  1. 反覆到穩定。對 $P_2$ 再做一次後繼檢驗得到 $P_3 = P_2$ — 收斂。於是合併 $B \leftarrow B+L$ 與 $H \leftarrow H+K$。結果為 10 列的表(圖 9.33)。
  2. Iterate until stable. Repeating the successor test on $P_2$ yields $P_3 = P_2$ — convergence. So merge $B \leftarrow B+L$ and $H \leftarrow H+K$. Result: 10-row table (Figure 9.33).
  3. 安定するまで反復する。$P_2$ に対して後継の検査をもう一度行うと $P_3 = P_2$ となり収束する。そこで $B \leftarrow B+L$ と $H \leftarrow H+K$ を併合する。結果は 10 行の表(図 9.33)である。

階段 2 — 合併圖(相容性,而非等價性)

Stage 2 — Merger diagram (compatibility, not equivalence)

第 2 段階 — マージャ図(等価性ではなく両立性)

兩列若其已指定的下一狀態項目彼此不衝突,就是相容(可合併)的 — don't-care 可以吸收任何值,而相同穩定狀態的配對永遠一致。建立一張圖,每列是一個頂點,每一組相容配對是一條邊。找出一組團覆蓋(其聯集涵蓋所有列的團集合);每個團就成為合併後的一列。

Two rows are compatible (mergeable) if their specified next-state entries don't conflict — don't-cares can absorb any value, and same-stable-state pairs always agree. Build a graph where each row is a vertex and each compatible pair is an edge. Find a clique cover (a set of cliques whose union is all rows); each clique becomes one merged row.

2 つの行は、指定済みの次状態の項目が食い違わなければ両立する(併合できる)。don't-care はどんな値も吸収でき、同じ安定状態どうしは常に一致する。各行を頂点、両立する対を辺とするグラフを作り、クリーク被覆(和集合が全行を覆うクリークの集合)を求める。各クリークが併合後の 1 行になる。

對圖 9.33 而言,合併圖給出的建議是:

For Figure 9.33 the merger diagram suggests:

図 9.33 については、マージャ図は次を示唆する:

  • $B$ 與 $H$ 可以合併 → 新的一列 $B$($B \cup H$)
  • $B$ and $H$ can merge → new row $B$ ($B \cup H$)
  • $B$ と $H$ は併合できる → 新しい行 $B$($B \cup H$)
  • $D$ 與 $E$ 可以合併 → 新的一列 $D$($D \cup E$)
  • $D$ and $E$ can merge → new row $D$ ($D \cup E$)
  • $D$ と $E$ は併合できる → 新しい行 $D$($D \cup E$)
  • $A$、$F$、$C$、$G$、$J$ 有多種相容組合可選 — 這是典型的試誤步驟
  • $A$, $F$, $C$, $G$, $J$ have multiple compatibility options — typical trial-and-error step
  • $A$、$F$、$C$、$G$、$J$ には両立する組合せが複数あり得る — ここは典型的な試行錯誤の場面である

採用其中一種覆蓋做連續縮減,可得 12 → 10 → 6 → ... 列。最終答案取決於你挑了哪些相容配對的分組(對任意流程表而言這通常是 NP-hard,但小規模的實例仍可處理)。

Successive reductions with one such cover give 12 → 10 → 6 → ... rows. The final answer depends on which compatible-pair groupings you pick (this is generally NP-hard for arbitrary flow tables, but small instances are tractable).

そうした被覆の 1 つを使って段階的に縮小すると、行数は 12 → 10 → 6 → … と減る。最終的な答えは、どの両立対のグループ分けを選んだかに依存する(任意のフロー表に対して一般には NP 困難だが、小規模なら扱える)。

Why two stages?

  • 分割程序找出的是邏輯上等價的狀態。合併它們是「免費」的 — don't-care 原封不動,沒有損失任何彈性。
  • Partitioning finds logically equivalent states. Merging them is "free" — same don't-cares preserved, no flexibility lost.
  • 分割手続きが見つけるのは論理的に等価な状態である。それらの併合は「ただ」である — don't-care はそのまま保たれ、柔軟性を何も失わない。
  • 合併找出的是相容(而非等價)的狀態。合併它們會把 don't-care 固定成某一種取值,犧牲彈性換取更進一步的狀態數縮減。
  • Merger finds compatible (not equivalent) states. Merging them resolves don't-cares one specific way, sacrificing flexibility but reducing state count further.
  • 併合が見つけるのは両立する(等価ではない)状態である。これを併合すると don't-care が特定の値に決まってしまい、柔軟性を犠牲にする代わりに状態数をさらに減らせる。

先做分割程序能為合併階段保留最大的彈性,通常會得到比單獨做合併更少的最終狀態數。

Doing partitioning first preserves maximum flexibility for the merger stage, often producing a smaller final state count than running merger alone.

先に分割手続きを済ませておくと併合段階の柔軟性が最大限に残り、併合だけを行う場合より最終的な状態数が少なくなることが多い。

實務流程:手算時先做分割(結果唯一 — 沒有選擇餘地),再畫合併圖並試幾組團覆蓋。狀態數最少的表,就是團數最少的那組團覆蓋。

Practical workflow: for hand work, start with the partition (deterministic — no choices), then sketch the merger diagram and try a couple of clique covers. The minimum-state table is the merger's clique cover with fewest cliques.

実務的な進め方:手計算ではまず分割から始め(決定的で選択の余地がない)、次にマージャ図を描いてクリーク被覆をいくつか試す。最小状態の表は、クリーク数が最も少ない被覆から得られる。

— example 9.8
9.35困難Hard難しい第一階Tier 1ティア 1E?R
請為 $f(x_1,\ldots,x_5) = \sum m(2,3,14,17,19,25,26,30) + D(10,23,27,31)$ 推導無冒險且成本最低的 SOP 實作。先找出成本最低的質蘊涵項覆蓋,再補上必要的額外質蘊涵項,使卡諾圖中每一對相鄰的 1 都被某個乘積項涵蓋。
Derive a hazard-free minimum-cost SOP implementation for $f(x_1,\ldots,x_5) = \sum m(2,3,14,17,19,25,26,30) + D(10,23,27,31)$. Find the minimum-cost prime-implicant cover, then add any extra prime implicants needed so that every pair of adjacent 1s in the K-map is covered by some product term.
$f(x_1,\ldots,x_5) = \sum m(2,3,14,17,19,25,26,30) + D(10,23,27,31)$ に対して、ハザードフリーで最小コストの SOP 実装を導け。最小コストの主項被覆を求め、そのうえでカルノー図中の隣接する 1 の対がいずれかの積項で覆われるよう、必要な主項を追加せよ。
10 第二階與第三階練習Tier 2 & Tier 3 Practiceティア 2・ティア 3 演習

依章節、再依難度階層編排的補充題目。Additional problems organized by chapter, then by tier.章ごと、さらにティアごとに整理した追加問題です。

第 2 章 — 邏輯電路Chapter 2 — Logic Circuits第 2 章 — 論理回路

第二階 · 中等Tier 2 · Midティア 2 · 中級

2.43困難Hard難しい第二階Tier 2ティア 2?R
請設計一個具有兩個輸出的電路:$f_1 = \sum m(0,2,3,4,5,7)$ 與 $f_2 = \sum m(1,2,3,5,6,7)$(3 變數)。請找出成本最低的共用閘實作。
註 —「共用閘實作」的意思是:設計單一電路同時計算 $f_1$ 與 $f_2$,兩者之間共用相同的閘,並最小化總成本(兩個輸出合計的閘數+輸入總數),而不是建造兩個各自獨立的電路。
Design a circuit with two outputs: $f_1 = \sum m(0,2,3,4,5,7)$ and $f_2 = \sum m(1,2,3,5,6,7)$ (3-variable). Find a minimum-cost shared-gate implementation.
Note — "shared-gate implementation" means: design one circuit that computes both $f_1$ and $f_2$ together, reusing common gates between them, and minimize the total cost (gate count + total input count across both outputs combined) instead of building two independent circuits.
2 つの出力 $f_1 = \sum m(0,2,3,4,5,7)$ と $f_2 = \sum m(1,2,3,5,6,7)$(3 変数)をもつ回路を設計せよ。最小コストのゲート共有実装を求めよ。
注 —「ゲート共有実装」とは、$f_1$ と $f_2$ を一緒に計算する 1 つの回路を設計し、両者で共通のゲートを再利用して、独立な回路を 2 つ作るのではなく総コスト(両出力を合わせたゲート数+入力数の合計)を最小化する、という意味である。
2.44簡單Easy易しい第二階Tier 2ティア 2?R
請用布林代數證明 $x + x \cdot y = x$(吸收定理)。
Using Boolean algebra, prove that $x + x \cdot y = x$ (absorption theorem).
ブール代数を用いて $x + x \cdot y = x$(吸収則)を証明せよ。
2.45簡單Easy易しい第二階Tier 2ティア 2?R
請畫出只使用 NAND 閘、實作函數 $f = a \cdot b + c$ 的邏輯電路。
Draw a logic circuit using only NAND gates that implements the function $f = a \cdot b + c$.
NAND ゲートだけを用いて関数 $f = a \cdot b + c$ を実現する論理回路を描け。
2.46中等Medium普通第二階Tier 2ティア 2?R
請撰寫一個結構化的 Verilog 模組,以閘層級基本元件實作 $f = (a \cdot b) + (\overline{a} \cdot c)$。
Write a structural Verilog module that implements $f = (a \cdot b) + (\overline{a} \cdot c)$ using gate-level primitives.
ゲートレベルのプリミティブを用いて $f = (a \cdot b) + (\overline{a} \cdot c)$ を実現する構造記述の Verilog モジュールを書け。
2.47簡單Easy易しい第二階Tier 2ティア 2?R
用文氏圖驗證 $x \cdot (y + z) = x \cdot y + x \cdot z$(分配律)。
Using a Venn diagram, verify that $x \cdot (y + z) = x \cdot y + x \cdot z$ (distributive law).
ベン図を用いて $x \cdot (y + z) = x \cdot y + x \cdot z$(分配律)が成り立つことを確かめよ。
2.48中等Medium普通第二階Tier 2ティア 2?R
求 $f(a,b,c,d) = \prod M(0,1,4,5,9,11,15)$ 的最小 POS 運算式。
Find the minimum POS expression for $f(a,b,c,d) = \prod M(0,1,4,5,9,11,15)$.
$f(a,b,c,d) = \prod M(0,1,4,5,9,11,15)$ の最小 POS 式を求めよ。
2.49簡單Easy易しい第二階Tier 2ティア 2?R
函數 $f = x_1 x_2 + \overline{x_1}\,x_3 + x_2 x_3$ 的成本(閘的數目 + 閘輸入的數目)是多少?
What is the cost (number of gates + number of gate inputs) of the function $f = x_1 x_2 + \overline{x_1}\,x_3 + x_2 x_3$?
関数 $f = x_1 x_2 + \overline{x_1}\,x_3 + x_2 x_3$ のコスト(ゲート数 + ゲート入力数)はいくらか。
2.50中等Medium普通第二階Tier 2ティア 2?R
分析下列邏輯網路:輸入訊號依如下方式通過各閘 — $g = \overline{a}$、$h = a \cdot b$、$f = g + h$。導出 $f$ 的真值表與化簡後的運算式。
Analyze the logic network: input signals pass through gates as follows — $g = \overline{a}$, $h = a \cdot b$, $f = g + h$. Derive the truth table and the simplified expression for $f$.
次の論理回路網を解析せよ:入力信号は次のようにゲートを通る — $g = \overline{a}$、$h = a \cdot b$、$f = g + h$。$f$ の真理値表と簡単化した式を導け。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

2.51中等Medium普通第三階Tier 3ティア 3?R
說明結構化 (structural) 與行為化 (behavioral) Verilog 描述的差異。針對 XOR 函數各舉一個簡短的例子。
Explain the difference between structural and behavioral Verilog descriptions. Give a short example of each for the XOR function.
構造記述 (structural) と動作記述 (behavioral) の Verilog 記述の違いを説明せよ。XOR 関数について、それぞれの短い例を示せ。
2.52中等Medium普通第三階Tier 3ティア 3?R
寫一個 Verilog 模組,用 assign 敘述實作習題 2.5 的函數。並寫一個簡單的測試平台,施加全部 16 種輸入組合。
Write a Verilog module that implements the function from exercise 2.5 using an assign statement. Write a simple testbench that applies all 16 input combinations.
演習 2.5 の関数を assign 文で実装する Verilog モジュールを書け。また、16 通りの入力組合せをすべて与える簡単なテストベンチを書け。
2.53困難Hard難しい第三階Tier 3ティア 3?R
某系統有四個感測器,每個都輸出 0 或 1。當兩個以上(含)的感測器輸出 1 時必須發出警報。用卡諾圖導出最小 SOP 運算式。
A system has four sensors, each producing 0 or 1. An alarm must be raised when two or more sensors output 1. Derive the minimum SOP expression using a Karnaugh map.
あるシステムには 4 個のセンサがあり、それぞれ 0 か 1 を出力する。2 個以上のセンサが 1 を出力したときに警報を出さなければならない。カルノー図を用いて最小 SOP 式を導け。
2.54困難Hard難しい第三階Tier 3ティア 3?R
只用二輸入 NAND 閘,求 $f(x_1,x_2,x_3,x_4) = \sum m(0,1,2,3,4,6,8,9,12)$ 的最小成本電路。假設輸入的原變數與補數形式皆可取得。
Find the minimum-cost circuit using only two-input NAND gates for $f(x_1,x_2,x_3,x_4) = \sum m(0,1,2,3,4,6,8,9,12)$. Assume inputs are available in both true and complemented form.
2 入力 NAND ゲートだけを用いて $f(x_1,x_2,x_3,x_4) = \sum m(0,1,2,3,4,6,8,9,12)$ の最小コスト回路を求めよ。入力は真の形と補数の形の両方が得られるものとする。
2.55困難Hard難しい第三階Tier 3ティア 3?R
證明或反證:$f = x_1 x_2 x_5 + x_1\overline{x_2}\,x_4 x_5 + \overline{x_1}\,x_2\overline{x_4}\,x_5 + x_1 x_2 x_3 x_4$ 等於 $g = x_2 x_3 x_4 + x_2\overline{x_3}\,\overline{x_4}\,x_5 + \overline{x_1}\,\overline{x_3}\,x_4 x_5 + x_1 x_2\overline{x_4}\,x_5$。
Prove or disprove: $f = x_1 x_2 x_5 + x_1\overline{x_2}\,x_4 x_5 + \overline{x_1}\,x_2\overline{x_4}\,x_5 + x_1 x_2 x_3 x_4$ equals $g = x_2 x_3 x_4 + x_2\overline{x_3}\,\overline{x_4}\,x_5 + \overline{x_1}\,\overline{x_3}\,x_4 x_5 + x_1 x_2\overline{x_4}\,x_5$.
次を証明または反証せよ:$f = x_1 x_2 x_5 + x_1\overline{x_2}\,x_4 x_5 + \overline{x_1}\,x_2\overline{x_4}\,x_5 + x_1 x_2 x_3 x_4$ は $g = x_2 x_3 x_4 + x_2\overline{x_3}\,\overline{x_4}\,x_5 + \overline{x_1}\,\overline{x_3}\,x_4 x_5 + x_1 x_2\overline{x_4}\,x_5$ に等しい。

第 3 章 — 數字表示法與算術Chapter 3 — Number Representation & Arithmetic第 3 章 — 数の表現と算術

第二階 · 中等Tier 2 · Midティア 2 · 中級

3.24困難Hard難しい第二階Tier 2ティア 2?R
導出 4 位元加法器的超前進位 (carry-lookahead) 方程式。以生成訊號 ($g_i$) 與傳遞訊號 ($p_i$) 表示 $c_1, c_2, c_3, c_4$。
Derive the carry-lookahead equations for a 4-bit adder. Express $c_1, c_2, c_3, c_4$ in terms of generate ($g_i$) and propagate ($p_i$) signals.
4 ビット加算器の桁上げ先見 (carry-lookahead) 方程式を導け。$c_1, c_2, c_3, c_4$ を生成信号 ($g_i$) と伝搬信号 ($p_i$) で表せ。
3.25簡單Easy易しい第二階Tier 2ティア 2?R
求下列 8 位元數的 2 的補數:$01010101$、$11110000$、$10000000$。
Find the 2's complement of the following 8-bit numbers: $01010101$, $11110000$, $10000000$.
次の 8 ビット数の 2 の補数を求めよ:$01010101$、$11110000$、$10000000$。
3.26簡單Easy易しい第二階Tier 2ティア 2?R
把十進位數 0.625 與 0.3 轉換成二進位小數(小數點後至少 8 位元)。指出哪一個是精確的、哪一個是近似的。
Convert the decimal numbers 0.625 and 0.3 to binary fractions (at least 8 bits after the binary point). Note which is exact and which is approximate.
10 進数 0.625 と 0.3 を 2 進小数に変換せよ(2 進小数点以下 8 ビット以上)。どちらが正確でどちらが近似かを示せ。
3.27中等Medium普通第二階Tier 2ティア 2?R
證明 XOR 運算滿足結合律:$x_i \oplus (y_i \oplus z_i) = (x_i \oplus y_i) \oplus z_i$。
Prove that the XOR operation is associative: $x_i \oplus (y_i \oplus z_i) = (x_i \oplus y_i) \oplus z_i$.
XOR 演算が結合的であることを証明せよ:$x_i \oplus (y_i \oplus z_i) = (x_i \oplus y_i) \oplus z_i$。
3.28簡單Easy易しい第二階Tier 2ティア 2?R
用 BCD(Binary-Coded Decimal)編碼十進位數 947。
Encode the decimal number 947 in BCD (Binary-Coded Decimal).
10 進数 947 を BCD(Binary-Coded Decimal)で符号化せよ。
3.29中等Medium普通第二階Tier 2ティア 2?R
把 BCD 數 $0110\;0111$ (67) 與 $0100\;0101$ (45) 相加。寫出必須加 6 的修正步驟。
Add the BCD numbers $0110\;0111$ (67) and $0100\;0101$ (45). Show the correction step where 6 must be added.
BCD 数 $0110\;0111$ (67) と $0100\;0101$ (45) を加算せよ。6 を加える補正の手順を示せ。
3.30簡單Easy易しい第二階Tier 2ティア 2?R
寫一個 Verilog 模組,用 + 運算子把兩個 8 位元數相加,並輸出 9 位元的結果(含進位輸出)。
Write a Verilog module that adds two 8-bit numbers using the + operator and outputs a 9-bit result (including carry-out).
+ 演算子を使って 2 つの 8 ビット数を加算し、9 ビットの結果(桁上げ出力を含む)を出力する Verilog モジュールを書け。
3.31中等Medium普通第二階Tier 2ティア 2?R
以 8 位元 2 的補數執行減法 $01110101 - 11010110$。轉換成十進位加以驗證。
Perform the subtraction $01110101 - 11010110$ in 8-bit 2's complement. Verify by converting to decimal.
8 ビットの 2 の補数で減算 $01110101 - 11010110$ を行え。10 進数に変換して検算せよ。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

3.32簡單Easy易しい第三階Tier 3ティア 3?R
在八進位、十六進位與二進位之間轉換下列各數:$(752)_8$、$(B3D)_{16}$。
Convert the following between octal, hexadecimal, and binary: $(752)_8$, $(B3D)_{16}$.
次の数を 8 進数、16 進数、2 進数の間で変換せよ:$(752)_8$、$(B3D)_{16}$。
3.33困難Hard難しい第三階Tier 3ティア 3?R
假設沒有扇入 (fan-in) 限制,求實作 n 位元超前進位加法器所需的閘數。使用 AND、OR 與 XOR 閘。
Determine the number of gates needed to implement an n-bit carry-lookahead adder assuming no fan-in constraints. Use AND, OR, and XOR gates.
ファンインの制約がないものとして、n ビットの桁上げ先見加算器の実現に必要なゲート数を求めよ。AND、OR、XOR ゲートを用いること。
3.34困難Hard難しい第三階Tier 3ティア 3?R
以閘延遲表示,n 位元漣波進位加法器的關鍵路徑延遲是多少?並與超前進位加法器比較。
What is the critical-path delay of an n-bit ripple-carry adder in terms of gate delays? Compare it with a carry-lookahead adder.
n ビットのリップルキャリー加算器のクリティカルパス遅延をゲート遅延で表すとどうなるか。桁上げ先見加算器と比較せよ。
3.35困難Hard難しい第三階Tier 3ティア 3?R
用兩個 2 位元 CLA 區塊設計一個階層式超前進位加法器,構成 4 位元加法器。畫出完整電路,並標示兩個層級的生成/傳遞訊號。
Design a hierarchical carry-lookahead adder using two 2-bit CLA blocks to build a 4-bit adder. Show the complete circuit with generate/propagate at both levels.
2 ビットの CLA ブロックを 2 個使って階層的な桁上げ先見加算器を設計し、4 ビット加算器を構成せよ。両方のレベルの生成/伝搬信号を含めた完全な回路を示せ。
3.36困難Hard難しい第三階Tier 3ティア 3?R
寫出 4×4 無號陣列乘法器的 Verilog 程式碼。用 generate 敘述產生部分積與加法邏輯。並以測試平台驗證。
Write Verilog code for a 4×4 unsigned array multiplier. Use generate statements to create the partial product and addition logic. Verify with a testbench.
4×4 の符号なしアレイ乗算器の Verilog コードを書け。generate 文を使って部分積と加算論理を生成せよ。テストベンチで検証せよ。

第 4 章 — 組合邏輯Chapter 4 — Combinational Logic第 4 章 — 組合せ論理

第二階 · 中等Tier 2 · Midティア 2 · 中級

4.48困難Hard難しい第二階Tier 2ティア 2?R
只用 2 對 1 多工器設計一個 8 對 1 多工器。需要多少個 2 對 1 多工器?畫出樹狀結構。
Design an 8-to-1 multiplexer using only 2-to-1 multiplexers. How many 2-to-1 muxes are needed? Draw the tree structure.
2-to-1 マルチプレクサだけを使って 8-to-1 マルチプレクサを設計せよ。2-to-1 MUX は何個必要か。ツリー構造を描け。
4.49簡單Easy易しい第二階Tier 2ティア 2?R
用 Verilog 的條件運算子 ? :,寫出一行實作 4 對 1 多工器的 assign 敘述。
Using the Verilog conditional operator ? :, write a one-line assign statement that implements a 4-to-1 multiplexer.
Verilog の条件演算子 ? : を使い、4-to-1 マルチプレクサを実装する 1 行の assign 文を書け。
4.50簡單Easy易しい第二階Tier 2ティア 2?R
解多工器依 2 位元的選擇訊號,把一個輸入送到四個輸出之一。寫出它的真值表。
A demultiplexer routes one input to one of four outputs based on a 2-bit select signal. Write its truth table.
デマルチプレクサは、2 ビットの選択信号に応じて 1 つの入力を 4 つの出力のいずれかへ振り分ける。その真理値表を書け。
4.51中等Medium普通第二階Tier 2ティア 2?R
用關係運算子 <==> 寫出一個 4 位元比較器的 Verilog 模組。
Write a Verilog module for a 4-bit comparator using the relational operators <, ==, >.
関係演算子 <==> を使って 4 ビット比較器の Verilog モジュールを書け。
4.52中等Medium普通第二階Tier 2ティア 2?R
寫一個 Verilog function,接收 4 位元的 BCD 輸入,並回傳對應的七段顯示器輸出(7 位元)。
Write a Verilog function that takes a 4-bit BCD input and returns the corresponding 7-segment display output (7 bits).
4 ビットの BCD 入力を受け取り、対応する 7 セグメント表示の出力(7 ビット)を返す Verilog の function を書け。
4.53中等Medium普通第二階Tier 2ティア 2?R
在 Verilog 中用 for 迴圈描述一個 8 位元的位元計數 (population count) 電路(計算 8 位元輸入中 1 的個數)。
Use a for loop in Verilog to describe an 8-bit population count circuit (counts the number of 1s in an 8-bit input).
Verilog の for ループを使って、8 ビットのポピュレーションカウント回路(8 ビット入力中の 1 の個数を数える)を記述せよ。
4.54中等Medium普通第二階Tier 2ティア 2?R
說明如何反覆套用 Shannon 展開,以導出 $f = w_2 + w_1 w_3 + \overline{w_1}\,w_3$ 的所有最小項。
Show how repeated application of Shannon's expansion can be used to derive all minterms of $f = w_2 + w_1 w_3 + \overline{w_1}\,w_3$.
シャノン展開を繰り返し適用して $f = w_2 + w_1 w_3 + \overline{w_1}\,w_3$ のすべての最小項を導く方法を示せ。
4.55簡單Easy易しい第二階Tier 2ティア 2?R
說明 Verilog 中 casexcasez 的差異。各自會在什麼情況下使用?
Explain the difference between casex and casez in Verilog. When would you use each?
Verilog の casexcasez の違いを説明せよ。それぞれどのようなときに使うか。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

4.56中等Medium普通第三階Tier 3ティア 3?R
寫一個 Verilog task,用來交換兩個 8 位元的值。從某個模組呼叫這個 task,把三個輸入依遞增順序排序。
Write a Verilog task that swaps two 8-bit values. Call this task from a module to sort three inputs in ascending order.
2 つの 8 ビット値を交換する Verilog の task を書け。この task をモジュールから呼び出して、3 つの入力を昇順に並べ替えよ。
4.57中等Medium普通第三階Tier 3ティア 3?R
用多工器實作超前進位加法器的進位級(第 0 級)。說明 $s_0$ 與 $c_1$ 是如何產生的。
Using multiplexers, implement the carry stage (stage 0) of a carry-lookahead adder. Show how $s_0$ and $c_1$ are generated.
マルチプレクサを用いて、桁上げ先見加算器の桁上げ段(第 0 段)を実装せよ。$s_0$ と $c_1$ がどのように生成されるかを示せ。
4.58困難Hard難しい第三階Tier 3ティア 3?R
用 Shannon 展開實作函數 $f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$,建構出多層電路。並與直接的 SOP 實作比較其成本。
Implement the function $f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$ using Shannon's expansion to build a multilevel circuit. Compare its cost with the direct SOP implementation.
シャノン展開を用いて関数 $f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$ を多段回路として実装せよ。そのコストを直接の SOP 実装と比較せよ。
4.59困難Hard難しい第三階Tier 3ティア 3?R
generate 結構在 Verilog 中設計一個參數化的 $n$-to-$2^n$ 解碼器。以 n = 3 驗證。
Design a parameterized $n$-to-$2^n$ decoder in Verilog using the generate construct. Verify for n = 3.
generate 構文を用いて、パラメータ化された $n$-to-$2^n$ デコーダを Verilog で設計せよ。n = 3 で検証せよ。
4.60困難Hard難しい第三階Tier 3ティア 3?R
實作一個可串接的 4 位元大小比較器,具有串接輸入 (Agtb_in, Aeqb_in, Altb_in)。說明如何把兩個串接起來以比較 8 位元數。
Implement a cascadable 4-bit magnitude comparator with cascade inputs (Agtb_in, Aeqb_in, Altb_in). Show how two can be chained to compare 8-bit numbers.
カスケード入力 (Agtb_in, Aeqb_in, Altb_in) を持つ、縦続接続可能な 4 ビットの大小比較器を実装せよ。2 個を連結して 8 ビット数を比較する方法を示せ。

第 5 章 — 正反器與循序電路Chapter 5 — Flip-Flops & Sequential第 5 章 — フリップフロップと順序回路

第二階 · 中等Tier 2 · Midティア 2 · 中級

5.36困難Hard難しい第二階Tier 2ティア 2?R
設計一個具備並列載入功能的 4 位元計數器:當 Load=1 時載入 4 位元的值 D,否則向上計數。並含非同步重置。寫出 Verilog 程式碼。
Design a 4-bit counter with parallel load capability: when Load=1, the counter loads a 4-bit value D; otherwise it counts up. Include an asynchronous reset. Write the Verilog code.
並列ロード機能を持つ 4 ビットカウンタを設計せよ:Load=1 のときは 4 ビットの値 D をロードし、そうでなければアップカウントする。非同期リセットも含めること。Verilog コードを書け。
5.37簡單Easy易しい第二階Tier 2ティア 2?R
寫出 JK 正反器的特性表與特性方程式。
Write the characteristic table and characteristic equation for a JK flip-flop.
JK フリップフロップの特性表と特性方程式を書け。
5.38中等Medium普通第二階Tier 2ティア 2?R
用 D 型正反器設計一個 4 位元的串入串出移位暫存器。畫出電路,並在輸入序列為 1,0,1,1 時追蹤其輸出。
Design a 4-bit serial-in, serial-out shift register using D flip-flops. Draw the circuit and trace the output when the input sequence is 1,0,1,1.
D フリップフロップを用いて 4 ビットの直列入力・直列出力シフトレジスタを設計せよ。回路を描き、入力系列が 1,0,1,1 のときの出力を追跡せよ。
5.39簡單Easy易しい第二階Tier 2ティア 2?R
初始值為 1000 的 4 位元環形計數器,其計數序列為何?
What is the counting sequence of a 4-bit ring counter initialized to 1000?
1000 に初期化された 4 ビットのリングカウンタの計数系列はどうなるか。
5.40中等Medium普通第二階Tier 2ティア 2?R
初始值為 0000 的 4 位元強生 (Johnson) 計數器,其計數序列為何?它會經過多少個相異的狀態?
What is the counting sequence of a 4-bit Johnson counter initialized to 0000? How many unique states does it pass through?
0000 に初期化された 4 ビットのジョンソンカウンタの計数系列はどうなるか。相異なる状態をいくつ通るか。
5.41中等Medium普通第二階Tier 2ティア 2?R
寫出一個 8 位元並列存取移位暫存器的 Verilog 程式碼,可由 2 位元的模式輸入控制左移、右移、並列載入或保持。
Write Verilog code for an 8-bit parallel-access shift register that can shift left, shift right, load in parallel, or hold, controlled by a 2-bit mode input.
2 ビットのモード入力によって左シフト、右シフト、並列ロード、保持を制御できる 8 ビットの並列アクセスシフトレジスタの Verilog コードを書け。
5.42中等Medium普通第二階Tier 2ティア 2?R
用同步重置設計一個 BCD 計數器(從 0000 數到 1001,然後繞回 0000)。寫出 Verilog 程式碼。
Design a BCD counter (counts 0000 to 1001, then wraps to 0000) using synchronous reset. Write the Verilog code.
同期リセットを用いて BCD カウンタ(0000 から 1001 まで数え、その後 0000 に戻る)を設計せよ。Verilog コードを書け。
5.43簡單Easy易しい第二階Tier 2ティア 2?R
always @(posedge Clock or negedge Resetn) 寫出一個具非同步重置的簡單 4 位元上數計數器的 Verilog 程式碼。
Write Verilog code for a simple 4-bit up counter with asynchronous reset using always @(posedge Clock or negedge Resetn).
always @(posedge Clock or negedge Resetn) を使って、非同期リセット付きの簡単な 4 ビットアップカウンタの Verilog コードを書け。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

5.44中等Medium普通第三階Tier 3ティア 3?R
給定一個輸入為 Sin、並列輸出為 Q[3:0] 的 4 位元移位暫存器,寫一個 Verilog 模組,偵測串列樣式 1011 是否已完整移入。
Given a 4-bit shift register with input Sin and parallel outputs Q[3:0], write a Verilog module that detects when the serial pattern 1011 has been completely shifted in.
入力 Sin と並列出力 Q[3:0] を持つ 4 ビットシフトレジスタが与えられたとき、直列パターン 1011 が完全にシフトインされたことを検出する Verilog モジュールを書け。
5.45困難Hard難しい第三階Tier 3ティア 3?R
用 D 型正反器設計一個模 6 計數器(從 0 數到 5)。用卡諾圖導出次一狀態邏輯,並畫出完整電路。
Design a modulo-6 counter (counts 0 through 5) using D flip-flops. Derive the next-state logic using Karnaugh maps and draw the complete circuit.
D フリップフロップを用いて mod-6 カウンタ(0 から 5 まで数える)を設計せよ。カルノー図を用いて次状態論理を導き、完全な回路を描け。
5.46困難Hard難しい第三階Tier 3ティア 3?R
某正反器的建立時間 tsu = 2 ns、保持時間 th = 1 ns、傳播延遲 tcQ = 3 ns。兩個正反器之間的組合邏輯延遲為 5 ns。最高時脈頻率是多少?若存在 0.5 ns 的時脈偏斜 (clock skew) 又如何?
A flip-flop has setup time tsu = 2 ns, hold time th = 1 ns, and propagation delay tcQ = 3 ns. The combinational logic between two flip-flops has a delay of 5 ns. What is the maximum clock frequency? What if there is a clock skew of 0.5 ns?
あるフリップフロップのセットアップ時間は tsu = 2 ns、ホールド時間は th = 1 ns、伝搬遅延は tcQ = 3 ns である。2 つのフリップフロップ間の組合せ回路の遅延は 5 ns である。最大クロック周波数はいくらか。0.5 ns のクロックスキューがある場合はどうか。
5.47困難Hard難しい第三階Tier 3ティア 3?R
某線性回授移位暫存器 (LFSR) 的回授多項式為 x³ + x + 1。從 001 開始,追蹤序列中的所有狀態。這是最大長度序列嗎?
A linear-feedback shift register (LFSR) has the feedback polynomial x³ + x + 1. Starting from 001, trace all states in the sequence. Is this a maximal-length sequence?
ある線形帰還シフトレジスタ (LFSR) の帰還多項式は x³ + x + 1 である。001 から始めて、系列中のすべての状態をたどれ。これは最大長系列か。
5.48困難Hard難しい第三階Tier 3ティア 3?R
設計一個除頻器,接收一個時脈輸入,產生頻率為輸入 1/6 且工作週期為 50% 的輸出時脈。請寫出 Verilog 程式碼。
Design a frequency divider that takes a clock input and produces an output clock at 1/6 of the input frequency with a 50% duty cycle. Give the Verilog code.
クロック入力を受け取り、その 1/6 の周波数でデューティ比 50% の出力クロックを生成する分周器を設計せよ。Verilog コードを示せ。

第 6 章 — 有限狀態機Chapter 6 — Finite State Machines第 6 章 — 有限状態機械

第二階 · 中等Tier 2 · Midティア 2 · 中級

6.31困難Hard難しい第二階Tier 2ティア 2?R
導出一個 FSM 的狀態圖,該 FSM 在輸入 w 上偵測 10011111 樣式(允許重疊)。以序列 w: 010111100110011111 驗證。
Derive the state diagram for an FSM that detects either 1001 or 1111 patterns on input w (overlapping allowed). Verify with the sequence w: 010111100110011111.
入力 w 上で 1001 または 1111 のパターンを検出する FSM(重なりを許す)の状態遷移図を導け。系列 w: 010111100110011111 で検証せよ。
6.32中等Medium普通第二階Tier 2ティア 2?R
有限狀態機的形式化模型是什麼?定義 5 元組 (S, I, O, δ, λ) 並說明各個構成元素。
What is the formal model of a finite state machine? Define the 5-tuple (S, I, O, δ, λ) and explain each component.
有限状態機械の形式的モデルとは何か。5 項組 (S, I, O, δ, λ) を定義し、それぞれの構成要素を説明せよ。
6.33簡單Easy易しい第二階Tier 2ティア 2?R
給定一個含兩個 D 正反器與組合邏輯的循序電路,請分析此電路:由給定的下一狀態方程式 D₁ = x ⊕ Q₂D₂ = Q₁ 導出狀態表並畫出狀態圖。
Given a sequential circuit with two D flip-flops and combinational logic, analyze the circuit: derive the state table and draw the state diagram from the given next-state equations D₁ = x ⊕ Q₂ and D₂ = Q₁.
D フリップフロップ 2 個と組合せ回路からなる順序回路について、回路を解析せよ:与えられた次状態方程式 D₁ = x ⊕ Q₂D₂ = Q₁ から状態表を導き、状態遷移図を描け。
6.34中等Medium普通第二階Tier 2ティア 2?R
設計一個仲裁器 FSM,將存取權授予兩個請求者 (r₁, r₂) 之一。此仲裁器有輸出 g₁ 與 g₂(授權)。當兩者同時請求時,應優先給 r₁。
Design an arbiter FSM that grants access to one of two requestors (r₁, r₂). The arbiter has outputs g₁ and g₂ (grants). It should give priority to r₁ when both request simultaneously.
2 つの要求元 (r₁, r₂) のいずれかにアクセス権を与えるアービタ FSM を設計せよ。このアービタは出力 g₁ と g₂(許可)をもつ。両者が同時に要求した場合は r₁ を優先すること。
6.35簡單Easy易しい第二階Tier 2ティア 2?R
對於複雜的設計,使用 ASM 圖相對於狀態圖有哪些優點?
What are the advantages of using ASM charts over state diagrams for complex designs?
複雑な設計において、状態遷移図の代わりに ASM チャートを用いる利点は何か。
6.36中等Medium普通第二階Tier 2ティア 2?R
列出並描述課本所述設計同步循序電路的六個基本步驟。
List and describe the six basic steps for designing a synchronous sequential circuit as outlined in the textbook.
教科書に示されている同期順序回路を設計するための 6 つの基本ステップを列挙し、説明せよ。
6.37中等Medium普通第二階Tier 2ティア 2?R
說明在 Verilog 中指定狀態編碼(例如使用 (* synthesis, encoding = "one-hot" *))會如何影響合成出的硬體。針對一個 8 狀態 FSM,比較二進位、格雷碼與 one-hot 編碼。
Explain how specifying state encoding in Verilog (e.g., using (* synthesis, encoding = "one-hot" *)) affects the synthesized hardware. Compare binary, Gray, and one-hot for an 8-state FSM.
Verilog で状態符号化を指定すること(たとえば (* synthesis, encoding = "one-hot" *) の使用)が、合成される回路にどう影響するかを説明せよ。8 状態の FSM について、2 進、グレイ符号、one-hot を比較せよ。
6.38困難Hard難しい第二階Tier 2ティア 2?R
以 D 正反器並依循序電路設計流程,設計一個模 8 計數器。導出狀態表、狀態指派,並以卡諾圖求出下一狀態邏輯方程式。
Design a modulo-8 counter using the sequential circuit design approach with D flip-flops. Derive the state table, state assignment, and next-state logic equations using K-maps.
D フリップフロップを用い、順序回路の設計手順に従って 8 を法とするカウンタを設計せよ。状態表、状態割当てを導き、カルノー図を用いて次状態論理の方程式を求めよ。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

6.39困難Hard難しい第三階Tier 3ティア 3?R
以 JK 正反器重做習題 6.38。將總閘數與 D 正反器實作相比較。
Repeat exercise 6.38 using JK flip-flops. Compare the total gate count with the D flip-flop implementation.
演習 6.38 を JK フリップフロップで解き直せ。総ゲート数を D フリップフロップによる実装と比較せよ。
6.40困難Hard難しい第三階Tier 3ティア 3?R
某循序電路有兩個輸入 w₁w₂。當 w₁=w₂ 連續成立四個時脈週期時,輸出 z=1。導出狀態圖與 Verilog 程式碼。
A sequential circuit has two inputs w₁ and w₂. It outputs z=1 when w₁=w₂ for four consecutive clock cycles. Derive the state diagram and Verilog code.
ある順序回路は 2 つの入力 w₁w₂ をもつ。w₁=w₂ が 4 クロックサイクル連続したとき z=1 を出力する。状態遷移図と Verilog コードを導け。
6.41困難Hard難しい第三階Tier 3ティア 3?R
設計一個串列加法器 FSM,將兩個 n 位元數字每次一個位元(LSB 先)地相加。分別設計 Moore 版與 Mealy 版,並比較輸出的時序。
Design a serial adder FSM that adds two n-bit numbers presented one bit at a time (LSB first). Design both Moore and Mealy versions and compare the timing of the output.
2 つの n ビット数を 1 ビットずつ(LSB から)与えて加算する直列加算器 FSM を設計せよ。Moore 版と Mealy 版の両方を設計し、出力のタイミングを比較せよ。
6.42困難Hard難しい第三階Tier 3ティア 3?R
將下列 Mealy FSM 轉換為等效的 Moore FSM:狀態 {A,B,C},輸入 w,輸出 z。轉移:A→(w=0:A/0, w=1:B/0)、B→(w=0:A/0, w=1:C/1)、C→(w=0:A/0, w=1:C/1)。列出所有步驟。
Convert the following Mealy FSM to an equivalent Moore FSM: States {A,B,C}, Input w, Output z. Transitions: A→(w=0:A/0, w=1:B/0), B→(w=0:A/0, w=1:C/1), C→(w=0:A/0, w=1:C/1). Show all steps.
次の Mealy FSM を等価な Moore FSM に変換せよ:状態 {A,B,C}、入力 w、出力 z。遷移は A→(w=0:A/0, w=1:B/0)、B→(w=0:A/0, w=1:C/1)、C→(w=0:A/0, w=1:C/1)。すべての手順を示せ。
6.43困難Hard難しい第三階Tier 3ティア 3?R
設計一個 Moore FSM,當偵測到 110101 樣式(允許重疊)時輸出 1。導出最簡狀態表、狀態指派與完整實作。
Design a Moore FSM that outputs 1 when either 110 or 101 patterns are detected (overlapping). Derive the minimal state table, state assignment, and complete implementation.
110 または 101 のパターンを検出したとき(重なりを許す)1 を出力する Moore FSM を設計せよ。最小の状態表、状態割当て、および完全な実装を導け。

第 7 章 — 資料路徑與控制器Chapter 7 — Datapaths & Controllers第 7 章 — データパスとコントローラ

第二階 · 中等Tier 2 · Midティア 2 · 中級

7.4簡單Easy易しい第二階Tier 2ティア 2?R
什麼是開關彈跳消除 (switch debouncing)?為什麼有必要?並描述一種硬體式與一種軟體式的處理方法。
What is switch debouncing? Why is it necessary, and describe one hardware-based and one software-based approach to handle it.
スイッチのチャタリング除去 (switch debouncing) とは何か。なぜ必要なのか。またハードウェアによる方法とソフトウェアによる方法を 1 つずつ述べよ。
7.8中等Medium普通第二階Tier 2ティア 2?R
使用歐幾里得演算法設計一個簡易的 GCD(最大公因數)計算器。畫出 ASM 圖並指出所需的資料路徑元件。
Design a simple GCD (Greatest Common Divisor) calculator using the Euclidean algorithm. Draw the ASM chart and identify the datapath components needed.
ユークリッドの互除法を用いて簡単な GCD(最大公約数)計算回路を設計せよ。ASM チャートを描き、必要となるデータパス要素を挙げよ。
7.9中等Medium普通第二階Tier 2ティア 2?R
為一個具備致能、同步載入與同步重置的參數化 n 位元計數器撰寫 Verilog 程式碼。並將其實體化為 16 位元計數器。
Write Verilog code for a parameterized n-bit counter with enable, synchronous load, and synchronous reset. Instantiate it as a 16-bit counter.
イネーブル、同期ロード、同期リセットを備えたパラメータ化された n ビットカウンタの Verilog コードを書け。さらにそれを 16 ビットカウンタとしてインスタンス化せよ。
7.3中等Medium普通第二階Tier 2ティア 2?R
為一個電路畫出 ASM 圖,該電路計算依序載入的四個 8 位元無號數的算術平均值。
Draw an ASM chart for a circuit that computes the arithmetic mean of four 8-bit unsigned numbers loaded sequentially.
順次ロードされる 4 個の 8 ビット符号なし数の算術平均を計算する回路の ASM チャートを描け。
7.6中等Medium普通第二階Tier 2ティア 2?R
這個簡易處理器支援 Load、Move、Add、Sub 等運算。請為每個運算寫出微指令(控制訊號)。
The simple processor supports the operations: Load, Move, Add, Sub. Write microinstructions (control signals) for each operation.
この簡易プロセッサは Load、Move、Add、Sub の演算をサポートする。各演算に対するマイクロ命令(制御信号)を書け。
7.11困難Hard難しい第二階Tier 2ティア 2?R
為一個位元計數電路撰寫完整的 Verilog 程式碼,該電路計算一個 8 位元暫存器中 1 的個數。請使用含移位暫存器與計數器的資料路徑,並由一個 FSM 控制。
Write complete Verilog code for a bit-counting circuit that counts the number of 1s in an 8-bit register. Use a datapath with a shift register and a counter, controlled by an FSM.
8 ビットレジスタ中の 1 の個数を数えるビット計数回路の完全な Verilog コードを書け。シフトレジスタとカウンタからなるデータパスを用い、FSM で制御すること。
7.13困難Hard難しい第二階Tier 2ティア 2E?R
設計一個位元計數電路:給定載入移位暫存器的 $n$ 位元無號輸入,計算輸入中 1 的個數。請提供資料路徑(移位暫存器、計數器、控制訊號)與控制 FSM 的 ASM 圖,然後為整個電路撰寫 Verilog 程式碼。
Design a bit-counting circuit that, given an $n$-bit unsigned input loaded into a shift register, counts the number of 1s in the input. Provide the datapath (shift register, counter, control signals) and an ASM chart for the controlling FSM, then write Verilog code for the complete circuit.
シフトレジスタにロードされた $n$ ビットの符号なし入力について、その中の 1 の個数を数えるビット計数回路を設計せよ。データパス(シフトレジスタ、カウンタ、制御信号)と制御 FSM の ASM チャートを示し、そのうえで回路全体の Verilog コードを書け。
7.14困難Hard難しい第二階Tier 2ティア 2E?R
為兩個 $n$ 位元無號數設計一個移位相加乘法器。使用被乘數暫存器、部分積累加器,以及存放乘數的移位暫存器。請提供控制 FSM 的 ASM 圖,並為資料路徑與控制器分別撰寫 Verilog 程式碼。
Design a shift-and-add multiplier for two $n$-bit unsigned numbers. Use a multiplicand register, a partial-product accumulator, and a shift register for the multiplier. Provide the ASM chart for the control FSM and write Verilog code for both the datapath and the controller.
2 つの $n$ ビット符号なし数に対するシフト・加算方式の乗算器を設計せよ。被乗数レジスタ、部分積アキュムレータ、乗数用のシフトレジスタを用いること。制御 FSM の ASM チャートを示し、データパスと制御部の両方の Verilog コードを書け。
7.16困難Hard難しい第二階Tier 2ティア 2E?R
設計一個電路,計算依序出現在輸入匯流排上的 $k$ 個 $n$ 位元無號數的算術平均值。請提供含累加器與除以 $k$ 運算的資料路徑、ASM 圖與 Verilog 程式碼。
Design a circuit that computes the arithmetic mean of $k$ unsigned $n$-bit numbers presented sequentially on an input bus. Provide a datapath with an accumulator and a divide-by-$k$ operation, an ASM chart, and Verilog code.
入力バス上に順次現れる $k$ 個の $n$ ビット符号なし数の算術平均を計算する回路を設計せよ。アキュムレータと $k$ で割る演算をもつデータパス、ASM チャート、および Verilog コードを示せ。
7.17困難Hard難しい第二階Tier 2ティア 2E?R
設計一個硬體排序電路,使用選擇排序或氣泡排序風格的演算法,將存放在小型暫存器檔案中的 $k$ 個 $n$ 位元無號數依遞增順序排序。請提供資料路徑、控制器的 ASM 圖,以及完整排序器的 Verilog 程式碼。
Design a hardware sort circuit that sorts $k$ unsigned $n$-bit numbers stored in a small register file into ascending order, using a selection-sort or bubble-sort style algorithm. Provide the datapath, ASM chart for the controller, and Verilog code for the complete sorter.
小さなレジスタファイルに格納された $k$ 個の $n$ ビット符号なし数を、選択ソートまたはバブルソート方式のアルゴリズムで昇順に並べ替えるハードウェアソート回路を設計せよ。データパス、制御部の ASM チャート、およびソータ全体の Verilog コードを示せ。
7.18困難Hard難しい第二階Tier 2ティア 2?R
設計一個完整的系統,從輸入埠讀取 4 位元數值,最多將 8 個數值存入暫存器檔案,並計算其總和與平均值。請給出 ASM 圖與 Verilog 程式碼。
Design a complete system that reads 4-bit values from an input port, stores up to 8 values in a register file, and computes their sum and average. Give the ASM chart and Verilog code.
入力ポートから 4 ビットの値を読み取り、最大 8 個の値をレジスタファイルに格納して、その総和と平均を計算する完全なシステムを設計せよ。ASM チャートと Verilog コードを示せ。
7.19中等Medium普通第二階Tier 2ティア 2?R
撰寫 Verilog 程式碼,使用三態緩衝器 (assign bus = enable ? data : 8'bz;) 將兩個模組連接到共用的 8 位元匯流排。
Write Verilog code that uses a tri-state buffer (assign bus = enable ? data : 8'bz;) to connect two modules to a shared 8-bit bus.
トライステートバッファ (assign bus = enable ? data : 8'bz;) を使って 2 つのモジュールを共有の 8 ビットバスに接続する Verilog コードを書け。
7.20中等Medium普通第二階Tier 2ティア 2?R
設計一個排序網路,使用比較交換 (compare-and-swap) 單元將三個 4 位元無號數依遞增順序排序。畫出方塊圖。
Design a sorting network that sorts three 4-bit unsigned numbers in ascending order using compare-and-swap units. Draw the block diagram.
比較交換 (compare-and-swap) ユニットを用いて 3 個の 4 ビット符号なし数を昇順に並べ替えるソーティングネットワークを設計せよ。ブロック図を描け。
7.21簡單Easy易しい第二階Tier 2ティア 2?R
在 ASM 圖中,Moore 型輸出與 Mealy 型輸出有什麼差別?畫一個小型 ASM 圖來說明兩者。
What is the difference between Moore-type and Mealy-type outputs in an ASM chart? Draw a small ASM chart illustrating both.
ASM チャートにおける Moore 型出力と Mealy 型出力の違いは何か。両方を示す小さな ASM チャートを描け。
7.22簡單Easy易しい第二階Tier 2ティア 2?R
什麼是同步器 (synchronizer) 電路?畫出雙正反器同步器,並說明為什麼單一正反器並不足夠。
What is a synchronizer circuit? Draw a two-flip-flop synchronizer and explain why a single flip-flop is insufficient.
同期化回路 (synchronizer) とは何か。フリップフロップ 2 段の同期化回路を描き、フリップフロップ 1 段では不十分な理由を説明せよ。
7.23中等Medium普通第二階Tier 2ティア 2?R
某除法器採用重複相減法。請為此方法撰寫虛擬碼,並就 255 ÷ 7 比較它與回復式除法器所需的週期數。
A divider uses the repeated-subtraction method. Write pseudo-code for this approach and compare the number of cycles needed versus the restoring divider for 255 ÷ 7.
ある除算器は繰り返し減算法を用いる。この方式の擬似コードを書き、255 ÷ 7 について復元型除算器と必要サイクル数を比較せよ。
7.24中等Medium普通第二階Tier 2ティア 2?R
一個 4 位元移位相加乘法器完成一次乘法需要多少個時脈週期?8 位元版本又如何?
How many clock cycles does a 4-bit shift-and-add multiplier need to complete one multiplication? What about an 8-bit version?
4 ビットのシフト・加算乗算器が 1 回の乗算を終えるのに何クロックサイクル必要か。8 ビット版ではどうか。
7.25中等Medium普通第二階Tier 2ティア 2?R
使用一個 SR 閂鎖與兩個上拉電阻,為機械式按鈕設計一個彈跳消除電路。畫出電路並說明其動作。
Design a debouncing circuit for a mechanical pushbutton using an SR latch and two pull-up resistors. Draw the circuit and explain the operation.
SR ラッチ 1 個と 2 個のプルアップ抵抗を用いて、機械式押しボタン用のチャタリング除去回路を設計せよ。回路を描き、その動作を説明せよ。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

7.26中等Medium普通第三階Tier 3ティア 3?R
說明為什麼時脈分佈在高速數位系統中至關重要。有哪些技術可用來將時脈偏斜降到最低?
Explain why clock distribution is critical in high-speed digital systems. What techniques can be used to minimize clock skew?
高速ディジタルシステムにおいてクロック分配が重要である理由を説明せよ。クロックスキューを最小化するにはどのような手法が使えるか。
7.27困難Hard難しい第三階Tier 3ティア 3?R
設計一個回復式除法器,將 8 位元被除數除以 4 位元除數。畫出資料路徑與控制單元的 ASM 圖。
Design a restoring divider that divides an 8-bit dividend by a 4-bit divisor. Show the datapath and ASM chart for the control unit.
8 ビットの被除数を 4 ビットの除数で割る復元型除算器を設計せよ。データパスと制御部の ASM チャートを示せ。
7.28困難Hard難しい第三階Tier 3ティア 3?R
為習題 7.12 的移位相加乘法器撰寫 Verilog 程式碼。並附上測試平台,計算 13 × 11 並驗證結果為 143。
Write Verilog code for the shift-and-add multiplier from exercise 7.12. Include a testbench that multiplies 13 × 11 and verifies the result is 143.
演習 7.12 のシフト・加算乗算器の Verilog コードを書け。13 × 11 を計算し、結果が 143 になることを検証するテストベンチも含めること。
7.29困難Hard難しい第三階Tier 3ティア 3?R
修改移位相加乘法器以處理有號數(2 的補數)。資料路徑與控制部分需要哪些改動?
Modify the shift-and-add multiplier to handle signed numbers (2's complement). What changes are needed in the datapath and control?
シフト・加算乗算器を符号付き数(2 の補数)に対応するよう改造せよ。データパスと制御部にどのような変更が必要か。
7.30困難Hard難しい第三階Tier 3ティア 3?R
設計一個 UART 傳送器,傳送含 1 個起始位元與 1 個停止位元的 8 位元資料。畫出 ASM 圖、指出資料路徑元件,並撰寫 Verilog 程式碼。
Design a UART transmitter that sends 8-bit data with 1 start bit and 1 stop bit. Draw the ASM chart, identify datapath components, and write Verilog code.
スタートビット 1 個とストップビット 1 個を伴う 8 ビットデータを送信する UART 送信器を設計せよ。ASM チャートを描き、データパス要素を挙げ、Verilog コードを書け。

第 8 章 — 最佳化Chapter 8 — Optimization第 8 章 — 最適化

第二階 · 中等Tier 2 · Midティア 2 · 中級

8.5簡單Easy易しい第二階Tier 2ティア 2?R
為什麼卡諾圖對超過 5–6 個變數的函數並不實用?本章提出了哪些替代方法?
Why are Karnaugh maps impractical for functions with more than 5–6 variables? What alternatives does the chapter present?
変数が 5〜6 個を超える関数に対してカルノー図が実用的でないのはなぜか。本章はどのような代替手法を示しているか。
8.9中等Medium普通第二階Tier 2ティア 2?R
什麼是 ROBDD(化簡有序 BDD)?會套用哪兩條化簡規則?為什麼標準形式 (canonical form) 對驗證很重要?
What is an ROBDD (Reduced Ordered BDD)? What two reduction rules are applied, and why is canonical form important for verification?
ROBDD(既約順序付き BDD)とは何か。適用される 2 つの簡約規則は何か。また、検証において標準形 (canonical form) が重要なのはなぜか。
8.20中等Medium普通第二階Tier 2ティア 2E?R
Analyze a NAND-only circuit (Figure 8.14a) by labeling internal nodes $P_1, P_2, P_3$ and propagating bubbles via DeMorgan's theorem until an equivalent AND/OR circuit is obtained. Show that the function is $f = x_1 x_2 x_4 + \overline{x_3}\, x_4 + \overline{x_5}$.
背景:範例 8.8 — 以推泡泡法分析純 NAND 電路Context: Example 8.8 — analyzing a NAND-only circuit by bubble-pushing背景:例 8.8 — バブルプッシュで NAND のみの回路を解析する

圖 8.14a 是四個 2 輸入 NAND 閘串接而成。每個閘的輸出都帶一個反相泡泡,因此用 DeMorgan 定律把泡泡推來推去會讓分析容易得多:$\overline{AB} = \overline{A} + \overline{B}$。

Figure 8.14a is a chain of four 2-input NAND gates. Each gate output gets a fresh inversion bubble, so analysis is easier if we push bubbles around using DeMorgan: $\overline{AB} = \overline{A} + \overline{B}$.

図 8.14a は 2 入力 NAND ゲート 4 個の縦続接続である。各ゲートの出力には反転バブルが付くので、DeMorgan の法則 $\overline{AB} = \overline{A} + \overline{B}$ を使ってバブルを移動させると解析がずっと楽になる。

x1 x2 x3 x4 x5 NAND P1 NAND P2 NAND P3 NAND f 圖 8.14a — 純 NAND 電路Figure 8.14a — NAND-only circuit図 8.14a — NAND のみの回路

直接追蹤(NAND 輸出)。每個 $P_i$ 都是其兩個輸入的 NAND:

Direct trace (NAND outputs). Each $P_i$ is the NAND of its two inputs:

そのまま追う(NAND の出力)。各 $P_i$ は 2 つの入力の NAND である:

$P_1 = \overline{x_1 x_2}, \quad P_2 = \overline{P_1 \cdot x_3}, \quad P_3 = \overline{P_2 \cdot x_4}, \quad f = \overline{P_3 \cdot x_5}.$

$P_1 = \overline{x_1 x_2}, \quad P_2 = \overline{P_1 \cdot x_3}, \quad P_3 = \overline{P_2 \cdot x_4}, \quad f = \overline{P_3 \cdot x_5}.$

$P_1 = \overline{x_1 x_2}, \quad P_2 = \overline{P_1 \cdot x_3}, \quad P_3 = \overline{P_2 \cdot x_4}, \quad f = \overline{P_3 \cdot x_5}.$

從輸出端推泡泡。對 $f$ 套用 DeMorgan,再逐層展開:

Bubble-push from the output. Apply DeMorgan to $f$, then unwind:

出力側からバブルを押す。$f$ に DeMorgan を適用し、順にほどいていく:

$f = \overline{P_3 \cdot x_5} = \overline{P_3} + \overline{x_5} = (P_2 \cdot x_4) + \overline{x_5}.$

$f = \overline{P_3 \cdot x_5} = \overline{P_3} + \overline{x_5} = (P_2 \cdot x_4) + \overline{x_5}.$

$f = \overline{P_3 \cdot x_5} = \overline{P_3} + \overline{x_5} = (P_2 \cdot x_4) + \overline{x_5}.$

$P_2 \cdot x_4 = \overline{P_1 \cdot x_3}\cdot x_4 = (\overline{P_1} + \overline{x_3})\,x_4 = (x_1 x_2 + \overline{x_3})\,x_4.$

$P_2 \cdot x_4 = \overline{P_1 \cdot x_3}\cdot x_4 = (\overline{P_1} + \overline{x_3})\,x_4 = (x_1 x_2 + \overline{x_3})\,x_4.$

$P_2 \cdot x_4 = \overline{P_1 \cdot x_3}\cdot x_4 = (\overline{P_1} + \overline{x_3})\,x_4 = (x_1 x_2 + \overline{x_3})\,x_4.$

Therefore $f = (x_1 x_2 + \overline{x_3})\,x_4 + \overline{x_5} = x_1 x_2 x_4 + \overline{x_3}\, x_4 + \overline{x_5}.$

為什麼行得通(推泡泡規則)。NAND 永遠可以改畫成兩個輸入都被反相的 OR:$\overline{AB} = \overline{A} + \overline{B}$。串接的 NAND 會交替傳遞 AND/OR 層,而內部連線上兩個泡泡相遇時會互相抵消(同一條線上兩個泡泡 ≡ 沒有泡泡)。抵消之後,殘存的泡泡只會停在真正引發反相的主要輸入上 — 這裡是 $x_3$ 與 $x_5$ — 於是得到圖 8.14c 的 AND-OR 等效電路。

Why this works (the bubble-pushing rule). A NAND can always be redrawn as an OR with both inputs inverted: $\overline{AB} = \overline{A} + \overline{B}$. Cascaded NANDs alternately propagate AND/OR layers, with bubbles cancelling on internal wires when they meet (two bubbles on the same wire ≡ no bubble). After cancellation, surviving bubbles end up only on the primary inputs that lit up the inversions — here, $x_3$ and $x_5$ — yielding the AND-OR equivalent in Figure 8.14c.

なぜこれでよいのか(バブルプッシュの規則)。NAND は常に、両入力を反転した OR として描き直せる:$\overline{AB} = \overline{A} + \overline{B}$。縦続接続された NAND は AND 層と OR 層を交互に伝え、内部配線上でバブルどうしが出会うと打ち消し合う(同じ線上の 2 つのバブル ≡ バブルなし)。打ち消しの後に残るバブルは、実際に反転を引き起こした一次入力にだけ付く — ここでは $x_3$ と $x_5$ である — こうして図 8.14c の AND-OR 等価回路が得られる。

清點殘存的泡泡。從 $f$ 往回走到每個輸入,數一數路徑上的 NAND 輸出泡泡:偶數個會抵消,奇數個則讓該輸入變成補數。以 $x_1, x_2$ 為例:兩個泡泡(在 NAND1 與 NAND4)— 且慢,NAND1 的輸出泡泡在輸出側,它接進沒有輸入泡泡的 NAND2;泡泡只出現在 NAND 輸出端,而每個 NAND 輸出都被下一個 NAND 吃掉。因此 NAND1 的輸出泡泡與被 DeMorgan 改畫的 NAND2(= 帶輸入泡泡的 AND)成對抵消,得到乾淨的 AND。逐一追蹤各輸入:$x_1, x_2, x_4$ → 沒有殘存泡泡;$x_3, x_5$ → 各殘存一個泡泡(取補數)。與上面的代數結果一致。

Counting the survivors. Travel from $f$ back to each input. Count NAND-output bubbles on the path: an even count cancels, an odd count leaves the input complemented. For $x_1, x_2$: two bubbles (at NAND1 and NAND4) — wait, NAND1 output bubble is on the output side, then it enters NAND2 which has no input bubble; bubbles only appear at NAND outputs, and every NAND output is consumed by the next NAND. So pair-cancellation between NAND1 output bubble and the implicit DeMorgan-redrawn NAND2 (= AND with input bubbles) yields a clean AND. Trace each input: $x_1, x_2, x_4$ → no surviving bubble; $x_3, x_5$ → one surviving bubble each (complemented). Matches the algebraic result above.

残るバブルを数える。$f$ から各入力へ逆にたどり、経路上の NAND 出力バブルを数える:偶数個なら打ち消し、奇数個ならその入力は反転される。$x_1, x_2$ の場合:バブルは 2 つ(NAND1 と NAND4)— いや、NAND1 の出力バブルは出力側にあり、その先は入力バブルのない NAND2 に入る。バブルは NAND の出力にしか現れず、すべての NAND 出力は次の NAND に消費される。したがって NAND1 の出力バブルと、DeMorgan で描き直した NAND2(= 入力バブル付きの AND)とが対で打ち消し合い、きれいな AND になる。各入力を追うと、$x_1, x_2, x_4$ → 残るバブルなし、$x_3, x_5$ → それぞれバブルが 1 つ残る(反転される)。上の代数的な結果と一致する。

— example 8.8
8.26中等Medium普通第二階Tier 2ティア 2E?R
對某 3 變數函數的覆蓋 $C_0=\{000, 001, 010, 011, 111\}$ 套用 $\star$-product(立方體)運算。產生 $C_1, C_2, \ldots$ 直到收斂,並確認質蘊涵項為 $\{x11, 0xx\}$。
Apply the $\star$-product (cubical) operation to the cover $C_0=\{000, 001, 010, 011, 111\}$ of a 3-variable function. Generate $C_1, C_2, \ldots$ until convergence and confirm the prime implicants are $\{x11, 0xx\}$.
ある 3 変数関数の被覆 $C_0=\{000, 001, 010, 011, 111\}$ に $\star$-product(キューブ)演算を適用せよ。収束するまで $C_1, C_2, \ldots$ を生成し、主項が $\{x11, 0xx\}$ であることを確かめよ。
8.2中等Medium普通第二階Tier 2ティア 2?R
僅使用 NAND 閘實作邏輯電路 f = ac + ad + bc + bd + e
Implement the logic circuit f = ac + ad + bc + bd + e using only NAND gates.
NAND ゲートのみを用いて論理回路 f = ac + ad + bc + bd + e を実現せよ。
8.8中等Medium普通第二階Tier 2ティア 2?R
以代數除法從 f = abd + abe + acd + ace 中抽取共同子運算式。寫出因式分解後的形式。
Use algebraic division to extract common sub-expressions from f = abd + abe + acd + ace. Show the factored form.
代数的除算を用いて f = abd + abe + acd + ace から共通部分式を抽出せよ。因数分解した形を示せ。
8.11中等Medium普通第二階Tier 2ティア 2?R
以順序 s < d₀ < d₁ 為 2 對 1 多工器函數 f = s·d₁ + s̄·d₀ 建構 BDD。接著改用順序 d₀ < d₁ < s。比較兩者的大小。
Construct the BDD for a 2-to-1 multiplexer function f = s·d₁ + s̄·d₀ with ordering s < d₀ < d₁. Then try ordering d₀ < d₁ < s. Compare sizes.
順序 s < d₀ < d₁ のもとで 2-to-1 マルチプレクサ関数 f = s·d₁ + s̄·d₀ の BDD を構成せよ。次に順序 d₀ < d₁ < s で試し、サイズを比較せよ。
8.16中等Medium普通第二階Tier 2ティア 2E?R
只用 NAND 閘實作 XOR 函數 $f = x_1 \oplus x_2$。先由 SOP 形式推導出五個 NAND 的實現,再以 $g = x_1 \uparrow x_2$ 做函數分解,得到四個 NAND 的實作。
Implement the XOR function $f = x_1 \oplus x_2$ using only NAND gates. First derive a five-NAND realization from the SOP form, then apply functional decomposition with $g = x_1 \uparrow x_2$ to obtain a four-NAND implementation.
NAND ゲートだけで XOR 関数 $f = x_1 \oplus x_2$ を実装せよ。まず SOP 形から NAND 5 個の実現を導き、次に $g = x_1 \uparrow x_2$ による関数分解を適用して NAND 4 個の実装を得よ。
8.22中等Medium普通第二階Tier 2ティア 2E?R
圖 8.22d 給出某 3 變數函數在輸入順序 $(x_2, x_1, x_3)$ 下的 BDD。交換節點 $x_1$ 與 $x_2$ 的位置,得到輸入順序為 $(x_1, x_2, x_3)$ 的 BDD。請用一張小真值表追蹤跨越交換邊界的邊之目的地。
Given the BDD for a 3-variable function with input order $(x_2, x_1, x_3)$ in Figure 8.22d, swap the positions of nodes $x_1$ and $x_2$ to obtain a BDD with input order $(x_1, x_2, x_3)$. Use a small truth table to track the destinations of edges crossing the swap boundary.
図 8.22d に、入力順序 $(x_2, x_1, x_3)$ をもつ 3 変数関数の BDD が与えられている。ノード $x_1$ と $x_2$ の位置を入れ替えて、入力順序 $(x_1, x_2, x_3)$ の BDD を求めよ。入替えの境界をまたぐ辺の行き先は、小さな真理値表で追跡すること。
8.24困難Hard難しい第二階Tier 2ティア 2E?R
以 Quine-McCluskey 表格法求函數 $f(x_1,\ldots,x_4) = \sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$ 的所有質蘊涵項。接著建立質蘊涵項覆蓋表,運用列與行的支配關係,選出最小成本的覆蓋。
Apply the Quine-McCluskey tabular method to find all prime implicants of the function $f(x_1,\ldots,x_4) = \sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$. Then construct the prime-implicant cover table, apply row and column dominance, and select a minimum-cost cover.
Quine-McCluskey の表法を用いて、関数 $f(x_1,\ldots,x_4) = \sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$ のすべての主項を求めよ。次に主項被覆表を作り、行と列の支配関係を適用して、最小コストの被覆を選べ。
8.28中等Medium普通第二階Tier 2ティア 2E?R
用 $\#$ 運算判斷圖 2.56 中函數的質蘊涵項 $\{x11, 0xx\}$ 何者為必須主項。請寫出明確的 $\#$ 計算過程,並說明結果非空所代表的意義。— 範例 8.14
Use the $\#$-operation to determine which of the prime implicants $\{x11, 0xx\}$ for the function in Figure 2.56 are essential. Show the explicit $\#$-computations and explain the significance of a non-empty result.— example 8.14
$\#$ 演算を用いて、図 2.56 の関数の主項 $\{x11, 0xx\}$ のうちどれが必須主項かを判定せよ。$\#$ の計算過程を明示し、結果が空でないことの意味を説明せよ。— 例題 8.14
8.32困難Hard難しい第二階Tier 2ティア 2E?R
對 $f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$ 施行函數分解(子函數取 $x_3$ 與 $x_4$)。逐步說明 $f$ 可化簡為 $f = \overline{x_3}\overline{x_4} + (x_1 + x_2)(x_3 + x_4)$。
Use functional decomposition (with subfunctions of $x_3$ and $x_4$) on $f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$. Show step-by-step that $f$ can be simplified to $f = \overline{x_3}\overline{x_4} + (x_1 + x_2)(x_3 + x_4)$.
$f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$ に($x_3$ と $x_4$ の部分関数を用いた)関数分解を適用せよ。$f$ が $f = \overline{x_3}\overline{x_4} + (x_1 + x_2)(x_3 + x_4)$ に簡単化できることを段階を追って示せ。
8.38困難Hard難しい第二階Tier 2ティア 2E?R
兩個串接的 4 輸入 LUT 可以實現 7 變數函數 $f(x_1,\ldots,x_7) = h[g(x_1,\ldots,x_4), x_5, x_6, x_7]$。請說明此結構能實現 $f = x_1 x_2 x_3 x_4 x_5 x_6 x_7$ 與 $f = x_1 + x_2 + \cdots + x_7$,但也論證存在無法只用兩個 4-LUT 實現的 7 變數函數。
Two cascaded 4-input LUTs can implement a 7-variable function $f(x_1,\ldots,x_7) = h[g(x_1,\ldots,x_4), x_5, x_6, x_7]$. Show that this structure can implement $f = x_1 x_2 x_3 x_4 x_5 x_6 x_7$ and $f = x_1 + x_2 + \cdots + x_7$, but argue that there exist 7-variable functions that cannot be realized with just two 4-LUTs.
縦続接続した 2 個の 4 入力 LUT は、7 変数関数 $f(x_1,\ldots,x_7) = h[g(x_1,\ldots,x_4), x_5, x_6, x_7]$ を実現できる。この構成で $f = x_1 x_2 x_3 x_4 x_5 x_6 x_7$ と $f = x_1 + x_2 + \cdots + x_7$ が実現できることを示し、一方で 4-LUT 2 個だけでは実現できない 7 変数関数が存在することを論じよ。
8.6中等Medium普通第二階Tier 2ティア 2?R
假設閘的最大扇入為 2,求 f(x₁,...,x₄) = Σm(0,3,4,7,9,10,13,14) 的最簡實現。
Find the simplest realization of f(x₁,...,x₄) = Σm(0,3,4,7,9,10,13,14) assuming gates have a maximum fan-in of 2.
ゲートの最大ファンインが 2 であるとして、f(x₁,...,x₄) = Σm(0,3,4,7,9,10,13,14) の最も簡単な実現を求めよ。
8.10中等Medium普通第二階Tier 2ティア 2?R
說明技術映射 (technology mapping) 如何把與技術無關的網表轉換成使用特定程式庫閘(例如標準單元庫)的網表。
Explain how technology mapping transforms a technology-independent netlist into one that uses specific library gates (e.g., from a standard cell library).
テクノロジマッピングが、テクノロジ非依存のネットリストを特定のライブラリゲート(たとえば標準セルライブラリ)を用いたネットリストへどのように変換するかを説明せよ。
8.13中等Medium普通第二階Tier 2ティア 2E?R
設計一個最小成本的合併電路,同時實現四變數的兩個函數 $f_1$ 與 $f_2$:$f_1$ 在 $x_1, x_2$ 至少有一個為 1 且 $x_3, x_4$ 兩者皆為 1 時 assert,或在 $x_1=x_2=0$ 且 $x_3, x_4$ 至少有一個為 1 時 assert;而 $f_2 = (x_1+x_2)(x_3+x_4)$。請用因式分解讓兩個輸出共用相同的子運算式。
Design a minimum-cost combined circuit for two functions $f_1$ and $f_2$ of four variables, where $f_1$ asserts when at least one of $x_1, x_2$ is 1 and both $x_3, x_4$ are 1, or when $x_1=x_2=0$ and at least one of $x_3, x_4$ is 1; and $f_2 = (x_1+x_2)(x_3+x_4)$. Use factoring to share common subexpressions across both outputs.
4 変数の 2 つの関数 $f_1$ と $f_2$ を実現する最小コストの共有回路を設計せよ。$f_1$ は、$x_1, x_2$ の少なくとも一方が 1 で $x_3, x_4$ がともに 1 のとき、または $x_1=x_2=0$ で $x_3, x_4$ の少なくとも一方が 1 のときにアサートされる。また $f_2 = (x_1+x_2)(x_3+x_4)$ である。因数分解を用いて、両方の出力で共通部分式を共有せよ。
8.14中等Medium普通第二階Tier 2ティア 2E?R
對 4 變數函數 $f = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\overline{x_3} x_4$ 施行函數分解。找出在卡諾圖多個行中重複出現的 2 變數子函數 $g(x_3,x_4)$,並用 $g$ 把 $f$ 改寫成多層電路。
Apply functional decomposition to the 4-variable function $f = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\overline{x_3} x_4$. Identify a 2-variable subfunction $g(x_3,x_4)$ that appears in multiple columns of the K-map and rewrite $f$ as a multilevel circuit using $g$.
4 変数関数 $f = x_1 x_3 \overline{x_4} + x_1 \overline{x_3} x_4 + \overline{x_2} x_3 \overline{x_4} + \overline{x_2}\overline{x_3} x_4$ に関数分解を適用せよ。カルノー図の複数の列に現れる 2 変数の部分関数 $g(x_3,x_4)$ を見つけ、$g$ を使って $f$ を多段回路として書き直せ。
8.15困難Hard難しい第二階Tier 2ティア 2E?R
A 5-variable function $f$ is given as a Karnaugh map (Figure 8.8a). By examining the rows and columns, find subfunctions $g(x_1,x_2,x_5)$ and $k(x_3,x_4)$ such that $f = h(g,k)$, then realize $f$ as a multilevel circuit and compare its cost to the minimum-cost SOP form.
背景:範例 8.3 — 藉由檢視 K-map 的列來做函數分解Context: Example 8.3 — functional decomposition by inspecting K-map rows背景:例 8.3 — カルノー図の行を観察して関数分解を行う

$f(x_1,x_2,x_3,x_4,x_5)$ 的卡諾圖 — 兩張 4×4 面板($x_5$ 每種取值各一張);欄由 $x_1 x_2$ 索引,列由 $x_3 x_4$ 索引:

The K-map of $f(x_1,x_2,x_3,x_4,x_5)$ — two 4×4 panels (one per value of $x_5$); columns indexed by $x_1 x_2$, rows by $x_3 x_4$:

$f(x_1,x_2,x_3,x_4,x_5)$ のカルノー図 — 4×4 のパネル 2 枚($x_5$ の値ごとに 1 枚)。列は $x_1 x_2$、行は $x_3 x_4$ で添字付けする:

$x_5 = 0$
$x_3 x_4$ \ $x_1 x_2$00011110
001000
01 ←0111
111000
10 ←0111
$x_5 = 1$
$x_3 x_4$ \ $x_1 x_2$00011110
000000
01 ←1111
110000
10 ←1111

步驟 1 — 觀察各列的樣式。每一列只相依於 $(x_1, x_2, x_5)$。出現兩種不同的樣式:

Step 1 — observe row patterns. Each row depends only on $(x_1, x_2, x_5)$. Two distinct patterns appear:

ステップ 1 — 行のパターンを観察する。各行は $(x_1, x_2, x_5)$ にしか依存しない。異なるパターンが 2 種類現れる:

  • 第 01 列與第 10 列(標示 ←):「$x_1, x_2, x_5$ 任一為 1 之處即為 1」→ $g(x_1,x_2,x_5) = x_1 + x_2 + x_5$
  • Rows 01 and 10 (marked ←): "1 wherever any of $x_1, x_2, x_5$ is 1" → $g(x_1,x_2,x_5) = x_1 + x_2 + x_5$
  • 行 01 と行 10(← 印):「$x_1, x_2, x_5$ のいずれかが 1 のところはすべて 1」→ $g(x_1,x_2,x_5) = x_1 + x_2 + x_5$
  • 第 00 列與第 11 列:互補的樣式,只有在 $x_1=x_2=x_5=0$ 時為 1 → $\overline{g}$
  • Rows 00 and 11: complementary pattern, 1 only at $x_1=x_2=x_5=0$ → $\overline{g}$
  • 行 00 と行 11:相補的なパターンで、$x_1=x_2=x_5=0$ のときだけ 1 → $\overline{g}$

步驟 2 — 判定哪些列屬於哪一種樣式。標「←」的那些列($x_3 x_4 = 01, 10$)正好就是 $x_3 \ne x_4$ 的情況。因此令 $k(x_3, x_4) = x_3 \oplus x_4$。

Step 2 — identify which rows have which pattern. The "←" rows ($x_3 x_4 = 01, 10$) are exactly the cases where $x_3 \ne x_4$. So let $k(x_3, x_4) = x_3 \oplus x_4$.

ステップ 2 — どの行がどのパターンかを見分ける。「←」の行($x_3 x_4 = 01, 10$)は、ちょうど $x_3 \ne x_4$ となる場合である。そこで $k(x_3, x_4) = x_3 \oplus x_4$ とおく。

Then: $k=1$ rows (01, 10) → $f = g$; $k=0$ rows (00, 11) → $f = \overline{g}$.

Step 3 — combine.

$$f = k\cdot g + \overline{k}\cdot \overline{g} = \overline{g \oplus k} = g \odot k$$

So $h(g, k) = g \odot k$ (XNOR).

Decomposed circuit:

x₁ x₂ x₅ OR g x₃ x₄ XOR k XNOR h(g,k) f

Cost comparison:

實現方式Realization実現方法閘數Gatesゲート数總輸入數Total inputs入力総数成本Costコスト
Multilevel: $f = g \odot k$, $g = x_1+x_2+x_5$, $k = x_3 \oplus x_4$3 (OR3, XOR2, XNOR2)3+2+2 = 710
直接求最小成本 SOP(約 16 個 1,沒有大矩形)Direct minimum-cost SOP (~16 ones, no large rectangles)直接の最小コスト SOP(1 が約 16 個、大きな矩形はない)~7–10 ANDs + 1 OR~25–30~35+

這個分解之所以划算,是因為卡諾圖中兩種列樣式各自相依於互斥的變數集合。課本給的啟示:卡諾圖上的空間規律(列或欄重複出現)代表有機會把某個子函數提取出來。

The decomposition pays off because the two K-map row patterns depend on disjoint variable sets. The textbook lesson: spatial regularity in the K-map (rows or columns repeating) signals an opportunity to factor out a subfunction.

この分解が効くのは、カルノー図の 2 種類の行パターンが互いに素な変数集合に依存しているからである。教科書の教訓:カルノー図に空間的な規則性(行や列の繰り返し)が見えたら、部分関数をくくり出せる好機である。

— example 8.3
8.17中等Medium普通第二階Tier 2ティア 2E?R
Convert the four-level AND-OR circuit in Figure 8.10a into (a) an equivalent NAND-only circuit and (b) an equivalent NOR-only circuit, by inserting bubble pairs and absorbing them into gates.
背景:範例 8.5 — 多層 AND/OR 電路的泡泡對轉換Context: Example 8.5 — bubble-pair conversion of multi-level AND/OR circuits背景:例題 8.5 — 多段 AND/OR 回路のバブルペア変換

訣竅。在一條連線上加兩個反相器(一組「泡泡對」)— 邏輯上兩者互相抵消,因此電路的函數不變。接著把每個泡泡吸收進該連線某一端的閘,依 DeMorgan 定理把 AND/OR 閘轉成 NAND/NOR 閘。

The trick. Add two inverters (a "bubble pair") on a wire — logically they cancel, so the circuit's function is unchanged. Then absorb each bubble into the gate at one end of the wire, converting AND/OR gates into NAND/NOR gates by DeMorgan's theorem.

仕掛け。1 本の配線にインバータを 2 個(「バブルペア」)挿入する — 論理的には打ち消し合うので、回路の関数は変わらない。次に各バブルを配線の一端のゲートに吸収させ、DeMorgan の定理によって AND/OR ゲートを NAND/NOR ゲートに変換する。

DeMorgan equivalences (the engine):

$$\overline{a \cdot b} = \overline{a} + \overline{b} \qquad \overline{a + b} = \overline{a} \cdot \overline{b}$$

Reading this as gate symbols:

原始閘Original gateもとのゲート= 等效= equivalent= 等価用來建構Use to build構成に使う
AND with output bubbleNANDNAND-only
OR with input bubblesNAND (by DeMorgan)NAND-only
OR with output bubbleNORNOR-only
AND with input bubblesNOR (by DeMorgan)NOR-only

轉換步驟。走遍電路中的每一條連線並加上泡泡對,讓每個閘都具備它所需的泡泡樣式:

The conversion recipe. Walk every wire in the circuit and add a bubble-pair so that each gate has the bubble pattern it needs:

変換の手順。回路のすべての配線をたどり、各ゲートが必要とするバブル配置になるようバブルペアを加える:

  • 只用 NAND 時:每個 AND 加上輸出泡泡,每個 OR 加上輸入泡泡。相鄰兩個閘共用一條連線時,兩個泡泡會在中間相遇並互相抵消 — 該連線又變回乾淨的訊號。此時每一個閘都具備成為 NAND 所需的泡泡樣式。
  • For NAND-only: every AND gets an output bubble; every OR gets input bubbles. When two adjacent gates share a wire, their bubbles meet in the middle and cancel — that wire becomes a clean signal again. Every gate now has the right bubble pattern to be a NAND.
  • NAND のみにする場合:すべての AND に出力バブルを、すべての OR に入力バブルを付ける。隣り合う 2 つのゲートが 1 本の配線を共有すると、両者のバブルが中間で出会って打ち消し合い、その配線はまた素の信号に戻る。これですべてのゲートが NAND となるバブル配置になる。
  • 只用 NOR 時:每個 OR 加上輸出泡泡,每個 AND 加上輸入泡泡。同樣以逐條連線抵消的論證 — 此時每個閘都是 NOR。
  • For NOR-only: every OR gets an output bubble; every AND gets input bubbles. Same wire-by-wire cancellation argument — every gate is now a NOR.
  • NOR のみにする場合:すべての OR に出力バブルを、すべての AND に入力バブルを付ける。配線ごとに打ち消し合うという同じ議論により、これで各ゲートは NOR になる。

剩下的部分:主要輸入與最終輸出上可能留有配不到對的泡泡,無法與其他閘的泡泡成對抵消。每個殘留的泡泡都以獨立的反相器實作 — 而反相器可以用輸入接在一起的 NAND(或 NOR)來做:

What's left over: primary inputs and the final output may have an unmatched bubble that doesn't pair up with another gate's bubble. Each leftover bubble is implemented as a separate inverter — which can be a NAND (or NOR) with its inputs tied together:

余るもの:主入力と最終出力には、他のゲートのバブルと対にならない未対応のバブルが残ることがある。余ったバブルはそれぞれ独立したインバータとして実装する — 入力どうしを結んだ NAND(または NOR)で作れる:

$$\text{NAND}(x, x) = \overline{x \cdot x} = \overline{x} \qquad \text{NOR}(x, x) = \overline{x + x} = \overline{x}$$

因此最終電路清一色由 NAND(或 NOR)閘構成,不需要其他種類的閘。

So the final circuit is uniformly NAND (or NOR) gates, no other gate types needed.

したがって最終的な回路は一様に NAND(または NOR)ゲートだけとなり、他の種類のゲートは要らない。

以課本的 4 層電路逐步示範:

Step-by-step on the textbook's 4-level circuit:

教科書の 4 段回路で手順を追う:

  1. 從圖 8.10a 開始(AND/OR/AND/OR 交替的層級,輸入為 $x_1$–$x_7$)。
  2. Start with Figure 8.10a (alternating AND/OR/AND/OR levels with inputs $x_1$–$x_7$).
  3. 図 8.10a から始める(AND/OR/AND/OR が交互に並ぶ段構成、入力は $x_1$–$x_7$)。
  4. 在每一條內部連線插入泡泡對,使每個 AND 都有輸出泡泡、每個 OR 都有輸入泡泡(圖 8.10b 以藍色標示)。
  5. Insert bubble pairs on every internal wire so every AND has an output bubble + every OR has input bubbles (Figure 8.10b shows these in blue).
  6. 内部配線すべてにバブルペアを挿入し、各 AND に出力バブル、各 OR に入力バブルが付くようにする(図 8.10b では青で示されている)。
  7. 把泡泡吸收進閘中:此時每個閘的符號都符合 NAND。
  8. Absorb bubbles into gates: every gate symbol now matches NAND.
  9. バブルをゲートに吸収させる:これで各ゲートの記号は NAND と一致する。
  10. 輸入 $x_1, x_5, x_6, x_7$ 與輸出 $f$ 上殘留的泡泡,變成以 NAND 當反相器的單元。
  11. Leftover bubbles at inputs $x_1, x_5, x_6, x_7$ and at output $f$ become NAND-as-inverter cells.
  12. 入力 $x_1, x_5, x_6, x_7$ と出力 $f$ に残ったバブルは、NAND をインバータとして使うセルになる。
  13. 結果:圖 8.10c — 一個功能與原電路完全相同、且只用 NAND 的電路。
  14. Result: Figure 8.10c — a NAND-only circuit functionally identical to the original.
  15. 結果は図 8.10c — もとの回路と機能が同一で、NAND だけからなる回路である。

要轉成只用 NOR(圖 8.11),把規則對調:OR 加輸出泡泡,AND 加輸入泡泡。$x_2, x_3, x_4$ 上殘留的泡泡變成以 NOR 當反相器的單元(圖 8.11b)。

For NOR-only conversion (Figure 8.11), swap the rules: ORs get output bubbles, ANDs get input bubbles. Leftover bubbles at $x_2, x_3, x_4$ become NOR-as-inverter cells (Figure 8.11b).

NOR のみへの変換(図 8.11)では規則を入れ替える:OR に出力バブル、AND に入力バブルを付ける。$x_2, x_3, x_4$ に残ったバブルは NOR をインバータとして使うセルになる(図 8.11b)。

泡泡抵消的小示例:

Tiny illustration of the bubble cancellation:

バブルが打ち消し合う様子の小さな図示:

Original: a, b → AND OR → f + pair: a, b → NAND ↳ bubbles cancel NAND → f

中間連線上的兩個泡泡互相抵消;帶輸出泡泡的 AND 就是 NAND;帶輸入泡泡的 OR 也是 NAND(由 DeMorgan 定理)。函數相同,卻是全 NAND 的實現。

The two bubbles on the middle wire cancel; the AND with output-bubble is a NAND; the OR with input-bubbles is also a NAND (by DeMorgan). Same function, all-NAND realization.

中間の配線にある 2 つのバブルは打ち消し合う。出力バブル付きの AND は NAND であり、入力バブル付きの OR も(DeMorgan により)NAND である。関数は同じで、実現は全 NAND となる。

— example 8.5
8.18中等Medium普通第二階Tier 2ティア 2E?R
Determine the function $f$ implemented by the multilevel AND-OR circuit in Figure 8.12 by labeling internal nodes and tracing from output to inputs. Express $f$ in two-level SOP form and compute its gate cost.
背景:範例 8.6 — 以節點標記分析多層電路Context: Example 8.6 — analyzing a multilevel circuit by node labeling背景:例題 8.6 — ノードにラベルを付けて多段回路を解析する

策略:替每一條內部連線取一個名稱($P_1, P_2, \ldots$),寫出每個閘輸出處的函數,再逐步代回,得到以主要輸入表示的 $f$。

The strategy: label every internal wire with a name ($P_1, P_2, \ldots$), write the function at each gate output, then substitute back to get $f$ in terms of the primary inputs.

方針:内部配線すべてに名前($P_1, P_2, \ldots$)を付け、各ゲート出力での関数を書き、順に代入し戻して主入力による $f$ を得る。

圖 8.12 — 該電路(深度 4 層,AND/OR 交替,輸入為 $x_1$–$x_7$):

Figure 8.12 — the circuit (4 levels deep, AND/OR alternation, inputs $x_1$–$x_7$):

図 8.12 — 対象の回路(深さ 4 段、AND/OR 交互、入力は $x_1$–$x_7$):

x₁ x₂ x₃ x₄ x₅ x₆ x₇ AND P₁ OR P₃ OR P₂ AND P₄ OR P₅ AND f

從輸入往前推:  $P_1 = x_2 x_3$, $P_2 = x_5 + x_6$, $P_3 = x_1 + P_1 = x_1 + x_2 x_3$, $P_4 = x_4 P_2 = x_4(x_5+x_6)$, $P_5 = P_4 + x_7 = x_4(x_5+x_6) + x_7$, 於是得到 $f = P_3 \cdot P_5 = (x_1 + x_2 x_3)\bigl(x_4(x_5+x_6) + x_7\bigr)$。

Trace from inputs forward:  $P_1 = x_2 x_3$,  $P_2 = x_5 + x_6$,  $P_3 = x_1 + P_1 = x_1 + x_2 x_3$,  $P_4 = x_4 P_2 = x_4(x_5+x_6)$,  $P_5 = P_4 + x_7 = x_4(x_5+x_6) + x_7$,  giving $f = P_3 \cdot P_5 = (x_1 + x_2 x_3)\bigl(x_4(x_5+x_6) + x_7\bigr)$.

入力側から順にたどる:  $P_1 = x_2 x_3$、 $P_2 = x_5 + x_6$、 $P_3 = x_1 + P_1 = x_1 + x_2 x_3$、 $P_4 = x_4 P_2 = x_4(x_5+x_6)$、 $P_5 = P_4 + x_7 = x_4(x_5+x_6) + x_7$、 これより $f = P_3 \cdot P_5 = (x_1 + x_2 x_3)\bigl(x_4(x_5+x_6) + x_7\bigr)$ となる。

兩層 SOP 形式(分配律): $f = x_1 x_4 x_5 + x_1 x_4 x_6 + x_1 x_7 + x_2 x_3 x_4 x_5 + x_2 x_3 x_4 x_6 + x_2 x_3 x_7$。

Two-level SOP form (distributive law):  $f = x_1 x_4 x_5 + x_1 x_4 x_6 + x_1 x_7 + x_2 x_3 x_4 x_5 + x_2 x_3 x_4 x_6 + x_2 x_3 x_7$.

2 レベル SOP 形式(分配則): $f = x_1 x_4 x_5 + x_1 x_4 x_6 + x_1 x_7 + x_2 x_3 x_4 x_5 + x_2 x_3 x_4 x_6 + x_2 x_3 x_7$。

共 6 個乘積項,輸入文字合計 25 個(3+3+2+4+4+3),再加上一個 6 輸入的 OR。

6 product terms, total 25 input literals (3+3+2+4+4+3) plus the 6-input OR.

積項は 6 個、入力リテラルは合計 25 個(3+3+2+4+4+3)で、さらに 6 入力の OR が 1 つ加わる。

Cost comparison:

形式Form形式閘數Gatesゲート数總輸入數Total inputs入力総数成本Costコスト延遲Delay遅延
Multilevel (Figure 8.12)6 (P₁,P₂ + P₃,P₄ + P₅ + f)2+2+2+2+2+2 = 12184 gate-delays
Two-level SOP7 (six ANDs + one OR)3+3+2+4+4+3 + 6 = 25322 gate-delays

取捨:多層形式的閘成本較低,但深度較深(較慢);兩層形式較快,但成本較高。多層最佳化基本上就是面積與速度之間的一個旋鈕。

Trade-off: the multilevel form has lower gate cost but more depth (slower); the two-level form is faster but more expensive. Multilevel optimization is mostly an area-vs-speed knob.

トレードオフ:多段形式はゲートコストが低い一方で段数が深く(遅く)なり、2 レベル形式は速いがコストが高い。多段最適化は、面積と速度を調整するつまみのようなものである。

— example 8.6
8.19中等Medium普通第二階Tier 2ティア 2E?R
針對例題 8.3 所導出的多層電路(其中 XOR/XNOR 已換成等效的 SOP),標記內部節點,並沿電路推導出輸出的 SOP 運算式。驗證其與原規格相符。— 範例 8.3
For the multilevel circuit derived in Example 8.3 (with the XOR/XNOR replaced by SOP equivalents), label the internal nodes and derive the SOP expression for the output by tracing the circuit. Verify it matches the original specification.— example 8.3
例題 8.3 で導いた多段回路(XOR/XNOR を等価な SOP で置き換えたもの)について、内部ノードにラベルを付け、回路をたどって出力の SOP 式を導け。それがもとの仕様と一致することを確かめよ。— 例題 8.3
8.21中等Medium普通第二階Tier 2ティア 2E?R
分析由 NAND 閘與 NOR 閘混合組成的電路(圖 8.15):標記中間節點 $P_1$ 到 $P_4$ 並套用迪摩根定理。將結果化簡為 $f = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$。— 範例 8.9
Analyze a circuit consisting of a mixture of NAND and NOR gates (Figure 8.15) by labeling intermediate nodes $P_1$ to $P_4$ and applying DeMorgan's theorem. Reduce the result to $f = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$.— example 8.9
NAND ゲートと NOR ゲートが混在する回路(図 8.15)を、中間ノードに $P_1$ から $P_4$ までのラベルを付け、ド・モルガンの定理を適用して解析せよ。結果を $f = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$ まで簡単化せよ。— 例題 8.9
8.23困難Hard難しい第二階Tier 2ティア 2E?R
以輸入順序 $x_1, x_2, x_3, x_4$ 建構 $f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$ 的 BDD:依序對 $x_1$ 與 $x_2$ 施行 Shannon 展開,並合併相同的子圖。再用該 BDD 推導出多層的 SOP 運算式。
Construct the BDD for $f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$ with input order $x_1, x_2, x_3, x_4$, by applying Shannon's expansion successively on $x_1$ and $x_2$ and merging identical subgraphs. Use the BDD to derive a multilevel SOP expression.
入力順序 $x_1, x_2, x_3, x_4$ で $f = x_1 x_3 + x_1 x_4 + x_2 x_4 + x_2 x_3 + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$ の BDD を、$x_1$、$x_2$ の順に Shannon 展開を適用し、同一の部分グラフを併合して構成せよ。得られた BDD から多段の SOP 式を導け。
8.25困難Hard難しい第二階Tier 2ティア 2E?R
對 $f(x_1,\ldots,x_4) = \sum m(0,3,10,15) + D(1,2,7,8,11,14)$,以表格法產生所有質蘊涵項。建立覆蓋表,觀察到其中既沒有必須主項、也沒有列或行的支配關係,因而改用分枝法求出最小成本的覆蓋。
For $f(x_1,\ldots,x_4) = \sum m(0,3,10,15) + D(1,2,7,8,11,14)$, generate all prime implicants tabularly. Build the cover table, observe that there are no essential prime implicants and no row/column dominance, and use branching to find a minimum-cost cover.
$f(x_1,\ldots,x_4) = \sum m(0,3,10,15) + D(1,2,7,8,11,14)$ について、表法ですべての主項を生成せよ。被覆表を作ると、必須主項も行・列の支配も存在しないことがわかる。そこで分岐法を用いて最小コストの被覆を求めよ。
8.27困難Hard難しい第二階Tier 2ティア 2E?R
已知某 4 變數函數的初始覆蓋 $C_0=\{0101, 1101, 1110, 011x, x01x\}$,用 $\star$-乘積運算導出所有質蘊涵項。以代數形式列出所得的乘積項。
Given the initial cover $C_0=\{0101, 1101, 1110, 011x, x01x\}$ for a 4-variable function, use the $\star$-product operation to derive all prime implicants. List the resulting product terms in algebraic form.
ある 4 変数関数の初期被覆 $C_0=\{0101, 1101, 1110, 011x, x01x\}$ が与えられている。$\star$ 積演算を用いてすべての主項を導け。得られた積項を代数形式で列挙せよ。
8.29困難Hard難しい第二階Tier 2ティア 2E?R
某 4 變數函數沒有 don't-care,其質蘊涵項集合為 $P=\{x01x, x101, 01x1, 0x1x, xx10\}$。用 $\#$ 運算找出所有必須主項,並對每個必須蘊涵項給出可證明它為必須的立方體。
For the prime-implicant set $P=\{x01x, x101, 01x1, 0x1x, xx10\}$ of a 4-variable function with no don't-cares, use the $\#$-operation to identify all essential prime implicants. Show the cube that demonstrates each essential implicant.
don't-care のない 4 変数関数の主項集合 $P=\{x01x, x101, 01x1, 0x1x, xx10\}$ について、$\#$ 演算を用いてすべての必須主項を求めよ。各必須主項について、それが必須であることを示すキューブを挙げよ。
8.30困難Hard難しい第二階Tier 2ティア 2E?R
對 5 變數函數 $f(x_1,\ldots,x_5)=\sum m(0,1,4,8,13,15,20,21,23,26,31)+D(5,10,24,28)$ 套用完整的立方體最小化程序(以 $\star$-乘積求質蘊涵項、以 $\#$ 運算找必須主項,再進行分枝)。給出最小成本的 SOP 運算式。
Apply the complete cubical minimization procedure ($\star$-product to find prime implicants, $\#$-operation to find essential ones, then branching) to the 5-variable function $f(x_1,\ldots,x_5)=\sum m(0,1,4,8,13,15,20,21,23,26,31)+D(5,10,24,28)$. Provide the minimum-cost SOP expression.
5 変数関数 $f(x_1,\ldots,x_5)=\sum m(0,1,4,8,13,15,20,21,23,26,31)+D(5,10,24,28)$ に、キューブによる最小化手続き一式($\star$ 積で主項を求め、$\#$ 演算で必須主項を求め、そのうえで分岐する)を適用せよ。最小コストの SOP 式を示せ。
8.33中等Medium普通第二階Tier 2ティア 2E?R
以輸入順序 $x_1, x_2, x_3, x_4$ 建構 $f = x_1 x_3 + x_2 x_4$ 的 BDD:先對 $x_1$ 施行 Shannon 展開,再在其中一個餘因子內對 $x_2$ 展開。
Construct a BDD for $f = x_1 x_3 + x_2 x_4$ with input order $x_1, x_2, x_3, x_4$ by applying Shannon's expansion first on $x_1$ and then on $x_2$ within one of the cofactors.
入力順序 $x_1, x_2, x_3, x_4$ で $f = x_1 x_3 + x_2 x_4$ の BDD を、まず $x_1$ について、続いて一方のコファクタの中で $x_2$ について Shannon 展開を適用して構成せよ。
8.34中等Medium普通第二階Tier 2ティア 2E?R
已知順序為 $x_1, x_2, x_3, x_4$ 的 $f = x_1 x_3 + x_2 x_4$ 之 BDD。交換內層的 $x_2$ 與 $x_3$ 兩層,導出輸入順序為 $x_1, x_3, x_2, x_4$ 的 BDD。請用真值表追蹤跨越交換邊界的邊之目的地。
Given the BDD for $f = x_1 x_3 + x_2 x_4$ with order $x_1, x_2, x_3, x_4$, derive a BDD with input order $x_1, x_3, x_2, x_4$ by swapping the inner $x_2$ and $x_3$ levels. Use a truth table to track the destinations of edges crossing the swap boundary.
順序 $x_1, x_2, x_3, x_4$ の $f = x_1 x_3 + x_2 x_4$ の BDD が与えられている。内側の $x_2$ と $x_3$ のレベルを入れ替えて、入力順序 $x_1, x_3, x_2, x_4$ の BDD を導け。入替えの境界をまたぐ辺の行き先は真理値表で追跡すること。
8.35困難Hard難しい第二階Tier 2ティア 2E?R
用表格法為 $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$(don't-care 為 $D=(9,12,14)$)推導最小成本的 SOP 運算式。列出所有產生的立方體以及覆蓋表的化簡過程。
Use the tabular method to derive a minimum-cost SOP expression for $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$ with don't-cares $D=(9,12,14)$. Show all generated cubes and the cover-table reduction.
表法を用いて、don't-care が $D=(9,12,14)$ である $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$ の最小コスト SOP 式を導け。生成したキューブすべてと被覆表の縮約過程を示せ。
8.36困難Hard難しい第二階Tier 2ティア 2E?R
用 $\star$-乘積運算求 $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$(don't-care 為 $D=(9,12,14)$)的所有質蘊涵項。列出逐次的覆蓋 $C_0, C_1, C_2, \ldots$ 直到收斂為止。
Use the $\star$-product operation to find all prime implicants of $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$ with don't-cares $D=(9,12,14)$. Show the successive covers $C_0, C_1, C_2, \ldots$ until convergence.
$\star$ 積演算を用いて、don't-care が $D=(9,12,14)$ である $f(x_1,\ldots,x_4) = \overline{x_1}\overline{x_3}\overline{x_4} + \overline{x_3}x_4 + x_1\overline{x_2}x_4 + x_1\overline{x_2}\overline{x_3}x_4$ のすべての主項を求めよ。収束するまでの被覆 $C_0, C_1, C_2, \ldots$ を順に示せ。
8.37困難Hard難しい第二階Tier 2ティア 2E?R
For the function in Examples 8.23 and 8.24, compare three implementation strategies: (a) minimum-cost SOP, (b) minimum-cost POS, and (c) a multilevel factored realization. Compute the gate-and-input cost of each and discuss the area-vs-delay trade-off.
Context: the function from Examples 8.23 / 8.24

The function:

$$f(x_1,x_2,x_3,x_4) = \sum m(0,1,3,4,7,11,13,15) + D(9,12,14)$$

K-map (4-variable, columns $x_3 x_4$, rows $x_1 x_2$, $d$ = don't-care):

$x_1 x_2$ \ $x_3 x_4$00011110
001 (m₀)1 (m₁)1 (m₃)0
011 (m₄)01 (m₇)0
11$d$ (m₁₂)1 (m₁₃)1 (m₁₅)$d$ (m₁₄)
100$d$ (m₉)1 (m₁₁)0

範例 8.23 以 Quine–McCluskey 表格法推導最小成本 SOP。選出的覆蓋為 $C = \{0x00,\ x0x1,\ xx11,\ 1xx1\}$,得到

Example 8.23 uses the Quine–McCluskey tabular method to derive a minimum-cost SOP. The selected cover is $C = \{0x00,\ x0x1,\ xx11,\ 1xx1\}$, giving

例題 8.23 では Quine–McCluskey の表法で最小コスト SOP を導く。選ばれた被覆は $C = \{0x00,\ x0x1,\ xx11,\ 1xx1\}$ であり、これより

$$f_\text{SOP} = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + \overline{x_2}\,x_4 + x_3\,x_4 + x_1\,x_4$$

範例 8.24 對同一個函數使用 *-product 運算,導出質蘊涵項的完整集合 $P = \{x_1\overline{x_3}\overline{x_4},\ \overline{x_3}\overline{x_4},\ \overline{x_1}\overline{x_2}\overline{x_3},\ \overline{x_2}x_3\overline{x_4},\ \overline{x_2}x_4,\ x_1 x_4,\ x_1 x_2\}$ — 以另一種演算法印證了相同的最小覆蓋。

Example 8.24 uses the *-product operation on the same function and derives the full set of prime implicants $P = \{x_1\overline{x_3}\overline{x_4},\ \overline{x_3}\overline{x_4},\ \overline{x_1}\overline{x_2}\overline{x_3},\ \overline{x_2}x_3\overline{x_4},\ \overline{x_2}x_4,\ x_1 x_4,\ x_1 x_2\}$ — confirming the same minimum cover from a different algorithm.

例題 8.24 では同じ関数に *-product 演算を適用し、主項の完全な集合 $P = \{x_1\overline{x_3}\overline{x_4},\ \overline{x_3}\overline{x_4},\ \overline{x_1}\overline{x_2}\overline{x_3},\ \overline{x_2}x_3\overline{x_4},\ \overline{x_2}x_4,\ x_1 x_4,\ x_1 x_2\}$ を導く — 別のアルゴリズムから同じ最小被覆が確認される。

習題 8.37 要求的內容:對同一個函數計算三種實現方式並比較成本。

What problem 8.37 asks: compute three realizations of this same function and compare costs.

問題 8.37 が求めること:同じ関数について 3 通りの実現を求め、コストを比較する。

(a) Minimum-cost SOP (from Example 8.23):

$$f = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + \overline{x_2}\,x_4 + x_3\,x_4 + x_1\,x_4$$

閘:4 個 AND(3 輸入 × 1、2 輸入 × 3)+ 1 個 OR(4 輸入)。輸入:$3+2+2+2 = 9$(AND)+ 4(OR)= 13。成本 = 5 個閘 + 13 個輸入 = 18。

Gates: 4 ANDs (3-input × 1, 2-input × 3) + 1 OR (4-input). Inputs: $3+2+2+2 = 9$ (AND) + 4 (OR) = 13. Cost = 5 gates + 13 inputs = 18.

ゲート:AND 4 個(3 入力 × 1、2 入力 × 3)+ OR 1 個(4 入力)。入力:$3+2+2+2 = 9$(AND)+ 4(OR)= 13。コスト = ゲート 5 + 入力 13 = 18。

(b) 最小成本 POS — 由 off-set 推導($f=0$ 出現在最小項 2、5、6、8、10;並利用 D=9,12,14 來擴大乘積群組)。以卡諾圖把 0 分群即得最大項覆蓋,例如

(b) Minimum-cost POS — derive from the off-set ($f=0$ at minterms 2, 5, 6, 8, 10; with D=9,12,14 used to enlarge product groups). K-map grouping of zeros yields the maxterm cover, e.g.

(b) 最小コスト POS — オフセットから導く(最小項 2, 5, 6, 8, 10 で $f=0$。D=9,12,14 を使って積のグループを大きくする)。カルノー図で 0 をまとめると最大項による被覆が得られる。たとえば

$$f_\text{POS} = (x_2 + x_3 + x_4)\,(\overline{x_1} + x_4)\,(\overline{x_2} + x_4 + \overline{x_3})$$

(確切的覆蓋取決於 don't-care 的指定方式;這是其中一組有效的最小覆蓋。)閘:3 個 OR(3 輸入 × 3)+ 1 個 AND(3 輸入)。輸入:$3+3+3 = 9$(OR)+ 3(AND)= 12。成本 = 4 個閘 + 12 個輸入 = 16。

(Exact cover depends on don't-care assignment; this is one valid minimum cover.) Gates: 3 ORs (3-input × 3) + 1 AND (3-input). Inputs: $3+3+3 = 9$ (OR) + 3 (AND) = 12. Cost = 4 gates + 12 inputs = 16.

(厳密な被覆は don't-care の与え方によって変わる。これは有効な最小被覆の一例である。)ゲート:OR 3 個(3 入力 × 3)+ AND 1 個(3 入力)。入力:$3+3+3 = 9$(OR)+ 3(AND)= 12。コスト = ゲート 4 + 入力 12 = 16。

(c) 多層因式分解實現 — 從 SOP 出發,把共同文字 $x_4$ 提出來:

(c) Multilevel factored realization — start from the SOP and factor out the common literal $x_4$:

(c) 多段の因数分解による実現 — SOP から出発し、共通リテラル $x_4$ をくくり出す:

$$f = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_4\,(\overline{x_2} + x_3 + x_1)$$

閘:1 個 AND3($\overline{x_1}\overline{x_3}\overline{x_4}$)、1 個 OR3($\overline{x_2}+x_3+x_1$)、1 個 AND2($x_4 \cdot $ 上述 OR)、1 個 OR2(最後一層)。輸入:$3 + 3 + 2 + 2 = 10$。成本 = 4 個閘 + 10 個輸入 = 14。

Gates: 1 AND3 ($\overline{x_1}\overline{x_3}\overline{x_4}$), 1 OR3 ($\overline{x_2}+x_3+x_1$), 1 AND2 ($x_4 \cdot $ above OR), 1 OR2 (final). Inputs: $3 + 3 + 2 + 2 = 10$. Cost = 4 gates + 10 inputs = 14.

ゲート:AND3 が 1 個($\overline{x_1}\overline{x_3}\overline{x_4}$)、OR3 が 1 個($\overline{x_2}+x_3+x_1$)、AND2 が 1 個($x_4 \cdot $ 上の OR)、OR2 が 1 個(最終段)。入力:$3 + 3 + 2 + 2 = 10$。コスト = ゲート 4 + 入力 10 = 14。

Comparison:

形式Form形式閘數Gatesゲート数輸入Inputs入力成本Costコスト延遲Delay遅延
(a) Min SOP513182 (AND→OR)
(b) Min POS412162 (OR→AND)
(c) Multilevel factored410143 (OR→AND→OR)

取捨:SOP 與 POS 都是兩層形式 — 只有 2 個閘延遲,最快 — 但代價是閘數較多。多層因式分解可把成本降低約 22%,卻多出一個閘延遲,因為訊號要多穿過一層邏輯。多層形式划不划算取決於製程的時序預算:在時脈較慢的 FPGA 結構中,面積的節省佔上風;在關鍵路徑吃緊的 ASIC 資料路徑上,兩層形式在深度上的優勢可能更重要。

Trade-off: SOP and POS are two-level — fastest at 2 gate-delays — but pay in gate count. Multilevel factored cuts cost by ~22% but adds one extra gate-delay because the signal traverses an extra logic level. Whether the multilevel form wins depends on the technology timing budget: in slow-clock FPGA fabric, area savings dominate; in critical-path ASIC datapaths, the two-level form's depth advantage may matter more.

トレードオフ:SOP と POS はどちらも2 レベルであり、ゲート遅延 2 段でもっとも速いが、ゲート数を代償として払う。多段の因数分解形式はコストを約 22% 削減する一方、信号が余分な論理段を通るぶんゲート遅延が 1 段増える。多段形式が有利かどうかは実装技術のタイミング予算次第である。クロックの遅い FPGA ファブリックでは面積の節約が効き、クリティカルパスの厳しい ASIC のデータパスでは 2 レベル形式の段数の少なさのほうが効いてくることもある。

— example 8.23
8.39困難Hard難しい第二階Tier 2ティア 2?R
對 5 變數函數 f = Σm(0,2,3,5,7,8,10,11,14,15,24,26,27,29,31) 套用 Quine-McCluskey 法。求出所有質蘊涵項與一組最小覆蓋。
Apply the Quine-McCluskey method to a 5-variable function: f = Σm(0,2,3,5,7,8,10,11,14,15,24,26,27,29,31). Find all prime implicants and a minimum cover.
5 変数関数 f = Σm(0,2,3,5,7,8,10,11,14,15,24,26,27,29,31) に Quine-McCluskey 法を適用せよ。すべての主項と最小被覆を 1 つ求めよ。
8.40中等Medium普通第二階Tier 2ティア 2?R
只用 NOR 閘實作 8.2 的同一個電路。
Implement the same circuit from 8.2 using only NOR gates.
8.2 と同じ回路を NOR ゲートだけで実装せよ。
8.41中等Medium普通第二階Tier 2ティア 2?R
說明邏輯函數的立方體表示法。把函數 f = x̄₁x₂ + x₁x̄₃ 表示成一組立方體。
Explain the cubical representation of logic functions. Represent the function f = x̄₁x₂ + x₁x̄₃ as a set of cubes.
論理関数のキューブ表現について説明せよ。関数 f = x̄₁x₂ + x₁x̄₃ をキューブの集合として表せ。
8.42中等Medium普通第二階Tier 2ティア 2?R
Given f = x₃x₅ + x₁x₂x₄ + x̄₁x₂x̄₄ + x₁x̄₃x₄ + x₁x₃x̄₄ + x₁x̄₂x₅ + x̄₁x₂x₅, derive a minimum-cost multilevel circuit.
8.43中等Medium普通第二階Tier 2ティア 2?R
推導 f(x₁,...,x₄) = Σm(4,7,8,11) + D(12,15) 的最小成本 SOP 實作與最小成本因式分解形式。比較兩者的成本。
Derive the minimum-cost SOP implementation and the minimum-cost factored form for f(x₁,...,x₄) = Σm(4,7,8,11) + D(12,15). Compare costs.
f(x₁,...,x₄) = Σm(4,7,8,11) + D(12,15) の最小コスト SOP 実装と最小コストの因数分解形を導け。両者のコストを比較せよ。
8.44簡單Easy易しい第二階Tier 2ティア 2?R
在立方體表示法的脈絡下,定義下列名詞:文字 (literal)、立方體 (cube)、覆蓋 (cover)、質蘊涵項 (prime implicant)、必須主項 (essential prime implicant)。
Define the terms: literal, cube, cover, prime implicant, essential prime implicant in the context of cubical representation.
キューブ表現の文脈で、リテラル (literal)、キューブ (cube)、被覆 (cover)、主項 (prime implicant)、必須主項 (essential prime implicant) の各用語を定義せよ。
8.45中等Medium普通第二階Tier 2ティア 2?R
在 Quine-McCluskey 法中,說明「不再合併」勾記的作用,以及如何用質蘊涵項表選出最終的覆蓋。
In the Quine-McCluskey method, explain the role of the "don't combine" check mark and how the prime implicant chart is used to select the final cover.
Quine-McCluskey 法において、「これ以上組み合わせない」を示すチェック印が果たす役割と、主項表を使って最終的な被覆を選ぶ方法を説明せよ。
8.46中等Medium普通第二階Tier 2ティア 2?R
為什麼變數順序對 BDD 很重要?對於函數 f = x₁x₂ + x₃x₄ + x₅x₆,你預期哪一種順序會產生較小的 BDD:交錯 (x₁<x₃<x₅<x₂<x₄<x₆) 還是分組 (x₁<x₂<x₃<x₄<x₅<x₆)?
Why is variable ordering important in BDDs? For the function f = x₁x₂ + x₃x₄ + x₅x₆, which ordering would you expect to produce a smaller BDD: interleaved (x₁<x₃<x₅<x₂<x₄<x₆) or grouped (x₁<x₂<x₃<x₄<x₅<x₆)?
BDD において変数順序が重要なのはなぜか。関数 f = x₁x₂ + x₃x₄ + x₅x₆ について、より小さい BDD になると予想されるのはどちらの順序か:インタリーブ (x₁<x₃<x₅<x₂<x₄<x₆) か、グループ化 (x₁<x₂<x₃<x₄<x₅<x₆) か。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

8.47困難Hard難しい第三階Tier 3ティア 3?R
建立質蘊涵項表並找出最小覆蓋,以完成習題 8.3。
Complete exercise 8.3 by constructing the prime implicant chart and finding a minimum cover.
主項表を作って最小被覆を求め、演習 8.3 を仕上げよ。
8.48困難Hard難しい第三階Tier 3ティア 3?R
說明 n 位元加法器進位輸出的 BDD,在某一種變數順序下大小是 n 的多項式,換成另一種順序卻是指數級。請以 n=3 為例展示。
Show that the BDD for an n-bit adder's carry-out is polynomial in n with one variable ordering but exponential with another. Demonstrate for n=3.
n ビット加算器の桁上げ出力の BDD が、ある変数順序では n の多項式規模になり、別の順序では指数規模になることを示せ。n=3 で実演せよ。
8.49困難Hard難しい第三階Tier 3ティア 3?R
假設輸入只能取得未取補數的形式,求 f(x₁,...,x₄) = Σm(0,4,8,13,14,15) 的最小成本電路。請使用函數分解。
Find the minimum-cost circuit for f(x₁,...,x₄) = Σm(0,4,8,13,14,15) assuming inputs are available in uncomplemented form only. Use functional decomposition.
入力が非反転形でしか得られないものとして、f(x₁,...,x₄) = Σm(0,4,8,13,14,15) の最小コスト回路を求めよ。関数分解を用いること。
8.50困難Hard難しい第三階Tier 3ティア 3?R
給定一個標準單元庫,內含 2 輸入 NAND(成本 2)、2 輸入 NOR(成本 2)、反相器(成本 1)與 3 輸入 NAND(成本 3)。請把函數 f = ab + cd 映射到此程式庫,使總成本最小。
Given a standard cell library with 2-input NAND (cost 2), 2-input NOR (cost 2), inverter (cost 1), and 3-input NAND (cost 3), map the function f = ab + cd to minimize total cost.
2 入力 NAND(コスト 2)、2 入力 NOR(コスト 2)、インバータ(コスト 1)、3 入力 NAND(コスト 3)からなる標準セルライブラリが与えられている。関数 f = ab + cd を、総コストが最小になるようこのライブラリへマッピングせよ。
8.51困難Hard難しい第三階Tier 3ティア 3?R
分析多層電路:t₁ = a + bt₂ = c·dt₃ = t₁·ef = t₂ + t₃。推導攤平後的 SOP 運算式,再在扇入限制為 2 的條件下重新因式分解,以求最小成本。
Analyze the multilevel circuit: t₁ = a + b, t₂ = c·d, t₃ = t₁·e, f = t₂ + t₃. Derive the flattened SOP expression, then re-factor for minimum cost with a fan-in constraint of 2.
多段回路 t₁ = a + bt₂ = c·dt₃ = t₁·ef = t₂ + t₃ を解析せよ。平坦化した SOP 式を導き、次にファンインを 2 に制限したうえで、最小コストになるよう因数分解し直せ。

第 9 章 — 非同步電路Chapter 9 — Asynchronous Circuits第 9 章 — 非同期回路

第二階 · 中等Tier 2 · Midティア 2 · 中級

9.7中等Medium普通第二階Tier 2ティア 2?R
針對合併後的流程表,說明「相容狀態」與「合併圖」的概念。如何用合併圖判斷哪些狀態可以共用同一列?
For the merged flow table, explain the concepts of "compatible states" and "merger diagram." How is the merger diagram used to determine which states can share a row?
併合したフロー表について、「両立状態」と「マージャ図」の概念を説明せよ。どの状態が同じ行を共有できるかを判断するのに、マージャ図はどのように使われるのか。
9.11中等Medium普通第二階Tier 2ティア 2?R
什麼是必要冒險 (essential hazard)?它與靜態冒險、動態冒險有何不同?能否靠加入冗餘閘來消除?
What is an essential hazard? How does it differ from static and dynamic hazards? Can it be eliminated by adding redundant gates?
本質ハザード (essential hazard) とは何か。静的ハザードや動的ハザードとどう違うのか。冗長なゲートを追加することで除去できるか。
9.13中等Medium普通第二階Tier 2ティア 2E?R
把閘控 D 閂鎖當作非同步循序電路來分析。將時脈 $C$ 視為輸入之一,推導下一狀態運算式 $Y = CD + \overline{C}y$、激勵表、流程表以及對應的狀態圖。
Analyze the gated D latch as an asynchronous sequential circuit. Derive the next-state expression $Y = CD + \overline{C}y$, the excitation table, the flow table, and the corresponding state diagram, treating the clock $C$ as one of the inputs.
ゲート付き D ラッチを非同期順序回路として解析せよ。クロック $C$ を入力の 1 つとみなし、次状態式 $Y = CD + \overline{C}y$、励振表、フロー表、および対応する状態遷移図を導け。
9.18困難Hard難しい第二階Tier 2ティア 2E?R
用交握 (handshake) 訊號設計一個簡單的雙裝置非同步仲裁器。輸入為請求訊號 $r_1, r_2$,輸出為授權訊號 $g_1, g_2$。請給出含三個狀態(閒置、已授權給 1、已授權給 2)的 Moore 狀態圖、一個用來避免對角轉移的額外不穩定狀態,以及修改後的流程表。
Design a simple two-device asynchronous arbiter using handshake signaling. Inputs are request signals $r_1, r_2$ and outputs are grant signals $g_1, g_2$. Provide a Moore state diagram with three states (idle, granted-1, granted-2), an extra unstable state to avoid a diagonal transition, and the modified flow table.
ハンドシェイク信号を用いた簡単な 2 デバイスの非同期アービタを設計せよ。入力は要求信号 $r_1, r_2$、出力は許可信号 $g_1, g_2$ である。3 状態(待機、1 番に許可、2 番に許可)の Moore 状態遷移図、対角遷移を避けるための余分な不安定状態、および修正したフロー表を示せ。
9.2中等Medium普通第二階Tier 2ティア 2?R
分析下列非同步電路:兩個交叉耦合的 NOR 閘,外部輸入為 x₁ 與 x₂。推導其流程表,並指出所有穩定狀態與不穩定狀態。
Analyze the following asynchronous circuit: two cross-coupled NOR gates with external inputs x₁ and x₂. Derive the flow table identifying all stable and unstable states.
次の非同期回路を解析せよ:外部入力 x₁ と x₂ をもつ、たすき掛け接続された 2 個の NOR ゲート。フロー表を導き、安定状態と不安定状態をすべて示せ。
9.10中等Medium普通第二階Tier 2ティア 2?R
從速度、功耗、可測試性與設計工作量四方面,比較同步設計與非同步設計的優缺點。
Compare the advantages and disadvantages of synchronous vs. asynchronous design in terms of speed, power, testability, and design effort.
速度、消費電力、テスト容易性、設計工数の観点から、同期設計と非同期設計の長所と短所を比較せよ。
9.16困難Hard難しい第二階Tier 2ティア 2E?R
設計一個串列同位產生器,做成具有輸入 $w$ 與輸出 $z$ 的非同步 Moore FSM:當 $w$ 上出現奇數個脈衝時 $z=1$。用四個狀態處理每個脈衝的兩個邊緣,選一組漢明距離為 1 的無競爭狀態指派,並推導下一狀態與輸出運算式。
Design a serial parity generator as an asynchronous Moore FSM with input $w$ and output $z$ such that $z=1$ if an odd number of pulses has appeared on $w$. Use four states to handle both edges of each pulse, choose a race-free state assignment with Hamming distance 1, and derive the next-state and output expressions.
入力 $w$、出力 $z$ をもつ非同期 Moore FSM として直列パリティ生成器を設計せよ。$w$ に現れたパルスの個数が奇数のとき $z=1$ とする。各パルスの両方のエッジを扱うために状態を 4 つ用い、ハミング距離 1 の競合のない状態割当てを選び、次状態式と出力式を導け。
9.22困難Hard難しい第二階Tier 2ティア 2E?R
Reduce the 8-row flow table of Figure 9.43 to a 2-state Mealy FSM by applying the partitioning procedure followed by row merging. Show the merger diagram and the resulting reduced flow table.
背景:範例 9.10 — 8 列的原始流程表縮減為 2 狀態的 Mealy FSMContext: Example 9.10 — 8-row primitive table reduced to 2-state Mealy FSM背景:例題 9.10 — 8 行の原始表を 2 状態の Mealy FSM に縮小する

設定。圖 9.43 是一張 8 列的原始流程表,描述一個類 Moore 的非同步 FSM。輸入為 $w_2 w_1$,列為 $A$–$H$,輸出 $z$ 逐列不同。令人意外的結論是:這張 8 列的表經過分割與合併,可以一路縮到只剩 2 個狀態,但結果是一個 Mealy FSM(部分輸出不只相依於狀態,還相依於輸入)。

Setup. Figure 9.43 is an 8-row primitive flow table for an asynchronous Moore-like FSM. Inputs $w_2 w_1$, rows $A$–$H$, output $z$ varies per row. The dramatic claim: this 8-row table reduces all the way down to just 2 states via partitioning + merger, but the result is a Mealy FSM (some output depends on input not just state).

設定。図 9.43 は非同期の Moore 型に近い FSM の 8 行原始フロー表である。入力は $w_2 w_1$、行は $A$–$H$、出力 $z$ は行ごとに異なる。驚くべき主張は、この 8 行の表が分割と併合によってわずか 2 状態まで縮むというものである。ただし結果は Mealy FSM になる(一部の出力が状態だけでなく入力にも依存する)。

階段 1 — 分割。先依輸出分組,再依下一狀態的後繼細分:

Stage 1 — Partitioning. Group by output and refine by next-state successors:

段階 1 — 分割。まず出力でグループ分けし、次状態の後継で細分する:

$$P_1 = (AF)(BEG)(C)(D)(H) \qquad P_2 = (AF)(BE)(G)(C)(D)(H) \qquad P_3 = P_2$$

因此分割這一步證明了 $A \equiv F$ 與 $B \equiv E$。把 $F$ 換成 $A$、$E$ 換成 $B$ → 得到 6 列的表(課本中的圖 9.44):

So the partitioning step proves $A \equiv F$ and $B \equiv E$. Replace $F$ with $A$ and $E$ with $B$ → 6-row table (Figure 9.44 in the textbook):

したがって分割の段階で $A \equiv F$ と $B \equiv E$ が示される。$F$ を $A$ に、$E$ を $B$ に置き換えると → 6 行の表(教科書の図 9.44)になる:

狀態State状態$w_2w_1$=00=01=10=11$z$
AABC0
BABH0
CACH0
DDGC1
GDGH0
HGCH1

階段 2 — 合併圖。建一張圖,每一列是一個頂點,每一組相容的列對(下一狀態的項目沒有衝突;Mealy 輸出相容)是一條邊。由圖 9.45:

Stage 2 — Merger diagram. Build a graph where each row is a vertex and each compatible pair (no conflicting next-state entries; Mealy-output compatibility) is an edge. From Figure 9.45:

段階 2 — マージャ図。各行を頂点とし、両立する行対(次状態の欄に矛盾がなく、Mealy 出力として両立する)を辺とするグラフを作る。図 9.45 より:

  • $A$、$B$、$C$ 形成一個團 → 可以全部合併成一個新狀態(稱之為 $A$)
  • $A$, $B$, $C$ form a clique → can all merge into a single new state (call it $A$)
  • $A$、$B$、$C$ はクリークをなす → すべて 1 つの新しい状態に併合できる(これを $A$ と呼ぶ)
  • $D$、$G$、$H$ 形成一個團 → 合併成一個新狀態(稱之為 $D$)
  • $D$, $G$, $H$ form a clique → merge into a single new state (call it $D$)
  • $D$、$G$、$H$ はクリークをなす → 1 つの新しい状態に併合する(これを $D$ と呼ぶ)

兩個團涵蓋了全部 6 個頂點 → 總共 2 個狀態。

Two cliques cover all 6 vertices → 2 states total.

2 つのクリークで 6 頂点すべてを覆える → 状態は合計 2 つ。

為什麼輸出不同卻仍能塌縮成 2 個狀態:合併後的 $\{D, G, H\}$ 同時含有 $z=1$ 的狀態($D, H$)與一個 $z=0$ 的狀態($G$)。在 Mealy FSM 中這沒有問題 — 此時輸出是合併後狀態加上當前輸入的函數($z$ 取決於在該輸入下你表現得像哪一個「子列」)。在合併後的那一列中,每個輸入欄位都繼承在該處達到穩定的那個原始列的輸出。穩定狀態的輸出保留下來;不穩定轉移的輸出則變成 Mealy 輸出。

Why this can collapse to 2 states even though outputs differ: the merge $\{D, G, H\}$ contains states with $z=1$ ($D, H$) and one with $z=0$ ($G$). That's fine in a Mealy FSM — the output is then a function of the merged state plus current input ($z$ depends on which "sub-row" you're acting like for that input). Within the merged row, each input column inherits the output from whichever original row stable-stated there. The stable-state outputs survive; the unstable-transition outputs become Mealy outputs.

出力が違うのに 2 状態まで潰せる理由:併合された $\{D, G, H\}$ には $z=1$ の状態($D, H$)と $z=0$ の状態($G$)が混ざっている。Mealy FSM ならそれで構わない — 出力は併合後の状態と現在の入力の関数になる($z$ は、その入力に対してどの「部分行」として振る舞っているかで決まる)。併合された行では、各入力列がそこで安定していたもとの行の出力を引き継ぐ。安定状態の出力はそのまま残り、不安定な遷移の出力が Mealy 出力になる。

Resulting 2-state Mealy table (Figure 9.46):

狀態State状態$w_2w_1$=00=01=10=11$z$ on (00, 01, 10, 11)
A {ABC}AAAD000
D {DGH}DDAD101

啟示:原始流程表看起來大得嚇人,但底層的狀態轉移圖往往幾乎微不足道。兩步驟的縮減(分割 + 合併)就能取出最少狀態的實現。在合併階段從 Moore 的框架改採 Mealy 的框架是常見的技巧 — 它放寬了輸出必須相等的限制,解開原本被卡住的合併。

The lesson: primitive flow tables look intimidatingly large, but the underlying state-transition graph is often almost trivial. Two-step reduction (partition + merger) extracts the minimum-state realization. Switching from Moore to Mealy framing during merger is a common trick — it relaxes the output-equality constraint and unlocks merges that would otherwise be blocked.

教訓:原始フロー表は見た目こそ圧倒されるほど大きいが、その背後にある状態遷移図はほとんど自明なことが多い。2 段階の縮小(分割 + 併合)で最小状態の実現が取り出せる。併合の際に Moore の枠組みから Mealy の枠組みに切り替えるのはよくある技であり、出力が等しいという制約を緩めて、そうでなければ塞がれていた併合を可能にする。

— example 9.10
9.26困難Hard難しい第二階Tier 2ティア 2E?R
For a 4-state asynchronous FSM (Figure 9.55) whose transition diagram requires transitions between every pair of states, introduce three extra unstable states $E, F, G$ to enable a race-free 3-bit state assignment on a 3-cube. Modify the flow table to include the new states and derive the excitation table.
背景:範例 9.14 — 加入額外的不穩定狀態以嵌入 3-cubeContext: Example 9.14 — adding extra unstable states to embed on a 3-cube文脈:例題 9.14 — 3-cube に埋め込むために不安定状態を追加する

圖 9.55a — 原始的 4 狀態 Moore 流程表

Figure 9.55a — original 4-state Moore flow table:

図 9.55a — もとの 4 状態 Moore フロー表

狀態State状態$w_2 w_1$=00=01=10=11$z_2 z_1$
AAACB00
BABDB01
CCBCD10
DCADD11

問題所在:把 8 個穩定格編號 1–8 並追蹤各次轉移後可以發現,任意一對狀態之間都有直接轉移 — A↔B、A↔C、A↔D、B↔C、B↔D、C↔D。2-cube 只有 4 個頂點與 4 條邊,因此沒有任何 2 位元指派能讓全部 6 對都達到漢明距離 1。2-cube 嵌入不可能成立。

The trouble: labeling the 8 stable cells 1–8 and tracing transitions reveals every pair of states has a direct transition — A↔B, A↔C, A↔D, B↔C, B↔D, C↔D. A 2-cube has only 4 vertices and 4 edges, so no 2-bit assignment can give all 6 pairs Hamming distance 1. 2-cube embedding is impossible.

問題点:8 個の安定セルに 1–8 の番号を付けて遷移をたどると、どの状態対にも直接の遷移があることが分かる — A↔B、A↔C、A↔D、B↔C、B↔D、C↔D。2-cube は頂点 4 個と辺 4 本しかないので、6 対すべてをハミング距離 1 にできる 2 ビット割当ては存在しない。2-cube への埋め込みは不可能である。

解法:改用 3-cube。3 個狀態位元可提供 8 個頂點;其中 4 個給原本的狀態,3 個給新的不穩定中間頂點,用來打斷那些無法實現的直接路徑。

The fix: move to a 3-cube. Three state bits give 8 vertices; we use 4 for the original states and 3 for new unstable intermediate vertices that break the impossible direct paths.

対策:3-cube に移る。状態ビットが 3 本なら頂点は 8 個になる。そのうち 4 個をもとの状態に、3 個を実現不可能な直接経路を断ち切る新しい不安定な中間頂点に使う。

步驟 1 — 挑一組基礎指派:$A=000$、$B=001$、$C=100$、$D=010$。位於 cube 邊上的直接對(漢明距離 1):

Step 1 — pick a base assignment: $A=000$, $B=001$, $C=100$, $D=010$. Direct cube-edge pairs (Hamming-1):

ステップ 1 — 基本の割当てを選ぶ:$A=000$、$B=001$、$C=100$、$D=010$。cube の辺で直接つながる対(ハミング距離 1):

  • A↔B (000↔001) ✓ ; A↔C (000↔100) ✓ ; A↔D (000↔010) ✓
  • B↔D (001↔010) ✗ — distance 2; need intermediate
  • B↔C (001↔100) ✗ — distance 2; need intermediate
  • C↔D (100↔010) ✗ — distance 2; need intermediate

步驟 2 — 在每一條長路徑上插入不穩定頂點:

Step 2 — insert unstable vertices on each long path:

ステップ 2 — 各長経路に不安定な頂点を挿入する:

長路徑Long path長い経路中間頂點Intermediate vertex中間頂点編碼Code符号子路徑(各為漢明距離 1)Sub-paths (each Hamming-1)部分経路(各ハミング距離 1)
B ↔ DE011B(001)→E(011)→D(010)
B ↔ CF101B(001)→F(101)→C(100)
C ↔ DG110C(100)→G(110)→D(010)

The 8th vertex 111 stays unused.

步驟 3 — 修改流程表。只要某個轉移原本會跨過一條長路徑,就把它改繞經對應的中間狀態。例如輸入 $w_2w_1=10$ 時的 B→D,現在變成 B→E(B 列的下一狀態為 E);而 E 的設定是輸入仍為 10 時 E→D(E 列的下一狀態為 D)。表格增為 7 列,但新增的項目全都是「暫態格」,對任何輸入都不穩定。

Step 3 — modify the flow table. Whenever a transition would have crossed a long path, redirect it through the matching intermediate. For example, B→D on input $w_2w_1=10$ now becomes B→E (next-state E in row B); E is set up so that with input still 10, E→D (next-state D in row E). The table grows to 7 rows but the new entries are all "transit cells" that aren't stable for any input.

ステップ 3 — フロー表を修正する。長経路をまたぐことになる遷移は、対応する中間状態を経由するよう振り替える。たとえば入力 $w_2w_1=10$ での B→D は B→E(行 B の次状態が E)となり、E は入力が 10 のままなら E→D(行 E の次状態が D)となるように設定する。表は 7 行に増えるが、新しい項目はいずれもどの入力に対しても安定でない「通過セル」である。

步驟 4 — 推導激勵表。有了 3 個狀態變數 $y_3 y_2 y_1$,就依上述指派為每一個(狀態、輸入)格寫出下一狀態碼 $Y_3 Y_2 Y_1$。接著把這些激勵項目畫成卡諾圖,即可求得下一狀態邏輯,用來驅動回到狀態位元閂鎖/正反器的三條回授迴路。

Step 4 — derive the excitation table. With 3 state variables $y_3 y_2 y_1$, write the next-state codes $Y_3 Y_2 Y_1$ for every (state, input) cell using the assignment above. The excitation entries can then be K-mapped to obtain the next-state logic, which drives the three feedback loops back to the state-bit latches/flip-flops.

ステップ 4 — 励振表を導く。状態変数 3 本 $y_3 y_2 y_1$ を用い、上の割当てに従って各(状態、入力)セルの次状態符号 $Y_3 Y_2 Y_1$ を書き出す。得られた励振項目をカルノー図にかければ次状態論理が求まり、これが状態ビットのラッチ/フリップフロップへ戻る 3 本の帰還ループを駆動する。

What problem 9.26 asks specifically:

  1. 找出 6 對狀態中哪幾對需要中間狀態(即 3 條長路徑)。
  2. Identify which of the 6 state-pairs need intermediates (the 3 long paths).
  3. 6 つの状態対のうち、どれに中間状態が必要か(3 本の長経路)を特定する。
  4. 選一組 3-cube 指派,讓每個狀態各佔一個相異頂點,並使所有必要的狀態對之間都存在單一位元變化的路徑(上面那組指派就是一個可行解)。
  5. Choose a 3-cube assignment that puts each state on a distinct vertex and provides single-bit-change paths between all required pairs (the assignment above is one valid solution).
  6. 各状態を別々の頂点に置き、必要なすべての対の間に 1 ビット変化の経路がある 3-cube 割当てを選ぶ(上の割当てはその一例である)。
  7. 在流程表中插入 E、F、G 作為不穩定的暫態列。
  8. Insert E, F, G as unstable transit rows in the flow table.
  9. フロー表に E、F、G を不安定な通過行として挿入する。
  10. 為修改後的 7 列流程表建立激勵表(下一狀態的二進位碼)。
  11. Build the excitation table (next-state binary codes) for the 7-row modified flow table.
  12. 修正後の 7 行のフロー表について励振表(次状態の 2 進符号)を作る。

為什麼這很重要:在非同步設計中,無競爭的狀態指派是必要條件 — 若兩個狀態位元同時改變,FSM 可能會短暫造訪某個非預期的 cube 頂點,而該頂點本身在錯誤的列上是穩定狀態,電路便可能因此卡死。把每一次多位元轉移拆成經由暫態狀態的單一位元跳躍,任何時刻就只會有一個位元改變,競爭也就不可能發生。

Why this matters: race-free state assignments are mandatory in asynchronous design — if two state bits change simultaneously, the FSM may briefly visit an unintended cube vertex, which is itself a stable state in the wrong row, and the circuit can deadlock. By breaking every multi-bit transition into single-bit hops through transit states, only one bit ever changes at a time and races become impossible.

これが重要な理由:非同期設計では競合のない状態割当ては必須である — 状態ビットが 2 本同時に変化すると、FSM は意図しない cube の頂点を一瞬訪れることがあり、その頂点は誤った行における安定状態そのものなので、回路がデッドロックしうる。多ビットの遷移をすべて通過状態を経由する 1 ビットずつのホップに分解すれば、変化するビットは常に 1 本だけとなり、競合は起こり得なくなる。

— example 9.14
9.31中等Medium普通第二階Tier 2ティア 2E?R
Derive the flow table of an asynchronous circuit (Figure 9.76) by extracting next-state expressions $Y_1 = w_1\overline{w_2} + \overline{w_2}y_1 + w_1 y_1 \overline{y_2}$ and $Y_2 = w_2 + w_1 y_1 + w_1 y_2$, and output $z = y_2$. Construct the excitation table and resolve safe-race transitions in which both state variables change simultaneously.
背景:範例 9.19 — 從電路逆推流程表Context: Example 9.19 — reverse-engineering a flow table from a circuit文脈:例題 9.19 — 回路からフロー表を逆算する

該電路(圖 9.76)實現一個非同步 FSM,狀態變數為 $y_1, y_2$,輸入為 $w_1, w_2$,輸出為 $z$。邏輯式: $Y_1 = w_1\overline{w_2} + \overline{w_2}\,y_1 + w_1 y_1 \overline{y_2}$、 $Y_2 = w_2 + w_1 y_1 + w_1 y_2$、 $z = y_2$。

The circuit (Figure 9.76) realizes an asynchronous FSM with state variables $y_1, y_2$, inputs $w_1, w_2$, output $z$. Logic:  $Y_1 = w_1\overline{w_2} + \overline{w_2}\,y_1 + w_1 y_1 \overline{y_2}$,  $Y_2 = w_2 + w_1 y_1 + w_1 y_2$,  $z = y_2$.

この回路(図 9.76)は、状態変数 $y_1, y_2$、入力 $w_1, w_2$、出力 $z$ をもつ非同期 FSM を実現する。論理式は $Y_1 = w_1\overline{w_2} + \overline{w_2}\,y_1 + w_1 y_1 \overline{y_2}$、 $Y_2 = w_2 + w_1 y_1 + w_1 y_2$、 $z = y_2$。

圖 9.76 — 非同步 SOP 電路(範例 9.19)Figure 9.76 — asynchronous SOP circuit (Example 9.19)図 9.76 — 非同期 SOP 回路(例 9.19) w1 w2 y1 y2 w̄2 ȳ2 A1 A2 A3 OR Y1 A4 A5 OR Y2 OR Y1 Δ y1 Δ y2 z Δ = 閘延遲(依圖 9.8 建模);狀態變數 y1、y2 回授到 AND 閘輸入。Δ = gate delay (modeled per Figure 9.8); state variables y1, y2 fed back to AND-gate inputs.Δ = ゲート遅延(図 9.8 に従いモデル化)。状態変数 y1、y2 は AND ゲート入力へ帰還する。

步驟 1 — 建立激勵表。對 $(y_2 y_1, w_2 w_1)$ 的每一組組合,計算下一狀態碼 $(Y_2 Y_1)$ 與輸出 $z$:

Step 1 — build the excitation table. For each combination of $(y_2 y_1, w_2 w_1)$, evaluate the next-state codes $(Y_2 Y_1)$ and the output $z$:

ステップ 1 — 励振表を作る。$(y_2 y_1, w_2 w_1)$ の各組合せについて、次状態符号 $(Y_2 Y_1)$ と出力 $z$ を求める:

$y_2 y_1$ \ $w_2 w_1$00011011$z$
00000110100
01010110110
10001010101
11111110111

步驟 2 — 找出穩定狀態。當且僅當該輸入下 $(Y_2 Y_1) = (y_2 y_1)$ 時,該格為穩定。把它們標示出來(在下面圖 9.77 的流程表形式中以粗體表示)。每一列對應一個現態碼。

Step 2 — identify stable states. A cell is stable iff $(Y_2 Y_1) = (y_2 y_1)$ for that input. Mark them (bold below in Figure 9.77's flow-table form). Each row corresponds to a present-state code.

ステップ 2 — 安定状態を見つける。あるセルが安定であるのは、その入力に対して $(Y_2 Y_1) = (y_2 y_1)$ となるとき、かつそのときに限る。それらに印を付ける(下の図 9.77 のフロー表形式では太字)。各行は現状態の符号に対応する。

步驟 3 — 為狀態命名。把每個二進位碼換成字母:$A = 00$、$B = 01$、$C = 10$、$D = 11$。於是:

Step 3 — name the states. Replace each binary code with a letter: $A = 00$, $B = 01$, $C = 10$, $D = 11$. Then:

ステップ 3 — 状態に名前を付ける。各 2 進符号を文字に置き換える:$A = 00$、$B = 01$、$C = 10$、$D = 11$。すると:

狀態State状態00011011$z$
A (00)ABCC0
B (01)BBCD0
C (10)ACCC1
D (11)DDCD1

步驟 4 — 檢查安全競爭的轉移。當一次輸入變化使兩個狀態變數同時改變時,就發生「競爭」。從激勵表中找出 $Y_2$ 與 $Y_1$ 都與現值 $y_2$、$y_1$ 不同的格。例如:

Step 4 — check for safe-race transitions. A "race" occurs when both state variables change simultaneously in response to one input change. From the excitation table, identify cells where both $Y_2$ and $Y_1$ differ from the present $y_2$ and $y_1$. Examples:

ステップ 4 — 安全な競合の遷移を確かめる。1 回の入力変化に対して 2 つの状態変数が同時に変わるとき、「競合」が起こる。励振表から、$Y_2$ と $Y_1$ の両方が現在の $y_2$、$y_1$ と異なるセルを探す。例:

  • $y_2 y_1 = 01, w_2 w_1 = 11$:下一狀態是 $11$ — 兩個位元都改變($y_2: 0\to 1$、$y_1: 1\to 1$?其實這裡只有 $y_2$ 改變,所以是單一位元)。每個項目都要仔細檢查。
  • $y_2 y_1 = 01, w_2 w_1 = 11$: next is $11$ — both bits change ($y_2: 0\to 1$, $y_1: 1\to 1$? actually only $y_2$ changes here, so single-bit). Inspect each entry carefully.
  • $y_2 y_1 = 01, w_2 w_1 = 11$:次は $11$ — 両方のビットが変わる($y_2: 0\to 1$、$y_1: 1\to 1$? 実際にはここで変わるのは $y_2$ だけなので 1 ビット変化である)。各項目を注意深く調べること。
  • $y_2 y_1 = 11, w_2 w_1 = 10$:下一狀態是 $10$ — 只有 $y_1$ 改變,屬單一位元。安全。
  • $y_2 y_1 = 11, w_2 w_1 = 10$: next is $10$ — only $y_1$ changes, single-bit. Safe.
  • $y_2 y_1 = 11, w_2 w_1 = 10$:次は $10$ — 変わるのは $y_1$ だけで 1 ビット変化。安全である。

定義:安全競爭。若不論哪個狀態變數先改變,FSM 最終都會安定在正確的穩定狀態,這樣的競爭就是「安全的」(非關鍵)。若中間狀態在同一輸入下也是穩定的,該競爭就是關鍵的(不安全)— 電路可能卡住。課本通常以列表方式處理這類分析題:把每一次多位元轉移逐一列出,並驗證所有單一位元變化的路徑都收斂到相同的目的地。

Definition: safe race. A race is "safe" (non-critical) if the FSM eventually settles in the correct stable state regardless of which state variable changes first. A race is critical (unsafe) if intermediate states are stable for the same input — the circuit may get stuck. The textbook usually solves the analysis problem by tabulating each multi-bit transition and verifying that all single-bit-change paths converge to the same destination.

定義:安全な競合。どちらの状態変数が先に変わっても FSM が最終的に正しい安定状態に落ち着くなら、その競合は「安全」(非臨界)である。同じ入力に対して中間状態も安定であれば、その競合は臨界(危険)であり、回路が動かなくなることがある。教科書ではふつう、多ビットの遷移を一つずつ表にし、1 ビット変化の経路がすべて同じ行き先に収束することを確かめて、この解析問題を解く。

What problem 9.31 asks:

  1. 把 $w$ 與 $y$ 的值代入 $Y_1$ 與 $Y_2$,填出激勵表。
  2. Plug $w$ and $y$ values into $Y_1$ and $Y_2$ to fill the excitation table.
  3. $w$ と $y$ の値を $Y_1$ と $Y_2$ に代入して励振表を埋める。
  4. 轉換成標上名稱的流程表;找出穩定格。
  5. Convert to a labeled flow table; identify stable cells.
  6. ラベル付きのフロー表に変換し、安定セルを見つける。
  7. 檢查每一個多位元變化的格是否具備競爭安全性。
  8. Check every multi-bit-change cell for race safety.
  9. 多ビット変化のセルすべてについて競合の安全性を確かめる。
  10. 確認輸出 $z = y_2$ 在每一列都符合預期行為。
  11. Confirm output $z = y_2$ matches expected behavior in each row.
  12. 出力 $z = y_2$ が各行で期待どおりの動作になっていることを確認する。
— example 9.19
9.3中等Medium普通第二階Tier 2ティア 2?R
非同步電路中的穩定狀態與不穩定狀態有何差異?請以流程表為例說明。
What is the difference between a stable state and an unstable state in an asynchronous circuit? Illustrate with a flow table example.
非同期回路における安定状態と不安定状態の違いは何か。フロー表の例を用いて説明せよ。
9.5中等Medium普通第二階Tier 2ティア 2?R
x₁=x₃=1x₂ 由 1 變為 0 時,指出運算式 f = x₁x₂ + x̄₂x₃ 中的靜態 1 冒險。要如何消除它?
Identify the static 1-hazard in the expression f = x₁x₂ + x̄₂x₃ when x₁=x₃=1 and x₂ changes from 1 to 0. How can it be eliminated?
x₁=x₃=1x₂ が 1 から 0 へ変化するとき、式 f = x₁x₂ + x̄₂x₃ に生じる静的 1 ハザードを指摘せよ。どうすれば除去できるか。
9.8中等Medium普通第二階Tier 2ティア 2?R
說明 f(x₁,x₂,x₃) = Σm(1,2,3,5,7) 的無冒險 SOP 電路,必須在最小 SOP 之外再加一個乘積項。請用卡諾圖指出所需的項。
Show that a hazard-free SOP circuit for f(x₁,x₂,x₃) = Σm(1,2,3,5,7) requires an additional product term beyond the minimum SOP. Identify the required term using a K-map.
f(x₁,x₂,x₃) = Σm(1,2,3,5,7) のハザードフリーな SOP 回路には、最小 SOP に加えてもう 1 つ積項が必要であることを示せ。必要となる項をカルノー図で指摘せよ。
9.9中等Medium普通第二階Tier 2ティア 2?R
分析由方程式 Y₁ = x̄₁(x₂ + y₁)Y₂ = x₁(x̄₂ + y₂) 所描述的非同步電路。推導其流程表並指出所有穩定狀態。
Analyze an asynchronous circuit given by the equations Y₁ = x̄₁(x₂ + y₁) and Y₂ = x₁(x̄₂ + y₂). Derive the flow table and identify all stable states.
Y₁ = x̄₁(x₂ + y₁)Y₂ = x₁(x̄₂ + y₂) で与えられる非同期回路を解析せよ。フロー表を導き、安定状態をすべて示せ。
9.14困難Hard難しい第二階Tier 2ティア 2E?R
把主從式 D 正反器(兩個串接的閘控 D 閂鎖)當作非同步循序電路來分析。推導下一狀態運算式 $Y_m = CD + \overline{C}y_m$ 與 $Y_s = Cy_m + \overline{C}y_s$、四狀態的激勵表,以及對應的流程表 $S_1$ 至 $S_4$。
Analyze a master-slave D flip-flop (two cascaded gated D latches) as an asynchronous sequential circuit. Derive the next-state expressions $Y_m = CD + \overline{C}y_m$ and $Y_s = Cy_m + \overline{C}y_s$, the four-state excitation table, and the corresponding flow table $S_1$ through $S_4$.
マスタスレーブ D フリップフロップ(縦続接続したゲート付き D ラッチ 2 個)を非同期順序回路として解析せよ。次状態式 $Y_m = CD + \overline{C}y_m$ と $Y_s = Cy_m + \overline{C}y_s$、4 状態の励振表、および対応するフロー表 $S_1$ から $S_4$ までを導け。
9.15困難Hard難しい第二階Tier 2ティア 2E?R
分析由 $Y_1 = y_1 \overline{y_2} + w_1 \overline{y_2} + w_1 \overline{w_2} y_1$、$Y_2 = y_1 y_2 + w_1 y_2 + w_2 + \overline{w_1}\overline{w_2}\overline{y_1}$ 與 $z = y_1 \overline{y_2}$ 所定義的非同步電路。推導激勵表、流程表與狀態圖,並辨認出此電路是一個簡單的雙硬幣販賣機控制器。
Analyze the asynchronous circuit defined by $Y_1 = y_1 \overline{y_2} + w_1 \overline{y_2} + w_1 \overline{w_2} y_1$, $Y_2 = y_1 y_2 + w_1 y_2 + w_2 + \overline{w_1}\overline{w_2}\overline{y_1}$, and $z = y_1 \overline{y_2}$. Derive the excitation table, flow table, and a state diagram, and recognize the circuit as a simple two-coin vending machine controller.
$Y_1 = y_1 \overline{y_2} + w_1 \overline{y_2} + w_1 \overline{w_2} y_1$、$Y_2 = y_1 y_2 + w_1 y_2 + w_2 + \overline{w_1}\overline{w_2}\overline{y_1}$、$z = y_1 \overline{y_2}$ で定義される非同期回路を解析せよ。励振表、フロー表、状態図を導き、この回路が単純な 2 枚コインの自動販売機コントローラであることを見抜け。
9.17困難Hard難しい第二階Tier 2ティア 2E?R
設計一個非同步的 modulo-4 上數計數器,計數輸入 $w$ 上的脈衝。使用八個狀態(四個脈衝的每個邊緣各一個),選擇一種狀態指派使所有轉移都只變動一個狀態變數,並推導下一狀態式 $Y_1, Y_2, Y_3$ 與輸出式 $z_2, z_1$。
Design an asynchronous modulo-4 up-counter that counts pulses on input $w$. Use eight states (one for each edge of four pulses), choose a state assignment so that all transitions involve a single state-variable change, and derive next-state expressions $Y_1, Y_2, Y_3$ and output expressions $z_2, z_1$.
入力 $w$ 上のパルスを数える非同期の modulo-4 アップカウンタを設計せよ。8 つの状態(4 発のパルスの各エッジに 1 つずつ)を用い、すべての遷移が状態変数 1 個の変化で済むような状態割当てを選び、次状態式 $Y_1, Y_2, Y_3$ と出力式 $z_2, z_1$ を導け。
9.19困難Hard難しい第二階Tier 2ティア 2E?R
Reduce the primitive flow table for a candy-vending machine that accepts nickels and dimes and dispenses when 10 cents is reached (Figure 9.26b). Apply the partitioning procedure first, then merge compatible rows to obtain the optimized 4-state flow table.
背景:圖 9.26b — 販賣機 FSM 的原始流程表Context: Figure 9.26b — primitive flow table for the vending FSM文脈:図 9.26b — 自動販売機 FSM の原始フロー表

規格。非同步 FSM,有兩個輸入 $D$(偵測到 10 ¢ 硬幣)與 $N$(偵測到 5 ¢ 硬幣)。收到至少 10 ¢ 時輸出 $z=1$(出貨)。多付到 15 ¢ 不找零。非同步設計規則:一次只能有一個輸入變數改變,因此 $DN=11$ 不可能出現。

Spec. Asynchronous FSM with two inputs $D$ (dime sensed) and $N$ (nickel sensed). Output $z=1$ when at least 10 ¢ has been collected (dispense). 15 ¢ overpay gives no change. Asynchronous-design rule: only one input variable may change at a time, so $DN=11$ is unreachable.

仕様。入力が 2 つの非同期 FSM で、$D$(10 ¢ 硬貨を検出)と $N$(5 ¢ 硬貨を検出)。10 ¢ 以上が集まると出力 $z=1$(払い出し)。15 ¢ 払い過ぎても釣り銭は出ない。非同期設計の規則により、一度に変化してよい入力変数は 1 つだけなので、$DN=11$ には到達しない。

六狀態的初始狀態圖(Moore 型,圖 9.26a):

Six-state initial state diagram (Moore-type, Figure 9.26a):

6 状態の初期状態遷移図(Moore 型、図 9.26a):

  • A ($z=0$) — reset, 0 ¢. $N=1$→B; $D=1$→C
  • B($z=0$)— 5 ¢,感測器仍顯示 5 ¢ 硬幣。當 $N$ 清除時 → D
  • B ($z=0$) — 5 ¢, sensor still showing nickel. When $N$ clears → D
  • B($z=0$)— 5 ¢、センサはまだ 5 ¢ 硬貨を示している。$N$ が消えると → D
  • C($z=1$)— 以 10 ¢ 硬幣達成 10 ¢,感測器仍顯示該硬幣。當 $D$ 清除時 → A
  • C ($z=1$) — 10 ¢ via dime, sensor still showing dime. When $D$ clears → A
  • C($z=1$)— 10 ¢ 硬貨で 10 ¢、センサはまだその硬貨を示している。$D$ が消えると → A
  • D ($z=0$) — 5 ¢, sensor idle. $N=1$→E; $D=1$→F
  • E ($z=1$) — 10 ¢ via 5+5. When sensor clears → A
  • F ($z=1$) — 15 ¢ via 5+10. When sensor clears → A

原始流程表(圖 9.26b) — 每列只有一個穩定狀態(粗體 = 穩定);破折號為 don't-care(禁止的 $DN=11$ 以及不可能發生的轉移項目):

Primitive flow table (Figure 9.26b) — one stable state per row (bold = stable); dashes are don't-cares (forbidden $DN=11$ and impossible-transition entries):

原始フロー表(図 9.26b) — 1 行に安定状態が 1 つ(太字 = 安定)。ダッシュは don't-care である(禁止された $DN=11$ と、起こり得ない遷移の項目):

狀態State状態$DN$=00=01=10=11$z$
AABC0
BDB0
CAC1
DDEF0
EAE1
FAF1

本題要求(兩階段縮減):

What the problem asks (two-step reduction):

問題が求めていること(2 段階の縮小):

  1. 分割:先依輸出分組再細分。輸出分割為 $\{A, B, D\}$($z=0$)與 $\{C, E, F\}$($z=1$)。再依各欄的下一狀態行為細分,可得等價對 $E \equiv C$(兩者分別在 $DN=01$/$10$ 上穩定,但都具有「在 00 時前往 A」的相同樣式),以及其他相容狀態的結果。
  2. Partitioning: group by output and refine. The output partition is $\{A, B, D\}$ ($z=0$) and $\{C, E, F\}$ ($z=1$). Refining by next-state behavior across columns produces the equivalence pair $E \equiv C$ (both stable on $DN=01$/$10$ respectively but with the same "go to A on 00" pattern) and other compatible-state findings.
  3. 分割:出力でグループ分けし、さらに細分する。出力による分割は $\{A, B, D\}$($z=0$)と $\{C, E, F\}$($z=1$)である。列ごとの次状態の振る舞いで細分すると、等価対 $E \equiv C$(それぞれ $DN=01$/$10$ で安定だが、どちらも「00 で A へ行く」という同じパターンをもつ)などの両立状態が得られる。
  4. 列合併:把已指定的下一狀態項目彼此不衝突的列合併起來(don't-care 可以任意填)。合併後,表格由 6 列縮成 4 列。
  5. Row merging: combine rows whose specified next-state entries don't conflict (don't-cares can be filled either way). After merging, the table collapses from 6 rows to 4.
  6. 行の併合:指定済みの次状態の項目が矛盾しない行どうしをまとめる(don't-care はどちらにも埋められる)。併合すると、表は 6 行から 4 行に縮む。

結果(課本圖 9.27)。存活下來的 4 個狀態分別對應 {閒置、已收 5 ¢ 且感測器已清除、5 ¢ 且感測器仍作用、已收 ≥10 ¢}。原本用來區分「以單一 10 ¢ 硬幣達成 10 ¢」與「以 5+5 達成 10 ¢」的穩定狀態對會合併,因為從該點之後,非同步輸出與穩定狀態行為完全相同。

Result (Figure 9.27 in the textbook). The 4 surviving states correspond to {idle, 5 ¢ collected with sensor cleared, 5 ¢ with sensor active, ≥10 ¢ collected}. Stable-state pairs that originally distinguished "10 ¢ via single dime" vs "10 ¢ via 5+5" merge because the asynchronous output and stable-state behavior are identical from that point on.

結果(教科書の図 9.27)。残った 4 状態は {待機、5 ¢ 投入でセンサが消えた状態、5 ¢ でセンサが有効な状態、≥10 ¢ 投入} に対応する。もともと「10 ¢ 硬貨 1 枚での 10 ¢」と「5+5 での 10 ¢」を区別していた安定状態の対は、その時点以降は非同期の出力も安定状態の振る舞いも同一なので併合される。

為什麼原始表可以縮減:每列只放一個穩定狀態的格式,本質上就很冗長。一旦允許把 don't-care 填上,其中許多列其實在做同一件事。「先分割再合併」這個兩階段程序,正是非同步 FSM 縮減的標準演算法。

Why primitive tables are reducible: the one-stable-per-row format is verbose by construction. Many of those rows turn out to be doing the same thing once you allow don't-cares to be filled in. The two-step partition-then-merge procedure is the canonical asynchronous-FSM reduction algorithm.

原始表が縮小できる理由:1 行に安定状態を 1 つだけ置く形式は、その作り方からして冗長である。don't-care を埋めてよいことにすると、それらの行の多くは同じ働きをしていると分かる。分割してから併合するこの 2 段階の手続きが、非同期 FSM の縮小における標準的なアルゴリズムである。

— example 9.7
9.21困難Hard難しい第二階Tier 2ティア 2E?R
化簡圖 9.38 中的 8 列流程表:先用分割法,再分別以 Moore 式與 Mealy 式合併圖進行合併。比較所得的狀態數,並討論何時 Mealy 形式能得到較少的狀態。— 例題 9.9
Reduce the 8-row flow table in Figure 9.38 first by partitioning, then by merging using both Moore-style and Mealy-style merger diagrams. Compare the resulting state counts and discuss when the Mealy form yields fewer states.— example 9.9
図 9.38 の 8 行のフロー表を、まず分割によって、次に Moore 流と Mealy 流の両方のマージャ図を用いた併合によって簡単化せよ。得られた状態数を比較し、Mealy 形式のほうが状態が少なくなるのはどんな場合かを論ぜよ。— 例題 9.9
9.23中等Medium普通第二階Tier 2ティア 2E?R
對狀態為 $A,B,C,D$ 的同位產生器 FSM,就狀態指派 $A=00, B=01, C=10, D=11$ 在 2-cube 上畫出轉移圖,並說明它需要對角轉移。接著驗證另一種指派 $A=00, B=01, C=11, D=10$ 可消除所有對角路徑。
For the parity-generator FSM with states $A,B,C,D$, draw a transition diagram on a 2-cube for the state assignment $A=00, B=01, C=10, D=11$ and show that it requires diagonal transitions. Then verify that the alternative assignment $A=00, B=01, C=11, D=10$ eliminates all diagonal paths.
状態が $A,B,C,D$ のパリティ生成 FSM について、状態割当て $A=00, B=01, C=10, D=11$ の遷移図を 2-cube 上に描き、対角の遷移が必要になることを示せ。次に、別の割当て $A=00, B=01, C=11, D=10$ では対角の経路がすべてなくなることを確かめよ。
9.24困難Hard難しい第二階Tier 2ティア 2E?R
對簡單的雙裝置仲裁器 FSM,說明沒有任何 3 狀態、2 個狀態變數的指派能得到漢明距離為 1 的轉移圖。加入第四個(不穩定)狀態 $D$ 以打斷 $B$ 與 $C$ 之間的對角轉移,據此修改流程表,並確保該不穩定狀態產生安全的輸出值。
For the simple two-device arbiter FSM, show that no 3-state, 2-state-variable assignment yields a Hamming-distance-1 transition graph. Add a fourth (unstable) state $D$ to break the diagonal transition between $B$ and $C$, modify the flow table accordingly, and ensure that the unstable state produces a safe output value.
単純な 2 デバイス調停器 (arbiter) の FSM について、3 状態・状態変数 2 個のどんな割当てでもハミング距離 1 の遷移グラフにはならないことを示せ。4 番目の(不安定な)状態 $D$ を加えて $B$ と $C$ の間の対角遷移を断ち切り、それに合わせてフロー表を修正し、不安定状態が安全な出力値を出すようにせよ。
9.25困難Hard難しい第二階Tier 2ティア 2E?R
A 4-state flow table (Figure 9.52a) has 7 stable-state entries. Relabel the table to enumerate stable-state instances, draw a transition diagram, and exploit an unspecified entry to find a state assignment that maps onto a 2-cube without diagonal transitions. Specify any required Mealy-style outputs to avoid output glitches in unstable states.
背景:範例 9.13 — 利用未指定的項目取得無競爭的狀態指派Context: Example 9.13 — exploiting an unspecified entry to get a race-free state assignment文脈:例題 9.13 — 未指定の項目を利用して競合のない状態割当てを得る

圖 9.52a — 原始的 4 狀態 Moore 流程表(粗體 = 穩定,「—」= 未指定):

Figure 9.52a — original 4-state Moore flow table (bold = stable, "—" = unspecified):

図 9.52a — もとの 4 状態 Moore フロー表(太字 = 安定、「—」= 未指定):

狀態State状態$w_2 w_1$=00=01=10=11$z_2 z_1$
AABCA00
BBBDC01
CACDC10
DBDA11

Counting stable-state cells: A×2, B×2, C×2, D×1 → 7 stable instances.

圖 9.52b — 以穩定實例編號 1–7 重新標記(每個穩定格都取得唯一的標籤,方便我們用目的地來指稱轉移):

Figure 9.52b — relabeled with stable-instance numbers 1–7 (each stable cell gets a unique label so we can name transitions by their destination):

図 9.52b — 安定インスタンス番号 1–7 で付け直したもの(安定セルごとに一意のラベルを与え、遷移をその行き先で呼べるようにする):

狀態State状態00011011
A1472
B3476
C1576
D372

重新標記為什麼有幫助:像 00 欄中「C → A」這樣的轉移,終點是標籤為 1 的穩定格 — 因此我們在那個箭頭上標註「1」。終點落在同一個穩定實例的多個轉移,可以共用同一個標籤。

Why the relabeling helps: a transition like "C → A" in column 00 ends at the stable cell labeled 1 — so we annotate that arrow with "1". Multiple transitions ending at the same stable instance can share a label.

ラベルを付け直すと何が良いか:列 00 の「C → A」のような遷移は、ラベル 1 の安定セルで終わる — そこでその矢印に「1」と注記する。同じ安定インスタンスで終わる複数の遷移は、ラベルを共有できる。

步驟 1 — 第一張轉移圖(指派 A=00、B=01、C=11、D=10)。把彼此有轉移往來的狀態對全部連起來;有問題的箭頭就是 2-cube 上的對角線(漢明距離 2):

Step 1 — first transition diagram (assignment A=00, B=01, C=11, D=10). Connect every pair of states that exchange transitions; the offending arrows are diagonals on the 2-cube (Hamming distance 2):

ステップ 1 — 最初の遷移図(割当ては A=00、B=01、C=11、D=10)。遷移をやり取りする状態対をすべて結ぶ。問題となる矢印は 2-cube 上の対角線(ハミング距離 2)である:

  • A↔C diagonal carries labels 1 (C→A) and 7 (A→C)
  • B↔D diagonal carries labels 3 (D→B) and 7 (B→D)

標籤 7 的路徑(前往穩定 D 的轉移)可以經由其他狀態走替代路線 — 因此能繞開對角線。但標籤 1 與 3 卡在對角線上 — 沒有替代路徑。所以這組指派行不通。

Label-7 paths (transitions to stable D) have alternative routes via other states — they can be re-routed off the diagonal. But labels 1 and 3 are stuck on diagonals — no alternate path. So this assignment fails.

ラベル 7 の経路(安定 D への遷移)には他の状態を経由する代替ルートがある — 対角線から外して迂回できる。しかしラベル 1 と 3 は対角線に張り付いたままで、代替経路がない。よってこの割当ては失敗である。

步驟 2 — 試著把 B 與 C 的碼對調(A=00、B=11、C=01、D=10)。現在 A↔B 成為對角線,而 B↔D 變成相鄰。重新檢查:

Step 2 — try swapping B and C codes (A=00, B=11, C=01, D=10). Now A↔B is the diagonal and B↔D becomes adjacent. Recheck:

ステップ 2 — B と C の符号を入れ替えてみる(A=00、B=11、C=01、D=10)。今度は A↔B が対角線になり、B↔D は隣接になる。もう一度確かめる:

  • C→A: 01 → 00, Hamming-1 ✓
  • D→B: 10 → 11, Hamming-1 ✓
  • A→B (label 4): 00 → 11, Hamming-2 ✗ — still diagonal

步驟 3 — 利用未指定的項目。D 列、01 欄是「—」。把它填成 $B$(於是 D 對 01 這個輸入成為「穿透」)。現在輸入 01 時的轉移 $A \to B$ 可以改繞成 $A \to D \to B$(兩次單一位元跳躍:00→10→11)。由於再也沒有人需要它,對角線 A↔B 就從轉移圖上消失了。

Step 3 — exploit the unspecified entry. Row D, column 01 is "—". Fill it with $B$ (so D becomes a "pass-through" for the 01-input). Now the transition $A \to B$ on input 01 can be re-routed as $A \to D \to B$ (two single-bit hops: 00→10→11). The diagonal A↔B disappears from the transition graph because nobody needs it any more.

ステップ 3 — 未指定の項目を利用する。行 D、列 01 は「—」である。ここを $B$ で埋める(こうすると D は入力 01 に対する「通り抜け」になる)。すると入力 01 での遷移 $A \to B$ を $A \to D \to B$(1 ビットずつ 2 回のホップ:00→10→11)に振り替えられる。もう誰もそれを必要としないので、対角線 A↔B は遷移図から消える。

Augmented transition diagram (Figure 9.53c):

D 10 B 11 A 00 C 01 3, 7, 4 6, 7 1, 7 2, 7, 4 所有邊的漢明距離皆為 1 — 沒有對角線All edges are Hamming-distance 1 — no diagonalsすべての辺はハミング距離 1 — 対角線はない

所有邊都是單一位元變化。2-cube 嵌入成立 → 狀態指派 A=00, B=11, C=01, D=10 是無競爭的。

All edges are single-bit changes. The 2-cube embedding works → state assignment A=00, B=11, C=01, D=10 is race-free.

すべての辺が 1 ビット変化である。2-cube への埋め込みが成立する → 状態割当て A=00, B=11, C=01, D=10 は競合がない。

為什麼之後需要 Mealy 模型。現在有好幾個轉移會經過不穩定的中間狀態(例如 A→D→B)。如果輸出嚴格是 $f(\text{state})$(Moore),FSM 在前往 B(其輸出為 01)的途中經過 D 時,就會短暫顯示 D 的輸出(11)。這就是輸出突波。為了抑制突波,修改後的流程表(圖 9.54a)逐欄把輸出重新指定為 $(\text{state}, w)$ 的函數:在不穩定格中,輸出被強制對齊最終穩定目的地的輸出,而非該不穩定轉移狀態的輸出。

Why a Mealy model is needed afterward. Several transitions now route through unstable intermediate states (e.g., A→D→B). If the output were strictly $f(\text{state})$ (Moore), the FSM would briefly show D's output (11) while passing through it on the way to B (whose output is 01). That's an output glitch. To suppress glitches, the modified flow table (Figure 9.54a) re-specifies the output column-by-column as a function of $(\text{state}, w)$: in unstable cells, the output is forced to match the eventual stable destination's output, not the unstable transition state's output.

そのあと Mealy モデルが必要になる理由。いまではいくつかの遷移が不安定な中間状態を経由する(たとえば A→D→B)。出力が厳密に $f(\text{state})$(Moore)だとすると、FSM は B(出力 01)へ向かう途中で D を通る間、D の出力(11)を一瞬示してしまう。これが出力グリッチである。グリッチを抑えるために、修正後のフロー表(図 9.54a)は出力を列ごとに $(\text{state}, w)$ の関数として指定し直す:不安定セルでは、出力を不安定な遷移状態の出力ではなく、最終的に落ち着く行き先の安定状態の出力に一致させる。

The general technique:

  1. 為穩定實例編號 → 轉移的標記更清楚。
  2. Number stable instances → cleaner transition labeling.
  3. 安定インスタンスに番号を付ける → 遷移のラベル付けがすっきりする。
  4. 畫出轉移圖;找出有問題的對角線。
  5. Draw transition graph; identify offending diagonals.
  6. 遷移図を描き、問題となる対角線を特定する。
  7. 只要某個標籤有多條路徑可走,就把對角轉移改繞經其他狀態。
  8. Re-route diagonal transitions through alternative states whenever a label has multiple paths available.
  9. あるラベルに複数の経路が使えるときは、対角遷移を別の状態経由に迂回させる。
  10. 利用未指定的項目來增加相容的替代路徑(這是關鍵洞見 — don't-care 不只用於化簡下一狀態,還會創造出新的轉移路徑)。
  11. Use unspecified entries to add compatible alternative paths (this is the key insight — don't-cares aren't just for next-state simplification, they create new transition paths too).
  12. 未指定の欄を使って、両立する代替経路を追加する(ここが要点である — don't-care は次状態の簡単化のためだけのものではなく、新しい遷移経路も生み出す)。
  13. 改用 Mealy 輸出,以抑制加長後的轉移路徑上所產生的突波。
  14. Switch to Mealy outputs to suppress glitches in the now-extended transition routes.
  15. Mealy 出力に切り替えて、延長された遷移経路で生じるグリッチを抑える。
— example 9.13
9.27困難Hard難しい第二階Tier 2ティア 2E?R
Re-implement the FSM of Example 9.14 by replacing each of its 4 states with an equivalent pair of states, so that the 8 vertices of a 3-cube are used. Verify that the resulting transition diagram has no diagonal paths and modify the flow table accordingly.
背景:範例 9.14 — 狀態分裂法(插入不穩定暫態狀態之外的另一種做法)Context: Example 9.14 — state-splitting approach (alternative to inserting unstable transit states)背景:例題 9.14 — 状態分割による方法(不安定な過渡状態を挿入する方法の代替)

與習題 9.26(圖 9.55)相同的 FSM:其 4 狀態轉移圖的 6 組狀態對全都需要轉移,因此無法嵌入 2-cube。

Same FSM as in problem 9.26 (Figure 9.55), where the 4-state transition diagram has all 6 state-pairs requiring transitions and can't embed on a 2-cube.

問題 9.26(図 9.55)と同じ FSM である。4 状態の遷移図では 6 組の状態対すべてに遷移が必要で、2-cube には埋め込めない。

圖 9.55a — 流程表(穩定狀態加底線;輸出 $z_2 z_1$):

Figure 9.55a — flow table (stable states underlined; output $z_2 z_1$):

図 9.55a — フロー表(安定状態に下線、出力 $z_2 z_1$):

狀態state状態$w_2w_1{=}00$$01$$10$$11$$z_2z_1$
AAACB00
BABDB01
CCBCD10
DCADD11
圖 9.56a — 轉移圖 (K4)Figure 9.56a — transition diagram (K4)図 9.56a — 遷移図 (K4) A B C D 對角線(漢明距離 2 — 阻礙嵌入 2-cube)diagonal (Hamming-2 — blocks 2-cube embedding)対角線(ハミング距離 2 — 2-cube への埋め込みを妨げる)

每一對狀態之間都至少有一次轉移(此圖為 $K_4$),因此任何 2 位元指派都必然出現至少一次漢明距離 2 的跳躍 — 也就是對角邊。加入第三個狀態位元後可得有 8 個頂點的 3-cube,訣竅就是用這些多出來的頂點,把對角線拆成單一位元的跳步。

Every pair of states has at least one transition (the diagram is $K_4$), so any 2-bit assignment forces at least one Hamming-2 step — that's the diagonal edge. Adding a third state-bit gives a 3-cube with 8 vertices, and the trick is to use those extra vertices to break the diagonals into single-bit hops.

どの状態対の間にも少なくとも 1 つの遷移がある(図は $K_4$ である)ため、2 ビットのどんな割当てでも必ずハミング距離 2 のステップが 1 つは生じる — それが対角の辺である。状態ビットを 3 つに増やせば頂点 8 個の 3-cube が得られ、その余分な頂点を使って対角線を 1 ビットずつのホップに分解するのが要領である。

習題 9.26 的解法是插入 3 個額外的不穩定狀態(E、F、G)。本題採用不同做法:把 4 個狀態各自複製成一組等價對,共得 8 個狀態 — 剛好填滿 3-cube 的 8 個頂點。

Problem 9.26 solves it by inserting 3 extra unstable states (E, F, G). This problem solves it differently: replicate each of the 4 states as an equivalent pair, giving 8 states total — exactly enough to fill the 8 vertices of a 3-cube.

問題 9.26 では、余分な不安定状態を 3 つ(E、F、G)挿入して解いた。本問では別の方法をとる:4 つの状態をそれぞれ等価な対に複製する。合計 8 状態となり、3-cube の 8 頂点をちょうど埋められる。

The state-splitting recipe:

  1. 對每個原狀態 $X$,引入一個複製狀態 $X'$,具有相同的輸出與相同的穩定格集合。$X$ 與 $X'$ 都是合法的穩定狀態。
  2. For each original state $X$, introduce a clone $X'$ with the same outputs and the same stable-cell set. Both $X$ and $X'$ are valid stable states.
  3. 元の各状態 $X$ に対し、同じ出力と同じ安定セル集合をもつクローン $X'$ を導入する。$X$ と $X'$ はどちらも正当な安定状態である。
  4. 原本進入 $X$ 的每一次轉移,都可以改為進入 $X'$,端看哪一種選擇能得到單一位元的碼變化。
  5. Each transition that originally entered $X$ may instead enter $X'$, depending on which choice gives a single-bit code change.
  6. もともと $X$ に入っていた各遷移は、どちらを選べば符号が 1 ビットだけ変わるかに応じて、代わりに $X'$ に入ってもよい。
  7. 為這 8 個狀態挑一組 3 位元指派,使每一條必要的(狀態,目標)邊都落在立方體的稜上(漢明距離 1)。
  8. Pick a 3-bit assignment for the 8 states such that every required (state, target) edge is on a cube edge (Hamming-1).
  9. 8 状態に 3 ビットの割当てを選び、必要な(状態、行き先)の辺がすべて立方体の稜上(ハミング距離 1)に来るようにする。

一組可行的指派範例:$A=000$、$A'=001$、$B=011$、$B'=010$、$C=110$、$C'=111$、$D=101$、$D'=100$。依格雷碼順序走過立方體頂點 — 相鄰兩個頂點只差一個位元,因此原本 4 狀態圖中每一條「長」對角線,都可以改成繞往目的狀態的對應複製狀態。

Sample assignment that works: $A=000$, $A'=001$, $B=011$, $B'=010$, $C=110$, $C'=111$, $D=101$, $D'=100$. Walk the cube vertices in Gray-code order — each consecutive pair differs by one bit, so every "long" diagonal in the original 4-state graph can be replaced by routing to the appropriate clone of the destination.

うまくいく割当ての例:$A=000$、$A'=001$、$B=011$、$B'=010$、$C=110$、$C'=111$、$D=101$、$D'=100$。立方体の頂点をグレイ符号の順にたどる — 連続する頂点は 1 ビットしか違わないので、もとの 4 状態グラフの「長い」対角線はいずれも、行き先の状態の適切なクローンへ経路を取ることで置き換えられる。

具體例子:A→B 一般需要 2 個位元同時跳變。改成這樣走:A=000 → A'=001(1 位元)→ B=011(1 位元)→ B'=010(1 位元)。轉移過程經過一個複製狀態(A'),最後落在正確狀態的複製狀態(B')。由於輸出相同,使用者根本分不出目前身在哪一個複製狀態。

Concrete example: A→B normally requires a 2-bit jump. Instead, route A=000 → A'=001 (1-bit) → B=011 (1-bit) → B'=010 (1-bit). The transit goes through a clone (A') and lands in the right state's clone (B'). Outputs match, so the user never knows which clone they're in.

具体例:A→B は通常 2 ビットの跳躍を要する。代わりに A=000 → A'=001(1 ビット)→ B=011(1 ビット)→ B'=010(1 ビット)と経路を取る。途中はクローン(A')を通り、正しい状態のクローン(B')に落ち着く。出力は一致しているので、利用者はどちらのクローンにいるか分からない。

與不穩定狀態法(習題 9.26)的取捨:

Trade-off vs. the unstable-state approach (problem 9.26):

不安定状態を使う方法(問題 9.26)との得失:

做法Approach手法狀態總數Total states状態の総数穩定列Stable rows安定行激勵邏輯Excitation logic励振論理
Insert E, F, G as transit (9.26)74 (original)每個狀態 3 個暫態格 — 複雜度中等3 transit cells per state — moderate complexity状態ごとに過渡セルが 3 個 — 複雑さは中程度
Split each state into pair (9.27)88 (each original split)對稱性較乾淨;用上了每一個立方體頂點Cleaner symmetry; uses every cube vertex対称性がすっきりしている。立方体の頂点をすべて使う

What 9.27 specifically asks:

  1. 把 A、B、C、D 各自與一個複製狀態 $A', B', C', D'$ 配成一對。
  2. Pair each of A, B, C, D with a clone $A', B', C', D'$.
  3. A、B、C、D のそれぞれをクローン $A', B', C', D'$ と対にする。
  4. 指派 3 位元碼,使每一次轉移都是漢明距離 1。
  5. Assign 3-bit codes so every transition is Hamming-1.
  6. すべての遷移がハミング距離 1 になるよう 3 ビット符号を割り当てる。
  7. 修改流程表:把 4 列換成 8 列;並指明各轉移要進入哪一個複製狀態。
  8. Modify the flow table: replace 4 rows with 8 rows; specify which clone the transitions enter.
  9. フロー表を修正する:4 行を 8 行に置き換え、各遷移がどちらのクローンに入るかを指定する。
  10. 確認新的轉移圖不再有任何對角路徑。
  11. Verify the new transition diagram has no diagonal paths.
  12. 新しい遷移図に対角の経路がないことを確かめる。

該選哪一種做法:狀態分裂往往能得到較簡單的下一狀態邏輯(對稱性有助於卡諾圖化簡),但列數加倍,且用掉全部的立方體頂點。插入不穩定暫態狀態(9.26)列數較少,但那些暫態格是明確的「非穩定」位置,必須仔細驗證它們絕不會永久閂住。

When to choose which approach: state-splitting tends to give simpler next-state logic (the symmetry helps K-map minimization), but doubles the row count and uses all cube vertices. Insertion of unstable transit states (9.26) has fewer rows but the transit cells are explicit "non-stable" places that must be carefully verified to never permanently latch.

どちらを選ぶか:状態分割は次状態論理が簡単になりやすい(対称性がカルノー図の簡単化を助ける)が、行数が倍になり、立方体の頂点を使い切る。不安定な過渡状態の挿入(9.26)は行数が少なくて済むが、過渡セルは明示的な「非安定」の場所であり、決して永久にラッチしないことを注意深く検証しなければならない。

— example 9.14
9.28困難Hard難しい第二階Tier 2ティア 2E?R
檢視由 $Y_m = CD + \overline{C}y_m$ 與 $Y_s = Cy_m + \overline{C}y_s$ 推得的主從式 D 正反器最小成本兩層實作。找出使電路在 $C$ 由 1 降到 0 時停在錯誤穩定狀態的靜態冒險,並加入冗餘質蘊涵項 $Dy_m$ 與 $y_m y_s$ 加以消除。
Examine the minimum-cost two-level realization of the master-slave D flip-flop derived from $Y_m = CD + \overline{C}y_m$ and $Y_s = Cy_m + \overline{C}y_s$. Identify the static hazard that causes the circuit to settle into an incorrect stable state when $C$ falls from 1 to 0, and add the redundant prime implicants $Dy_m$ and $y_m y_s$ to remove it.
$Y_m = CD + \overline{C}y_m$ と $Y_s = Cy_m + \overline{C}y_s$ から導かれるマスタスレーブ D フリップフロップの最小コスト 2 レベル実装を調べよ。$C$ が 1 から 0 へ落ちるときに回路が誤った安定状態に落ち着く原因となる静的ハザードを特定し、冗長な主項 $Dy_m$ と $y_m y_s$ を加えて取り除け。
9.29中等Medium普通第二階Tier 2ティア 2E?R
說明對於含 don't-care 最小項的 SOP 電路,要達到無冒險只需要涵蓋相鄰 1 格對的乘積項,而不需要全部的質蘊涵項。將此結論應用到圖 9.64 的函數,推導出無冒險的實作 $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$。— 例題 9.17
Show that for a SOP circuit with don't-care minterms, only product terms covering pairs of adjacent 1s are needed for hazard freedom—not all prime implicants. Apply this to the function in Figure 9.64 to derive a hazard-free realization $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$.— example 9.17
don't-care 最小項をもつ SOP 回路では、ハザードフリーにするのに必要なのは隣接する 1 の対を覆う積項だけであり、すべての主項が要るわけではないことを示せ。これを図 9.64 の関数に適用し、ハザードのない実装 $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$ を導け。— 例題 9.17
9.30中等Medium普通第二階Tier 2ティア 2E?R
Analyze the static hazard in a POS circuit (Figure 9.65a). When $x_1=x_3=0$ and $x_2$ rises from 0 to 1, identify the unequal-delay path that produces a $0\to 1\to 0$ glitch on the output. Add the sum term that covers all adjacent 0s to obtain a hazard-free POS realization.
背景:範例 9.18 — POS 電路中的靜態冒險Context: Example 9.18 — static hazard in a POS circuit背景:例題 9.18 — POS 回路における静的ハザード

圖 9.65a — POS 電路:$f = (x_1 + x_2)(\overline{x_2} + x_3)$ 以兩個 OR 閘饋入一個 AND 閘來實現。內部節點為 $p = x_1 + x_2$ 與 $q = \overline{x_2} + x_3$。

Figure 9.65a — the POS circuit: $f = (x_1 + x_2)(\overline{x_2} + x_3)$ realized as two OR gates feeding an AND gate. Internal nodes $p = x_1 + x_2$ and $q = \overline{x_2} + x_3$.

図 9.65a — POS 回路:$f = (x_1 + x_2)(\overline{x_2} + x_3)$ を、2 つの OR ゲートが 1 つの AND ゲートに入る形で実現する。内部ノードは $p = x_1 + x_2$ と $q = \overline{x_2} + x_3$ である。

冒險情境。設 $x_1 = x_3 = 0$,並讓 $x_2$ 由 0 切換到 1。整個過程中函數本應維持 $f = 0$(穩態下 AND 的兩個輸入不可能同時為 1):

The hazard scenario. Set $x_1 = x_3 = 0$ and toggle $x_2$ from 0 to 1. The function should stay at $f = 0$ throughout (both inputs to the AND cannot simultaneously be 1 in steady state):

ハザードの場面。$x_1 = x_3 = 0$ とし、$x_2$ を 0 から 1 へ切り替える。この間、関数は $f = 0$ のままであるべきである(定常状態では AND の 2 入力が同時に 1 になることはない):

$x_2$$p = x_1 + x_2$$q = \overline{x_2} + x_3$$f = p \cdot q$
0 (steady)0+0 = 01+0 = 10·1 = 0 ✓
1 (steady)0+1 = 10+0 = 01·0 = 0 ✓

突波。在 $x_2: 0 \to 1$ 的轉態過程中,$p$ 由 0 升到 1(OR 看到 $x_2$ 上升),而且發生在 $q$ 由 1 落到 0 之前(因為 $\overline{x_2}$ 上的反相器多了一段延遲,第二個 OR 才看到變化)。在這段短暫的時間窗內 $p = q = 1$,於是 $f = 1$。輸出出現 $0 \to 1 \to 0$ 的突波 — 這就是靜態 0 冒險

The glitch. During the $x_2: 0 \to 1$ transition, $p$ rises from 0 to 1 (the OR sees $x_2$ go up) before $q$ falls from 1 to 0 (because the inverter on $\overline{x_2}$ adds an extra delay before the second OR sees the change). For a brief window $p = q = 1$, so $f = 1$. The output exhibits a $0 \to 1 \to 0$ glitch — a static-0 hazard.

グリッチ。$x_2: 0 \to 1$ の遷移中、$p$ は 0 から 1 へ上がる(OR が $x_2$ の立上りを見る)が、それは $q$ が 1 から 0 へ落ちるよりである($\overline{x_2}$ 側のインバータが余分な遅延を加え、2 つ目の OR が変化を見るのが遅れるため)。短い時間だけ $p = q = 1$ となり、$f = 1$ になる。出力には $0 \to 1 \to 0$ のグリッチが現れる — これが静的 0 ハザードである。

為什麼 POS 電路會在相鄰 0 格上發生冒險。在 POS 電路中,和項的 AND 只有在至少一個和項為 0 時才輸出 0。當兩個卡諾圖 0 格相鄰、卻沒有單一和項同時涵蓋兩者時,就會在其邊界發生冒險 — 兩個項可能瞬間都為 1,使 $f = 1$。

Why POS circuits hazard on adjacent 0s. In a POS circuit, the AND of OR-terms produces 0 only when at least one OR-term is 0. A hazard occurs at the boundary between two K-map 0-cells where no single sum-term covers both — momentarily both terms can be 1, giving $f = 1$.

POS 回路が隣接する 0 でハザードを起こす理由。POS 回路では、和項の AND は少なくとも 1 つの和項が 0 のときにのみ 0 を出す。カルノー図の 2 つの 0 セルが隣接していて、その両方を覆う単一の和項が存在しないとき、その境界でハザードが起きる — 一瞬だけ両方の項が 1 になり、$f = 1$ となるからである。

修法。加入一個冗餘和項 $(x_1 + x_3)$,同時涵蓋這兩個相鄰的 0 格(它只有在 $x_1 = x_3 = 0$ 時才為 0)。有了這個額外項,相鄰 0 格之間的每一次轉移,整個過程中都至少有一個和項維持在 0:

The fix. Add a redundant sum-term $(x_1 + x_3)$ that covers both adjacent 0-cells (it is 0 only when $x_1 = x_3 = 0$). With this extra term, every transition between adjacent 0s leaves at least one OR-term at 0 throughout the transition:

対策。隣接する 2 つの 0 セルをともに覆う冗長な和項 $(x_1 + x_3)$ を加える(この項は $x_1 = x_3 = 0$ のときにのみ 0 になる)。この余分な項があれば、隣接する 0 の間のどの遷移でも、遷移中ずっと少なくとも 1 つの和項が 0 に保たれる:

$$f_{\text{hazard-free}} = (x_1 + x_2)(\overline{x_2} + x_3)(x_1 + x_3)$$

消除冒險的代價:多一個 OR2 閘,加上 AND 多一個輸入。這個額外的閘在邏輯上是冗餘的 — 它並不改變函數 — 但它補上了讓突波得以發生的那道縫隙。

Cost of removing the hazard: one extra OR2 gate plus one input to the AND. The extra gate is logically redundant — it does not change the function — but it bridges the gap that allowed the glitch.

ハザードを除く代価:OR2 ゲートが 1 つと、AND への入力が 1 本増える。この余分なゲートは論理的には冗長であり、関数を変えない — しかしグリッチを許していた隙間を埋めてくれる。

Dual rule (memorize):

  • SOP 電路:冒險發生在相鄰1格之間的轉移上。修法:對每一組相鄰的 1 格加入涵蓋它們的乘積項。
  • SOP circuits: hazards on transitions between adjacent 1-cells. Fix: add product term covering each pair of adjacent 1s.
  • SOP 回路:ハザードは隣接する1 セル間の遷移で起きる。対策:隣接する 1 の対それぞれを覆う積項を加える。
  • POS 電路:冒險發生在相鄰0格之間的轉移上。修法:對每一組相鄰的 0 格加入涵蓋它們的和項。
  • POS circuits: hazards on transitions between adjacent 0-cells. Fix: add sum term covering each pair of adjacent 0s.
  • POS 回路:ハザードは隣接する0 セル間の遷移で起きる。対策:隣接する 0 の対それぞれを覆う和項を加える。
— example 9.18
9.32中等Medium普通第二階Tier 2ティア 2E?R
檢查例題 9.19 所推導的下一狀態式是否有冒險。用 $Y_1$ 與 $Y_2$ 的卡諾圖找出哪一個質蘊涵項一旦缺少就會留下靜態冒險,並補上這個缺漏的蘊涵項以得到無冒險的實作。— 例題 9.19
Examine the next-state expressions derived in Example 9.19 for hazards. Use Karnaugh maps for $Y_1$ and $Y_2$ to identify any prime implicant that, if missing, leaves a static hazard. Add the missing implicant to obtain a hazard-free realization.— example 9.19
例題 9.19 で導いた次状態式にハザードがないか調べよ。$Y_1$ と $Y_2$ のカルノー図を用いて、欠けると静的ハザードが残る主項を特定し、その欠けている内項を補ってハザードのない実装を得よ。— 例題 9.19
9.33困難Hard難しい第二階Tier 2ティア 2E?R
設計一個具輸入 $w$ 與輸出 $z$ 的非同步電路,把 $w$ 上每隔一個的脈衝複製成 $z$ 上的脈衝。請提出狀態圖、流程表、無競爭的狀態指派,以及最終的下一狀態式與輸出式。
Design an asynchronous circuit with input $w$ and output $z$ that replicates every second pulse on $w$ as a pulse on $z$. Provide a state diagram, flow table, race-free state assignment, and final next-state and output expressions.
入力 $w$、出力 $z$ をもち、$w$ 上の 1 つおきのパルスを $z$ 上のパルスとして再現する非同期回路を設計せよ。状態図、フロー表、競合のない状態割当て、そして最終的な次状態式と出力式を示せ。
9.34困難Hard難しい第二階Tier 2ティア 2E?R
Reduce the 8-row flow table of Figure 9.81 using the partitioning procedure and a merger diagram (preserving the Moore model). Then find a state assignment that allows mapping onto a 3-cube without diagonal transitions and derive the excitation table.
背景:範例 9.22 — 8 列 Moore 流程表的完整化簡與狀態指派Context: Example 9.22 — full reduction + state assignment for an 8-row Moore flow table背景:例題 9.22 — 8 行の Moore フロー表の完全な簡単化と状態割当て

圖 9.81 — 原本的 8 列原始流程表(Moore 型,輸出 $z$ 只取決於狀態):

Figure 9.81 — original 8-row primitive flow table (Moore-type, output $z$ depends only on state):

図 9.81 — もとの 8 行の原始フロー表(Moore 型、出力 $z$ は状態のみに依存):

狀態State状態$w_2 w_1$=00=01=10=11$z$
AAEC0
BEHB1
CGCF0
DADB1
EGEB0
FDCF0
GGEC0
HAHB1

階段 1 — 分割:依輸出分組(反覆細分直到穩定):

Stage 1 — Partitioning by output groups (refine until stable):

段階 1 — 分割:出力のグループで分ける(安定するまで細分を繰り返す):

$$P_1 = (ACEFG)(BDH) \qquad P_2 = (AG)(B)(C)(D)(E)(F)(H) \qquad P_3 = P_2$$

找到等價關係:$A \equiv G$。把兩者合併成單一狀態(仍稱為 $A$)。結果為 7 列的表(圖 9.82)。

Equivalence found: $A \equiv G$. Merge them into a single state (call it $A$). Result: 7-row table (Figure 9.82).

等価性が見つかる:$A \equiv G$。両者を 1 つの状態に併合する(これを $A$ と呼ぶ)。結果は 7 行の表(図 9.82)となる。

階段 2 — 合併圖:在 7 列的縮減表上找出下列相容對的合併:

Stage 2 — Merger diagram on the 7-row reduced table identifies these compatible-pair merges:

段階 2 — マージャ図:7 行に縮小した表について、次の両立対の併合が見つかる:

  • $A$ 與 $E$ — don't-care 樣式相同,下一狀態相容
  • $A$ and $E$ — same don't-care pattern, compatible next-states
  • $A$ と $E$ — don't-care のパターンが同じで、次状態も両立する
  • $C$ and $F$ — compatible next-states
  • $D$ 與 $H$ — 下一狀態相容(兩者都輸出 $z=1$,且在輸入 11 時都轉往 $B$)
  • $D$ and $H$ — compatible next-states (both produce $z=1$, both go to $B$ on input 11)
  • $D$ と $H$ — 次状態が両立する(どちらも $z=1$ を出し、入力 11 でともに $B$ へ進む)

合併後:4 狀態的表(圖 9.84)。重新標記以便進行狀態指派。

After merging: 4-state table (Figure 9.84). Relabel for state assignment.

併合後:4 状態の表(図 9.84)。状態割当てのためにラベルを付け直す。

階段 3 — 狀態指派。重新標記後的 4 狀態轉移圖(圖 9.86a)有一條對角線:某個輸入下的 D→A,標記為「1」 — 漢明距離 2 的跳躍。

Stage 3 — State assignment. The relabeled 4-state transition diagram (Figure 9.86a) has one diagonal: D→A on some input, labeled "1" — Hamming-2 jump.

段階 3 — 状態割当て。ラベルを付け直した 4 状態の遷移図(図 9.86a)には対角線が 1 本ある:ある入力での D→A で、ラベルは「1」 — ハミング距離 2 の跳躍である。

修法:利用一個 don't-care 項,把對角轉移 D→A 改繞經狀態 C(都是漢明距離 1 的跳步):$D \to C \to A$。改繞之後(圖 9.86b),轉移圖不再有對角線,可以嵌入 2-cube。狀態指派就直接取 $A=00, B=01, C=11, D=10$(或類似的格雷碼對映)。

The fix: exploit a don't-care entry to route the diagonal D→A through state C (Hamming-1 hops): $D \to C \to A$. After this re-routing (Figure 9.86b), the transition diagram has no diagonals and embeds onto a 2-cube. State assignment becomes simply $A=00, B=01, C=11, D=10$ (or similar Gray-code mapping).

対策:don't-care の欄を利用して、対角遷移 D→A を状態 C 経由(いずれもハミング距離 1 のホップ)に迂回させる:$D \to C \to A$。この迂回のあと(図 9.86b)、遷移図に対角線はなくなり、2-cube に埋め込める。状態割当ては単純に $A=00, B=01, C=11, D=10$(あるいは同様のグレイ符号の対応)でよい。

階段 4 — 激勵表。指派固定之後,為每一個(狀態,輸入)格寫下下一狀態碼 $(Y_2 Y_1)$。把各欄畫成卡諾圖,推導出 $Y_1$ 與 $Y_2$ 的邏輯。輸出 $z$ 只是狀態的函數(Moore),因此直接由現態位元畫卡諾圖即可。

Stage 4 — Excitation table. With the assignment fixed, write next-state codes $(Y_2 Y_1)$ for every (state, input) cell. K-map the columns to derive logic for $Y_1$ and $Y_2$. Output $z$ is a function of state alone (Moore), so it K-maps directly from the present-state bits.

段階 4 — 励振表。割当てを決めたら、(状態、入力)の各セルについて次状態符号 $(Y_2 Y_1)$ を書き込む。列ごとにカルノー図を描いて $Y_1$ と $Y_2$ の論理を導く。出力 $z$ は状態だけの関数(Moore)なので、現状態のビットから直接カルノー図で求まる。

The full pipeline summary:

Stage運算Operation演算縮減後列數Rows after縮小後の行数
0Original primitive flow table8
1Partitioning ($A \equiv G$)7
2Merger diagram (A+E, C+F, D+H)4
3State assignment + diagonal-routing fix4 (no change in count)
4Excitation table → K-maps → next-state logic

習題 9.34 具體要求什麼:走完上述階段 1–4,並全程維持 Moore 模型(因此合併的限制是「穩定格中的輸出相同」,而不是較寬鬆的 Mealy 相容性)。

What problem 9.34 specifically asks: walk through stages 1–4 above, preserving the Moore model throughout (so the merger constraint is "same output in stable cells", not the looser Mealy compatibility).

問題 9.34 が具体的に求めていること:上の段階 1–4 をひととおり実行し、全体を通して Moore モデルを保つこと(したがって併合の制約は「安定セルでの出力が同じ」であり、より緩い Mealy の両立性ではない)。

— example 9.22
9.36困難Hard難しい第二階Tier 2ティア 2?R
合成一個具輸入 S 與 R 的 set-reset 閂鎖非同步電路:S=1 時輸出變為 1,R=1 時輸出變為 0,不允許 S=R=1。推導原始流程表、合併列、指派狀態,並推導輸出方程式。
Synthesize an asynchronous circuit for a set-reset latch with inputs S and R: when S=1 output goes to 1, when R=1 output goes to 0, S=R=1 is not allowed. Derive the primitive flow table, merge rows, assign states, and derive output equations.
入力 S と R をもつセットリセットラッチの非同期回路を合成せよ。S=1 で出力は 1 になり、R=1 で出力は 0 になり、S=R=1 は許されない。原始フロー表を導き、行を併合し、状態を割り当て、出力方程式を導け。
9.37中等Medium普通第二階Tier 2ティア 2?R
對下列流程表進行狀態化簡:狀態 A–D,輸入 x₁x₂={00,01,10,11}。找出等價狀態,並產生化簡後的表。
Perform state reduction on the following flow table: States A–D, Inputs x₁x₂={00,01,10,11}. Identify equivalent states and produce the reduced table.
次のフロー表について状態縮小を行え:状態 A–D、入力 x₁x₂={00,01,10,11}。等価な状態を見つけ、縮小した表を作れ。
9.38中等Medium普通第二階Tier 2ティア 2?R
用 one-hot 狀態編碼實作一個 3 狀態的非同步 FSM。對非同步電路而言,它相較於二進位編碼有哪些優點?
Use one-hot state encoding to implement a 3-state asynchronous FSM. What are the advantages over binary encoding for asynchronous circuits?
one-hot の状態符号化を用いて 3 状態の非同期 FSM を実装せよ。非同期回路において、2 進符号化に対する利点は何か。
9.39簡單Easy易しい第二階Tier 2ティア 2?R
為什麼非同步電路比同步電路更難設計?請列出至少三項具體的挑戰。
Why are asynchronous circuits more difficult to design than synchronous circuits? List at least three specific challenges.
非同期回路が同期回路より設計しにくいのはなぜか。具体的な困難を少なくとも 3 つ挙げよ。
9.40中等Medium普通第二階Tier 2ティア 2?R
說明原始流程表與合併(化簡)後流程表的差異。為什麼在狀態指派之前必須先做合併?
Explain the difference between the primitive flow table and the merged (reduced) flow table. Why is merging necessary before state assignment?
原始フロー表と併合(縮小)後のフロー表の違いを説明せよ。状態割当ての前に併合が必要なのはなぜか。
9.41中等Medium普通第二階Tier 2ティア 2?R
當預期的轉態為 1→0,電路輸出卻出現 1→0→1→0 的序列時,就發生了動態冒險。動態冒險在什麼條件下會發生?要如何消除?
A dynamic hazard occurs in the circuit output sequence 1→0→1→0 when the intended transition is 1→0. Under what conditions do dynamic hazards occur? How can they be eliminated?
意図した遷移が 1→0 であるのに回路の出力が 1→0→1→0 という系列になるとき、動的ハザードが起きている。動的ハザードはどんな条件で生じるか。どうすれば取り除けるか。
9.42簡單Easy易しい第二階Tier 2ティア 2?R
在非同步設計中,什麼是「don't happen」輸入組合?在設計過程中要如何運用它們?
What is a "don't happen" input combination in asynchronous design? How are they used in the design process?
非同期設計における「don't happen」入力組合せとは何か。設計の過程でそれらをどのように使うのか。
9.43困難Hard難しい第二階Tier 2ティア 2?R
設計一個非同步電路,作為兩個請求訊號 r₁ 與 r₂ 的仲裁器。電路應把使用權(g₁ 或 g₂)授予先提出請求的一方,並保持到該請求解除為止。
Design an asynchronous circuit that acts as an arbiter for two request signals r₁ and r₂. The circuit should grant access (g₁ or g₂) to the first requester and hold until that request is released.
2 つの要求信号 r₁ と r₂ の調停器 (arbiter) として働く非同期回路を設計せよ。回路は先に要求した側にアクセス権(g₁ または g₂)を与え、その要求が解除されるまで保持すること。

第三階 · 補遺Tier 3 · Residualティア 3 · 補遺

9.44困難Hard難しい第三階Tier 3ティア 3?R
利用轉移圖為一個 4 狀態的非同步電路找出無競爭的狀態指派。驗證其中不存在臨界競爭。
Find a race-free state assignment for a 4-state asynchronous circuit using transition diagrams. Verify that no critical races exist.
遷移図を用いて、4 状態の非同期回路の競合のない状態割当てを求めよ。臨界競合が存在しないことを確かめよ。
9.45困難Hard難しい第三階Tier 3ティア 3?R
設計一個非同步販賣機控制器:它接受 5¢ 與 10¢ 硬幣。當累計金額達到 15¢ 以上時,出貨並重置。從原始流程表開始推導出完整電路。
Design an asynchronous vending machine controller: it accepts 5¢ and 10¢ coins. When the total reaches 15¢ or more, it dispenses a product and resets. Derive the complete circuit starting from the primitive flow table.
非同期の自動販売機コントローラを設計せよ。5¢ と 10¢ のコインを受け付け、合計が 15¢ 以上になったら商品を払い出してリセットする。原始フロー表から出発して回路全体を導け。
9.46困難Hard難しい第三階Tier 3ティア 3?R
說明如何利用額外的狀態變數,為一個 5 狀態的非同步電路達成無競爭的狀態指派。解釋共用列 (shared-row) 技巧。
Show how to use additional state variables to achieve a race-free state assignment for a 5-state asynchronous circuit. Explain the shared-row technique.
追加の状態変数を用いて、5 状態の非同期回路に競合のない状態割当てを実現する方法を示せ。共有行 (shared-row) 法を説明せよ。
9.47困難Hard難しい第三階Tier 3ティア 3?R
給定一個 6 列、輸入為 x₁, x₂ 的流程表,用合併圖判定相容群組的最大數目。進行狀態指派並推導下一狀態方程式。
Given a flow table with 6 rows and inputs x₁, x₂, use the merger diagram to determine the maximum number of compatible groups. Perform the state assignment and derive the next-state equations.
6 行、入力 x₁, x₂ のフロー表が与えられたとき、マージャ図を用いて両立するグループの最大個数を求めよ。状態割当てを行い、次状態方程式を導け。
9.48困難Hard難しい第三階Tier 3ティア 3?R
證明任何以兩層 SOP 形式實作的函數都不會有靜態 0 冒險。靜態 0 冒險在什麼情況下才會出現?
Prove that any function implemented in a two-level SOP form will have no static 0-hazards. When can static 0-hazards appear?
2 レベル SOP 形式で実装されたどんな関数にも静的 0 ハザードが生じないことを証明せよ。静的 0 ハザードはどんなときに現れうるか。
11 邏輯符號速查Logic Symbols Reference論理記号リファレンス

布林/數位邏輯運算子記法的速查表,涵蓋教科書、數學與 Verilog 三種寫法。Quick-reference cheatsheet for Boolean / digital-logic operator notation across textbooks, math, and Verilog.ブール代数・ディジタル論理の演算子表記を、教科書・数学・Verilog の三通りでまとめた早見表です。

Basic Gates

符號Symbol記号Op讀作Reads as読み方範例Example
· ∧ & && *AND"and" / conjunction$x \cdot y$, $x \wedge y$
+ ∨ | ||OR"or" / disjunction$x + y$, $x \vee y$
¬ ~ ! ′ ‾NOT"not" / complement$\overline{x}$, $\neg x$, $x'$

Compound Gates

符號Symbol記号Op讀作Reads as読み方等效式Equivalent等価な式
⊕ ⊻ ^XOR"exclusive or"$x \oplus y = x\overline{y} + \overline{x}y$
⊙ ≡ ↔XNOR"equivalence"$x \odot y = \overline{x \oplus y}$
⊼ ↑NAND"Sheffer stroke"$x \uparrow y = \overline{x \cdot y}$
⊽ ↓NOR"Pierce arrow"$x \downarrow y = \overline{x + y}$

Implication & Set-Style

符號Symbol記号Op讀作/意義Reads as / Meaning読み方/意味
→ ⊃ ⇒implies"if … then" — $x \to y = \overline{x} + y$
↔ ≡iff「若且唯若」(等同於 XNOR)"if and only if" (same as XNOR)「〜のとき、かつそのときに限り」(XNOR と同じ)
intersection集合的 AND — 對集合而言與 · 效果相同set AND — same effect as · for sets集合の AND — 集合に対しては · と同じ働きをする
union集合的 OR — 對集合而言與 + 效果相同set OR — same effect as + for sets集合の OR — 集合に対しては + と同じ働きをする
⊂ ⊆subset「被…所蘊涵」 — 在數位邏輯中很少用到"is implied by" — rare in digital logic「〜に含意される」 — デジタル論理ではまれ

Constants & Quantifiers

符號Symbol記号意義Meaning意味
0 F ⊥false / logic 0 / GND
1 T ⊤true / logic 1 / Vcc
「對所有」(用於證明/SAT)"for all" (used in proofs / SAT)「すべての〜について」(証明や SAT で使う)
"there exists"

Verilog / HDL Operators

VerilogVerilogVerilogOp備註Notes備考
&ANDbitwise; &a = AND-reduction
|ORbitwise; |a = OR-reduction
~NOTbitwise complement
^XOR^a = XOR-reduction (parity)
~^ , ^~XNORbitwise equivalence
~&NANDreduction NAND
~|NORreduction NOR
&& || !logical1-bit boolean (returns 0 or 1)
== ===equalitylogical / case (matches X, Z)

Truth-Table & Canonical-Form Notation

符號Symbol記号意義Meaning意味
Σ m(…)sum of minterms (canonical SOP)
Π M(…)product of maxterms (canonical POS)
D(…) d(…)don't-care set
$m_i$最小項 i(只在第 i 列為 1 的乘積項)minterm i (product term that is 1 only on row i)最小項 i(第 i 行でのみ 1 になる積項)
$M_i$最大項 i(只在第 i 列為 0 的和項)maxterm i (sum term that is 0 only on row i)最大項 i(第 i 行でのみ 0 になる和項)
Convention notes:
解答Solutions解答

全部習題的完整詳解Complete worked solutions for all exercises全演習問題の詳細解答

第 2 章 — 布林代數Chapter 2 — Boolean Algebra第 2 章 — ブール代数
2.1

$f = x_1 \cdot x_2 + \overline{x_1} \cdot x_3$

$x_1$$x_2$$x_3$$x_1 x_2$$\overline{x_1} x_3$$f$
000000
001011
010000
011011
100000
101000
110101
111101
2.2

$f = (a+b) \cdot (c+d)$

$$\overline{f} = \overline{(a+b) \cdot (c+d)}$$ $$= \overline{(a+b)} + \overline{(c+d)} \quad \text{(DeMorgan's)}$$ $$= (\bar{a} \cdot \bar{b}) + (\bar{c} \cdot \bar{d})$$

$\therefore \boxed{\overline{f} = \bar{a}\bar{b} + \bar{c}\bar{d}}$

2.3

$f(x_1, x_2, x_3) = \sum m(1,2,5,6,7)$

標準 SOP(最小項之和)— 把每個最小項編號轉成二進位,並將 0 的位元取補數:

Canonical SOP (sum of minterms) — convert each minterm number to binary, complement 0s:

標準形 SOP(最小項の和)— 各最小項の番号を 2 進に直し、0 のビットを補数にする:

最小項Minterm最小項$x_1$$x_2$$x_3$Term
1001$\overline{x_1}\,\overline{x_2}\,x_3$
2010$\overline{x_1}\,x_2\,\overline{x_3}$
5101$x_1\,\overline{x_2}\,x_3$
6110$x_1\,x_2\,\overline{x_3}$
7111$x_1\,x_2\,x_3$
$$f = \overline{x_1}\,\overline{x_2}\,x_3 + \overline{x_1}\,x_2\,\overline{x_3} + x_1\,\overline{x_2}\,x_3 + x_1\,x_2\,\overline{x_3} + x_1\,x_2\,x_3$$

標準 POS(最大項之積,缺少的最小項為 0,3,4)— 把每個缺少的最小項轉成二進位,再將各位元取補數以構成 OR 項:

Canonical POS (product of maxterms, missing minterms = 0,3,4) — convert each missing minterm to binary, then complement each bit to form an OR term:

標準形 POS(最大項の積、欠けている最小項は 0,3,4)— 欠けている各最小項を 2 進に直し、各ビットを補数にして OR 項を作る:

最小項Minterm最小項$x_1$$x_2$$x_3$最大項(各項取補數)Maxterm (complement each)最大項(各項を反転)
0000$M_0 = (x_1+x_2+x_3)$
3011$M_3 = (x_1+\overline{x_2}+\overline{x_3})$
4100$M_4 = (\overline{x_1}+x_2+x_3)$
$$f = (x_1+x_2+x_3)(x_1+\overline{x_2}+\overline{x_3})(\overline{x_1}+x_2+x_3)$$

K-map simplification:

       x₂x₃
x₁  00 01 11 10
 0:  0  1  0  1
 1:  0  1  1  1

Groups:

  • $\{1,5\}$(第 01 欄,兩列皆有)→ $\overline{x_2}\,x_3$ — 只有 $x_1$ 改變,故被消去
  • $\{1,5\}$ (column 01, both rows) → $\overline{x_2}\,x_3$ — only $x_1$ changes, eliminated
  • $\{1,5\}$(列 01、両方の行)→ $\overline{x_2}\,x_3$ — 変化するのは $x_1$ だけなので消去される
  • $\{2,6\}$(第 10 欄,兩列皆有)→ $x_2\,\overline{x_3}$ — 只有 $x_1$ 改變,故被消去
  • $\{2,6\}$ (column 10, both rows) → $x_2\,\overline{x_3}$ — only $x_1$ changes, eliminated
  • $\{2,6\}$(列 10、両方の行)→ $x_2\,\overline{x_3}$ — 変化するのは $x_1$ だけなので消去される
  • $\{5,7\}$(第 1 列,01 & 11 兩欄)→ $x_1\,x_3$ — 只有 $x_2$ 改變,故被消去
  • $\{5,7\}$ (row 1, columns 01 & 11) → $x_1\,x_3$ — only $x_2$ changes, eliminated
  • $\{5,7\}$(行 1、列 01 & 11)→ $x_1\,x_3$ — 変化するのは $x_2$ だけなので消去される

Minimized SOP: $\boxed{f = \overline{x_2}\,x_3 + x_2\,\overline{x_3} + x_1\,x_3}$

(標準 SOP 原有 5 項 / 15 個文字 → 經 K-map 化簡為 3 項 / 7 個文字)

(Canonical SOP had 5 terms / 15 literals → K-map reduced to 3 terms / 7 literals)

(標準形 SOP は 5 項 / 15 リテラルだったが → K-map で 3 項 / 7 リテラルに簡単化された)

2.4

$f = \sum m(0,1,2,5,6,7)$. K-map:

       x₂x₃
x₁  00 01 11 10
 0:  1  1  0  1
 1:  0  1  1  1

Groups:

  • $\{0,2\}$ → $\overline{x_1}\,\overline{x_3}$
  • $\{1,5\}$ → $\overline{x_2}\,x_3$
  • $\{6,7\}$ → $x_1\,x_2$

最簡 SOP: $\boxed{f = \overline{x_1}\,\overline{x_3} + \overline{x_2}\,x_3 + x_1\,x_2}$

Minimized SOP: $\boxed{f = \overline{x_1}\,\overline{x_3} + \overline{x_2}\,x_3 + x_1\,x_2}$

最簡 SOP: $\boxed{f = \overline{x_1}\,\overline{x_3} + \overline{x_2}\,x_3 + x_1\,x_2}$

2.5

$f = \sum m(0,2,5,7,8,10,13,15)$. 4-variable K-map:

        x₃x₄
x₁x₂  00 01 11 10
  00:   1  0  0  1
  01:   0  1  1  0
  11:   0  1  1  0
  10:   1  0  0  1

Groups:

  • $\{0,2,8,10\}$ → $\overline{x_2}\,\overline{x_4}$
  • $\{5,7,13,15\}$ → $x_2\,x_4$

最簡 SOP: $\boxed{f = \overline{x_2}\,\overline{x_4} + x_2\,x_4 = x_2 \odot x_4 \;\text{(XNOR)}}$

Minimized SOP: $\boxed{f = \overline{x_2}\,\overline{x_4} + x_2\,x_4 = x_2 \odot x_4 \;\text{(XNOR)}}$

最簡 SOP: $\boxed{f = \overline{x_2}\,\overline{x_4} + x_2\,x_4 = x_2 \odot x_4 \;\text{(XNOR)}}$

2.6

$f = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$。4 變數 K-map,其中 0、5 為 don't-care:

$f = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$. 4-var K-map with don't cares at 0, 5:

$f = \sum m(1,3,4,6,9,11,12,14) + D(0,5)$。0 と 5 が don't-care である 4 変数 K-map:

        x₃x₄
x₁x₂  00 01 11 10
  00:   d  1  1  0
  01:   1  d  0  1
  11:   1  0  0  1
  10:   0  1  1  0

Groups:

  • $\{1, 3, 9, 11\}$(第 00 & 10 列,第 01 & 11 欄)→ $\overline{x_2}\,x_4$ — $x_2=0$、$x_4=1$ 維持不變
  • $\{1, 3, 9, 11\}$ (rows 00 & 10, cols 01 & 11) → $\overline{x_2}\,x_4$ — $x_2=0$, $x_4=1$ constant
  • $\{1, 3, 9, 11\}$(行 00 & 10、列 01 & 11)→ $\overline{x_2}\,x_4$ — $x_2=0$、$x_4=1$ が一定
  • $\{4, 6, 12, 14\}$(第 01 & 11 列,第 00 & 10 欄)→ $x_2\,\overline{x_4}$ — $x_2=1$、$x_4=0$ 維持不變
  • $\{4, 6, 12, 14\}$ (rows 01 & 11, cols 00 & 10) → $x_2\,\overline{x_4}$ — $x_2=1$, $x_4=0$ constant
  • $\{4, 6, 12, 14\}$(行 01 & 11、列 00 & 10)→ $x_2\,\overline{x_4}$ — $x_2=1$、$x_4=0$ が一定

這兩個四格區塊涵蓋了全部 8 個最小項,不需要動用 don't-care。

These two quads cover all 8 minterms without needing don't-cares.

この 2 つの 4 セルブロックは、don't-care を使わずに 8 個の最小項すべてを覆う。

最簡 SOP: $\boxed{f = \overline{x_2}\,x_4 + x_2\,\overline{x_4} = x_2 \oplus x_4 \;\text{(XOR)}}$

Minimized SOP: $\boxed{f = \overline{x_2}\,x_4 + x_2\,\overline{x_4} = x_2 \oplus x_4 \;\text{(XOR)}}$

最簡 SOP: $\boxed{f = \overline{x_2}\,x_4 + x_2\,\overline{x_4} = x_2 \oplus x_4 \;\text{(XOR)}}$

2.7

要具備功能完備性,必須能實作 NOT 與 AND(或 NOT 與 OR)。

Functional completeness requires implementing NOT and AND (or NOT and OR).

関数完全であるためには、NOT と AND(あるいは NOT と OR)を実現できることが必要である。

NOT from NAND:

$$\text{NAND}(x, x) = \overline{x \cdot x} = \overline{x} \quad \checkmark$$

AND from NAND:

$$\text{AND}(x, y) = \overline{\overline{x \cdot y}} = \text{NAND}\!\big(\text{NAND}(x,y),\;\text{NAND}(x,y)\big) \quad \checkmark$$

OR from NAND:

$$\text{OR}(x, y) = \text{NAND}(\overline{x},\;\overline{y}) = \text{NAND}\!\big(\text{NAND}(x,x),\;\text{NAND}(y,y)\big) \quad \checkmark$$

既然 $\{\text{NOT}, \text{AND}\}$ 是功能完備的,而兩者都能只用 NAND 實現,因此 NAND 是功能完備的。$\blacksquare$

Since $\{\text{NOT}, \text{AND}\}$ is functionally complete and both are realizable with NAND only, NAND is functionally complete. $\blacksquare$

$\{\text{NOT}, \text{AND}\}$ は関数完全であり、そのどちらも NAND だけで実現できるので、NAND は関数完全である。$\blacksquare$

2.8

三路開關燈:任何一個開關切換時輸出就改變 → 三個輸入的 XOR。

3-way light: output changes when any switch toggles → XOR of three inputs.

3 路スイッチの照明:どのスイッチを切り替えても出力が変わる → 3 入力の XOR である。

$x_1$$x_2$$x_3$$f$
0000
0011
0101
0110
1001
1010
1100
1111

$f = \sum m(1,2,4,7)$。最簡 SOP:$\boxed{f = x_1 \oplus x_2 \oplus x_3}$

$f = \sum m(1,2,4,7)$. Min SOP: $\boxed{f = x_1 \oplus x_2 \oplus x_3}$

$f = \sum m(1,2,4,7)$。最簡 SOP:$\boxed{f = x_1 \oplus x_2 \oplus x_3}$

$$= \overline{x_1}\,\overline{x_2}\,x_3 + \overline{x_1}\,x_2\,\overline{x_3} + x_1\,\overline{x_2}\,\overline{x_3} + x_1\,x_2\,x_3$$

(XOR 不存在更簡單的 SOP。)

(No simpler SOP exists for XOR.)

(XOR にこれより簡単な SOP は存在しない。)

2.9
module mux2to1 (
    input  wire s, d0, d1,
    output reg  y
);
    always @(*) begin
        if (s)
            y = d1;
        else
            y = d0;
    end
endmodule

同樣可行: assign f = ~s & w0 | s & w1; — 直接把布林 MUX 方程式寫成連續指定。

Also valid: assign f = ~s & w0 | s & w1; — the Boolean mux equation directly as a continuous assignment.

これも正しい: assign f = ~s & w0 | s & w1; — MUX のブール式をそのまま継続的代入として書いたものである。

2.10

3 個輸入的多數決:當有 2 個以上的輸入為 1 時輸出 1。

Majority of 3 inputs: output 1 when 2 or more inputs are 1.

3 入力の多数決:入力のうち 2 つ以上が 1 のとき出力が 1 になる。

$a$$b$$c$$f$
0000
0010
0100
0111
1000
1011
1101
1111

$f = \sum m(3,5,6,7)$。由 K-map 可得:$\boxed{f = ab + ac + bc}$

$f = \sum m(3,5,6,7)$. K-map gives: $\boxed{f = ab + ac + bc}$

$f = \sum m(3,5,6,7)$。K-map から次を得る:$\boxed{f = ab + ac + bc}$

電路:三個 AND 閘分別產生 $ab$、$ac$、$bc$;再接一個 3 輸入 OR 閘。

Circuit: three AND gates for $ab$, $ac$, $bc$; one 3-input OR gate.

回路:$ab$、$ac$、$bc$ 用の AND ゲート 3 個と、3 入力 OR ゲート 1 個。

a b c AND ab AND ac AND bc OR f
2.11
  • 最小項 (Minterm):乘積項,每個變數恰好出現一次(原變數或補數);僅在一組輸入組合下為 1。例如 $m_5 = x_1\overline{x_2}\,x_3$ 只在 $(1,0,1)$ 時為 1。
  • 最大項 (Maxterm):和項,每個變數恰好出現一次;僅在一組輸入組合下為 0。例如 $M_0 = x_1 + x_2 + x_3$ 只在 $(0,0,0)$ 時為 0。
  • 蘊涵項 (Implicant):一個乘積項,只涵蓋 f=1 的列(不涵蓋任何 f=0 的列)。例如 $x_1 x_3$ 涵蓋 $\{m_5, m_7\}$,兩者皆 $f=1$。
  • 質蘊涵項 (Prime Implicant, PI):無法再與其他蘊涵項合併以消去變數的蘊涵項(無法再擴大)。例如 $x_3$ 涵蓋 $\{m_1,m_3,m_5,m_7\}$;$x_1 x_3$ 不是質蘊涵項,因為它被 $x_3$ 包含。
  • 必要質蘊涵項 (Essential PI):唯一涵蓋某個最小項的質蘊涵項;在任何最小覆蓋中都必須包含。例如 $\overline{x_1}\,x_2$ 是必要的,因為 $m_2$ 只被它涵蓋。
  • Minterm: A product term in which every variable appears exactly once (complemented or uncomplemented); evaluates to 1 for exactly one input combination. e.g. $m_5 = x_1\overline{x_2}\,x_3$ equals 1 only at $(1,0,1)$.
  • Maxterm: A sum term in which every variable appears exactly once; evaluates to 0 for exactly one input combination. e.g. $M_0 = x_1 + x_2 + x_3$ equals 0 only at $(0,0,0)$.
  • Implicant: A product term that covers only rows where f=1 (never a 0-row). e.g. $x_1 x_3$ covers $\{m_5, m_7\}$, both $f=1$.
  • Prime implicant (PI): An implicant that cannot be combined with another implicant to eliminate a variable (cannot be enlarged). e.g. $x_3$ covers $\{m_1,m_3,m_5,m_7\}$; $x_1 x_3$ is not prime since it is contained in $x_3$.
  • Essential PI: A prime implicant that is the only one covering at least one minterm; must be in every minimum cover. e.g. $\overline{x_1}\,x_2$ is essential because $m_2$ is covered only by it.
  • 最小項 (Minterm):すべての変数がちょうど 1 回ずつ(そのままか補数で)現れる積項。ただ 1 通りの入力組合せでのみ 1 になる。例:$m_5 = x_1\overline{x_2}\,x_3$ は $(1,0,1)$ でのみ 1 になる。
  • 最大項 (Maxterm):すべての変数がちょうど 1 回ずつ現れる和項。ただ 1 通りの入力組合せでのみ 0 になる。例:$M_0 = x_1 + x_2 + x_3$ は $(0,0,0)$ でのみ 0 になる。
  • 内項 (Implicant):f=1 の行だけを覆う積項(0 の行は決して覆わない)。例:$x_1 x_3$ は $\{m_5, m_7\}$ を覆い、どちらも $f=1$ である。
  • 主項 (Prime Implicant, PI):他の内項と併合して変数を消すことができない(これ以上大きくできない)内項。例:$x_3$ は $\{m_1,m_3,m_5,m_7\}$ を覆う。$x_1 x_3$ は $x_3$ に含まれるので主項ではない
  • 必須主項 (Essential PI):ある最小項を覆う唯一の主項。どの最小被覆にも必ず含まれる。例:$\overline{x_1}\,x_2$ は必須である。$m_2$ を覆うのがこれだけだからである。

範例:Example:例: $f(x_1,x_2,x_3) = \sum m(1,2,3,5,7)$

$x_1$$x_2$$x_3$$f$
0000
0011$m_1$
0101$m_2$
0111$m_3$
1000
1011$m_5$
1100
1111$m_7$
  • 最小項:僅在 $(1,0,1)$ 時為 1。
  • Minterm: $m_5 = x_1\overline{x_2}\,x_3$ — only equals 1 at row $(1,0,1)$.
  • 最小項:$m_5 = x_1\overline{x_2}\,x_3$ — 行 $(1,0,1)$ でのみ 1 になる。
  • 最大項:僅在 $(0,0,0)$ 時為 0。
  • Maxterm: $M_0 = x_1 + x_2 + x_3$ — only equals 0 at row $(0,0,0)$.
  • 最大項:$M_0 = x_1 + x_2 + x_3$ — 行 $(0,0,0)$ でのみ 0 になる。
  • 蘊涵項:$x_1 x_3$ 涵蓋 $\{m_5, m_7\}$,兩者皆 $f=1$。單一最小項如 $m_3$ 也是蘊涵項。
  • Implicant: $x_1 x_3$ covers $\{m_5, m_7\}$, both have $f=1$. A single minterm like $m_3$ is also an implicant.
  • 内項:$x_1 x_3$ は $\{m_5, m_7\}$ を覆い、どちらも $f=1$ である。$m_3$ のような単一の最小項も内項である。
  • 質蘊涵項:$x_3$ 涵蓋 $\{m_1,m_3,m_5,m_7\}$,無法再擴大。$\overline{x_1}\,x_2$ 涵蓋 $\{m_2,m_3\}$,無法再擴大。而 $x_1 x_3$ 不是質蘊涵項,因為它被更大的 $x_3$ 包含。
  • Prime Implicant: $x_3$ covers $\{m_1,m_3,m_5,m_7\}$ — cannot be enlarged further. $\overline{x_1}\,x_2$ covers $\{m_2,m_3\}$ — cannot be enlarged. But $x_1 x_3$ is not prime because it is contained within the larger PI $x_3$.
  • 主項:$x_3$ は $\{m_1,m_3,m_5,m_7\}$ を覆い、これ以上大きくできない。$\overline{x_1}\,x_2$ は $\{m_2,m_3\}$ を覆い、やはり拡大できない。一方 $x_1 x_3$ はより大きな主項 $x_3$ に含まれるので主項ではない
  • 必要質蘊涵項:$\overline{x_1}\,x_2$ 是必要的,因為 $m_2$ 只被它涵蓋。$x_3$ 是必要的,因為 $m_1, m_5, m_7$ 只被它涵蓋。
  • Essential PI: $\overline{x_1}\,x_2$ is essential — $m_2$ is covered only by this PI. $x_3$ is essential — $m_1, m_5, m_7$ are covered only by it.
  • 必須主項:$\overline{x_1}\,x_2$ は必須である — $m_2$ を覆うのはこの主項だけだからである。$x_3$ も必須である — $m_1, m_5, m_7$ を覆うのはこれだけである。

最簡積項和:$\boxed{f = x_3 + \overline{x_1}\,x_2}$

Minimum SOP:$\boxed{f = x_3 + \overline{x_1}\,x_2}$

最簡積和形:$\boxed{f = x_3 + \overline{x_1}\,x_2}$

2.43

$f_1 = \sum m(0,2,3,4,5,7)$, $f_2 = \sum m(1,2,3,5,6,7)$.

K-map for $f_1$:

       x₂x₃
x₁  00 01 11 10
 0:  1  0  1  1
 1:  1  1  1  0

沒有四格區塊(只有 6 個 1,既沒有連成一排的 4 格,也沒有全為 1 的 2×2 區塊)。三個兩格區塊即可涵蓋全部六個 1:

No quads (only 6 ones, no 4-in-a-row/2×2 block of all 1s). Three pairs cover all six 1s:

4 セルブロックはない(1 は 6 個しかなく、4 連続も、すべて 1 の 2×2 ブロックもない)。3 つの 2 セル対で 6 個の 1 をすべて覆える:

  • $\{m_0, m_4\}$ (column 00) → $\overline{x_2}\,\overline{x_3}$
  • $\{m_2, m_3\}$ (top row, cols 10–11) → $\overline{x_1}\,x_2$
  • $\{m_5, m_7\}$ (bottom row, cols 01–11) → $x_1 x_3$

$\boxed{f_1 = \overline{x_2}\,\overline{x_3} + \overline{x_1}\,x_2 + x_1 x_3}$

K-map for $f_2$:

       x₂x₃
x₁  00 01 11 10
 0:  0  1  1  1
 1:  0  1  1  1

兩個必要的四格區塊即可涵蓋全部六個 1:

Two essential quads cover all six 1s:

2 つの必須の 4 セルブロックで 6 個の 1 をすべて覆える:

  • $\{m_1, m_3, m_5, m_7\}$ (cols 01 ∪ 11, all $x_3{=}1$) → $x_3$
  • $\{m_2, m_3, m_6, m_7\}$ (cols 11 ∪ 10, all $x_2{=}1$) → $x_2$

$\boxed{f_2 = x_2 + x_3}$

共用閘的實作:注意 $\overline{x_2}\,\overline{x_3} = \overline{(x_2 + x_3)} = \overline{f_2}$。因此用一個 OR 閘算出 $f_2$,再以它的反相輸出提供 $f_1$ 的 $\overline{x_2}\,\overline{x_3}$ 項:

Shared-gate implementation: Note that $\overline{x_2}\,\overline{x_3} = \overline{(x_2 + x_3)} = \overline{f_2}$. So one OR gate computes $f_2$, and its inverted output supplies the $\overline{x_2}\,\overline{x_3}$ term of $f_1$:

ゲート共有による実装:$\overline{x_2}\,\overline{x_3} = \overline{(x_2 + x_3)} = \overline{f_2}$ であることに注意する。したがって OR ゲート 1 個で $f_2$ を求め、その反転出力を $f_1$ の $\overline{x_2}\,\overline{x_3}$ 項として供給する:

  1. $T = x_2 + x_3$   (OR2)  — this is $f_2$
  2. $\overline{T}$   (NOT)
  3. $A = \overline{x_1}\,x_2$   (AND2)
  4. $B = x_1 x_3$   (AND2)
  5. $f_1 = \overline{T} + A + B$   (OR3)

成本(閘數 + 輸入總數,補數文字不計費):

Cost (gates + total inputs, complemented literals free):

コスト(ゲート数 + 総入力数、補数リテラルは無料とする):

  • Independent: $f_1$ = 4 gates + 9 inputs = 13; $f_2$ = 1 + 2 = 3 → 16
  • 共用:5 個閘 + 10 個輸入 = 15  (重複使用 $x_2{+}x_3$ 的 OR 閘,省下 1)
  • Shared: 5 gates + 10 inputs = 15  (saving 1 by reusing the $x_2{+}x_3$ OR-gate)
  • 共有あり:ゲート 5 個 + 入力 10 個 = 15  ($x_2{+}x_3$ の OR ゲートを再利用して 1 節約)
2.44

Prove $x + x \cdot y = x$:

$$x + x \cdot y = x \cdot 1 + x \cdot y \quad \text{(identity: } x = x \cdot 1\text{)}$$ $$= x \cdot (1 + y) \quad \text{(factoring)}$$ $$= x \cdot 1 \quad \text{(since } 1 + y = 1\text{)}$$ $$= x \quad \text{(identity)} \quad \blacksquare$$

This is the absorption law.

2.45

$f = a \cdot b + c$。利用雙重反相轉換成 NAND-NAND:

$f = a \cdot b + c$. Convert to NAND-NAND using double inversion:

$f = a \cdot b + c$。二重反転を使って NAND-NAND に変換する:

$$f = a \cdot b + c = \overline{\overline{a \cdot b} \cdot \overline{c}}$$

Implementation:

  • Gate 1: $\text{NAND}(a, b) = \overline{ab}$
  • 閘 2:$\text{NAND}(c, c) = \overline{c}$(作用等同 NOT)
  • Gate 2: $\text{NAND}(c, c) = \overline{c}$ (acts as NOT)
  • ゲート 2:$\text{NAND}(c, c) = \overline{c}$(NOT として働く)
  • 閘 3:$\text{NAND}(\overline{ab},\; \overline{c}) = \overline{\overline{ab} \cdot \overline{c}} = ab + c = f$
  • Gate 3: $\text{NAND}(\overline{ab},\; \overline{c}) = \overline{\overline{ab} \cdot \overline{c}} = ab + c = f$
  • ゲート 3:$\text{NAND}(\overline{ab},\; \overline{c}) = \overline{\overline{ab} \cdot \overline{c}} = ab + c = f$

Three NAND gates total.

2.46

f = (a AND b) OR (NOT a AND c)

module structural_f (
    input  wire a, b, c,
    output wire f
);
    wire not_a, and1, and2;
    not  g0 (not_a, a);
    and  g1 (and1, a, b);
    and  g2 (and2, not_a, c);
    or   g3 (f, and1, and2);
endmodule
2.47

Use a 3-circle Venn diagram for $x, y, z$.

左式: $x \cdot (y+z)$ — 位於 $x$ 內、且位於($y$ 或 $z$)內的區域:

LHS: $x \cdot (y+z)$ — region inside $x$ AND inside ($y$ or $z$):

左辺: $x \cdot (y+z)$ — $x$ の内側かつ($y$ または $z$)の内側の領域:

x y z

右式: $x\cdot y + x\cdot z$ — 區域 $(x\cap y) \cup (x\cap z)$:

RHS: $x\cdot y + x\cdot z$ — region $(x\cap y) \cup (x\cap z)$:

右辺: $x\cdot y + x\cdot z$ — 領域 $(x\cap y) \cup (x\cap z)$:

x y z

兩者陰影完全相同,分配律因此獲證。$\blacksquare$

Identical shadings, proving the distributive law. $\blacksquare$

網掛けが完全に一致し、分配律が証明される。$\blacksquare$

2.48

$f = \prod M(0,1,4,5,9,11,15)$. Zeros at minterms 0,1,4,5,9,11,15.

以 4 變數卡諾圖標出 $f=0$ 的位置,把 0 分組以取得 POS:

4-var K-map for $f=0$ positions, group the 0s for POS:

4 変数カルノー図に $f=0$ の位置を取り、POS を得るために 0 をまとめる:

  • $\{0,1,4,5\}$ → $(x_1 + x_2)$
  • $\{9,11\}$ → $(\overline{x_1} + x_2 + \overline{x_4})$
  • $\{15\}$ → $(\overline{x_1} + \overline{x_2} + \overline{x_3} + \overline{x_4})$

最小 POS: $\boxed{f = (x_1+x_2)(\overline{x_1}+\overline{x_2}+x_4)(\overline{x_1}+\overline{x_2}+\overline{x_3})}$

Min POS: $\boxed{f = (x_1+x_2)(\overline{x_1}+\overline{x_2}+x_4)(\overline{x_1}+\overline{x_2}+\overline{x_3})}$

最小 POS: $\boxed{f = (x_1+x_2)(\overline{x_1}+\overline{x_2}+x_4)(\overline{x_1}+\overline{x_2}+\overline{x_3})}$

2.49

$f = x_1 x_2 + \overline{x_1}\,x_3 + x_2 x_3$

Literal count: $x_1 x_2$ (2) + $\overline{x_1}\,x_3$ (2) + $x_2 x_3$ (2) = 6 literals.

閘數(兩層):3 個 AND 閘(各 2 輸入)+ 1 個 OR 閘(3 輸入)= 4 個閘。

Gate count (2-level): 3 AND gates (2-input each) + 1 OR gate (3-input) = 4 gates.

ゲート数(2 レベル):AND ゲート 3 個(各 2 入力)+ OR ゲート 1 個(3 入力)= 4 ゲート。

成本(閘數 + 輸入數):$3 \times 2 + 1 \times 3 = 9$ 個閘輸入 + 4 個閘 = 成本 9。

Cost (gates + inputs): $3 \times 2 + 1 \times 3 = 9$ gate inputs + 4 gates = cost of 9.

コスト(ゲート数 + 入力数):$3 \times 2 + 1 \times 3 = 9$ ゲート入力 + 4 ゲート = コスト 9。

注意:$x_2 x_3$ 是多餘的一致項 (consensus term);化簡後:$f = x_1 x_2 + \overline{x_1}\,x_3$(成本 = 5)。

Note: $x_2 x_3$ is a redundant consensus term; minimized: $f = x_1 x_2 + \overline{x_1}\,x_3$ (cost = 5).

注意:$x_2 x_3$ は冗長な合意項 (consensus term) である。簡単化すると $f = x_1 x_2 + \overline{x_1}\,x_3$(コスト = 5)。

2.50

Circuit: $g = \overline{a}$; $h = a \cdot b$; $f = g + h$

$$f = g + h = \overline{a} + a \cdot b$$ $$= \overline{a} + b \quad \text{(absorption dual / consensus)}$$

$\boxed{f = \overline{a} + b}$(等價於 $a \rightarrow b$,即蘊涵)。

$\boxed{f = \overline{a} + b}$ (equivalent to $a \rightarrow b$, implication).

$\boxed{f = \overline{a} + b}$($a \rightarrow b$、すなわち含意と等価である)。

$a$$b$$f$
001
011
100
111
2.51

Structural XOR:

module xor_struct (input a, b, output f);
    wire na, nb, t1, t2;
    not g0(na, a);
    not g1(nb, b);
    and g2(t1, a, nb);
    and g3(t2, na, b);
    or  g4(f, t1, t2);
endmodule

Behavioral XOR:

module xor_behav (input a, b, output f);
    assign f = a ^ b;
endmodule

結構化描述會明確實體化各個閘;行為化描述則以數學方式描述功能,把實作方式的選擇交給合成工具。

Structural explicitly instantiates gates; behavioral describes function mathematically and lets synthesis choose implementation.

構造記述はゲートを明示的にインスタンス化する。動作記述は機能を数学的に記述し、実装の選択は合成に任せる。

2.52

From 2.6: $f = \overline{x_2}\,\overline{x_4} + x_2\,x_4$

module f_2_6 (
    input  wire x1, x2, x3, x4,
    output wire f
);
    assign f = (~x2 & ~x4) | (x2 & x4);
endmodule

module tb;
    reg  x1,x2,x3,x4;
    wire f;
    f_2_6 uut(.x1(x1),.x2(x2),.x3(x3),.x4(x4),.f(f));
    integer i;
    initial begin
        $display("x1 x2 x3 x4 | f");
        for (i=0; i<16; i=i+1) begin
            {x1,x2,x3,x4} = i[3:0];
            #10;
            $display("%b  %b  %b  %b  | %b", x1,x2,x3,x4,f);
        end
        $finish;
    end
endmodule
2.53

4 個感測器中有 2 個以上作用時 Alarm = 1。$f = \sum m(3,5,6,7,9,10,11,12,13,14,15)$。

Alarm = 1 when 2 or more of 4 sensors active. $f = \sum m(3,5,6,7,9,10,11,12,13,14,15)$.

4 個のセンサのうち 2 個以上が作動したとき Alarm = 1 となる。$f = \sum m(3,5,6,7,9,10,11,12,13,14,15)$。

4-var K-map groups:

  • $\{3,7,11,15\}$ → $x_3 x_4$
  • $\{5,7,13,15\}$ → $x_2 x_4$
  • $\{6,7,14,15\}$ → $x_2 x_3$
  • $\{9,11,13,15\}$ → $x_1 x_4$
  • $\{10,11,14,15\}$ → $x_1 x_3$
  • $\{12,13,14,15\}$ → $x_1 x_2$

6 個質蘊涵項全都是必要質蘊涵項。最小 SOP:

All 6 prime implicants are essential. Minimal SOP:

6 個の主項はすべて必須主項である。最小 SOP:

$$\boxed{f = x_1 x_2 + x_1 x_3 + x_1 x_4 + x_2 x_3 + x_2 x_4 + x_3 x_4}$$
2.54

$f = \sum m(0,1,2,3,4,6,8,9,12)$。用 4 變數卡諾圖,再轉換成 NAND-NAND。

$f = \sum m(0,1,2,3,4,6,8,9,12)$. 4-var K-map, convert to NAND-NAND.

$f = \sum m(0,1,2,3,4,6,8,9,12)$。4 変数カルノー図を用い、NAND-NAND に変換する。

K-map groups:

  • $\{0,1,2,3\}$ → $\overline{x_1}\,\overline{x_2}$
  • $\{0,1,8,9\}$ → $\overline{x_2}\,\overline{x_3}$
  • $\{0,4,8,12\}$ → $\overline{x_3}\,\overline{x_4}$
  • $\{4,6\}$ → $\overline{x_1}\,x_2\,\overline{x_4}$

最小 SOP: $\boxed{f = \overline{x_1}\,\overline{x_2} + \overline{x_2}\,\overline{x_3} + \overline{x_3}\,\overline{x_4} + \overline{x_1}\,x_2\,\overline{x_4}}$

Minimal SOP: $\boxed{f = \overline{x_1}\,\overline{x_2} + \overline{x_2}\,\overline{x_3} + \overline{x_3}\,\overline{x_4} + \overline{x_1}\,x_2\,\overline{x_4}}$

最小 SOP: $\boxed{f = \overline{x_1}\,\overline{x_2} + \overline{x_2}\,\overline{x_3} + \overline{x_3}\,\overline{x_4} + \overline{x_1}\,x_2\,\overline{x_4}}$

$$\text{NAND-NAND: } f = \overline{\overline{\overline{x_1}\,\overline{x_2}} \cdot \overline{\overline{x_2}\,\overline{x_3}} \cdot \overline{\overline{x_3}\,\overline{x_4}} \cdot \overline{\overline{x_1}\,x_2\,\overline{x_4}}}$$
2.55

要證明或推翻 5 變數函數的 $f = g$,可建立真值表(各 32 列),或使用代數運算/BDD 建構。

To prove or disprove $f = g$ for 5-variable functions, build truth tables (32 rows each) or use algebraic manipulation / BDD construction.

5 変数関数について $f = g$ を証明または反証するには、真理値表(各 32 行)を作るか、代数的変形あるいは BDD の構成を用いる。

方法:計算 $h = f \oplus g$。若 32 種輸入組合下都有 $h = 0$,則 $f = g$;否則找出使 $h = 1$ 的反例列。

Method: Compute $h = f \oplus g$. If $h = 0$ for all 32 input combinations, $f = g$; otherwise find a counterexample row where $h = 1$.

方法:$h = f \oplus g$ を計算する。32 通りの入力組合せすべてで $h = 0$ なら $f = g$ である。そうでなければ $h = 1$ となる反例の行を見つける。

實務上:以相同的變數順序把兩者都表示成 BDD。若兩個 ROBDD 的根指向同一個節點(標準形式),則兩者等價;否則不等價。

In practice: represent both as BDDs with the same variable order. If their ROBDD roots point to the same node (canonical form), they are equivalent; otherwise inequivalent.

実務では、同じ変数順序で両者を BDD として表現する。2 つの ROBDD の根が同じノードを指す(標準形)なら等価であり、そうでなければ非等価である。

2.12E

The truth table is

$x$$y$$L$
000
011
101
110
Summing the two minterms gives $L = \overline{x}\,y + x\,\overline{y}$, which is the XOR function $L = x \oplus y$.

2.13E
$a$$b$$s_1$$s_0$
0000
0101
1001
1110
So $s_0 = a \oplus b$ (sum bit) and $s_1 = a \cdot b$ (carry bit). Implement with one XOR gate and one AND gate sharing the same inputs $a,b$ — this is the half-adder.
2.14E

用分配律展開左式:$(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\overline{x_1} + x_1 x_3 + \overline{x_1}\,\overline{x_3} + \overline{x_3} x_3 = 0 + x_1 x_3 + \overline{x_1}\,\overline{x_3} + 0 = x_1 x_3 + \overline{x_1}\,\overline{x_3}$,正好等於右式。(這就是 XNOR 恆等式。)

Expand the LHS using distributivity: $(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\overline{x_1} + x_1 x_3 + \overline{x_1}\,\overline{x_3} + \overline{x_3} x_3 = 0 + x_1 x_3 + \overline{x_1}\,\overline{x_3} + 0 = x_1 x_3 + \overline{x_1}\,\overline{x_3}$, which equals the RHS. (This is the XNOR identity.)

分配律を用いて左辺を展開する:$(x_1+\overline{x_3})(\overline{x_1}+x_3) = x_1\overline{x_1} + x_1 x_3 + \overline{x_1}\,\overline{x_3} + \overline{x_3} x_3 = 0 + x_1 x_3 + \overline{x_1}\,\overline{x_3} + 0 = x_1 x_3 + \overline{x_1}\,\overline{x_3}$ となり、右辺に等しい。(これは XNOR の恒等式である。)

2.15E

把左式分組成 $(\overline{x_1}+x_1) x_3 \cdot \text{(impossible)}$… 更好的做法:依變數 $x_3$ 兩兩合併。$\overline{x_1}\,\overline{x_3} + x_1 x_3$ 是一個 XNOR;$\overline{x_2}x_3 + x_2\overline{x_3}$ 是一個 XOR。這兩者在以 $x_2$/$x_1$ 展開時會消去部分項,再套用 $x+\overline{x}=1$ 與吸收律,即得最簡式 $f = x_1 \oplus x_2 \cdot 0 + \dots = \overline{x_1\oplus x_2} + x_1\overline{x_2}$,也就是右式 $x_1 x_2 + \overline{x_1}\,\overline{x_2} + x_1\overline{x_2}$。由吸收律 $x_1\overline{x_2} + x_1 x_2 = x_1$,故最簡形式為 $f = x_1 + \overline{x_1}\,\overline{x_2} = x_1 + \overline{x_2}$。

Group the LHS as $(\overline{x_1}+x_1) x_3 \cdot \text{(impossible)}$… better: combine pairs by the variable $x_3$. $\overline{x_1}\,\overline{x_3} + x_1 x_3$ is one XNOR; $\overline{x_2}x_3 + x_2\overline{x_3}$ is one XOR. These two cancel some terms when expanded with $x_2$/$x_1$, and applying $x+\overline{x}=1$ and absorption gives the simplest expression $f = x_1 \oplus x_2 \cdot 0 + \dots = \overline{x_1\oplus x_2} + x_1\overline{x_2}$, equivalently the RHS $x_1 x_2 + \overline{x_1}\,\overline{x_2} + x_1\overline{x_2}$. By absorption $x_1\overline{x_2} + x_1 x_2 = x_1$, so the simplest form is $f = x_1 + \overline{x_1}\,\overline{x_2} = x_1 + \overline{x_2}$.

左辺を $(\overline{x_1}+x_1) x_3 \cdot \text{(impossible)}$ とまとめる… より良いのは、変数 $x_3$ について対を組み合わせることである。$\overline{x_1}\,\overline{x_3} + x_1 x_3$ は 1 つの XNOR、$\overline{x_2}x_3 + x_2\overline{x_3}$ は 1 つの XOR である。この 2 つは $x_2$/$x_1$ で展開すると一部の項が打ち消し合い、$x+\overline{x}=1$ と吸収則を適用すれば最簡の式 $f = x_1 \oplus x_2 \cdot 0 + \dots = \overline{x_1\oplus x_2} + x_1\overline{x_2}$、すなわち右辺 $x_1 x_2 + \overline{x_1}\,\overline{x_2} + x_1\overline{x_2}$ が得られる。吸収則より $x_1\overline{x_2} + x_1 x_2 = x_1$ なので、最簡形は $f = x_1 + \overline{x_1}\,\overline{x_2} = x_1 + \overline{x_2}$ である。

2.16E

Use a 3-circle Venn diagram for $x, y, z$.

左式: $x + y\cdot z$ 把整個圓 $x$ 連同透鏡形區域 $y\cap z$ 一併塗色:

LHS: $x + y\cdot z$ shades all of circle $x$ plus the lens-shaped region $y\cap z$:

左辺: $x + y\cdot z$ は円 $x$ 全体と、レンズ形の領域 $y\cap z$ を網掛けする:

x y z

右式: $(x+y)\cdot(x+z)$ 把「在 $x$ 或 $y$ 內」與「在 $x$ 或 $z$ 內」的交集塗色 — 也就是所有落在 $x$ 內、或同時落在 $y$ 與 $z$ 內的點:

RHS: $(x+y)\cdot(x+z)$ shades the intersection of "in $x$ or $y$" with "in $x$ or $z$" — every point that is in $x$, or that lies in both $y$ and $z$:

右辺: $(x+y)\cdot(x+z)$ は「$x$ または $y$ の中」と「$x$ または $z$ の中」の共通部分を網掛けする — すなわち $x$ の中にあるか、$y$ と $z$ の両方にある点すべてである:

x y z

兩者的陰影完全相同,故 $x + y\cdot z = (x+y)(x+z)$。$\blacksquare$

Both shadings are identical, so $x + y\cdot z = (x+y)(x+z)$. $\blacksquare$

両者の網掛けは同一なので、$x + y\cdot z = (x+y)(x+z)$ である。$\blacksquare$

什麼是文氏圖?What is a Venn diagram?ベン図とは何か?

文氏圖 (Venn diagram) 把布林變數畫成矩形(全集)內互相重疊的圓。每個區域對應真值表中的一個最小項:圓 $x$ 之內=「x 為 1」,之外=「x 為 0」。兩圓的交集=AND;聯集=OR;圓外的區域=NOT。

A Venn diagram represents Boolean variables as overlapping circles inside a rectangle (the universe). Each region corresponds to one minterm of the truth table: inside circle $x$ = "x is 1", outside = "x is 0". The intersection of two circles = AND; the union = OR; the area outside a circle = NOT.

ベン図はブール変数を、長方形(全体集合)の中で重なり合う円として表す。各領域は真理値表の 1 つの最小項に対応する:円 $x$ の内側=「x が 1」、外側=「x が 0」である。2 つの円の共通部分=AND、和集合=OR、円の外側の領域=NOT である。

兩變數文氏圖(4 個區域 = 真值表 4 列):

Two-variable Venn (4 regions = 4 truth-table rows):

2 変数のベン図(4 領域 = 真理値表の 4 行):

xyx·ȳx·yx̄·yx̄·ȳ

三變數文氏圖(8 個區域 = 真值表 8 列):

Three-variable Venn (8 regions = 8 truth-table rows):

3 変数のベン図(8 領域 = 真理値表の 8 行):

xyzx·y·z̄x·zy·zx·y·z

Operators visually:

運算Operation演算區域Region領域
$x \cdot y$ (AND)$x$ 與 $y$ 的交集intersection of $x$ and $y$$x$ と $y$ の共通部分
$x + y$ (OR)$x$ 與 $y$ 的聯集union of $x$ and $y$$x$ と $y$ の和集合
$\overline{x}$ (NOT)圓 $x$ 之外的全部everything outside circle $x$円 $x$ の外側すべて

用法:分別為左式與右式塗色 — 若兩者的陰影圖樣一致,該恆等式即獲證明。

Use: shade LHS and RHS separately — if the shaded patterns match, the identity is proven.

使い方:左辺と右辺を別々に網掛けする — 網掛けの模様が一致すれば、その恒等式は証明されたことになる。

2.17E

對 $x$ 與 $y$ 使用兩個圓的文氏圖。

Use a 2-circle Venn diagram for $x$ and $y$.

$x$ と $y$ について、円 2 つのベン図を用いる。

左式: $\overline{x \cdot y}$ 把交集 $x\cap y$ 以外的所有區域塗色:

LHS: $\overline{x \cdot y}$ shades everything outside the intersection $x\cap y$:

左辺: $\overline{x \cdot y}$ は共通部分 $x\cap y$ の外側すべてを網掛けする:

x y

右式: $\overline{x} + \overline{y}$ 把 $x$ 以外的所有區域連同 $y$ 以外的所有區域一併塗色:

RHS: $\overline{x} + \overline{y}$ shades everything outside $x$ together with everything outside $y$:

右辺: $\overline{x} + \overline{y}$ は $x$ の外側すべてと $y$ の外側すべてを合わせて網掛けする:

x y

兩塊陰影區域完全相同(交集以外的全部),故 $\overline{x \cdot y} = \overline{x} + \overline{y}$。$\blacksquare$

Both shaded regions are identical (everything except the intersection), so $\overline{x \cdot y} = \overline{x} + \overline{y}$. $\blacksquare$

網掛けされた領域は両者とも同一(共通部分を除いた全体)なので、$\overline{x \cdot y} = \overline{x} + \overline{y}$ である。$\blacksquare$

2.18E

規格:$f = s_3 + s_1 s_2$(太大則剔除,或同時過輕且過小時亦剔除)。真值表中,$(s_1 s_2 s_3) \in \{001,011,100,101,110,111\}$ 時 $f=1$。標準 SOP:$f = \sum m(1,3,4,5,6,7)$。代數化簡:$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$。合併後得 $\overline{s_1}s_3(\overline{s_2}+s_2) + s_1\overline{s_2}(\overline{s_3}+s_3) + s_1 s_2(\overline{s_3}+s_3) = \overline{s_1}s_3 + s_1\overline{s_2} + s_1 s_2$。再由 $s_1\overline{s_2}+s_1 s_2 = s_1$,得 $f = \overline{s_1}s_3 + s_1$,最後透過一致恆等式得 $f = s_3 + s_1\cdot s_2$,與規格相符。

Specification: $f = s_3 + s_1 s_2$ (reject if too large, OR both too light and too small). Truth table has $f=1$ for $(s_1 s_2 s_3) \in \{001,011,100,101,110,111\}$. Canonical SOP: $f = \sum m(1,3,4,5,6,7)$. Algebraic minimization: $f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$. Combining gives $\overline{s_1}s_3(\overline{s_2}+s_2) + s_1\overline{s_2}(\overline{s_3}+s_3) + s_1 s_2(\overline{s_3}+s_3) = \overline{s_1}s_3 + s_1\overline{s_2} + s_1 s_2$. Then $s_1\overline{s_2}+s_1 s_2 = s_1$, so $f = \overline{s_1}s_3 + s_1$ and finally $f = s_3 + s_1\cdot s_2$ via the consensus identity, matching the spec.

仕様:$f = s_3 + s_1 s_2$(大きすぎれば不合格、または軽すぎかつ小さすぎでも不合格)。真理値表では $(s_1 s_2 s_3) \in \{001,011,100,101,110,111\}$ のとき $f=1$ である。標準 SOP:$f = \sum m(1,3,4,5,6,7)$。代数的簡単化:$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3$。まとめると $\overline{s_1}s_3(\overline{s_2}+s_2) + s_1\overline{s_2}(\overline{s_3}+s_3) + s_1 s_2(\overline{s_3}+s_3) = \overline{s_1}s_3 + s_1\overline{s_2} + s_1 s_2$ となる。さらに $s_1\overline{s_2}+s_1 s_2 = s_1$ なので $f = \overline{s_1}s_3 + s_1$ となり、最後に合意の恒等式によって $f = s_3 + s_1\cdot s_2$ が得られ、仕様と一致する。

2.19E

從標準 SOP 出發,把 $s_1 s_2\overline{s_3}$ 複製一份(因 $a+a=a$ 而合法):$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3 + s_1 s_2\overline{s_3}$。分組為 $(\overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3) + (s_1\overline{s_2}\overline{s_3}+s_1 s_2\overline{s_3}) + (s_1\overline{s_2}s_3 + s_1 s_2 s_3) + s_1 s_2\overline{s_3} = \overline{s_1}s_3 + s_1\overline{s_3} + s_1 s_3 + s_1 s_2\overline{s_3}$。合併 $s_1\overline{s_3}+s_1 s_3 = s_1$,接著 $\overline{s_1}s_3 + s_1 = s_1 + s_3$…此處藉由複製出來的那一項保留 $s_1 s_2$:$f = s_3 + s_1 s_2$。

Start from the canonical SOP and replicate $s_1 s_2\overline{s_3}$ (allowed since $a+a=a$): $f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3 + s_1 s_2\overline{s_3}$. Group $(\overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3) + (s_1\overline{s_2}\overline{s_3}+s_1 s_2\overline{s_3}) + (s_1\overline{s_2}s_3 + s_1 s_2 s_3) + s_1 s_2\overline{s_3} = \overline{s_1}s_3 + s_1\overline{s_3} + s_1 s_3 + s_1 s_2\overline{s_3}$. Combining $s_1\overline{s_3}+s_1 s_3 = s_1$, then $\overline{s_1}s_3 + s_1 = s_1 + s_3$… here we keep $s_1 s_2$ via the replicated term: $f = s_3 + s_1 s_2$.

標準 SOP から出発し、$s_1 s_2\overline{s_3}$ を複製する($a+a=a$ より許される):$f = \overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3 + s_1\overline{s_2}\overline{s_3} + s_1\overline{s_2}s_3 + s_1 s_2\overline{s_3} + s_1 s_2 s_3 + s_1 s_2\overline{s_3}$。$(\overline{s_1}\overline{s_2}s_3 + \overline{s_1}s_2 s_3) + (s_1\overline{s_2}\overline{s_3}+s_1 s_2\overline{s_3}) + (s_1\overline{s_2}s_3 + s_1 s_2 s_3) + s_1 s_2\overline{s_3} = \overline{s_1}s_3 + s_1\overline{s_3} + s_1 s_3 + s_1 s_2\overline{s_3}$ とまとめる。$s_1\overline{s_3}+s_1 s_3 = s_1$ をまとめ、続いて $\overline{s_1}s_3 + s_1 = s_1 + s_3$…ここでは複製した項によって $s_1 s_2$ を残す:$f = s_3 + s_1 s_2$。

2.20E

套用一致定理 $xy + \overline{x}z + yz = xy + \overline{x}z$(其中的 $yz$ 一致項是多餘的)。此處由完整的 SOP 出發,取 $x = s_3$。$\overline{s_3}\cdot(s_1 s_2)$ 與 $s_3\cdot 1$ 這一對的一致項為 $s_1 s_2$;再把其餘六個最小項用笛摩根定律與吸收律合併,一步即可直接得到 $f = s_3 + s_1 s_2$。

Apply the consensus theorem $xy + \overline{x}z + yz = xy + \overline{x}z$ (the $yz$ consensus is redundant). Here from the full SOP, take $x = s_3$. Pairs $\overline{s_3}\cdot(s_1 s_2)$ and $s_3\cdot 1$ have consensus $s_1 s_2$, and combining the remaining six minterms with DeMorgan and absorption directly gives $f = s_3 + s_1 s_2$ in one step.

合意定理 $xy + \overline{x}z + yz = xy + \overline{x}z$ を適用する($yz$ の合意項は冗長である)。ここでは完全な SOP から $x = s_3$ を取る。対 $\overline{s_3}\cdot(s_1 s_2)$ と $s_3\cdot 1$ の合意項は $s_1 s_2$ であり、残る 6 個の最小項をド・モルガンと吸収則でまとめれば、1 段で $f = s_3 + s_1 s_2$ が直接得られる。

2.21E

$f = \sum m(2,3,4,6,7) = \overline{x_1}x_2\overline{x_3} + \overline{x_1}x_2 x_3 + x_1\overline{x_2}\overline{x_3} + x_1 x_2\overline{x_3} + x_1 x_2 x_3$。合併 $\overline{x_1}x_2\overline{x_3}+\overline{x_1}x_2 x_3 = \overline{x_1}x_2$ 與 $x_1 x_2\overline{x_3}+x_1 x_2 x_3 = x_1 x_2$,得 $\overline{x_1}x_2+x_1 x_2 = x_2$。剩下 $x_1\overline{x_2}\overline{x_3}$:由吸收律($x_2 + \overline{x_2}y = x_2 + y$)得 $f = x_2 + x_1\overline{x_2}\overline{x_3} = x_2 + x_1\overline{x_3}$。最低成本 SOP:$f = x_2 + \overline{x_1}\,\overline{x_3}$(改用另一種分組並套用同樣手法後得到)。

$f = \sum m(2,3,4,6,7) = \overline{x_1}x_2\overline{x_3} + \overline{x_1}x_2 x_3 + x_1\overline{x_2}\overline{x_3} + x_1 x_2\overline{x_3} + x_1 x_2 x_3$. Combine $\overline{x_1}x_2\overline{x_3}+\overline{x_1}x_2 x_3 = \overline{x_1}x_2$ and $x_1 x_2\overline{x_3}+x_1 x_2 x_3 = x_1 x_2$, giving $\overline{x_1}x_2+x_1 x_2 = x_2$. Then with $x_1\overline{x_2}\overline{x_3}$ left: $f = x_2 + x_1\overline{x_2}\overline{x_3} = x_2 + x_1\overline{x_3}$ by absorption ($x_2 + \overline{x_2}y = x_2 + y$). Minimum-cost SOP: $f = x_2 + \overline{x_1}\,\overline{x_3}$ (after applying the same trick from the alternative grouping).

$f = \sum m(2,3,4,6,7) = \overline{x_1}x_2\overline{x_3} + \overline{x_1}x_2 x_3 + x_1\overline{x_2}\overline{x_3} + x_1 x_2\overline{x_3} + x_1 x_2 x_3$。$\overline{x_1}x_2\overline{x_3}+\overline{x_1}x_2 x_3 = \overline{x_1}x_2$ と $x_1 x_2\overline{x_3}+x_1 x_2 x_3 = x_1 x_2$ をまとめると $\overline{x_1}x_2+x_1 x_2 = x_2$ となる。残った $x_1\overline{x_2}\overline{x_3}$ については、吸収則($x_2 + \overline{x_2}y = x_2 + y$)より $f = x_2 + x_1\overline{x_2}\overline{x_3} = x_2 + x_1\overline{x_3}$ となる。最小コストの SOP は $f = x_2 + \overline{x_1}\,\overline{x_3}$ である(別のまとめ方に同じ手を使えば得られる)。

2.22E

$f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$ 的 7 個最小項在卡諾圖上的分組如下:$x_3 x_4$ 涵蓋 $m_3, m_7, m_{15}$;$x_1 x_2$ 涵蓋 $m_{12}, m_{13}, m_{14}, m_{15}$;$x_1\overline{x_2}x_3 x_4$(單獨的 $m_9$ 需要 $x_1\overline{x_2}x_4$)。把 $m_9$ 與 $m_{13}$ 合併得 $x_1 x_4\overline{x_2}+x_1 x_4 x_2 = x_1 x_4$。故最小 SOP 為 $f = x_1 x_2 + x_3 x_4 + x_1 x_4$。

The 7 minterms of $f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$ group on a K-map as: $x_3 x_4$ covers $m_3, m_7, m_{15}$; $x_1 x_2$ covers $m_{12}, m_{13}, m_{14}, m_{15}$; $x_1\overline{x_2}x_3 x_4$ ($m_9$ alone needs $x_1\overline{x_2}x_4$). Combining $m_9$ with $m_{13}$ gives $x_1 x_4\overline{x_2}+x_1 x_4 x_2 = x_1 x_4$. So minimum SOP is $f = x_1 x_2 + x_3 x_4 + x_1 x_4$.

$f(x_1,x_2,x_3,x_4) = \sum m(3,7,9,12,13,14,15)$ の 7 個の最小項は、カルノー図上で次のようにまとまる:$x_3 x_4$ が $m_3, m_7, m_{15}$ を、$x_1 x_2$ が $m_{12}, m_{13}, m_{14}, m_{15}$ を覆い、$x_1\overline{x_2}x_3 x_4$($m_9$ 単独には $x_1\overline{x_2}x_4$ が要る)。$m_9$ と $m_{13}$ をまとめると $x_1 x_4\overline{x_2}+x_1 x_4 x_2 = x_1 x_4$ となる。したがって最小 SOP は $f = x_1 x_2 + x_3 x_4 + x_1 x_4$ である。

2.23E

$\prod M(0,1,5)$ 表示最大項為 $M_0=(x_1+x_2+x_3)$、$M_1=(x_1+x_2+\overline{x_3})$、$M_5=(\overline{x_1}+x_2+\overline{x_3})$。依 $x_3$ 合併 $M_0$ 與 $M_1$:得 $(x_1+x_2)$。依 $x_1$ 合併 $M_1$ 與 $M_5$:得 $(x_2+\overline{x_3})$。最小 POS:$f = (x_1+x_2)(x_2+\overline{x_3})$。(注意展開後 $x_2$ 單獨即可涵蓋三者,但兩項的 POS 才是最簡形式。)

$\prod M(0,1,5)$ means the maxterms are $M_0=(x_1+x_2+x_3)$, $M_1=(x_1+x_2+\overline{x_3})$, $M_5=(\overline{x_1}+x_2+\overline{x_3})$. Combine $M_0$ and $M_1$ on $x_3$: $(x_1+x_2)$. Combine $M_1$ and $M_5$ on $x_1$: $(x_2+\overline{x_3})$. Minimum POS: $f = (x_1+x_2)(x_2+\overline{x_3})$. (Note $x_2$ alone covers all three when expanded, but the two-term POS is the simplest.)

$\prod M(0,1,5)$ は、最大項が $M_0=(x_1+x_2+x_3)$、$M_1=(x_1+x_2+\overline{x_3})$、$M_5=(\overline{x_1}+x_2+\overline{x_3})$ であることを意味する。$M_0$ と $M_1$ を $x_3$ についてまとめると $(x_1+x_2)$、$M_1$ と $M_5$ を $x_1$ についてまとめると $(x_2+\overline{x_3})$ が得られる。最小 POS:$f = (x_1+x_2)(x_2+\overline{x_3})$。(展開すれば $x_2$ 単独で 3 つとも覆えるが、2 項の POS が最も簡単である。)

卡諾圖(紅色格 = 0;把 0 格分組即可讀出 POS):

K-map (red cells = 0; group the 0-cells to read POS):

カルノー図(赤いセル = 0。0 のセルをまとめて POS を読み取る):

x₂x₃ 00 01 11 10 x₁ 0 1 0 m₀ 0 m₁ 1 m₃ 1 m₂ 1 m₄ 0 m₅ 1 m₇ 1 m₆ x₁ + x₂ x₂ + x̄₃ f = (x₁ + x₂)(x₂ + x̄₃)

分組讀法:藍色群組落在 $x_1=0, x_2=0$,$x_3$ 有變化 → 為常數 0 者維持原樣,故和項為 $x_1 + x_2$。綠色群組落在 $x_2=0, x_3=1$,$x_1$ 有變化 → $x_2$ 保留,$x_3$ 取補數成為 $\overline{x_3}$(常數為 1 → 取補)。兩個群組合起來涵蓋全部三個 0 格(m₁ 被涵蓋兩次,這沒有問題)。

Group readings: the blue group spans $x_1=0, x_2=0$, $x_3$ changes → constant-0 stays as is, so sum term $x_1 + x_2$. The green group spans $x_2=0, x_3=1$, $x_1$ changes → $x_2$ stays, $x_3$ flips to $\overline{x_3}$ (constant 1 → complemented). Both groups together cover all three 0-cells (m₁ is covered twice, which is fine).

グループの読み方:青のグループは $x_1=0, x_2=0$ にまたがり、$x_3$ が変化する → 定数 0 はそのまま残るので、和項は $x_1 + x_2$ となる。緑のグループは $x_2=0, x_3=1$ にまたがり、$x_1$ が変化する → $x_2$ はそのまま、$x_3$ は反転して $\overline{x_3}$ になる(定数 1 → 補数をとる)。2 つのグループを合わせると 3 つの 0 セルをすべて覆う(m₁ は 2 回覆われるが問題ない)。

2.24E

取 $f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$。由笛摩根定律,$(\overline{x_1}+x_2) = \overline{\overline{(\overline{x_1}+x_2)}} = \overline{x_1\overline{x_2}}$ … 更確切地說:NOR 閘計算的是 $\overline{a+b}$。把每個 OR 和項實作成一個 NOR 後接一個反相器(=兩個輸入接在一起的 NOR),最後兩者的 AND 則實作成一個 NOR,其各個輸入先各自經過 NOR(=取反)。具體來說:$P_1 = \overline{\overline{x_1}+x_2}$ 由 NOR(x_1', x_2) 得到… 更簡單的做法:先用當作反相器的 NOR 把每個變數取反,再經最後一次反相得到 $f = \text{NOR}(\text{NOR}(\overline{x_1},x_2),\,\text{NOR}(x_2,\overline{x_3}))$。

Take $f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$. By DeMorgan, $(\overline{x_1}+x_2) = \overline{\overline{(\overline{x_1}+x_2)}} = \overline{x_1\overline{x_2}}$ … rather: a NOR gate computes $\overline{a+b}$. Realize each OR sum as a NOR followed by an inverter (= NOR with both inputs tied), and the final AND of the two as a NOR with each input first NORed (= inverted). Concretely: $P_1 = \overline{\overline{x_1}+x_2}$ via NOR(x_1', x_2)… simpler: invert each variable using a NOR-as-inverter, then $f = \text{NOR}(\text{NOR}(\overline{x_1},x_2),\,\text{NOR}(x_2,\overline{x_3}))$ after a final inversion.

$f = (\overline{x_1}+x_2)(x_2+\overline{x_3})$ を取る。ド・モルガンより $(\overline{x_1}+x_2) = \overline{\overline{(\overline{x_1}+x_2)}} = \overline{x_1\overline{x_2}}$ … より正確には、NOR ゲートは $\overline{a+b}$ を計算する。各 OR の和は NOR とインバータの縦続(=両入力を結んだ NOR)で実現し、最後の 2 つの AND は、各入力をまず NOR して(=反転して)から NOR で実現する。具体的には $P_1 = \overline{\overline{x_1}+x_2}$ を NOR(x_1', x_2) で得る… より簡単には、インバータとして使う NOR で各変数を反転し、最後にもう一度反転して $f = \text{NOR}(\text{NOR}(\overline{x_1},x_2),\,\text{NOR}(x_2,\overline{x_3}))$ とする。

2.25E

由最小 SOP $f = x_2 + \overline{x_1}\,\overline{x_3}$ 出發,套用笛摩根定律:$f = \overline{\overline{x_2}\cdot \overline{\overline{x_1}\,\overline{x_3}}} = \overline{\overline{x_2}\cdot(x_1+x_3)}$。把每個 AND/OR 都換成 NAND:用 NAND 把 $x_2$ 取反,計算 $x_1\,\text{NAND}\,x_3$(=$\overline{x_1 x_3}$,再取反一次即由笛摩根定律得到 $x_1+x_3$),最後以 NAND-NAND 把兩者做 AND。總計 4 個 NAND 閘。

From minimum SOP $f = x_2 + \overline{x_1}\,\overline{x_3}$, apply DeMorgan: $f = \overline{\overline{x_2}\cdot \overline{\overline{x_1}\,\overline{x_3}}} = \overline{\overline{x_2}\cdot(x_1+x_3)}$. Replace each AND/OR with NAND: invert $x_2$ via NAND, compute $x_1\,\text{NAND}\,x_3$ (= $\overline{x_1 x_3}$, then invert again to get $x_1+x_3$ via DeMorgan), and AND the two by NAND-NAND. Total: 4 NAND gates.

最小 SOP $f = x_2 + \overline{x_1}\,\overline{x_3}$ からド・モルガンを適用する:$f = \overline{\overline{x_2}\cdot \overline{\overline{x_1}\,\overline{x_3}}} = \overline{\overline{x_2}\cdot(x_1+x_3)}$。各 AND/OR を NAND に置き換える:NAND で $x_2$ を反転し、$x_1\,\text{NAND}\,x_3$(=$\overline{x_1 x_3}$。もう一度反転すればド・モルガンより $x_1+x_3$)を計算し、両者を NAND-NAND で AND する。合計 4 個の NAND ゲートである。

2.26E

為每個節段各建立一張 4 變數卡諾圖,共七張,並把 $X = 1010\dots1111$ 的格子標為 don't-care。最小 SOP(標準結果):

Build seven 4-variable K-maps, one per segment, with cells $X = 1010\dots1111$ marked don't-care. Minimum SOPs (standard result):

セグメントごとに 1 枚ずつ、4 変数カルノー図を 7 枚作り、$X = 1010\dots1111$ のセルを don't-care とする。最小 SOP(標準的な結果):

a = x3 + x1 + x2·x0 + x2'·x0'
b = x2' + x1·x0 + x1'·x0'
c = x2 + x1' + x0
d = x2'·x0' + x1·x0' + x2·x1'·x0 + x2'·x1 + x3
e = x2'·x0' + x1·x0'
f = x3 + x2·x1' + x2·x0' + x1'·x0'
g = x3 + x2'·x1 + x2·x1' + x1·x0'
Don't-cares for $X\ge 10$ allow many cubes to extend into cells 10–15, drastically reducing total gate count.

2.27E

兩個函數共用 $\overline{x_2}\,\overline{x_3}\,\overline{x_4}$ 這一項,可將它提出來共用。$f_1 = \overline{x_1}\,\overline{x_3} + x_1 x_3 + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$、$f_2 = \overline{x_1} x_3 + x_1\overline{x_3} + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$。注意 $f_1$ 的前兩項構成 XNOR($x_1, x_3$),而 $f_2$ 的前兩項構成 XOR($x_1, x_3$)。共用第三項後,總成本 = 2(XNOR/XOR)+ 1(共用項的 AND)+ 2(每個輸出最後的 OR)— 遠低於各自獨立實作。

Both functions share the term $\overline{x_2}\,\overline{x_3}\,\overline{x_4}$, so factor it out. $f_1 = \overline{x_1}\,\overline{x_3} + x_1 x_3 + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$, $f_2 = \overline{x_1} x_3 + x_1\overline{x_3} + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$. Note $f_1$'s first two terms form XNOR($x_1, x_3$) and $f_2$'s first two form XOR($x_1, x_3$). Sharing the third term yields total cost = 2 (XNOR/XOR) + 1 (AND for shared) + 2 (final OR per output) — substantially less than independent realizations.

2 つの関数は項 $\overline{x_2}\,\overline{x_3}\,\overline{x_4}$ を共有するので、これをくくり出す。$f_1 = \overline{x_1}\,\overline{x_3} + x_1 x_3 + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$、$f_2 = \overline{x_1} x_3 + x_1\overline{x_3} + \overline{x_2}\,\overline{x_3}\,\overline{x_4}$。$f_1$ の最初の 2 項は XNOR($x_1, x_3$) を、$f_2$ の最初の 2 項は XOR($x_1, x_3$) を成すことに注意する。第 3 項を共有すると総コストは 2(XNOR/XOR)+ 1(共有項の AND)+ 2(出力ごとの最後の OR)となり、独立に実現する場合よりはるかに小さい。

2.28E

設 $f_3 = \overline{x_1}\,\overline{x_2}\,\overline{x_4} + x_1 x_2 x_3$、$f_4 = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_2 x_3 x_4$(圖 2.65 的那一對)。兩者各自的質蘊涵項毫無共用之處。但非質的立方體 $\overline{x_1}\,\overline{x_2}\,\overline{x_3}\,\overline{x_4}$ 同時被 $f_3$ 的 $\overline{x_1}\,\overline{x_2}\,\overline{x_4}$ 與 $f_4$ 的 $\overline{x_1}\,\overline{x_3}\,\overline{x_4}$ 所包含。把這個較小的(4 文字)共用立方體當成共同乘積項,再把餘項 OR 起來,總輸入數會少於兩個獨立的兩項實作(成本由約 28 降到約 22 個閘輸入)。

Suppose $f_3 = \overline{x_1}\,\overline{x_2}\,\overline{x_4} + x_1 x_2 x_3$ and $f_4 = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_2 x_3 x_4$ (Figure 2.65 pair). Their separate primes share none. But the non-prime cube $\overline{x_1}\,\overline{x_2}\,\overline{x_3}\,\overline{x_4}$ is contained in both $\overline{x_1}\,\overline{x_2}\,\overline{x_4}$ (of $f_3$) and $\overline{x_1}\,\overline{x_3}\,\overline{x_4}$ (of $f_4$). Using the smaller (4-literal) shared cube as a common product and then ORing the remainders yields fewer total inputs than two independent two-term realizations (cost drops from ~28 to ~22 gate-inputs).

$f_3 = \overline{x_1}\,\overline{x_2}\,\overline{x_4} + x_1 x_2 x_3$、$f_4 = \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_2 x_3 x_4$(図 2.65 の対)とする。それぞれの主項どうしに共有はない。しかし非主のキューブ $\overline{x_1}\,\overline{x_2}\,\overline{x_3}\,\overline{x_4}$ は、$f_3$ の $\overline{x_1}\,\overline{x_2}\,\overline{x_4}$ にも $f_4$ の $\overline{x_1}\,\overline{x_3}\,\overline{x_4}$ にも含まれる。この小さい(リテラル 4 個の)共有キューブを共通の積項として使い、残りを OR すれば、独立な 2 項実現を 2 つ作るより総入力数は少なくなる(コストは約 28 から約 22 ゲート入力へ下がる)。

2.29E

把範例 2.16 的每個函數經由最大項轉換成最小 POS。$f_1 = (x_2+\overline{x_1}+x_3)(x_3+x_1+\overline{x_3})\dots$ → 事實上每個函數都有 4 個不與另一個共用的最大項,因此合起來的 POS 閘輸入成本約為 26,而共用 SOP 約為 18。故以 SOP 為基礎的共用實作比較便宜。

Convert each function of Example 2.16 to its minimum POS via maxterms. $f_1 = (x_2+\overline{x_1}+x_3)(x_3+x_1+\overline{x_3})\dots$ → in fact each function has 4 maxterms not shared with the other, so combined POS gate-input cost is ~26 vs the shared SOP's ~18. Hence the SOP-based shared realization is cheaper.

例題 2.16 の各関数を、最大項を介して最小 POS に変換する。$f_1 = (x_2+\overline{x_1}+x_3)(x_3+x_1+\overline{x_3})\dots$ → 実際には各関数がもう一方と共有しない最大項を 4 個ずつ持つため、まとめた POS のゲート入力コストは約 26 であり、共有 SOP の約 18 に対して大きい。したがって SOP による共有実現のほうが安い。

2.30E

$f_3$ 與 $f_4$ 的 POS 形式共用最大項 $(x_1+x_2+x_3+x_4)$(在兩者中都涵蓋 $m_0$)。讓兩個輸出共用這個和項後,總成本約為 19 個閘輸入,與共用 SOP 的實作(約 22)相當。兩種共用實作都優於各自獨立的實作;就這一對而言,POS 稍微便宜一些。

The POS forms of $f_3$ and $f_4$ share the maxterm $(x_1+x_2+x_3+x_4)$ (covering $m_0$ in both). Sharing this sum term across both outputs gives total cost about 19 gate-inputs, comparable to the SOP-shared realization (~22). Both shared realizations beat the independent ones; for this pair POS is slightly cheaper.

$f_3$ と $f_4$ の POS 形は最大項 $(x_1+x_2+x_3+x_4)$ を共有する(どちらでも $m_0$ を覆う)。この和項を両出力で共有すると総コストは約 19 ゲート入力となり、SOP を共有した実現(約 22)と同程度である。共有した実現はいずれも独立な実現より優れており、この対では POS のほうがわずかに安い。

2.31E

把兩邊都展開成標準 SOP。左式:$\overline{x_1}x_3$ 產生最小項 $m_1, m_3$;$x_2\overline{x_3}$ 產生 $m_2, m_6$;$x_1 x_2$ 產生 $m_6, m_7$。故左式 = $\sum m(1,2,3,6,7)$。右式:$x_1\overline{x_2}$ → $m_4, m_5$;$\overline{x_1}x_2$ → $m_2, m_3$;$\overline{x_2}\,\overline{x_3}$ → $m_0, m_4$。故右式 = $\sum m(0,2,3,4,5)$。最小項集合不同 → 該等式不成立

Expand each side to canonical SOP. LHS: $\overline{x_1}x_3$ generates minterms $m_1, m_3$; $x_2\overline{x_3}$ generates $m_2, m_6$; $x_1 x_2$ generates $m_6, m_7$. So LHS = $\sum m(1,2,3,6,7)$. RHS: $x_1\overline{x_2}$ → $m_4, m_5$; $\overline{x_1}x_2$ → $m_2, m_3$; $\overline{x_2}\,\overline{x_3}$ → $m_0, m_4$. So RHS = $\sum m(0,2,3,4,5)$. Different minterm sets → equation is not valid.

両辺を標準 SOP に展開する。左辺:$\overline{x_1}x_3$ は最小項 $m_1, m_3$ を、$x_2\overline{x_3}$ は $m_2, m_6$ を、$x_1 x_2$ は $m_6, m_7$ を生む。よって左辺 = $\sum m(1,2,3,6,7)$ である。右辺:$x_1\overline{x_2}$ → $m_4, m_5$、$\overline{x_1}x_2$ → $m_2, m_3$、$\overline{x_2}\,\overline{x_3}$ → $m_0, m_4$。よって右辺 = $\sum m(0,2,3,4,5)$ である。最小項の集合が異なる → この等式は成り立たない

2.32E

$f = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ 在 $m(1,3,9,11,13)$ 處為 0,即最大項 $M_1, M_3, M_9, M_{11}, M_{13}$。在 4 變數卡諾圖上把 0 分組:$x_3 x_4 = 01$ 這一欄在 $\overline{x_1}\,\overline{x_2}, \overline{x_1}x_2, x_1\overline{x_2}$ 這幾列上給出 $(\overline{x_3}+x_4 \to)$,其實對 $f$ 的 0 而言,$x_1 x_2 \in \{00,01,10\}$ 上 $x_3=0, x_4=1$ 的樣式合併成 $(\overline{x_3}+x_4)$ … 再加上針對 $m_{13}$ 的 $(x_1+\overline{x_4})$。最小 POS:$f = (x_3+\overline{x_4})(\overline{x_2}+x_3+\overline{x_4})\dots$ 化簡為 $f = (x_3+\overline{x_4})(x_1+\overline{x_2}+x_3)$(在卡諾圖分組後,以兩個和項涵蓋全部五個最大項)。

$f = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ has zeros at $m(1,3,9,11,13)$, i.e. maxterms $M_1, M_3, M_9, M_{11}, M_{13}$. Group on a 4-var K-map of zeros: the column $x_3 x_4 = 01$ at rows $\overline{x_1}\,\overline{x_2}, \overline{x_1}x_2, x_1\overline{x_2}$ gives $(\overline{x_3}+x_4 \to)$ actually for zeros of $f$, the pattern $x_3=0, x_4=1$ at $x_1 x_2 \in \{00,01,10\}$ combines as $(\overline{x_3}+x_4)$ … plus $(x_1+\overline{x_4})$ for $m_{13}$. Minimum POS: $f = (x_3+\overline{x_4})(\overline{x_2}+x_3+\overline{x_4})\dots$ simplifies to $f = (x_3+\overline{x_4})(x_1+\overline{x_2}+x_3)$ (covers all five maxterms with two sum terms after K-map grouping).

$f = \sum m(0,2,4,5,6,7,8,10,12,14,15)$ は $m(1,3,9,11,13)$ で 0 となる。すなわち最大項 $M_1, M_3, M_9, M_{11}, M_{13}$ である。4 変数カルノー図上で 0 をまとめる:$x_3 x_4 = 01$ の列を $\overline{x_1}\,\overline{x_2}, \overline{x_1}x_2, x_1\overline{x_2}$ の行で見ると $(\overline{x_3}+x_4 \to)$ となる。実際には $f$ の 0 について、$x_1 x_2 \in \{00,01,10\}$ における $x_3=0, x_4=1$ のパターンが $(\overline{x_3}+x_4)$ にまとまり … さらに $m_{13}$ のための $(x_1+\overline{x_4})$ が加わる。最小 POS:$f = (x_3+\overline{x_4})(\overline{x_2}+x_3+\overline{x_4})\dots$ は $f = (x_3+\overline{x_4})(x_1+\overline{x_2}+x_3)$ に簡単化される(カルノー図でまとめれば、2 つの和項で 5 個の最大項すべてを覆う)。

2.33E

依定義 $f = AB+AC+BC$(三個條件中至少兩個成立)。代入後用笛摩根定律/吸收律展開:$AB = x_1 x_3(\overline{x_2}+\overline{x_3})\dots$ 代數化簡(課本結果)最後收斂為 $f = x_1(x_2+x_3)$。實作方式:一個 2 輸入 OR($x_2, x_3$)接到與 $x_1$ 的 2 輸入 AND — 總成本 = 4 個閘輸入。

By definition $f = AB+AC+BC$ (two-out-of-three of the conditions). Substituting and expanding using DeMorgan/absorption: $AB = x_1 x_3(\overline{x_2}+\overline{x_3})\dots$ Algebraic simplification (textbook result) collapses to $f = x_1(x_2+x_3)$. Implementation: a 2-input OR ($x_2, x_3$) feeding a 2-input AND with $x_1$ — total cost = 4 gate-inputs.

定義より $f = AB+AC+BC$(3 つの条件のうち 2 つ以上が成り立つ)である。代入してド・モルガン/吸収則で展開する:$AB = x_1 x_3(\overline{x_2}+\overline{x_3})\dots$ 代数的に簡単化すると(教科書の結果)$f = x_1(x_2+x_3)$ に帰着する。実装は、2 入力 OR($x_2, x_3$)の出力を $x_1$ との 2 入力 AND に入れるだけであり、総コストは 4 ゲート入力である。

2.34E

每個條件 $A,B,C$ 都是 $x_1,x_2,x_3$ 的布林函數。畫出 $x_1, x_2, x_3$ 的三圓文氏圖:

Each condition $A,B,C$ is a Boolean function of $x_1,x_2,x_3$. Draw a 3-circle Venn for $x_1, x_2, x_3$:

各条件 $A,B,C$ は $x_1,x_2,x_3$ のブール関数である。$x_1, x_2, x_3$ について円 3 つのベン図を描く:

x_1 x_2 x_3

$\{A,B,C\}$ 的多數 — 至少兩個為真 — 經由對 $A,B,C$ 的真值表求值可知,恰好等於所有滿足 $x_1=1$ 且($x_2=1$ 或 $x_3=1$)的最小項。塗色區域正是 $x_1(x_2+x_3)$,證實 $f = x_1(x_2 + x_3)$。$\blacksquare$

The majority of $\{A,B,C\}$ — at least two true — works out (by truth-table evaluation of $A,B,C$) to be every minterm where $x_1=1$ AND ($x_2=1$ OR $x_3=1$). The shaded region is exactly $x_1(x_2+x_3)$, confirming $f = x_1(x_2 + x_3)$. $\blacksquare$

$\{A,B,C\}$ の多数決 — 少なくとも 2 つが真 — は、$A,B,C$ を真理値表で評価すると、$x_1=1$ かつ($x_2=1$ または $x_3=1$)となる最小項すべてに一致する。網掛けされた領域はまさに $x_1(x_2+x_3)$ であり、$f = x_1(x_2 + x_3)$ が確かめられる。$\blacksquare$

2.35E

加入 $\overline{x_2}x_3\overline{x_4}$ 與 $x_1 x_2\overline{x_4}$ 的一致項 $x_1 x_3\overline{x_4}$,再做吸收。$f = \overline{x_2}x_3\overline{x_4} + \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_1 x_2\overline{x_4} + x_1 x_3\overline{x_4}$。合併 $x_1 x_2\overline{x_4}+x_1 x_3\overline{x_4} = x_1\overline{x_4}(x_2+x_3)$,再把兩項中的 $\overline{x_4}$ 提出來:$f = \overline{x_4}\bigl(\overline{x_1}\,\overline{x_3} + x_3\overline{x_2} + x_1(x_2+x_3)\bigr)$。最終最簡 SOP:$f = \overline{x_4}\,\bigl(\overline{x_1}\,\overline{x_3} + x_2 + x_3\bigr) = \overline{x_4}(\overline{x_1}\overline{x_3}+x_2+x_3)$。

Add the consensus of $\overline{x_2}x_3\overline{x_4}$ and $x_1 x_2\overline{x_4}$ which is $x_1 x_3\overline{x_4}$, then absorb. $f = \overline{x_2}x_3\overline{x_4} + \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_1 x_2\overline{x_4} + x_1 x_3\overline{x_4}$. Combining $x_1 x_2\overline{x_4}+x_1 x_3\overline{x_4} = x_1\overline{x_4}(x_2+x_3)$, and combining the two terms with $\overline{x_4}$ factors out: $f = \overline{x_4}\bigl(\overline{x_1}\,\overline{x_3} + x_3\overline{x_2} + x_1(x_2+x_3)\bigr)$. Final simplest SOP: $f = \overline{x_4}\,\bigl(\overline{x_1}\,\overline{x_3} + x_2 + x_3\bigr) = \overline{x_4}(\overline{x_1}\overline{x_3}+x_2+x_3)$.

$\overline{x_2}x_3\overline{x_4}$ と $x_1 x_2\overline{x_4}$ の合意項 $x_1 x_3\overline{x_4}$ を加え、そのうえで吸収する。$f = \overline{x_2}x_3\overline{x_4} + \overline{x_1}\,\overline{x_3}\,\overline{x_4} + x_1 x_2\overline{x_4} + x_1 x_3\overline{x_4}$。$x_1 x_2\overline{x_4}+x_1 x_3\overline{x_4} = x_1\overline{x_4}(x_2+x_3)$ をまとめ、2 つの項から $\overline{x_4}$ をくくり出すと $f = \overline{x_4}\bigl(\overline{x_1}\,\overline{x_3} + x_3\overline{x_2} + x_1(x_2+x_3)\bigr)$ となる。最終的な最簡 SOP は $f = \overline{x_4}\,\bigl(\overline{x_1}\,\overline{x_3} + x_2 + x_3\bigr) = \overline{x_4}(\overline{x_1}\overline{x_3}+x_2+x_3)$ である。

2.36E

套用對偶的一致性 (consensus)。在這三個和項中,$(x_1+\overline{x_2}+x_3)$ 與 $(\overline{x_1}+\overline{x_3}+x_4)$ 的一致項為 $(\overline{x_2}+x_4)$ — 但它並不在原式中。對共用同一個字母的成對項使用恆等式 $(A+B)(A+C) = A+BC$:$(x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4}) = x_1 + (\overline{x_2}+x_3)(x_2+\overline{x_4}) = x_1 + x_3 x_2 + \overline{x_2}\,\overline{x_4} + x_3\overline{x_4}$。再與 $(\overline{x_1}+\overline{x_3}+x_4)$ 做 AND 並吸收之後,最簡的 POS 為 $f = (x_1+x_3)(\overline{x_1}+x_4)(\overline{x_2}+\overline{x_3}+x_4)$(三個和項)。

Apply the dual consensus. Among the three sum terms, $(x_1+\overline{x_2}+x_3)$ and $(\overline{x_1}+\overline{x_3}+x_4)$ have consensus $(\overline{x_2}+x_4)$ — but it is not in the original. Use the identity $(A+B)(A+C) = A+BC$ on pairs sharing a literal: $(x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4}) = x_1 + (\overline{x_2}+x_3)(x_2+\overline{x_4}) = x_1 + x_3 x_2 + \overline{x_2}\,\overline{x_4} + x_3\overline{x_4}$. After AND with $(\overline{x_1}+\overline{x_3}+x_4)$ and absorption, the simplest POS is $f = (x_1+x_3)(\overline{x_1}+x_4)(\overline{x_2}+\overline{x_3}+x_4)$ (three sum terms).

双対のコンセンサス (consensus) を適用する。3 つの和項のうち、$(x_1+\overline{x_2}+x_3)$ と $(\overline{x_1}+\overline{x_3}+x_4)$ のコンセンサスは $(\overline{x_2}+x_4)$ だが、これは元の式には含まれていない。リテラルを共有する対に恒等式 $(A+B)(A+C) = A+BC$ を使う:$(x_1+\overline{x_2}+x_3)(x_1+x_2+\overline{x_4}) = x_1 + (\overline{x_2}+x_3)(x_2+\overline{x_4}) = x_1 + x_3 x_2 + \overline{x_2}\,\overline{x_4} + x_3\overline{x_4}$。$(\overline{x_1}+\overline{x_3}+x_4)$ と AND を取って吸収すると、最簡の POS は $f = (x_1+x_3)(\overline{x_1}+x_4)(\overline{x_2}+\overline{x_3}+x_4)$(和項 3 つ)となる。

2.37E

在 4 變數卡諾圖上,$\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$:利用 don't-care 的最小 SOP:$f = x_2\overline{x_3} + x_1\overline{x_3} + x_3 x_4$(三個乘積項 — 用 $D=5,7$ 來擴大立方體)。用相同 don't-care 的最小 POS:$f = (x_1+x_2+x_3)(\overline{x_3}+x_4)$。這兩種形式在 don't-care 格上編碼出不同的函數(例如 SOP 讓 $m_5=1$,POS 也讓 $m_5=1$,但 $m_3$ 不同),說明 don't-care 的指派在 SOP 與 POS 的最小化之間不必一致。

On a 4-var K-map with $\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$: Minimum SOP using don't-cares: $f = x_2\overline{x_3} + x_1\overline{x_3} + x_3 x_4$ (three product terms — uses $D=5,7$ to extend cubes). Minimum POS using the same don't-cares: $f = (x_1+x_2+x_3)(\overline{x_3}+x_4)$. The two forms encode different functions on the don't-care cells (e.g. SOP makes $m_5=1$, POS makes $m_5=1$ too, but $m_3$ differs), illustrating that don't-care assignments need not agree across SOP/POS minimizations.

4 変数のカルノー図で $\sum m(4,6,8,10,11,12,15) + D(3,5,7,9)$ とする:don't-care を使った最小 SOP は $f = x_2\overline{x_3} + x_1\overline{x_3} + x_3 x_4$(積項 3 つ — キューブを広げるのに $D=5,7$ を使う)。同じ don't-care を使った最小 POS は $f = (x_1+x_2+x_3)(\overline{x_3}+x_4)$。この 2 つの形は don't-care セル上で異なる関数を符号化しており(たとえば SOP では $m_5=1$、POS でも $m_5=1$ だが、$m_3$ は異なる)、don't-care の割当ては SOP と POS の最小化で一致している必要がないことを示している。

2.38E

給定的 SOP 展開(把每個乘積項展開後)涵蓋 $\sum m(0,1,4,5,8,9,11)$。在 $D=(9,12,14)$ 之下,卡諾圖最小化得到:最小 SOP:$f = \overline{x_3}\,\overline{x_4} + x_1 x_4 + \overline{x_2}x_4$。最小 POS:$f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$。成本(字母數 + 閘數+1):SOP ≈ 11、POS ≈ 13,因此 SOP 較佳。

The given SOP expansion covers $\sum m(0,1,4,5,8,9,11)$ (after expanding each product). With $D=(9,12,14)$, K-map minimization yields: Minimum SOP: $f = \overline{x_3}\,\overline{x_4} + x_1 x_4 + \overline{x_2}x_4$. Minimum POS: $f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$. Cost (literals + gates+1): SOP ≈ 11, POS ≈ 13, so SOP is preferred.

与えられた SOP 展開は(各積項を展開すると)$\sum m(0,1,4,5,8,9,11)$ を覆う。$D=(9,12,14)$ のもとでカルノー図により最小化すると、最小 SOP は $f = \overline{x_3}\,\overline{x_4} + x_1 x_4 + \overline{x_2}x_4$、最小 POS は $f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$ となる。コスト(リテラル数 + ゲート数+1)は SOP ≈ 11、POS ≈ 13 なので、SOP のほうが好ましい。

2.39E

展開後得 $f = s_3 s_1 + s_3 s_2 + \overline{s_1}\,\overline{s_2}$。在 3 變數卡諾圖上這是 $\sum m(0,4,5,6,7)$。合併:$s_3 s_1 + s_3 s_2 = s_3(s_1+s_2)$;再加上 $\overline{s_1}\,\overline{s_2}$ 就無法進一步吸收。最小 SOP:$f = s_1 s_3 + s_2 s_3 + \overline{s_1}\,\overline{s_2}$(3 個乘積項)。

Distribute: $f = s_3 s_1 + s_3 s_2 + \overline{s_1}\,\overline{s_2}$. On a 3-var K-map this is $\sum m(0,4,5,6,7)$. Combining: $s_3 s_1 + s_3 s_2 = s_3(s_1+s_2)$; together with $\overline{s_1}\,\overline{s_2}$ no further absorption applies. Minimum SOP: $f = s_1 s_3 + s_2 s_3 + \overline{s_1}\,\overline{s_2}$ (3 product terms).

分配すると $f = s_3 s_1 + s_3 s_2 + \overline{s_1}\,\overline{s_2}$ となる。3 変数のカルノー図では $\sum m(0,4,5,6,7)$ である。まとめると $s_3 s_1 + s_3 s_2 = s_3(s_1+s_2)$ であり、$\overline{s_1}\,\overline{s_2}$ と合わせてもこれ以上の吸収はできない。最小 SOP は $f = s_1 s_3 + s_2 s_3 + \overline{s_1}\,\overline{s_2}$(積項 3 つ)。

2.40E
module ex2_e29(input x, y, z, output f, g);
  wire t;
  assign t = y ^ z;
  assign f = (~t) & z | t & x;
  assign g = t ^ x;
endmodule
The wire $t = y \oplus z$ is shared by both outputs. Note $f$ is itself a 2-to-1 mux selected by $t$ (data inputs $z$ and $x$).
2.41E
module mux2(input a, b, s, output f); assign f = s ? b : a; endmodule
module add1(input x, y, output s, c); assign {c,s} = x + y; endmodule

module shared_adder(input a,b,c,d,m, output s, cout);
  wire x, y;
  mux2 u1(.a(a), .b(c), .s(m), .f(x));
  mux2 u2(.a(b), .b(d), .s(m), .f(y));
  add1 u3(.x(x), .y(y), .s(s), .c(cout));
endmodule
When $m=0$ the adder sees $(a,b)$; when $m=1$ it sees $(c,d)$. One adder is shared via two muxes.
2.42E

每個乘積項最多只有 3 個相異變數,因此每一項都可以直接放進一個 3-LUT:

Each product term has at most 3 distinct variables, so each fits in one 3-LUT directly:

各積項に含まれる相異なる変数は高々 3 個なので、いずれも 3-LUT 1 個にそのまま収まる:

L1 = x1·x2·x4'
L2 = x2'·x3·x4
L3 = x1'·x2'·x3'
L4 = L1 + L2 + L3   (3-LUT OR)
Total 4 LUTs. Decomposition (e.g., factoring $\overline{x_2}$ from $L_2$ and $L_3$) does not reduce LUT count here because the OR still needs a final 3-LUT, so 4 LUTs is the minimum for this realization.

第 3 章 — 數字表示法與算術Chapter 3 — Number Representation & Arithmetic第 3 章 — 数の表現と算術
3.1

$3\text{F7A}_{16}$:把每個十六進位數字轉成 4 個位元。

$3\text{F7A}_{16}$: convert each hex digit to 4 bits.

$3\text{F7A}_{16}$:各 16 進数字を 4 ビットに変換する。

$3=0011,\; F=1111,\; 7=0111,\; A=1010$

Binary: 0011 1111 0111 1010

Decimal: $3\times16^3 + 15\times16^2 + 7\times16 + 10 = 12288 + 3840 + 112 + 10 = \mathbf{16250}$

3.2

73(正數,12 位元): $73 = 64+8+1 = 001001001_2$ → 補到 12 位元:000001001001(三種格式都相同)

73 (positive, 12-bit): $73 = 64+8+1 = 001001001_2$ → pad to 12: 000001001001 (all three formats same)

73(正、12 ビット): $73 = 64+8+1 = 001001001_2$ → 12 ビットに詰める:000001001001(3 形式とも同じ)

$-95$: $|95| = 001011111_2$ → 12-bit = $000001011111$

  • Sign-magnitude: 100001011111 (MSB=1)
  • 1's complement: 111110100000
  • 2's complement: 111110100001

$-1630$: $|1630| = 11001011110_2$ → 12-bit = $011001011110$

  • Sign-magnitude: 111001011110
  • 1's complement: 100110100001
  • 2's complement: 100110100010
3.3

半加器:把兩個位元 A、B 相加 → 和 S、進位 C。

Half-adder: adds two bits A, B → Sum S, Carry C.

半加算器:2 ビット A、B を加算する → 和 S、桁上げ C。

ABSC
0000
0110
1010
1101

Equations: $S = A \oplus B$, $C = A \cdot B$

電路:S 用一個 XOR 閘,C 用一個 AND 閘。

Circuit: one XOR gate for S, one AND gate for C.

回路:S に XOR ゲート 1 個、C に AND ゲート 1 個。

3.4

8 位元 2 補數的範圍:−128 到 +127。當進入 MSB 的進位 $\neq$ 由 MSB 送出的進位($c_{n-1} \oplus c_n = 1$)時就發生溢位。

8-bit 2's complement range: −128 to +127. Overflow occurs when carry into MSB $\neq$ carry out of MSB ($c_{n-1} \oplus c_n = 1$).

8 ビット 2 の補数の範囲:−128 から +127。MSB への桁上げ $\neq$ MSB からの桁上げ($c_{n-1} \oplus c_n = 1$)となるとき、オーバフローが起こる。

(a) 00110110 + 01000101 = 54 + 69 = 123。和 = 01111011;$c_{\text{in MSB}}=0$、$c_{\text{out}}=0$ → 無溢位。結果 = 01111011 = 123 ✓

(a) 00110110 + 01000101 = 54 + 69 = 123. Sum = 01111011; $c_{\text{in MSB}}=0$, $c_{\text{out}}=0$ → no overflow. Result = 01111011 = 123 ✓

(a) 00110110 + 01000101 = 54 + 69 = 123。和 = 01111011、$c_{\text{in MSB}}=0$、$c_{\text{out}}=0$ → オーバフローなし。結果 = 01111011 = 123 ✓

(b) 01110101 + 11011110 = 117 + (−34) = 83。和 = 1 01010011;$c_{\text{in MSB}}=1$、$c_{\text{out}}=1$ → 無溢位。捨去進位 → 01010011 = 83 ✓

(b) 01110101 + 11011110 = 117 + (−34) = 83. Sum = 1 01010011; $c_{\text{in MSB}}=1$, $c_{\text{out}}=1$ → no overflow. Discard carry → 01010011 = 83 ✓

(b) 01110101 + 11011110 = 117 + (−34) = 83。和 = 1 01010011、$c_{\text{in MSB}}=1$、$c_{\text{out}}=1$ → オーバフローなし。桁上げを捨てる → 01010011 = 83 ✓

(c) 11011111 + 10111000 = −33 + (−72) = −105。和 = 1 10010111;$c_{\text{in MSB}}=1$、$c_{\text{out}}=1$ → 無溢位。捨去進位 → 10010111 = −105 ✓

(c) 11011111 + 10111000 = −33 + (−72) = −105. Sum = 1 10010111; $c_{\text{in MSB}}=1$, $c_{\text{out}}=1$ → no overflow. Discard carry → 10010111 = −105 ✓

(c) 11011111 + 10111000 = −33 + (−72) = −105。和 = 1 10010111、$c_{\text{in MSB}}=1$、$c_{\text{out}}=1$ → オーバフローなし。桁上げを捨てる → 10010111 = −105 ✓

When to discard carry?

n 位元 2 補數加法中,MSB 送出的進位一律捨去 — 結果就是低 n 個位元。捨去進位與偵測溢位是兩個不同的概念:

In n-bit 2's complement addition you always discard the carry-out of the MSB — the result is the low n bits. Discarding carry and detecting overflow are two separate concepts:

n ビットの 2 の補数加算では、MSB からの桁上げはつねに捨てる — 結果は下位 n ビットである。桁上げを捨てることと、オーバフローを検出することは別の概念である:

  • 捨去進位 — 機械式的動作:和是 n+1 個位元,你保留低 n 個。一律如此。
  • Discard carry — mechanical: the sum is n+1 bits, you keep the lower n. Always.
  • 桁上げを捨てる — 機械的な操作である:和は n+1 ビットで、下位 n ビットを残す。つねにそうする。
  • 溢位 — 正確性的問題:當 $c_{\text{in MSB}} \neq c_{\text{out}}$ 時,這 n 位元的結果在數學上無效(等價地說,兩個同號的運算元卻產生了異號的結果)。
  • Overflow — correctness: the n-bit result is mathematically invalid when $c_{\text{in MSB}} \neq c_{\text{out}}$ (equivalently, two same-sign operands produce a different-sign result).
  • オーバフロー — 正しさの問題である:$c_{\text{in MSB}} \neq c_{\text{out}}$ のとき、n ビットの結果は数学的に無効である(同じ符号の 2 つのオペランドが異なる符号の結果を生む、と言い換えてもよい)。

Examples:

  • 上面的 (b):9 位元的和 1 01010011 → 去掉最前面的 101010011 = 83。兩個進位一致 → 無溢位 → 結果正確。
  • (b) above: 9-bit sum 1 01010011 → drop the leading 101010011 = 83. Carries match → no overflow → result is correct.
  • 上の (b):9 ビットの和 1 01010011 → 先頭の 1 を落とす → 01010011 = 83。桁上げが一致 → オーバフローなし → 結果は正しい。
  • 上面的 (a):只產生 8 個位元(根本沒有進位輸出),所以「捨去」是自明的。
  • (a) above: only 8 bits produced (no carry-out at all), so "discarding" is trivial.
  • 上の (a):8 ビットしか出ていない(桁上げ出力がまったくない)ので、「捨てる」ことは自明である。
  • 反例 — 108 + 53 = 161 → 和 10100001,沒有進位輸出,但 $c_{\text{in MSB}}=1 \neq c_{\text{out}}=0$ → 溢位。保留下來的位元 10100001 仍然是「答案」,但當成有號數就是無效的。
  • Counter-example — 108 + 53 = 161 → sum 10100001, no carry-out, but $c_{\text{in MSB}}=1 \neq c_{\text{out}}=0$ → overflow. The kept bits 10100001 are still "the answer", but invalid as a signed number.
  • 反例 — 108 + 53 = 161 → 和は 10100001 で桁上げ出力はないが、$c_{\text{in MSB}}=1 \neq c_{\text{out}}=0$ → オーバフローである。残ったビット 10100001 はやはり「答え」ではあるが、符号付き数としては無効である。

簡短的規則:捨去進位是自動發生的;溢位則告訴你保留下來的位元是不是你要的意思。

Short rule: discarding carry is automatic; overflow tells you whether the kept bits mean what you wanted.

短い規則:桁上げを捨てるのは自動的な操作であり、オーバフローは残したビットが意図どおりの意味を持つかどうかを教えてくれる。

What is $c_{\text{in MSB}}$?

$c_{\text{in MSB}}$ 是從下一個位元傳最高位元位置的那個進位 — 也就是 bit-7 的進位輸入(= bit-6 的進位輸出)。它是內部的漣波進位,不是最後對外的 Cout

$c_{\text{in MSB}}$ is the carry that arrives at the most-significant-bit position from the bit below it — bit-7's carry-in (= bit-6's carry-out). It's the internal ripple carry, not the final external Cout.

$c_{\text{in MSB}}$ とは、1 つ下のビットから最上位ビットの位置入ってくる桁上げ — つまり bit-7 の桁上げ入力(= bit-6 の桁上げ出力)である。これは内部のリプル桁上げであって、最終的に外へ出る Cout ではない

For the counter-example 108 + 53:

   c:  1 1 1 1 1 0 0 0      <- c[i] = carry INTO bit i
       ─────────────────
   A:  0 1 1 0 1 1 0 0   (108)
   B:  0 0 1 1 0 1 0 1   (53)
       ─────────────────
   S:  1 0 1 0 0 0 0 1   (161 / −95)   Cout = 0
       ↑
       bit 7 (MSB)  →  c_in MSB = c[7] = 1 (leftmost of c row)

Trace right→left:

  • bit 2: $1+1=0$ carry → $c_3 = 1$
  • bit 3: $1+0+1=0$ carry → $c_4 = 1$
  • bit 4: $0+1+1=0$ carry → $c_5 = 1$
  • bit 5: $1+1+1=1$ carry → $c_6 = 1$
  • bit 6:$1+1+1=1$ 並進位 → $c_7 = 1$ ← 這就是 $c_{\text{in MSB}}$
  • bit 6: $1+1+1=1$ carry → $c_7 = 1$ ← this is $c_{\text{in MSB}}$
  • bit 6:$1+1+1=1$ で桁上げ → $c_7 = 1$ ← これが $c_{\text{in MSB}}$ である
  • bit 7(MSB):$0+0+1=1$,進位輸出 $c_8 = 0$ ← 這就是 Cout
  • bit 7 (MSB): $0+0+1=1$, carry-out $c_8 = 0$ ← this is Cout
  • bit 7(MSB):$0+0+1=1$、桁上げ出力 $c_8 = 0$ ← これが Cout である

因此 $c_{\text{in MSB}} = c_7 = 1$(有一個 1 進到 MSB),但 $\text{Cout} = 0$(沒有 1 從它離開)。兩者不同 → 溢位:$V = c_{\text{in MSB}} \oplus \text{Cout} = 1 \oplus 0 = 1$。

So $c_{\text{in MSB}} = c_7 = 1$ (a 1 reaches the MSB), but $\text{Cout} = 0$ (no 1 leaves it). They differ → overflow: $V = c_{\text{in MSB}} \oplus \text{Cout} = 1 \oplus 0 = 1$.

したがって $c_{\text{in MSB}} = c_7 = 1$(1 が MSB に届いている)だが、$\text{Cout} = 0$(そこから 1 は出ていない)。両者は異なる → オーバフローであり、$V = c_{\text{in MSB}} \oplus \text{Cout} = 1 \oplus 0 = 1$ となる。

關鍵觀念:Cout 與 $c_{\text{in MSB}}$ 是符號位元兩側的兩個不同進位 — 比較這兩者就能偵測溢位。

Key idea: Cout and $c_{\text{in MSB}}$ are two different carries on either side of the sign bit — overflow is detected by comparing them.

要点:Cout と $c_{\text{in MSB}}$ は符号ビットの両側にある別々の桁上げである — この 2 つを比べることでオーバフローを検出する。

3.5

在 $n$ 位元 2 補數加法中,$c_n$ 是 MSB 送出的進位,$c_{n-1}$ 是進入 MSB 的進位。

For $n$-bit 2's complement addition, $c_n$ is carry out of MSB, $c_{n-1}$ is carry into MSB.

$n$ ビットの 2 の補数加算では、$c_n$ が MSB からの桁上げ出力、$c_{n-1}$ が MSB への桁上げである。

$$\boxed{\text{Overflow} = c_n \oplus c_{n-1}}$$

Proof by cases:

  • 正 + 正 → 結果必須為正。若結果的 MSB=1,則 $c_{n-1}=1$、$c_n=0$ → overflow=1 $\checkmark$
  • pos + pos → result must be positive. If result has MSB=1, $c_{n-1}=1$, $c_n=0$ → overflow=1 $\checkmark$
  • 正 + 正 → 結果は正でなければならない。結果の MSB=1 なら $c_{n-1}=1$、$c_n=0$ → overflow=1 $\checkmark$
  • 負 + 負 → 結果必須為負。若結果的 MSB=0,則 $c_{n-1}=0$、$c_n=1$ → overflow=1 $\checkmark$
  • neg + neg → result must be negative. If result MSB=0, $c_{n-1}=0$, $c_n=1$ → overflow=1 $\checkmark$
  • 負 + 負 → 結果は負でなければならない。結果の MSB=0 なら $c_{n-1}=0$、$c_n=1$ → overflow=1 $\checkmark$
  • 正 + 負 → 不可能溢位;$c_n = c_{n-1}$ 恆成立 → overflow=0 $\checkmark$
  • pos + neg → no overflow possible; $c_n = c_{n-1}$ always → overflow=0 $\checkmark$
  • 正 + 負 → オーバフローは起こり得ない。つねに $c_n = c_{n-1}$ である → overflow=0 $\checkmark$
3.6

4 位元漣波進位加法器:把四個全加器串接起來。

4-bit ripple-carry adder: chain four full adders.

4 ビットのリプルキャリー加算器:全加算器を 4 個つなぐ。

A[3:0] ──┐           B[3:0] ──┐
          │                    │
  A0,B0 →[FA0]→ S0; C0→[FA1]→ S1; C1→[FA2]→ S2; C2→[FA3]→ S3,C3
  Cin=0    cₒᵤₜ₀       cₒᵤₜ₁         cₒᵤₜ₂         Cout

每個全加器 (FA):輸入 A_i、B_i、C_in;輸出 Sum_i、C_out。

Each Full Adder (FA): inputs A_i, B_i, C_in; outputs Sum_i, C_out.

各全加算器 (FA):入力は A_i、B_i、C_in、出力は Sum_i、C_out である。

進位由 FA0 → FA1 → FA2 → FA3 逐級傳遞(關鍵路徑 = 4 個 FA 的延遲)。

Carry ripples from FA0 → FA1 → FA2 → FA3 (critical path = 4 FA delays).

桁上げは FA0 → FA1 → FA2 → FA3 と伝搬する(クリティカルパス = FA 4 段分の遅延)。

3.7

使用一個控制訊號 Sub。Sub=0 時做加法;Sub=1 時做減法 $(A - B = A + \overline{B} + 1)$

Use a control signal Sub. When Sub=0: add; when Sub=1: subtract $(A - B = A + \overline{B} + 1)$.

制御信号 Sub を使う。Sub=0 のとき加算、Sub=1 のとき減算 $(A - B = A + \overline{B} + 1)$ を行う。

把 B 的每個位元與 Sub 做 XOR:$B'_i = B_i \oplus \text{Sub}$。並把 Sub 當成 $C_{in}$ 送進加法器。

XOR each B bit with Sub: $B'_i = B_i \oplus \text{Sub}$. Feed Sub as $C_{in}$ to the adder.

B の各ビットと Sub の XOR を取る:$B'_i = B_i \oplus \text{Sub}$。さらに Sub を $C_{in}$ として加算器に入れる。

Sub a₀ b₀ FA₀ S₀ a₁ b₁ FA₁ S₁ a₂ b₂ FA₂ S₂ a₃ b₃ FA₃ S₃ c₁ c₂ c₃ Cout
module add_sub4 (
    input  [3:0] A, B,
    input        Sub,
    output [3:0] S,
    output       Cout, Overflow
);
    wire [3:0] B_in;
    wire c4, c3;
    assign B_in = B ^ {4{Sub}};
    assign {c4, S} = A + B_in + Sub; // sub is for 2 的補數 +1two’s complement +12 の補数 +1
    // carry into MSB is c3 (internal), overflow = c4 ^ c3
    assign Cout = c4;
    assign Overflow = c4 ^ (A[3] ^ B_in[3] ^ S[3]); // simplified
endmodule
3.8

Multiply $1101$ (13) $\times$ $1011$ (11):

        1101   (multiplicand)
      × 1011   (multiplier)
      ------
        1101   (1101 × 1)
       1101    (1101 × 1, shift 1)
      0000     (1101 × 0, shift 2)
     1101      (1101 × 1, shift 3)
     --------
    10001111   = 143 ✓
3.9

$-6.5$ in IEEE 754 single precision (32-bit):

Sign = 1 (negative). $|6.5| = 110.1_2 = 1.101 \times 2^2$.

Exponent $= 2 + 127\;\text{(bias)} = 129 = 10000001_2$.

Mantissa (fraction) = 101 followed by 20 zeros = 10100000000000000000000.

Result: 1 10000001 10100000000000000000000

Hex: C0D00000

3.10
module full_adder (
    input  a, b, cin,
    output sum, cout
);
    assign sum  = a ^ b ^ cin;
    assign cout = (a & b) | (a & cin) | (b & cin);
endmodule

module ripple_adder #(parameter N=8) (
    input  [N-1:0] A, B,
    input          Cin,
    output [N-1:0] Sum,
    output         Cout
);
    wire [N:0] c;
    assign c[0] = Cin;
    genvar i;
    generate
        for (i = 0; i < N; i = i+1) begin : fa_loop
            full_adder fa_inst (
                .a(A[i]), .b(B[i]), .cin(c[i]),
                .sum(Sum[i]), .cout(c[i+1])
            );
        end
    endgenerate
    assign Cout = c[N];
endmodule
3.11

由右往左掃描法:從最右邊開始把位元照抄,一直抄到第一個 1(含)為止,其餘位元全部取反。

The scan-from-right method: copy rightmost bits up to and including the first 1, then invert all remaining bits.

右から走査する方法:右端のビットから最初の 1 までを(その 1 も含めて)そのまま写し、残りのビットをすべて反転する。

為什麼成立:設 $N = \ldots 1\underbrace{0\ldots0}_{k}$(最後一個 1 在位置 $k$,其下皆為 0)。2 補數 $= \overline{N} + 1$。對 $\overline{N}$ 加 1 時,進位會一路穿過位置 $0 \ldots k-1$ 上的所有 1(這些位元在 $N$ 中是 0,在 $\overline{N}$ 中被反相成 1),把它們清成 0 並把進位送進位置 $k$。位置 $k$ 在 $N$ 中是 1,在 $\overline{N}$ 中被反相成 0,加上 $+1$ 的進位後又變回 1。更高的位元:就是 $\overline{N}$ 的位元(由 $N$ 反相而來)。淨結果:位元 $0 \ldots k-1$ 為 0(與 $N$ 相同),位元 $k$ 為 1(與 $N$ 相同),$k$ 以上的位元則被反相。$\blacksquare$

Why it works: Let $N = \ldots 1\underbrace{0\ldots0}_{k}$ (last 1 at position $k$, zeros below). 2's comp $= \overline{N} + 1$. Adding 1 to $\overline{N}$ propagates carries through all the 1s at positions $0 \ldots k-1$ (which were 0s in $N$, inverted to 1s in $\overline{N}$), zeroing them and carrying into position $k$. Position $k$ was 1 in $N$, inverted to 0 in $\overline{N}$, $+1$ carry makes it 1. Higher bits: $\overline{N}$ bits (inverted from $N$). Net result: bits $0 \ldots k-1$ are 0 (same as $N$), bit $k$ is 1 (same as $N$), bits above $k$ are inverted. $\blacksquare$

なぜうまくいくのか:$N = \ldots 1\underbrace{0\ldots0}_{k}$ とする(最後の 1 が位置 $k$ にあり、それより下はすべて 0)。2 の補数は $= \overline{N} + 1$ である。$\overline{N}$ に 1 を足すと、桁上げが位置 $0 \ldots k-1$ にあるすべての 1($N$ では 0 で、$\overline{N}$ では 1 に反転されたもの)を通って伝搬し、それらを 0 にして位置 $k$ へ桁上げを送る。位置 $k$ は $N$ では 1、$\overline{N}$ では 0 に反転されており、$+1$ の桁上げによってふたたび 1 になる。それより上のビットは $\overline{N}$ のビット($N$ を反転したもの)である。正味の結果として、ビット $0 \ldots k-1$ は 0($N$ と同じ)、ビット $k$ は 1($N$ と同じ)、$k$ より上のビットは反転されている。$\blacksquare$

3.12
格式Format形式最小Min最小最大Max最大
Unsigned 8-bit0255
Sign-magnitude−127+127
1's complement−127+127
2's complement−128+127

2 補數多出一個負數(−128),因為 10000000 沒有對應的正數;而符號-數值表示法與 1 補數則有兩種零的表示。

2's complement has one extra negative number (−128) because 10000000 has no positive counterpart; sign-magnitude and 1's complement have two representations of zero.

2 の補数では負の数が 1 つ多い(−128)。10000000 に対応する正の数が存在しないからである。一方、符号絶対値表現と 1 の補数には 0 の表現が 2 通りある。

3.24

Define: $g_i = A_i B_i$ (generate), $p_i = A_i \oplus B_i$ (propagate).

$$c_1 = g_0 + p_0 c_0$$ $$c_2 = g_1 + p_1 g_0 + p_1 p_0 c_0$$ $$c_3 = g_2 + p_2 g_1 + p_2 p_1 g_0 + p_2 p_1 p_0 c_0$$ $$c_4 = g_3 + p_3 g_2 + p_3 p_2 g_1 + p_3 p_2 p_1 g_0 + p_3 p_2 p_1 p_0 c_0$$

所有進位都在 2 層邏輯(AND-OR)內平行算出,而漣波進位則需要 8 層。

All carries computed in parallel in 2 logic levels (AND-OR), vs. 8 levels for ripple-carry.

リプルキャリーの 8 段に対し、すべての桁上げは 2 段の論理(AND-OR)で並列に計算される。

3.25

2's complement: invert all bits, add 1.

01010101: invert → 10101010, +1 → 10101011 (= −85)

11110000: invert → 00001111, +1 → 00010000 (= +16; confirms −16 → +16)

10000000:取反 → 01111111,+1 → 10000000(特例:−128,在 8 位元中沒有對應的正數)

10000000: invert → 01111111, +1 → 10000000 (special case: −128, no positive counterpart in 8-bit)

10000000:反転 → 01111111、+1 → 10000000(特殊な場合:−128 であり、8 ビットには対応する正の数がない)

3.26

0.625: 0.625×2=1.25→1; 0.25×2=0.5→0; 0.5×2=1.0→1; exact.

$0.625 = 0.101_2$ (exact in 3 bits)

0.3: 0.3×2=0.6→0; 0.6×2=1.2→1; 0.2×2=0.4→0; 0.4×2=0.8→0; 0.8×2=1.6→1; 0.6→1; 0.2→0; 0.4→0 (repeats)

$0.3 \approx 0.01001100_2$ (8 bits, repeating)

3.27

Prove $(A \oplus B) \oplus C = A \oplus (B \oplus C)$:

注意 $A \oplus B = A\overline{B} + \overline{A}B$。展開 $(A \oplus B) \oplus C$:

Note $A \oplus B = A\overline{B} + \overline{A}B$. Expand $(A \oplus B) \oplus C$:

$A \oplus B = A\overline{B} + \overline{A}B$ であることに注意する。$(A \oplus B) \oplus C$ を展開する:

$$= (A\overline{B} + \overline{A}B)\overline{C} + \overline{(A\overline{B} + \overline{A}B)} \cdot C$$ $$= A\overline{B}\,\overline{C} + \overline{A}B\overline{C} + (\overline{A}\,\overline{B} + AB)C$$ $$= A\overline{B}\,\overline{C} + \overline{A}B\overline{C} + \overline{A}\,\overline{B}C + ABC$$

展開 $A \oplus (B \oplus C)$ 會得到相同的 4 個最小項 $(1,2,4,7)$。$\blacksquare$

Expanding $A \oplus (B \oplus C)$ yields the same 4 minterms $(1,2,4,7)$. $\blacksquare$

$A \oplus (B \oplus C)$ を展開しても同じ 4 つの最小項 $(1,2,4,7)$ が得られる。$\blacksquare$

3.28

BCD 把每一個十進位數字編成 4 個位元。

BCD encodes each decimal digit in 4 bits.

BCD は 10 進の各桁を 4 ビットで符号化する。

947: 9 = 1001, 4 = 0100, 7 = 0111

BCD(947) = 1001 0100 0111

3.29

BCD addition 67 + 45:

  0110 0111  (67 BCD)
+ 0100 0101  (45 BCD)
-----------
  1010 1100  (binary sum)

低半位元組 1100 = 12 > 9 → 加上 0110 修正,並產生進位:

Lower nibble 1100 = 12 > 9 → add 0110 correction, generate carry:

下位ニブル 1100 = 12 > 9 → 補正の 0110 を加え、桁上げを発生させる:

  1100 + 0110 = 0010 carry 1
Upper nibble 1010 + 1 (carry) = 1011 > 9 → add 0110:
  1011 + 0110 = 0001 carry 1

Result: 0001 0001 0010 BCD = 112 ✓ (67+45=112)

3.30
module adder8 (
    input  [7:0] A, B,
    input        Cin,
    output [8:0] Result
);
    assign Result = {1'b0, A} + {1'b0, B} + Cin;
endmodule

9 位元結果中的 Result[8] 抓到了進位輸出。用 {1'b0, A} 在相加前先零延伸到 9 位元,就能得到正確的 9 位元和。

The 9-bit result Result[8] captures the carry out. Using {1'b0, A} zero-extends to 9 bits before addition, giving a correct 9-bit sum.

9 ビットの結果のうち Result[8] が桁上げ出力を捉える。{1'b0, A} によって加算前に 9 ビットへゼロ拡張することで、正しい 9 ビットの和が得られる。

3.31

01110101 (117) − 11010110. Subtraction = add 2's complement of subtrahend.

11010110 的 2 補數:取反→00101001,+1→00101010(表示的是 −42,但當成無號數則是 +42)。

2's complement of 11010110: invert→00101001, +1→00101010 (= −42 represented, but +42 in unsigned).

11010110 の 2 の補数:反転→00101001、+1→00101010(表しているのは −42 だが、符号なしでは +42 である)。

  01110101  (117)
+ 00101010  (+42... wait, -(-42)=+42)
----------

Actually: 01110101 − 11010110 = 01110101 + 2'scomp(11010110).

11010110 inverted = 00101001, +1 = 00101010.

01110101 + 00101010 = 10011111. Carry out = 0.

結果 $10011111$ 在 2 補數下 $= -97$。驗算:$117 - (-42) = 159$,但在 8 位元有號數中 $11010110 = -42$,所以 $117-(-42)=159$ 會溢位。換個角度,若把 $11010110$ 當成無號數 $= 214$:$117-214 = -97$。結果 $= 10011111_2 = -97$

Result $10011111$ in 2's complement $= -97$. Check: $117 - (-42) = 159$, but in 8-bit signed, $11010110 = -42$, so $117-(-42)=159$ overflows. Alternately if $11010110$ unsigned $= 214$: $117-214 = -97$. Result $= 10011111_2 = -97$.

結果 $10011111$ は 2 の補数で $= -97$ である。検算:$117 - (-42) = 159$ だが、8 ビット符号付きでは $11010110 = -42$ なので、$117-(-42)=159$ はオーバフローする。あるいは $11010110$ を符号なしの $= 214$ とみれば $117-214 = -97$ である。結果 $= 10011111_2 = -97$

3.32

$(752)_8$ to binary: $7=111,\; 5=101,\; 2=010$ → $111101010_2$

轉十六進位:把二進位由右往左每 4 位元一組:$0001\;1110\;1010$ → $1\text{EA}_{16}$

To hex: group binary in 4s from right: $0001\;1110\;1010$ → $1\text{EA}_{16}$

16 進へ:2 進数を右から 4 ビットずつ区切る:$0001\;1110\;1010$ → $1\text{EA}_{16}$

$(\text{B3D})_{16}$ to binary: $B=1011,\; 3=0011,\; D=1101$ → $101100111101_2$

轉八進位:把二進位由右往左每 3 位元一組:$101\;100\;111\;101$ → $5475_8$

To octal: group binary in 3s from right: $101\;100\;111\;101$ → $5475_8$

8 進へ:2 進数を右から 3 ビットずつ区切る:$101\;100\;111\;101$ → $5475_8$

3.33

For an $n$-bit CLA adder:

  • 產生/傳遞 (Generate/Propagate):$n$ 個 XOR 閘($p$)+ $n$ 個 AND 閘($g$)= $2n$ 個閘。
  • Generate/Propagate: $n$ XOR gates ($p$) + $n$ AND gates ($g$) = $2n$ gates.
  • 生成/伝搬 (Generate/Propagate):XOR ゲート $n$ 個($p$)+ AND ゲート $n$ 個($g$)= ゲート $2n$ 個。
  • 進位邏輯($c_1 \ldots c_n$):每個 $c_i$ 都是 AND-OR 形式:$c_i$ 需要 $i+1$ 個 AND 閘加 1 個 OR 閘。總計 $\approx n(n+1)/2$ 個 AND + $n$ 個 OR。
  • Carry logic ($c_1 \ldots c_n$): each $c_i$ is AND-OR: $c_i$ has $i+1$ AND gates + 1 OR gate. Total $\approx n(n+1)/2$ AND + $n$ OR.
  • 桁上げ論理($c_1 \ldots c_n$):各 $c_i$ は AND-OR 形式である:$c_i$ には AND ゲートが $i+1$ 個と OR ゲートが 1 個必要である。合計で $\approx n(n+1)/2$ 個の AND + $n$ 個の OR となる。
  • Sum bits: $n$ XOR gates.

總閘數約為 $\approx O(n^2)$ 個閘,但深度為 $O(1)$(標準 4 位元 CLA 區塊固定 4 層)。若以階層式 CLA 實作 $n$ 位元:$O(n \log n)$ 個閘、$O(\log n)$ 深度。

Total gate count $\approx O(n^2)$ gates but $O(1)$ depth (constant 4 levels for standard 4-bit CLA block). For $n$-bit using hierarchical CLA: $O(n \log n)$ gates with $O(\log n)$ depth.

総ゲート数は $\approx O(n^2)$ だが、深さは $O(1)$ である(標準的な 4 ビット CLA ブロックでは 4 段で一定)。$n$ ビットを階層型 CLA で構成する場合は、ゲート数 $O(n \log n)$、深さ $O(\log n)$ となる。

3.34

漣波進位加法器($n$ 位元):關鍵路徑 $= n \times t_{FA} \approx n \times 2\;\text{gate levels} = O(n)$ 的延遲。

Ripple-carry adder ($n$-bit): Critical path $= n \times t_{FA} \approx n \times 2\;\text{gate levels} = O(n)$ delay.

リプルキャリー加算器($n$ ビット):クリティカルパスは $= n \times t_{FA} \approx n \times 2\;\text{gate levels} = O(n)$ の遅延である。

4 位元、每個閘 1 ns 時:約 $\sim 8$ ns(經過 4 個 FA,每個 2 層)。

For 4-bit at 1 ns per gate: $\sim 8$ ns (through 4 FAs, each 2 levels).

4 ビットでゲートあたり 1 ns なら $\sim 8$ ns(FA 4 個を通り、各 2 段)。

超前進位加法器(CLA):進位在 2 層邏輯內算出,接著總和再多 1 層 XOR,合計 3 層;階層式 CLA 則為 $O(\log n)$。

Carry-lookahead adder (CLA): Carries computed in 2 logic levels; sum then 1 more XOR level = 3 levels total, $O(\log n)$ for hierarchical CLA.

桁上げ先見加算器(CLA):桁上げは 2 段の論理で求まり、和はさらに XOR 1 段で、合計 3 段となる。階層型 CLA では $O(\log n)$ である。

4 位元 CLA:不論 $n$ 為何都約 $\sim 3$ 個閘延遲(在同一區塊內)。

For 4-bit CLA: $\sim 3$ gate delays regardless of $n$ (within one block).

4 ビット CLA では、$n$ によらず $\sim 3$ ゲート遅延である(1 ブロック内において)。

取捨:CLA 用掉較多閘(扇入變大),但在位元寬的加法器上明顯較快。

Tradeoff: CLA uses more gates (fan-in grows) but is significantly faster for wide adders.

トレードオフ:CLA はゲート数が増える(ファンインが大きくなる)が、幅の広い加算器では大幅に速い。

3.35

以兩個 2 位元 CLA 區塊構成的階層式 CLA(分別處理位元 0-1 與位元 2-3):

Hierarchical CLA using two 2-bit CLA blocks (each handles bits 0-1 and bits 2-3):

2 ビット CLA ブロック 2 個による階層型 CLA(それぞれビット 0-1 とビット 2-3 を担当する):

區塊 0(位元 0,1):算出 $c_1, c_2$,以及群組產生 $G_0 = g_1 + p_1 g_0$、群組傳遞 $P_0 = p_1 p_0$。

Block 0 (bits 0,1): computes $c_1, c_2$, and group generate $G_0 = g_1 + p_1 g_0$, group propagate $P_0 = p_1 p_0$.

ブロック 0(ビット 0,1):$c_1, c_2$ と、グループ生成 $G_0 = g_1 + p_1 g_0$、グループ伝播 $P_0 = p_1 p_0$ を求める。

區塊 1(位元 2,3):使用區塊 0 送來的 $c_2$,算出 $c_3, c_4, G_1, P_1$。

Block 1 (bits 2,3): uses $c_2$ from Block 0; computes $c_3, c_4, G_1, P_1$.

ブロック 1(ビット 2,3):ブロック 0 からの $c_2$ を使い、$c_3, c_4, G_1, P_1$ を求める。

Top-level carry:

$$c_2 = G_0 + P_0 \cdot c_0 \qquad c_4 = G_1 + P_1 \cdot c_2$$

如此在 4 位元內同樣達到 $O(1)$ 的進位深度,再加一層階層即可擴充到 16 位元。

This achieves the same $O(1)$ carry depth within 4 bits, and extends to 16-bit with another hierarchical level.

これにより 4 ビット内では同じ $O(1)$ の桁上げ深さが得られ、階層をもう 1 段増やせば 16 ビットへ拡張できる。

3.36
module array_mult4 (
    input  [3:0] A, B,
    output [7:0] P
);
    wire [3:0] pp [3:0];
    wire [7:0] sum;
    genvar i;
    generate
        for (i = 0; i < 4; i = i+1) begin : partial
            assign pp[i] = A & {4{B[i]}};
        end
    endgenerate
    // Sum partial products with shifts
    assign P = pp[0]
             + (pp[1] << 1)
             + (pp[2] << 2)
             + (pp[3] << 3);
endmodule

每一列 pp[i] 都是 A 與複製後的 B[i] 做 AND。經過移位相加即得到 8 位元的乘積。

Each row pp[i] is the AND of A with a replicated B[i]. Shifted addition produces the 8-bit product.

各行 pp[i] は、A と複製した B[i] との AND である。シフトしながら加算することで 8 ビットの積が得られる。

3.13E

加上 $10^n$ 再減掉:$A - B = A + (10^n - B) - 10^n$。$10^n - B$ 就是 $B$ 的 10 的補數。做完加法 $A + (10^n - B)$ 之後,當 $A \ge B$ 時最高位會產生進位 $1$(代表 $10^n$);把這個進位輸出丟掉,就等於免費減掉了 $10^n$。當 $A < B$ 時不會有進位,結果為 $10^n - (B-A)$,也就是那個負值答案的 10 的補數。

Add $10^n$ and subtract: $A - B = A + (10^n - B) - 10^n$. $10^n - B$ is the 10's complement of $B$. After the addition $A + (10^n - B)$ we obtain a value whose leading position carries $1$ (representing $10^n$) when $A \ge B$; discarding that carry-out subtracts the $10^n$ for free. When $A < B$, no carry occurs and the result is $10^n - (B-A)$, which is the 10's complement of the negative answer.

$10^n$ を足してから引く:$A - B = A + (10^n - B) - 10^n$。$10^n - B$ は $B$ の 10 の補数である。加算 $A + (10^n - B)$ を行うと、$A \ge B$ のときは最上位に $1$ の桁上げ($10^n$ を表す)が出る。この桁上げ出力を捨てれば、$10^n$ の減算がただで済む。$A < B$ のときは桁上げが出ず、結果は $10^n - (B-A)$ となり、これは負の答えの 10 の補数である。

3.14E

$045 - 027$:$027$ 的 10 的補數是 $1000 - 027 = 973$。$045 + 973 = 1018$;丟掉最前面的 1 → $018 = +18$。$027 - 045$:$045$ 的 10 的補數是 $955$。$027 + 955 = 982$;沒有進位輸出,所以結果是 $982$,也就是 $-18$ 的 10 的補數(因為 $1000 - 982 = 18$)。

$045 - 027$: 10's-comp of $027$ is $1000 - 027 = 973$. $045 + 973 = 1018$; discard the leading 1 → $018 = +18$. $027 - 045$: 10's-comp of $045$ is $955$. $027 + 955 = 982$; no carry-out, so the result is $982$, which is the 10's complement of $-18$ (since $1000 - 982 = 18$).

$045 - 027$:$027$ の 10 の補数は $1000 - 027 = 973$。$045 + 973 = 1018$ で、先頭の 1 を捨てて → $018 = +18$。$027 - 045$:$045$ の 10 の補数は $955$。$027 + 955 = 982$ で桁上げ出力は出ないので、結果は $982$ であり、これは $-18$ の 10 の補数である($1000 - 982 = 18$ だから)。

3.15E

$+5 = 0101$、$+2 = 0010$。$0010$ 的 2 的補數是 $1110$。$0101 + 1110 = 1\,0011$。丟掉第 4 位元的進位輸出(= $2^4 = 16$)→ $0011 = +3$。被丟掉的那個位元正好對應到 $2^n$ 項,與預期完全相符。

$+5 = 0101$, $+2 = 0010$. 2's-comp of $0010$ is $1110$. $0101 + 1110 = 1\,0011$. Discard the carry-out from bit 4 (= $2^4 = 16$) → $0011 = +3$. The discarded bit corresponds to the $2^n$ term, exactly as predicted.

$+5 = 0101$、$+2 = 0010$。$0010$ の 2 の補数は $1110$。$0101 + 1110 = 1\,0011$。ビット 4 からの桁上げ出力(= $2^4 = 16$)を捨てて → $0011 = +3$。捨てたビットはちょうど $2^n$ の項に対応しており、予想どおりである。

3.16E

$+2 = 0010$、$+5 = 0101$。$0101$ 的 2 的補數是 $1011$。$0010 + 1011 = 1101$,沒有進位輸出。$1101$ 在 4 位元 2 的補數下是 $-(0010+1) = -3$,✓。

$+2 = 0010$, $+5 = 0101$. 2's-comp of $0101$ is $1011$. $0010 + 1011 = 1101$ with no carry-out. $1101$ in 4-bit 2's complement is $-(0010+1) = -3$, ✓.

$+2 = 0010$、$+5 = 0101$。$0101$ の 2 の補数は $1011$。$0010 + 1011 = 1101$ で桁上げ出力はない。$1101$ は 4 ビット 2 の補数で $-(0010+1) = -3$ である、✓。

3.17E

$+5 = 0101$、$-2 = 1110$。$-2$ 的 2 的補數是 $0010$。$0101 + 0010 = 0111 = +7$。✓(此例中沒有進位要丟棄,因為加數是正的。)

$+5 = 0101$, $-2 = 1110$. 2's-comp of $-2$ is $0010$. $0101 + 0010 = 0111 = +7$. ✓ (No carry to discard in this case because the addend is positive.)

$+5 = 0101$、$-2 = 1110$。$-2$ の 2 の補数は $0010$。$0101 + 0010 = 0111 = +7$。✓(この場合は加数が正なので、捨てるべき桁上げはない。)

3.18E

反覆除以 16:

Repeated division by 16:

16 で繰り返し割る:

步驟stepステップquot餘數(十六進位)rem (hex)剰余(16 進)
14959/1693415 = F
934/16586
58/16310 = A
3/1603
Reading remainders from bottom up: $14959_{10} = \mathbf{3A6F_{16}}$.

3.19E

把 0.8254 反覆乘以 2,並記下整數部分:$1.6508, 1.3016, 0.6032, 1.2064, 0.4128, 0.8256, 1.6512, 1.3024$ → 位元 1,1,0,1,0,1,1,1。因此 $0.8254_{10} \approx \mathbf{0.11010111_2}$(含截斷誤差)。

Multiply 0.8254 by 2 repeatedly, recording the integer part: $1.6508, 1.3016, 0.6032, 1.2064, 0.4128, 0.8256, 1.6512, 1.3024$ → bits 1,1,0,1,0,1,1,1. So $0.8254_{10} \approx \mathbf{0.11010111_2}$ (with truncation error).

0.8254 に 2 を繰り返し掛け、整数部を記録する:$1.6508, 1.3016, 0.6032, 1.2064, 0.4128, 0.8256, 1.6512, 1.3024$ → ビットは 1,1,0,1,0,1,1,1。したがって $0.8254_{10} \approx \mathbf{0.11010111_2}$ である(打ち切り誤差を含む)。

3.20E

整數部分:$214_{10} = 11010110_2$(反覆除以 2)。小數部分 $0.45$:×2 依序得到 $0.9, 1.8, 1.6, 1.2, 0.4, 0.8, 1.6, \dots$ → 位元 $0,1,1,1,0,0,1,\dots$。結果:$214.45_{10} \approx \mathbf{11010110.0111001\ldots_2}$。

Integer part: $214_{10} = 11010110_2$ (by repeated /2). Fractional part $0.45$: ×2 yields $0.9, 1.8, 1.6, 1.2, 0.4, 0.8, 1.6, \dots$ → bits $0,1,1,1,0,0,1,\dots$. Result: $214.45_{10} \approx \mathbf{11010110.0111001\ldots_2}$.

整数部:$214_{10} = 11010110_2$(2 で繰り返し割る)。小数部 $0.45$:×2 すると $0.9, 1.8, 1.6, 1.2, 0.4, 0.8, 1.6, \dots$ → ビットは $0,1,1,1,0,0,1,\dots$。結果:$214.45_{10} \approx \mathbf{11010110.0111001\ldots_2}$。

3.21E

以 2 的補數做減法 $S = X - Y$,並搭配有號旗標:

With 2's-complement subtraction $S = X - Y$ and signed flags:

2 の補数による減算 $S = X - Y$ と符号付きフラグを用いると:

  • $X = Y$: $Z = 1$
  • $X < Y$:$N \oplus V = 1$(也就是結果為負而無溢位,或有溢位而結果不為負)
  • $X < Y$: $N \oplus V = 1$ (i.e., result negative without overflow OR overflow without negative)
  • $X < Y$:$N \oplus V = 1$(すなわち、オーバフローなしで結果が負、またはオーバフローありで結果が負でない)
  • $X \le Y$: $Z + (N\oplus V) = 1$
  • $X > Y$: $\overline{Z}\,\overline{(N\oplus V)} = 1$
  • $X \ge Y$: $\overline{N\oplus V} = 1$

3.22E

結構化版本實例化四個全加器模組,把 $Y$ 反相並令 $c_0=1$ 以構成 $X-Y$,再由此推導出 $Z = !|S$、$N = S[3]$、$V = c_3 \oplus c_2$。

Structural version instantiates four full-adder modules with $Y$ inverted and $c_0=1$ to form $X-Y$, then derives $Z = !|S$, $N = S[3]$, $V = c_3 \oplus c_2$.

構造記述版では全加算器モジュールを 4 個インスタンス化し、$Y$ を反転して $c_0=1$ とすることで $X-Y$ を作り、そこから $Z = !|S$、$N = S[3]$、$V = c_3 \oplus c_2$ を導く。

module comp4(input [3:0] X, Y, output Z, N, V, AeqB, AltB, AleB, AgtB, AgeB);
  wire [3:0] S; wire [3:0] c;
  full_add fa0(X[0], ~Y[0], 1'b1, S[0], c[0]);
  full_add fa1(X[1], ~Y[1], c[0], S[1], c[1]);
  full_add fa2(X[2], ~Y[2], c[1], S[2], c[2]);
  full_add fa3(X[3], ~Y[3], c[2], S[3], c[3]);
  assign Z = ~|S, N = S[3], V = c[3]^c[2];
  assign AeqB = Z, AltB = N^V, AleB = Z|(N^V), AgtB = ~(Z|(N^V)), AgeB = ~(N^V);
endmodule
Generic version uses parameter n=4 and a generate for loop over full_add instances.

3.23E

漣波進位陣列(Figure 3.35):每一列都是延遲 $\approx n\cdot t_{FA}$ 的 $n$ 位元漣波加法器,共有 $n-1$ 列,因此總延遲 $\approx (n-1)n\, t_{FA} + t_{AND}$。$n=4$ 時:$\approx 12 t_{FA} + t_{AND}$。進位保留陣列(Figure 3.48):部分積的化簡用了 $n-1$ 列進位保留加法器(每列 $\approx t_{FA}$),最後再接一個由 $n$ 個 FA 組成的漣波加法器。總計 $\approx (n-1) t_{FA} + n\, t_{FA} + t_{AND} = (2n-1) t_{FA} + t_{AND}$。$n=4$ 時:$\approx 7 t_{FA} + t_{AND}$。進位保留大約快 $n/2$×。

Ripple-carry array (Figure 3.35): each row is an $n$-bit ripple adder of delay $\approx n\cdot t_{FA}$, and there are $n-1$ rows, so total delay $\approx (n-1)n\, t_{FA} + t_{AND}$. For $n=4$: $\approx 12 t_{FA} + t_{AND}$. Carry-save array (Figure 3.48): the partial-product reduction uses $n-1$ rows of carry-save adders (each $\approx t_{FA}$) plus one final ripple adder of $n$ FAs. Total $\approx (n-1) t_{FA} + n\, t_{FA} + t_{AND} = (2n-1) t_{FA} + t_{AND}$. For $n=4$: $\approx 7 t_{FA} + t_{AND}$. Carry-save is roughly $n/2$× faster.

リプルキャリー配列(Figure 3.35):各行は遅延 $\approx n\cdot t_{FA}$ の $n$ ビットリプル加算器であり、行は $n-1$ 本あるので、総遅延は $\approx (n-1)n\, t_{FA} + t_{AND}$ となる。$n=4$ では $\approx 12 t_{FA} + t_{AND}$。桁上げ保存配列(Figure 3.48):部分積の圧縮に桁上げ保存加算器を $n-1$ 段(各段 $\approx t_{FA}$)使い、最後に FA $n$ 個のリプル加算器を 1 つ置く。合計は $\approx (n-1) t_{FA} + n\, t_{FA} + t_{AND} = (2n-1) t_{FA} + t_{AND}$。$n=4$ では $\approx 7 t_{FA} + t_{AND}$。桁上げ保存のほうがおよそ $n/2$× 速い。

第 4 章 — 組合邏輯Chapter 4 — Combinational Logic第 4 章 — 組合せ論理
4.1

$f = \sum m(0,2,3,4,5,7)$。3-to-8 解碼器對每一個最小項恰好 assert 一條輸出。

$f = \sum m(0,2,3,4,5,7)$. A 3-to-8 decoder asserts exactly one output for each minterm.

$f = \sum m(0,2,3,4,5,7)$。3-to-8 デコーダは、各最小項に対してちょうど 1 本の出力をアサートする。

把解碼器輸出 $Y_0, Y_2, Y_3, Y_4, Y_5, Y_7$ 接到一個 OR 閘:

Connect decoder outputs $Y_0, Y_2, Y_3, Y_4, Y_5, Y_7$ to an OR gate:

デコーダ出力 $Y_0, Y_2, Y_3, Y_4, Y_5, Y_7$ を 1 つの OR ゲートに接続する:

$$f = Y_0 + Y_2 + Y_3 + Y_4 + Y_5 + Y_7$$

解碼器的輸入是 $x_1 x_2 x_3$,輸出為高態有效。不需要化簡;OR 閘直接實作出標準 SOP。

The decoder has inputs $x_1 x_2 x_3$ and active-high outputs. No minimization needed; the OR gate directly implements the canonical SOP.

デコーダの入力は $x_1 x_2 x_3$ で、出力はアクティブハイである。簡単化は不要であり、OR ゲートがそのまま標準形 SOP を実現する。

4.2

$f = \sum m(0,2,3,6)$。對 $x_1$ 做 Shannon 展開:

$f = \sum m(0,2,3,6)$. Shannon expansion on $x_1$:

$f = \sum m(0,2,3,6)$。$x_1$ に関する Shannon 展開:

$$f = \overline{x_1} \cdot f(0,x_2,x_3) + x_1 \cdot f(1,x_2,x_3)$$

$f|_{x_1=0}$: minterms $\{0,2,3\}$ → $f_0(x_2,x_3) = \overline{x_3} + x_2$

$f|_{x_1=1}$: minterm $\{6\}$ → $(x_2 x_3) = 10$ → $f_1 = x_2\overline{x_3}$

2 對 1 多工器:選擇線 $= x_1$;$D_0 = \overline{x_3} + x_2$、$D_1 = x_2\overline{x_3}$。

2-to-1 mux: select $= x_1$; $D_0 = \overline{x_3} + x_2$, $D_1 = x_2\overline{x_3}$.

2-to-1 MUX:選択入力 $= x_1$、$D_0 = \overline{x_3} + x_2$、$D_1 = x_2\overline{x_3}$。

4.3

4-to-1 MUX,選擇線為 $S_1 S_0$,輸入為 $D_0 \ldots D_3$,輸出為 $Y$:

4-to-1 mux with select $S_1 S_0$, inputs $D_0 \ldots D_3$, output $Y$:

選択入力 $S_1 S_0$、入力 $D_0 \ldots D_3$、出力 $Y$ の 4-to-1 MUX:

$$Y = \overline{S_1}\,\overline{S_0}\,D_0 + \overline{S_1}\,S_0\,D_1 + S_1\,\overline{S_0}\,D_2 + S_1\,S_0\,D_3$$
Circuit:
- 2 NOT gates: S̄₁, S̄₀
- 4 AND gates (3-input each): one per term
- 1 OR gate (4-input)

合計:2 NOT + 4 AND + 1 OR = 7 個閘。

Total: 2 NOT + 4 AND + 1 OR = 7 gates.

合計:2 NOT + 4 AND + 1 OR = 7 ゲート。

4.4

4-to-2 優先權編碼器:由優先權最高的有效輸入決定輸出;只要有任何輸入為有效,V=1。

4-to-2 priority encoder: highest-priority active input determines output; V=1 if any input active.

4-to-2 プライオリティエンコーダ:優先度の最も高い有効入力が出力を決める。入力のいずれかが有効なら V=1 となる。

$I_3$$I_2$$I_1$$I_0$$Y_1$$Y_0$$V$
0000xx0
0001001
001x011
01xx101
1xxx111

$Y_1 = I_3 + I_2$; $\;Y_0 = I_3 + I_1\overline{I_2}$; $\;V = I_0 + I_1 + I_2 + I_3$

閘級:4-to-2 優先編碼器(I₃ 優先權最高)Gate-level: 4-to-2 priority encoder (I₃ highest)ゲートレベル:4-to-2 プライオリティエンコーダ(I₃ が最優先) Y₁ = I₃ + I₂ I₂ I₃ ≥1 Y₁ Y₀ = I₃ + I₁·Ī₂ I₁ I₂ NOT Ī₂ & I₃ ≥1 Y₀ V = I₀ + I₁ + I₂ + I₃ I₀ I₁ I₂ I₃ ≥1 V
4.5

帶致能 E(高電位有效)的 2 對 4 解碼器:

2-to-4 decoder with enable E (active-high):

イネーブル E(アクティブハイ)付きの 2-to-4 デコーダ:

$E$$A_1$$A_0$$Y_0$$Y_1$$Y_2$$Y_3$
0xx0000
1001000
1010100
1100010
1110001
module dec2to4 (input E, A1, A0, output reg [3:0] Y);
    always @(*) begin
        if (!E)
            Y = 4'b0000;
        else
            case ({A1, A0})
                2'b00:   Y = 4'b0001;
                2'b01:   Y = 4'b0010;
                2'b10:   Y = 4'b0100;
                2'b11:   Y = 4'b1000;
                default: Y = 4'b0000;
            endcase
    end
endmodule
4.6

BCD 轉七段顯示(共陰極,段 a-g)。數字 0-9;輸入 10-15 為 don't-care。

BCD to 7-segment (common cathode, segments a-g). Digits 0-9; inputs 10-15 are don't-cares.

BCD から 7 セグメントへの変換(カソードコモン、セグメント a-g)。数字は 0-9 で、入力 10-15 は don't-care である。

數字Digit数字wxyzabcdefg
000001111110
100010110000
200101101101
300111111001
401000110011
501011011011
601101011111
701111110000
810001111111
910011111011

以輸入 10–15 為 don't-care 進行 K-map 化簡(BCD = wxyz,MSB = w):

K-map minimization with don't-cares for inputs 10–15 (BCD = wxyz, MSB = w):

入力 10–15 を don't-care として K-map で簡単化する(BCD = wxyz、MSB = w):

$$\boxed{a = w + y + xz + \overline{x}\,\overline{z}} \qquad \boxed{b = \overline{x} + yz + \overline{y}\,\overline{z}} \qquad \boxed{c = x + \overline{z} + \overline{y}}$$ $$\boxed{d = w + \overline{x}\,\overline{z} + \overline{x}y + y\overline{z} + x\overline{y}z} \qquad \boxed{e = \overline{x}\,\overline{z} + y\overline{z} = \overline{z}(\overline{x}+y)}$$ $$\boxed{f = w + \overline{y}\,\overline{z} + x\overline{z} + x\overline{y}} \qquad \boxed{g = w + \overline{x}y + x\overline{y} + x\overline{z}}$$
4.7

2 位元大小比較器。輸入為 $A = A_1 A_0$、$B = B_1 B_0$。

2-bit magnitude comparator. Inputs $A = A_1 A_0$, $B = B_1 B_0$.

2 ビットの大小比較器。入力は $A = A_1 A_0$、$B = B_1 B_0$。

當 $A_1 > B_1$,或 $A_1 = B_1$ 且 $A_0 > B_0$ 時,$A > B$。

$A > B$ when $A_1 > B_1$, or $A_1 = B_1$ and $A_0 > B_0$.

$A_1 > B_1$ のとき、あるいは $A_1 = B_1$ かつ $A_0 > B_0$ のとき、$A > B$ である。

$$\text{AgtB} = A_1\overline{B_1} + (A_1 \odot B_1) \cdot A_0\overline{B_0}$$ $$\text{AeqB} = (A_1 \odot B_1) \cdot (A_0 \odot B_0) \quad [\odot = \text{XNOR}]$$ $$\text{AltB} = \overline{A_1}B_1 + (A_1 \odot B_1) \cdot \overline{A_0}B_0$$

注意:不論輸入為何,AgtB、AeqB、AltB 之中恰好有一個為 1。

Note: exactly one of AgtB, AeqB, AltB is 1 for any input.

注意:どの入力に対しても、AgtB、AeqB、AltB のうちちょうど 1 つが 1 になる。

4.8

用兩個 2-to-4 解碼器(各自帶 enable)組成一個 3-to-8 解碼器:

Two 2-to-4 decoders (each with enable) build a 3-to-8 decoder:

2-to-4 デコーダ 2 個(それぞれ enable 付き)で 3-to-8 デコーダを構成する:

  • 解碼器 A 負責 A₂=0:致能 = Ā₂;輸入 A₁,A₀ → 輸出 Y₀..Y₃
  • Decoder A handles A₂=0: enable = Ā₂; inputs A₁,A₀ → outputs Y₀..Y₃
  • デコーダ A は A₂=0 を担当する:イネーブル = Ā₂、入力 A₁,A₀ → 出力 Y₀..Y₃
  • 解碼器 B 負責 A₂=1:致能 = A₂;輸入 A₁,A₀ → 輸出 Y₄..Y₇
  • Decoder B handles A₂=1: enable = A₂; inputs A₁,A₀ → outputs Y₄..Y₇
  • デコーダ B は A₂=1 を担当する:イネーブル = A₂、入力 A₁,A₀ → 出力 Y₄..Y₇

當 A₂=0 時,解碼器 A 被致能,在 Y₀..Y₃ 之間做選擇。當 A₂=1 時,解碼器 B 被致能,在 Y₄..Y₇ 之間做選擇。任何時刻 8 條輸出中恰好有一條為有效。

When A₂=0, decoder A is enabled and selects among Y₀..Y₃. When A₂=1, decoder B is enabled and selects among Y₄..Y₇. Exactly one of the 8 outputs is active at any time.

A₂=0 のときはデコーダ A が enable され、Y₀..Y₃ の中から選択する。A₂=1 のときはデコーダ B が enable され、Y₄..Y₇ の中から選択する。どの時点でも 8 本の出力のうちちょうど 1 本が有効である。

A₀ A₁ A₂ NOT Ā₂ A₂ Decoder A 2-to-4 (with EN) A₀ A₁ EN Y₀ Y₁ Y₂ Y₃ Decoder B 2-to-4 (with EN) A₀ A₁ EN Y₄ Y₅ Y₆ Y₇ 用兩個 2-to-4 解碼器組成 3-to-8 解碼器3-to-8 decoder from two 2-to-4 decoders2-to-4 デコーダ 2 個で 3-to-8 デコーダを構成する
4.9
module priority_enc8 (
    input  [7:0] in,
    output reg [2:0] out,
    output reg valid
);
    always @(*) begin
        valid = 1'b1;
        if      (in[7]) out = 3'd7;
        else if (in[6]) out = 3'd6;
        else if (in[5]) out = 3'd5;
        else if (in[4]) out = 3'd4;
        else if (in[3]) out = 3'd3;
        else if (in[2]) out = 3'd2;
        else if (in[1]) out = 3'd1;
        else if (in[0]) out = 3'd0;
        else begin out = 3'd0; valid = 1'b0; end
    end
endmodule
4.10

在組合邏輯的 always 區塊中,若 case 敘述不完整且沒有 default,凡是沒有在所有分支中被指派的輸出,都會被推論成閂鎖

An incomplete case statement without a default in a combinational always block infers latches for any output not assigned in all branches.

組合せ回路の always ブロックで、default のない不完全な case 文を書くと、すべての分岐で代入されない出力に対してラッチが推論される。

對於未指定的情況,合成器會保留前一個值,這就需要儲存元件(閂鎖)。這通常不是設計者的本意,會造成非預期的行為與合成警告。

The synthesizer holds the previous value for unspecified cases, which requires storage elements (latches). This is usually unintended and leads to unexpected behavior and synthesis warnings.

指定されていない場合について、合成器は前の値を保持しようとするため、記憶素子(ラッチ)が必要になる。これはたいてい意図しないものであり、予期しない動作と合成時の警告を招く。

修法:一定要加上 default 分支,或使用 always @(*) 並完整指派所有輸出。

Fix: always include a default branch, or use always @(*) with full assignments.

対策:必ず default 分岐を入れるか、always @(*) を使ってすべてに代入する。

4.11

Gray code:相鄰的兩個碼恰好只差 1 個位元。4 位元的情形:由二進位 $B_3 B_2 B_1 B_0$ 得到 $G_3 G_2 G_1 G_0$:

Gray code: consecutive codes differ in exactly 1 bit. For 4-bit: $G_3 G_2 G_1 G_0$ from binary $B_3 B_2 B_1 B_0$:

Gray code:連続する符号はちょうど 1 ビットだけ異なる。4 ビットの場合、2 進の $B_3 B_2 B_1 B_0$ から $G_3 G_2 G_1 G_0$ を求める:

$$G_3 = B_3 \qquad G_2 = B_3 \oplus B_2 \qquad G_1 = B_2 \oplus B_1 \qquad G_0 = B_1 \oplus B_0$$
module bin2gray (input [3:0] B, output [3:0] G);
    assign G = B ^ (B >> 1);
endmodule
二進位Bin2 進格雷碼Grayグレイ符号二進位Bin2 進格雷碼Grayグレイ符号
0000000010001100
0001000110011101
0010001110101111
0011001010111110
4.12

Shannon's expansion:

$$f(x_1,\ldots,x_n) = \overline{x_i} \cdot f(x_1,\ldots,0,\ldots,x_n) + x_i \cdot f(x_1,\ldots,1,\ldots,x_n)$$

證明:每一組輸入組合都滿足 $x_i = 0$ 或 $x_i = 1$。

Proof: Every input combination has $x_i = 0$ or $x_i = 1$.

証明:どの入力組合せでも $x_i = 0$ か $x_i = 1$ のいずれかである。

$x_i = 0$ 的情形:右式 $= 1 \cdot f(\ldots,0,\ldots) + 0 \cdot f(\ldots,1,\ldots) = f(\ldots,0,\ldots)$ = 左式。$\checkmark$

Case $x_i = 0$: RHS $= 1 \cdot f(\ldots,0,\ldots) + 0 \cdot f(\ldots,1,\ldots) = f(\ldots,0,\ldots)$ = LHS. $\checkmark$

$x_i = 0$ の場合:右辺 $= 1 \cdot f(\ldots,0,\ldots) + 0 \cdot f(\ldots,1,\ldots) = f(\ldots,0,\ldots)$ = 左辺。$\checkmark$

$x_i = 1$ 的情形:右式 $= 0 \cdot f(\ldots,0,\ldots) + 1 \cdot f(\ldots,1,\ldots) = f(\ldots,1,\ldots)$ = 左式。$\checkmark$

Case $x_i = 1$: RHS $= 0 \cdot f(\ldots,0,\ldots) + 1 \cdot f(\ldots,1,\ldots) = f(\ldots,1,\ldots)$ = LHS. $\checkmark$

$x_i = 1$ の場合:右辺 $= 0 \cdot f(\ldots,0,\ldots) + 1 \cdot f(\ldots,1,\ldots) = f(\ldots,1,\ldots)$ = 左辺。$\checkmark$

既然兩種情形對所有輸入組合都成立,此展開式即為有效。$\blacksquare$

Since both cases hold for all input combinations, the expansion is valid. $\blacksquare$

両方の場合がすべての入力組合せで成り立つので、この展開は正しい。$\blacksquare$

4.48

用 2-to-1 MUX 以樹狀結構組成 8-to-1 MUX:

Build 8-to-1 mux from 2-to-1 muxes in a tree:

2-to-1 MUX を木構造に組んで 8-to-1 MUX を構成する:

第 1 層(4 個 MUX):把 D₀/D₁、D₂/D₃、D₄/D₅、D₆/D₇ 兩兩配對,由 S₀ 選擇。

Level 1 (4 muxes): pair up D₀/D₁, D₂/D₃, D₄/D₅, D₆/D₇, selected by S₀.

第 1 段(MUX 4 個):D₀/D₁、D₂/D₃、D₄/D₅、D₆/D₇ を組にし、S₀ で選択する。

第 2 層(2 個 MUX):把第 1 層的輸出兩兩配對,由 S₁ 選擇。

Level 2 (2 muxes): pair level-1 outputs, selected by S₁.

第 2 段(MUX 2 個):第 1 段の出力を組にし、S₁ で選択する。

第 3 層(1 個 MUX):把第 2 層的輸出配對,由 S₂ 選擇。

Level 3 (1 mux): pair level-2 outputs, selected by S₂.

第 3 段(MUX 1 個):第 2 段の出力を組にし、S₂ で選択する。

總計:4+2+1 = 7 個 2-to-1 MUX。S₂ 是選擇線的 MSB。

Total: 4+2+1 = 7 two-to-one muxes. S₂ is the MSB of select.

合計:4+2+1 = 2-to-1 MUX 7 個。S₂ は選択入力の MSB である。

4.49
module mux4to1 (
    input  [1:0] sel,
    input  [3:0] d,
    output reg   y
);
    always @(*)
        y = d[sel];
    // alternatively using conditional operator:
    // assign y = (sel==2'b00) ? d[0] :
    //            (sel==2'b01) ? d[1] :
    //            (sel==2'b10) ? d[2] : d[3];
endmodule
4.50

1-to-4 解多工器:依 S₁S₀ 把單一輸入 I 導向四條輸出中的其中一條。

1-to-4 demultiplexer: routes single input I to one of four outputs based on S₁S₀.

1-to-4 デマルチプレクサ:S₁S₀ に応じて、単一の入力 I を 4 本の出力のいずれか 1 本へ振り分ける。

$S_1$$S_0$$Y_0$$Y_1$$Y_2$$Y_3$
00I000
010I00
1000I0
11000I

$Y_i = I \cdot \text{(decoder output for } i\text{)} = I \cdot m_i(S_1, S_0)$

4.51
module comparator4 (
    input  [3:0] A, B,
    output       AgtB, AeqB, AltB
);
    assign AgtB = (A > B);
    assign AeqB = (A == B);
    assign AltB = (A < B);
endmodule

合成工具會把關係運算子展開成最佳化過的組合邏輯。

Synthesis tools expand the relational operators into optimized combinational logic.

合成ツールは関係演算子を最適化された組合せ回路へ展開する。

4.52
module bcd_to_7seg (
    input  [3:0] bcd,
    output reg [6:0] seg  // seg[6]=a, seg[5]=b,..., seg[0]=g
);
    function [6:0] decode;
        input [3:0] d;
        case (d)
            4'd0: decode = 7'b1111110;
            4'd1: decode = 7'b0110000;
            4'd2: decode = 7'b1101101;
            4'd3: decode = 7'b1111001;
            4'd4: decode = 7'b0110011;
            4'd5: decode = 7'b1011011;
            4'd6: decode = 7'b1011111;
            4'd7: decode = 7'b1110000;
            4'd8: decode = 7'b1111111;
            4'd9: decode = 7'b1111011;
            default: decode = 7'b0000000;
        endcase
    endfunction
    always @(*) seg = decode(bcd);
endmodule
4.53
module popcount8 (
    input  [7:0] data,
    output reg [3:0] count
);
    integer i;
    always @(*) begin
        count = 0;
        for (i = 0; i < 8; i = i+1)
            count = count + data[i];
    end
endmodule

合成時會把 for 迴圈展開成一棵加法器樹。結果為 1 位元的個數(0 到 8,需要 4 位元)。

The for loop is unrolled by synthesis into a tree of adders. Result is the number of 1-bits (0 to 8, needs 4 bits).

for ループは合成によって加算器のツリーに展開される。結果は 1 のビット数(0 から 8、4 ビット必要)である。

4.54

對所有變數遞迴套用 Shannon 展開:

Apply Shannon's expansion recursively on all variables:

すべての変数に対して Shannon 展開を再帰的に適用する:

$$f(x_1,x_2,x_3) = \overline{x_1}\,\overline{x_2} \cdot f(0,0,x_3) + \overline{x_1}\,x_2 \cdot f(0,1,x_3) + x_1\,\overline{x_2} \cdot f(1,0,x_3) + x_1\,x_2 \cdot f(1,1,x_3)$$

每個餘因子 $f(a,b,x_3)$ 再對 $x_3$ 展開:

Each cofactor $f(a,b,x_3)$ is further expanded on $x_3$:

各コファクタ $f(a,b,x_3)$ をさらに $x_3$ について展開する:

$$f(a,b,x_3) = \overline{x_3} \cdot f(a,b,0) + x_3 \cdot f(a,b,1)$$

對每一個特定的最小項,$f(a,b,c) \in \{0,1\}$。如此遞迴下去便得到標準的最小項之和:$f = \sum_i m_i \cdot f(m_i)$,其中總和取遍所有使 $f = 1$ 的輸入組合。$\blacksquare$

$f(a,b,c) \in \{0,1\}$ for each specific minterm. This recursively produces the canonical sum of minterms: $f = \sum_i m_i \cdot f(m_i)$, where the sum is over all input combinations where $f = 1$. $\blacksquare$

個々の最小項について $f(a,b,c) \in \{0,1\}$ である。これを再帰的に続けると標準形の最小項の和が得られる:$f = \sum_i m_i \cdot f(m_i)$。ここで和は $f = 1$ となるすべての入力組合せにわたる。$\blacksquare$

4.55

casez:在 case 項目比對時,把 z(高阻抗)與 ? 視為 don't-care 位元。用於優先權編碼器與部分比對。

casez: Treats z (high-impedance) and ? as don't-care bits in case item comparisons. Used for priority encoders and partial matches.

casez:case 項目の比較で z(ハイインピーダンス)と ? を don't-care ビットとして扱う。優先順位エンコーダや部分一致に用いる。

casex:x(未知)與 z 兩者都視為 don't-care。遮罩更為激進 — 連 case 運算式本身的未知值也會被遮掉,可能因此掩蓋模擬上的不一致。

casex: Treats both x (unknown) and z as don't-care. More aggressive masking — also masks unknown values in the case expression itself, which can hide simulation mismatches.

casex:x(不定)と z の両方を don't-care として扱う。マスクがより強引で — case 式そのものの不定値までマスクしてしまうため、シミュレーションの不一致を隠すことがある。

最佳實務:合成時優先使用 casez(或搭配 ?casez);避免使用 casex,因為它會在模擬中遮蔽 X,可能藏起錯誤。

Best practice: Prefer casez (or casez with ?) for synthesis; avoid casex as it masks Xs in simulation, potentially hiding bugs.

ベストプラクティス:合成では casez(あるいは ? を伴う casez)を優先する。casex はシミュレーションで X をマスクしてしまい、バグを隠しかねないので避ける。

4.56
module sort3 (
    input  [7:0] a, b, c,
    output reg [7:0] x, y, z  // x≤y≤z
);
    task swap;
        inout [7:0] p, q;
        reg   [7:0] t;
        begin
            if (p > q) begin t = p; p = q; q = t; end
        end
    endtask
    always @(*) begin
        x = a; y = b; z = c;
        swap(x, y);   // ensure x≤y
        swap(y, z);   // bubble largest to z
        swap(x, y);   // final sort x≤y
    end
endmodule
4.57

CLA 進位:$c_{i+1} = g_i + p_i c_i$。這其實是一個 2-to-1 mux 的結構:

CLA carry: $c_{i+1} = g_i + p_i c_i$. This is a 2-to-1 mux structure:

CLA の桁上げ:$c_{i+1} = g_i + p_i c_i$。これは 2-to-1 mux の構造である:

$c_{i+1} = \text{mux}(p_i,\; g_i,\; c_i)$:若 $p_i = 1$,輸出 $= c_i$(傳遞);若 $p_i = 0$,輸出 $= g_i$(產生或消去)。

$c_{i+1} = \text{mux}(p_i,\; g_i,\; c_i)$: if $p_i = 1$, output $= c_i$ (propagate); if $p_i = 0$, output $= g_i$ (generate or kill).

$c_{i+1} = \text{mux}(p_i,\; g_i,\; c_i)$:$p_i = 1$ なら出力は $= c_i$(伝搬)、$p_i = 0$ なら出力は $= g_i$(生成または消滅)となる。

也就是選擇端 $= p_i$、$D_1 = c_i$、$D_0 = g_i$ 的 2-to-1 mux。

This is a 2-to-1 mux with select $= p_i$, $D_1 = c_i$, $D_0 = g_i$.

すなわち選択入力が $= p_i$、$D_1 = c_i$、$D_0 = g_i$ の 2-to-1 mux である。

$$c_{i+1} = p_i \cdot c_i + \overline{p_i} \cdot g_i = \text{mux}(p_i,\; g_i,\; c_i)$$

這種「carry select」mux 結構正是高速 carry-select 加法器的基礎。

This "carry select" mux structure underlies fast carry-select adders.

この「carry select」mux 構造が、高速な carry-select 加算器の土台になっている。

4.58

$f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$。對 $w_1$ 做 Shannon 展開:

$f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$. Expand by Shannon on $w_1$:

$f = w_1 w_2 + w_2 w_3 + \overline{w_1}\,\overline{w_2}\,w_3$。$w_1$ について Shannon 展開する:

$$f|_{w_1=0} = w_2 w_3 + \overline{w_2}\,w_3 = w_3(w_2 + \overline{w_2}) = w_3$$ $$f|_{w_1=1} = w_2 + w_2 w_3 = w_2(1 + w_3) = w_2$$

使用選擇線 $= w_1$ 的 2 對 1 多工器:$D_0 = w_3$、$D_1 = w_2$。

Use 2-to-1 mux with select $= w_1$: $D_0 = w_3$, $D_1 = w_2$.

選択入力 $= w_1$ の 2-to-1 MUX を使う:$D_0 = w_3$、$D_1 = w_2$。

$$\boxed{f = \overline{w_1} \cdot w_3 + w_1 \cdot w_2}$$
4.59
module decoder_n #(parameter N=3) (
    input  [N-1:0]   addr,
    input            en,
    output [(1<
4.60

可串接的 4 位元比較器多了幾個輸入:來自較低位級的 GIN(greater-in)、EIN(equal-in)、LIN(less-in)。

Cascadable 4-bit comparator has additional inputs: GIN (greater-in), EIN (equal-in), LIN (less-in) from the less-significant stage.

縦続接続できる 4 ビット比較器には、下位段から来る GIN(greater-in)、EIN(equal-in)、LIN(less-in)という入力が追加される。

GOUT = AgtB_internal OR (AeqB_internal AND GIN)

EOUT = AeqB_internal AND EIN

LOUT = AltB_internal OR (AeqB_internal AND LIN)

最低位級以 GIN=0、EIN=1、LIN=0 初始化。由 LSB 往 MSB 逐級串接;最高位級輸出最終結果。

Initialize the LSB stage with GIN=0, EIN=1, LIN=0. Chain stages from LSB to MSB; the MSB stage outputs the final result.

最下位段は GIN=0、EIN=1、LIN=0 で初期化する。LSB から MSB へ段を連ね、最上位段が最終結果を出力する。

4.13E

兩個 2-to-1 mux 都由 $s$ 控制:$y_1 = \overline{s}\,x_1 + s\,x_2$、$y_2 = \overline{s}\,x_2 + s\,x_1$。$s=0$ 時每個輸出各自送出同編號的輸入;$s=1$ 時兩者互換。

Two 2-to-1 muxes both controlled by $s$: $y_1 = \overline{s}\,x_1 + s\,x_2$, $y_2 = \overline{s}\,x_2 + s\,x_1$. When $s=0$ each output forwards its same-index input; when $s=1$ they swap.

2-to-1 mux を 2 個とも $s$ で制御する:$y_1 = \overline{s}\,x_1 + s\,x_2$、$y_2 = \overline{s}\,x_2 + s\,x_1$。$s=0$ では各出力が同じ番号の入力をそのまま通し、$s=1$ では入れ替わる。

4.14E

Maj($w_1, w_2, w_3$) = $w_1 w_2 + w_1 w_3 + w_2 w_3$。以 $w_1, w_2$ 作為 4-to-1 mux 的選擇端:

Maj($w_1, w_2, w_3$) = $w_1 w_2 + w_1 w_3 + w_2 w_3$. With $w_1, w_2$ as the 4-to-1 mux selects:

Maj($w_1, w_2, w_3$) = $w_1 w_2 + w_1 w_3 + w_2 w_3$。$w_1, w_2$ を 4-to-1 mux の選択入力とすると:

$w_1 w_2$$f$
000
01$w_3$
10$w_3$
111
So data inputs $I_0=0, I_1=w_3, I_2=w_3, I_3=1$.

Verilog(4-to-1 MUX 形式,與表格對應):

Verilog (4-to-1 MUX form, matching the table):

Verilog(表に対応する 4-to-1 MUX の形):

module majority3 (
  input  w1, w2, w3,
  output reg f
);
  // {w1, w2} chooses one of four data inputs: {0, w3, w3, 1}
  always @(*) begin
    case ({w1, w2})
      2'b00: f = 1'b0;   // I0
      2'b01: f = w3;     // I1
      2'b10: f = w3;     // I2
      2'b11: f = 1'b1;   // I3
    endcase
  end
endmodule

Verilog(直接以最小 SOP 實作):

Verilog (direct minimum SOP):

Verilog(最小 SOP を直接記述):

module majority3 (
  input  w1, w2, w3,
  output f
);
  assign f = (w1 & w2) | (w1 & w3) | (w2 & w3);
endmodule
4.15E

遞迴分解 $w_1\oplus w_2\oplus w_3 = w_1 \oplus (w_2\oplus w_3)$。先用一個由 $w_2$ 選擇的 mux 算出 $w_2\oplus w_3$(資料輸入為 $w_3$ 與 $\overline{w_3}$)。接著第二個由 $w_1$ 選擇的 mux 以該 XOR 結果及其補數為資料輸入,產生 $f$。合計:2 個 mux,外加補數資料線所需的反相器。

Recursively decompose $w_1\oplus w_2\oplus w_3 = w_1 \oplus (w_2\oplus w_3)$. Use one mux selected by $w_2$ to compute $w_2\oplus w_3$ (data inputs $w_3$ and $\overline{w_3}$). Then a second mux selected by $w_1$ takes that XOR result and its complement as data, producing $f$. Total: 2 muxes plus inverters for the complemented data lines.

$w_1\oplus w_2\oplus w_3 = w_1 \oplus (w_2\oplus w_3)$ と再帰的に分解する。まず $w_2$ で選択する mux 1 個で $w_2\oplus w_3$ を作る(データ入力は $w_3$ と $\overline{w_3}$)。次に $w_1$ で選択する 2 個目の mux が、その XOR 結果とその補数をデータ入力に取り、$f$ を得る。合計:mux 2 個と、反転データ線用のインバータである。

Verilog(兩級串接的 2-to-1 MUX): 這個概念非常重要

Verilog (two cascaded 2-to-1 MUXes): the concept is very important

Verilog(2 段縦続の 2-to-1 MUX): この考え方は非常に重要である

module xor3_via_muxes (
  input  w1, w2, w3,
  output f
);
  // First mux: select=w2, computes w2 ⊕ w3
  //   when w2=0 → output = w3
  //   when w2=1 → output = ~w3
  wire xor23 = w2 ? ~w3 : w3;

  // Second mux: select=w1, computes w1 ⊕ xor23
  //   when w1=0 → output = xor23
  //   when w1=1 → output = ~xor23
  assign f = w1 ? ~xor23 : xor23;
endmodule

Verilog(直接用 XOR — 供對照): 錯誤答案

Verilog (direct XOR — for comparison): wrong answer

Verilog(XOR を直接使う — 比較用): 誤答

module xor3_direct (
  input  w1, w2, w3,
  output f
);
  assign f = w1 ^ w2 ^ w3;
endmodule

兩者實現的是同一個函數。以 MUX 為基礎的寫法把遞迴分解 $w_1 \oplus (w_2 \oplus w_3)$ 明確表現出來,也展示了 Shannon 展開如何把任意函數化為一棵 2-to-1 MUX 樹。

Both produce the same function. The MUX-based form makes the recursive decomposition $w_1 \oplus (w_2 \oplus w_3)$ explicit and shows how Shannon-expansion turns an arbitrary function into a tree of 2-to-1 MUXes.

どちらも同じ関数を実現する。MUX による形は再帰的分解 $w_1 \oplus (w_2 \oplus w_3)$ を明示し、Shannon 展開が任意の関数を 2-to-1 MUX のツリーに変える様子を示している。

4.16E

$f = \overline{w_1}\,\overline{w_3} + w_2 w_3$。對 $w_1$ 展開:$f_{w_1}=w_2 w_3$、$f_{\overline{w_1}} = \overline{w_3}+w_2 w_3 = \overline{w_3}+w_2$。→ 6 個輸入。對 $w_2$ 展開:$f_{w_2} = \overline{w_1}\,\overline{w_3}+w_3$、$f_{\overline{w_2}} = \overline{w_1}\,\overline{w_3}$。→ 5 個輸入。對 $w_3$ 展開:$f_{w_3} = w_2$、$f_{\overline{w_3}} = \overline{w_1}$。於是 $f = \overline{w_3}\,\overline{w_1} + w_3 w_2$ — 只要 4 個閘輸入。以 $w_3$ 展開勝出。

$f = \overline{w_1}\,\overline{w_3} + w_2 w_3$. On $w_1$: $f_{w_1}=w_2 w_3$, $f_{\overline{w_1}} = \overline{w_3}+w_2 w_3 = \overline{w_3}+w_2$. → 6 inputs. On $w_2$: $f_{w_2} = \overline{w_1}\,\overline{w_3}+w_3$, $f_{\overline{w_2}} = \overline{w_1}\,\overline{w_3}$. → 5 inputs. On $w_3$: $f_{w_3} = w_2$, $f_{\overline{w_3}} = \overline{w_1}$. So $f = \overline{w_3}\,\overline{w_1} + w_3 w_2$ — only 4 gate-inputs. Expansion on $w_3$ wins.

$f = \overline{w_1}\,\overline{w_3} + w_2 w_3$。$w_1$ で展開:$f_{w_1}=w_2 w_3$、$f_{\overline{w_1}} = \overline{w_3}+w_2 w_3 = \overline{w_3}+w_2$。→ 入力 6 本。$w_2$ で展開:$f_{w_2} = \overline{w_1}\,\overline{w_3}+w_3$、$f_{\overline{w_2}} = \overline{w_1}\,\overline{w_3}$。→ 入力 5 本。$w_3$ で展開:$f_{w_3} = w_2$、$f_{\overline{w_3}} = \overline{w_1}$。よって $f = \overline{w_3}\,\overline{w_1} + w_3 w_2$ — ゲート入力 4 本だけで済む。$w_3$ による展開が勝ちである。

→ Shannon 展開 — 速查表

→ Shannon's Expansion — cheat sheet

→ Shannon 展開 — チートシート

4.17E

對 $w_1$ 做 Shannon 展開:$f_{\overline{w_1}} = \overline{w_3}$、$f_{w_1} = w_2 + w_3$。(a) 由 $w_1$ 選擇的 2-to-1 mux,資料輸入為 $\overline{w_3}$ 與 $(w_2+w_3)$ — 需要一個反相器與一個 OR。(b) 對 $\{w_1, w_3\}$ 做 Shannon 展開:$(w_1, w_3) \in \{00,01,10,11\}$ 各處的餘因子為 $\{1, 0, 1, w_2\to 1\}\to\{1,0,1,1\}$。因此由 $\{w_1, w_3\}$ 選擇的 4-to-1 mux,其資料輸入為 $1, 0, w_2, 1$。

Shannon on $w_1$: $f_{\overline{w_1}} = \overline{w_3}$, $f_{w_1} = w_2 + w_3$. (a) 2-to-1 mux selected by $w_1$, data inputs $\overline{w_3}$ and $(w_2+w_3)$ — needs an inverter and an OR. (b) Shannon on $\{w_1, w_3\}$: cofactors at $(w_1, w_3) \in \{00,01,10,11\}$ are $\{1, 0, 1, w_2\to 1\}\to\{1,0,1,1\}$. So 4-to-1 mux selected by $\{w_1, w_3\}$ has data inputs $1, 0, w_2, 1$.

$w_1$ について Shannon 展開する:$f_{\overline{w_1}} = \overline{w_3}$、$f_{w_1} = w_2 + w_3$。(a) $w_1$ で選択する 2-to-1 mux のデータ入力は $\overline{w_3}$ と $(w_2+w_3)$ — インバータ 1 個と OR 1 個が要る。(b) $\{w_1, w_3\}$ について Shannon 展開する:$(w_1, w_3) \in \{00,01,10,11\}$ でのコファクタは $\{1, 0, 1, w_2\to 1\}\to\{1,0,1,1\}$ である。したがって $\{w_1, w_3\}$ で選択する 4-to-1 mux のデータ入力は $1, 0, w_2, 1$ となる。

4.18E

Maj $= w_1 w_2 + w_1 w_3 + w_2 w_3$。對 $w_1$ 做 Shannon 展開:$f_{\overline{w_1}} = w_2 w_3$、$f_{w_1} = w_2 + w_3$。再把每個餘因子對 $w_2$ 展開:$f_{\overline{w_1}\overline{w_2}}=0$、$f_{\overline{w_1}w_2} = w_3$;$f_{w_1\overline{w_2}} = w_3$、$f_{w_1 w_2} = 1$。樹狀結構為:兩個由 $w_2$ 選擇的 mux(資料分別是 $0,w_3$ 與 $w_3,1$)餵給一個由 $w_1$ 選擇的 mux。合計:3 個 2-to-1 mux。

Maj $= w_1 w_2 + w_1 w_3 + w_2 w_3$. Shannon on $w_1$: $f_{\overline{w_1}} = w_2 w_3$, $f_{w_1} = w_2 + w_3$. Shannon each cofactor on $w_2$: $f_{\overline{w_1}\overline{w_2}}=0$, $f_{\overline{w_1}w_2} = w_3$; $f_{w_1\overline{w_2}} = w_3$, $f_{w_1 w_2} = 1$. Build the tree as two muxes selected by $w_2$ (data $0,w_3$ and $w_3,1$) feeding one mux selected by $w_1$. Total: 3 2-to-1 muxes.

Maj $= w_1 w_2 + w_1 w_3 + w_2 w_3$。$w_1$ について Shannon 展開する:$f_{\overline{w_1}} = w_2 w_3$、$f_{w_1} = w_2 + w_3$。各コファクタをさらに $w_2$ について展開する:$f_{\overline{w_1}\overline{w_2}}=0$、$f_{\overline{w_1}w_2} = w_3$、$f_{w_1\overline{w_2}} = w_3$、$f_{w_1 w_2} = 1$。ツリーは、$w_2$ で選択する mux 2 個(データはそれぞれ $0,w_3$ と $w_3,1$)が $w_1$ で選択する mux 1 個へ入る形に組む。合計:2-to-1 mux が 3 個である。

4.19E

En=1 的 2-to-4 解碼器會輸出其選擇輸入 $s_0, s_1$ 的四個最小項。把每個最小項 $m_i$ 與對應的資料 $w_i$ 做 AND,再把四個結果做 OR:$f = m_0 w_0 + m_1 w_1 + m_2 w_2 + m_3 w_3$ — 這正是 4-to-1 mux 的功能。

A 2-to-4 decoder with En=1 outputs the four minterms of its select inputs $s_0, s_1$. AND each minterm $m_i$ with the corresponding data $w_i$ and OR all four results: $f = m_0 w_0 + m_1 w_1 + m_2 w_2 + m_3 w_3$ — exactly the function of a 4-to-1 mux.

En=1 の 2-to-4 デコーダは、選択入力 $s_0, s_1$ の 4 つの最小項を出力する。各最小項 $m_i$ を対応するデータ $w_i$ と AND し、4 つの結果を OR する:$f = m_0 w_0 + m_1 w_1 + m_2 w_2 + m_3 w_3$ — これはまさに 4-to-1 mux の機能である。

4.20E
module mux2to1(input w0, w1, s, output f);
  assign f = s ? w1 : w0;
endmodule
4.21E
module mux2to1(input w0, w1, s, output reg f);
  always @(*) begin
    if (s) f = w1;
    else   f = w0;
  end
endmodule
4.22E
module mux16to1(input [15:0] W, input [3:0] S, output f);
  wire [3:0] m;
  mux4to1 g0(W[3:0],   S[1:0], m[0]);
  mux4to1 g1(W[7:4],   S[1:0], m[1]);
  mux4to1 g2(W[11:8],  S[1:0], m[2]);
  mux4to1 g3(W[15:12], S[1:0], m[3]);
  mux4to1 g4(m, S[3:2], f);
endmodule
4.23E
module mux4to1(input [3:0] W, input [1:0] S, output reg f);
  always @(*) case (S)
    2'b00: f = W[0];
    2'b01: f = W[1];
    2'b10: f = W[2];
    2'b11: f = W[3];
  endcase
endmodule
4.24E
module dec2to4(input [1:0] W, input En, output reg [3:0] Y);
  always @(*) case ({En, W})
    3'b100: Y = 4'b0001;
    3'b101: Y = 4'b0010;
    3'b110: Y = 4'b0100;
    3'b111: Y = 4'b1000;
    default: Y = 4'b0000;
  endcase
endmodule
4.25E
module dec2to4(input [1:0] W, input En, output reg [3:0] Y);
  always @(*) begin
    if (En == 0) Y = 4'b0000;
    else case (W)
      2'b00: Y = 4'b0001;
      2'b01: Y = 4'b0010;
      2'b10: Y = 4'b0100;
      2'b11: Y = 4'b1000;
    endcase
  end
endmodule
4.26E
module dec4to16(input [3:0] W, input En, output [15:0] Y);
  wire [3:0] M;
  dec2to4 d0(W[3:2], En, M);
  dec2to4 d1(W[1:0], M[0], Y[3:0]);
  dec2to4 d2(W[1:0], M[1], Y[7:4]);
  dec2to4 d3(W[1:0], M[2], Y[11:8]);
  dec2to4 d4(W[1:0], M[3], Y[15:12]);
endmodule
dec2to4 是什麼?What is dec2to4?dec2to4 とは何か?

dec2to4帶致能輸入的 2-to-4 二進位解碼器 — 也就是上面那個 4-to-16 解碼器裡被實例化 5 次的可重複使用小單元。兩個選擇位元決定四個輸出中哪一個被 assert;致能輸入則管控整個解碼器,可把其輸出強制為 0。

dec2to4 is a 2-to-4 binary decoder with an enable input — the small reusable cell that gets instantiated 5 times in the 4-to-16 decoder above. Two select bits choose which one of four outputs is asserted; the enable input gates the whole decoder so its outputs can be forced to zero.

dec2to4イネーブル入力付きの 2-to-4 バイナリデコーダである — 上の 4-to-16 デコーダで 5 回インスタンス化される、再利用可能な小さなセルである。2 本の選択ビットが 4 出力のどれをアサートするかを決め、イネーブル入力がデコーダ全体をゲートして、その出力を 0 に固定できるようにする。

行為 — 對於輸入 W[1:0]En

Behavior — for inputs W[1:0] and En:

動作 — 入力 W[1:0]En に対して:

EnW[1]W[0]Y[3]Y[2]Y[1]Y[0]
0xx0000
1000001
1010010
1100100
1111000

等價地說:Y[i] = En AND(W 的二進位值等於 i);其餘的 Y 全為 0。

Equivalently: Y[i] = En AND (binary value of W equals i); all other Y's are 0.

同じことを言い換えると:Y[i] = En AND(W の 2 進値が i に等しい)であり、ほかの Y はすべて 0 である。

Verilog:

module dec2to4 (
  input  [1:0] W,
  input        En,
  output reg [3:0] Y
);
  always @(*) begin
    Y = 4'b0000;
    if (En) Y[W] = 1'b1;   // assert exactly one output
  end
endmodule

(或者等價地,用一個扁平的 case (W) 再與 En 做 AND。)

(Or, equivalently, a flat case (W) + AND with En.)

(あるいは同等に、フラットな case (W)En の AND でもよい。)

為什麼會在這裡出現:4-to-16 解碼器那一題(4.26)把 dec2to4 當成建構區塊,在兩級樹狀結構中實例化 5 次:

Why it shows up here: the 4-to-16 decoder problem (4.26) uses dec2to4 as a building block instantiated 5 times in a 2-stage tree:

ここで出てくる理由:4-to-16 デコーダの問題(4.26)は dec2to4構成要素として、2 段のツリーの中で 5 回インスタンス化する:

  • 頂層(1 個實例):d0(W[3:2], En, M) — 解碼高兩位元,並由 En 管控。四個輸出 M[0..3] 中只有一個為高。
  • Top stage (1 instance): d0(W[3:2], En, M) — decodes the high two bits, gated by En. Only one of the four outputs M[0..3] is high.
  • 上位段(インスタンス 1 個):d0(W[3:2], En, M) — 上位 2 ビットをデコードし、En でゲートする。4 つの出力 M[0..3] のうち 1 本だけが H になる。
  • 底層(4 個實例):d1..d4 — 每個都以低兩位元 W[1:0] 為選擇輸入,並用其中一條 M[i] 當致能。只有致能為高的那個底層解碼器會產生輸出,其餘三個輸出全為 0。
  • Bottom stage (4 instances): d1..d4 — each takes the low two bits W[1:0] as its select, and uses one of M[i] as its enable. Only the bottom decoder whose enable is high produces an output; the other three output all-zeros.
  • 下位段(インスタンス 4 個):d1..d4 — いずれも下位 2 ビット W[1:0] を選択入力とし、M[i] のいずれか 1 本をイネーブルに使う。イネーブルが H になった下位デコーダだけが出力を出し、残り 3 個は全 0 を出力する。

整體效果:16 個輸出 Y[0..15] 中恰好有一個為高 — 也就是索引等於 W[3:0] 二進位值的那一個(前提是 En=1)。這與實際 DRAM 的列/行位址解碼器所用的階層式解碼技巧完全相同。

Net effect: exactly one of the 16 outputs Y[0..15] is high — the one whose index equals the binary value of W[3:0] (provided En=1). This is the same hierarchical-decoder trick used in real DRAM row/column address decoders.

全体としての効果:16 本の出力 Y[0..15] のうちちょうど 1 本が H になる — 添字が W[3:0] の 2 進値に等しいものである(En=1 のとき)。これは実際の DRAM の行/列アドレスデコーダで使われている階層デコーダの手法とまったく同じである。

為什麼要用階層式?扁平的 4-to-16 解碼器需要 16 個 4 輸入 AND 閘(64 支輸入腳)。兩級樹狀結構用 5 個 dec2to4 模組 ≈ 5 × 4 = 20 個 2 輸入閘 ≈ 40 支輸入腳 — 面積稍微小一些,但更重要的是樹狀形式可以推廣:$n$-to-$2^n$ 解碼器可以用 dec2to4 單元組成的 $\lceil n/2 \rceil$ 級樹來建構。同樣的致能技巧,也正是讓許多記憶體晶片能掛在共用位址匯流排上串接的關鍵 — 每顆晶片的 chip-select 都來自更上一級的解碼器。

Why hierarchical? A flat 4-to-16 decoder would need 16 4-input AND gates (64 input pins). The 2-stage tree uses 5 dec2to4 modules ≈ 5 × 4 = 20 2-input gates ≈ 40 input pins — slightly less area, but more importantly the tree shape generalizes: an $n$-to-$2^n$ decoder can be built from $\lceil n/2 \rceil$-stage trees of dec2to4 cells. The same enable trick is what lets you cascade many memory chips on a shared address bus — each chip's chip-select comes from a higher-stage decoder.

なぜ階層構造にするのか?フラットな 4-to-16 デコーダには 4 入力 AND ゲートが 16 個(入力ピン 64 本)必要である。2 段のツリーなら dec2to4 モジュール 5 個 ≈ 5 × 4 = 20 個の 2 入力ゲート ≈ 入力ピン 40 本ですむ — 面積がわずかに小さいだけでなく、より重要なのはツリーの形が一般化できることである:$n$-to-$2^n$ デコーダは dec2to4 セルによる $\lceil n/2 \rceil$ 段のツリーで構成できる。同じイネーブルの手法こそが、共有アドレスバス上に多数のメモリチップを縦続接続できる理由でもある — 各チップの chip-select は上位段のデコーダから来る。

4.27E
module seg7(input [3:0] hex, output reg [6:0] leds);
  always @(*) case (hex)  // active-low; bits a..g
    4'h0: leds = 7'b0000001;
    4'h1: leds = 7'b1001111;
    4'h2: leds = 7'b0010010;
    4'h3: leds = 7'b0000110;
    4'h4: leds = 7'b1001100;
    4'h5: leds = 7'b0100100;
    4'h6: leds = 7'b0100000;
    4'h7: leds = 7'b0001111;
    4'h8: leds = 7'b0000000;
    4'h9: leds = 7'b0000100;
    4'hA: leds = 7'b0001000;
    4'hB: leds = 7'b1100000;
    4'hC: leds = 7'b0110001;
    4'hD: leds = 7'b1000010;
    4'hE: leds = 7'b0110000;
    4'hF: leds = 7'b0111000;
  endcase
endmodule
4.28E
module alu74381(input [2:0] S, input [3:0] A, B, output reg [3:0] F);
  always @(*) case (S)
    3'b000: F = 4'b0000;       // clear
    3'b001: F = B - A;
    3'b010: F = A - B;
    3'b011: F = A + B;
    3'b100: F = A ^ B;
    3'b101: F = A | B;
    3'b110: F = A & B;
    3'b111: F = 4'b1111;       // preset
  endcase
endmodule
4.29E
module prio4(input [3:0] W, output reg [1:0] Y, output reg z);
  always @(*) begin
    z = |W;
    casex (W)
      4'b1xxx: Y = 2'd3;
      4'b01xx: Y = 2'd2;
      4'b001x: Y = 2'd1;
      4'b0001: Y = 2'd0;
      default: Y = 2'd0;
    endcase
  end
endmodule
4.30E
module dec2to4(input [1:0] W, input En, output reg [3:0] Y);
  integer k;
  always @(*) begin
    Y = 4'b0;
    for (k = 0; k < 4; k = k+1)
      if (En && (W == k)) Y[k] = 1'b1;
  end
endmodule
4.31E
module prio4(input [3:0] W, output reg [1:0] Y, output reg z);
  integer k;
  always @(*) begin
    Y = 2'b0; z = 1'b0;
    for (k = 0; k < 4; k = k+1)
      if (W[k]) begin Y = k[1:0]; z = 1'b1; end
  end
endmodule
Because later loop iterations overwrite earlier ones, the highest-index asserted bit wins.
4.32E
module cmp4(input [3:0] A, B, output reg AeqB, AgtB, AltB);
  always @(*) begin
    AeqB = 0; AgtB = 0; AltB = 0;
    if      (A == B) AeqB = 1;
    else if (A >  B) AgtB = 1;
    else             AltB = 1;
  end
endmodule
4.33E
module rca #(parameter n=4)(input [n-1:0] A, B, input cin,
                              output [n-1:0] S, output cout);
  wire [n:0] c; assign c[0] = cin; assign cout = c[n];
  genvar i;
  generate for (i=0; i
4.34E
module mux16to1(input [15:0] W, input [3:0] S, output reg f);
  reg [3:0] M;
  task mux4; input [3:0] X; input [1:0] s; output y;
    case (s) 0:y=X[0]; 1:y=X[1]; 2:y=X[2]; 3:y=X[3]; endcase
  endtask
  always @(*) begin
    mux4(W[3:0],   S[1:0], M[0]);
    mux4(W[7:4],   S[1:0], M[1]);
    mux4(W[11:8],  S[1:0], M[2]);
    mux4(W[15:12], S[1:0], M[3]);
    mux4(M, S[3:2], f);
  end
endmodule
4.35E
module mux16to1(input [15:0] W, input [3:0] S, output f);
  function mux4; input [3:0] X; input [1:0] s;
    case (s) 0:mux4=X[0]; 1:mux4=X[1]; 2:mux4=X[2]; 3:mux4=X[3]; endcase
  endfunction
  wire [3:0] M;
  assign M[0] = mux4(W[3:0],   S[1:0]);
  assign M[1] = mux4(W[7:4],   S[1:0]);
  assign M[2] = mux4(W[11:8],  S[1:0]);
  assign M[3] = mux4(W[15:12], S[1:0]);
  assign f    = mux4(M,        S[3:2]);
endmodule
Difference: a function returns one value (no output ports) and may be used in a continuous assign; a task can have multiple outputs but must be invoked inside an always block.
4.36E

用一個 3-to-8 解碼器產生最小項 $m_0\dots m_7$,再把對應 $m_0, m_1, m_3, m_4, m_6, m_7$ 的輸出做 OR:$f = m_0+m_1+m_3+m_4+m_6+m_7$。一個 6 輸入 OR 閘就夠了。

Use a 3-to-8 decoder to produce minterms $m_0\dots m_7$, then OR the outputs corresponding to $m_0, m_1, m_3, m_4, m_6, m_7$: $f = m_0+m_1+m_3+m_4+m_6+m_7$. One 6-input OR gate suffices.

3-to-8 デコーダで最小項 $m_0\dots m_7$ を作り、$m_0, m_1, m_3, m_4, m_6, m_7$ に対応する出力を OR する:$f = m_0+m_1+m_3+m_4+m_6+m_7$。6 入力 OR ゲート 1 個で足りる。

4.37E

輸入 $w_0\dots w_7$ 為 one-hot。真值表把 $w_i=1$ 對應到 $y_2 y_1 y_0 = i$。$y_0 = w_1+w_3+w_5+w_7$、$y_1 = w_2+w_3+w_6+w_7$、$y_2 = w_4+w_5+w_6+w_7$(三個 4 輸入 OR 閘)。

One-hot inputs $w_0\dots w_7$. Truth table maps $w_i=1$ to $y_2 y_1 y_0 = i$. $y_0 = w_1+w_3+w_5+w_7$, $y_1 = w_2+w_3+w_6+w_7$, $y_2 = w_4+w_5+w_6+w_7$ (three 4-input OR gates).

入力 $w_0\dots w_7$ は one-hot である。真理値表は $w_i=1$ を $y_2 y_1 y_0 = i$ に対応づける。$y_0 = w_1+w_3+w_5+w_7$、$y_1 = w_2+w_3+w_6+w_7$、$y_2 = w_4+w_5+w_6+w_7$(4 入力 OR ゲート 3 個)。

4.38E

以 $(w_1, w_4)$ 作為 mux 的選擇端做 Shannon 展開。餘因子由 $f$ 算得:$f|_{00}=0$、$f|_{01}=w_5(\overline{w_2}+w_3)$、$f|_{10}=\overline{w_2}+w_3$、$f|_{11}=1$。因此以 $\{w_1, w_4\}$ 選擇、資料輸入為 $0,\,w_5(\overline{w_2}+w_3),\,\overline{w_2}+w_3,\,1$ 的 4-to-1 mux 即可實現 $f$。額外邏輯:一個 OR($\overline{w_2}+w_3$)同時餵給與 $w_5$ 的 AND 以及第三個資料輸入 — 這裡假設 $\overline{w_2}$ 來自一個反相器。

Shannon on $(w_1, w_4)$ as the mux selects. Cofactors are computed from $f$: $f|_{00}=0$, $f|_{01}=w_5(\overline{w_2}+w_3)$, $f|_{10}=\overline{w_2}+w_3$, $f|_{11}=1$. So a 4-to-1 mux selected by $\{w_1, w_4\}$ with data inputs $0,\,w_5(\overline{w_2}+w_3),\,\overline{w_2}+w_3,\,1$ realizes $f$. Extra logic: one OR ($\overline{w_2}+w_3$) feeding both an AND with $w_5$ and the third data input — assuming $\overline{w_2}$ comes from an inverter.

$(w_1, w_4)$ を mux の選択入力として Shannon 展開する。コファクタは $f$ から求まる:$f|_{00}=0$、$f|_{01}=w_5(\overline{w_2}+w_3)$、$f|_{10}=\overline{w_2}+w_3$、$f|_{11}=1$。したがって $\{w_1, w_4\}$ で選択し、データ入力を $0,\,w_5(\overline{w_2}+w_3),\,\overline{w_2}+w_3,\,1$ とした 4-to-1 mux が $f$ を実現する。追加の論理は OR 1 個($\overline{w_2}+w_3$)で、これが $w_5$ との AND と 3 番目のデータ入力の両方へ入る — $\overline{w_2}$ はインバータから得られるものとする。

4.39E
$b_2 b_1 b_0$$g_2 g_1 g_0$
000000
001001
010011
011010
100110
101111
110101
111100
By inspection: $g_2 = b_2$, $g_1 = b_1 \oplus b_2$, $g_0 = b_0 \oplus b_1$. ✓
4.40E

Shannon 展開:$f = \overline{w_1} f_{\overline{w_1}} + w_1 f_{w_1}$。(a) 若 $f_{\overline{w_1}} = 0$:$f = w_1\, f_{w_1}$ — mux 退化成單一個 AND 閘。(b) 若 $f_{\overline{w_1}} = 1$:$f = \overline{w_1} + w_1 f_{w_1} = \overline{w_1} + f_{w_1}$ — mux 退化成單一個 OR 閘。

Shannon: $f = \overline{w_1} f_{\overline{w_1}} + w_1 f_{w_1}$. (a) If $f_{\overline{w_1}} = 0$: $f = w_1\, f_{w_1}$ — the mux degenerates to a single AND gate. (b) If $f_{\overline{w_1}} = 1$: $f = \overline{w_1} + w_1 f_{w_1} = \overline{w_1} + f_{w_1}$ — the mux degenerates to a single OR gate.

Shannon 展開:$f = \overline{w_1} f_{\overline{w_1}} + w_1 f_{w_1}$。(a) $f_{\overline{w_1}} = 0$ のとき:$f = w_1\, f_{w_1}$ — mux は AND ゲート 1 個に退化する。(b) $f_{\overline{w_1}} = 1$ のとき:$f = \overline{w_1} + w_1 f_{w_1} = \overline{w_1} + f_{w_1}$ — mux は OR ゲート 1 個に退化する。

4.41E

4-to-1 mux 有 6 個輸入($w_0..w_3, s_0, s_1$)。用 4-LUT 的話,兩個 LUT 就夠:LUT1 取 $(w_0, w_1, s_0, s_1)$ 產生 $a = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1$;LUT2 取 $(a, w_2, w_3, s_0, s_1)$ — 輸入太多了。更好的做法:LUT1 取 $(w_0, w_1, s_0)$ → $\overline{s_0}w_0+s_0 w_1$;LUT2 取 $(w_2, w_3, s_0)$ → $\overline{s_0}w_2+s_0 w_3$;LUT3 取這兩個輸出與 $s_1$ → 最後一級 mux。這樣是 3 個 3 輸入的 LUT(或有一個輸入未用的 4-LUT)。最佳化後的 2-LUT 對映:LUT1$(w_0,w_1,s_0,s_1) = \overline{s_1}(\overline{s_0}w_0+s_0 w_1)$,而 LUT2$(\text{LUT1}, w_2, w_3, s_0)$ 再把上半部 OR 進來 — 共 2 個 4-LUT。

A 4-to-1 mux has 6 inputs ($w_0..w_3, s_0, s_1$). With 4-LUTs, two LUTs suffice: LUT1 takes $(w_0, w_1, s_0, s_1)$ and produces $a = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1$; LUT2 takes $(a, w_2, w_3, s_0, s_1)$ — too many. Better: LUT1 takes $(w_0, w_1, s_0)$ → $\overline{s_0}w_0+s_0 w_1$; LUT2 takes $(w_2, w_3, s_0)$ → $\overline{s_0}w_2+s_0 w_3$; LUT3 takes those two outputs and $s_1$ → final mux. That is 3 LUTs of 3 inputs (or 4-LUTs with one input unused). The optimized 2-LUT mapping: LUT1$(w_0,w_1,s_0,s_1) = \overline{s_1}(\overline{s_0}w_0+s_0 w_1)$ and LUT2$(\text{LUT1}, w_2, w_3, s_0)$ ORs in the upper half — 2 4-LUTs.

4-to-1 mux は入力が 6 本ある($w_0..w_3, s_0, s_1$)。4-LUT なら 2 個で足りる:LUT1 は $(w_0, w_1, s_0, s_1)$ を取って $a = \overline{s_1}\overline{s_0}w_0 + \overline{s_1}s_0 w_1$ を作り、LUT2 は $(a, w_2, w_3, s_0, s_1)$ を取る — これでは入力が多すぎる。よりよい方法:LUT1 は $(w_0, w_1, s_0)$ → $\overline{s_0}w_0+s_0 w_1$、LUT2 は $(w_2, w_3, s_0)$ → $\overline{s_0}w_2+s_0 w_3$、LUT3 はその 2 出力と $s_1$ を取る → 最終段の mux。これは 3 入力の LUT が 3 個(あるいは入力を 1 本余らせた 4-LUT)である。最適化した 2-LUT へのマッピングは、LUT1$(w_0,w_1,s_0,s_1) = \overline{s_1}(\overline{s_0}w_0+s_0 w_1)$ と、上半分を OR で取り込む LUT2$(\text{LUT1}, w_2, w_3, s_0)$ — 4-LUT 2 個である。

4.42E

五個由 Shift 選擇的 2-to-1 mux;資料線(Shift=0, Shift=1)為:$y_3:(w_3, 0)$、$y_2:(w_2, w_3)$、$y_1:(w_1, w_2)$、$y_0:(w_0, w_1)$、$k:(0, w_0)$。Shift=0 時 $W$ 原封不動通過,且 $k=0$;Shift=1 時右移(LSB 進入 $k$,MSB 補 0)。

Five 2-to-1 muxes selected by Shift; data lines (Shift=0, Shift=1): $y_3:(w_3, 0)$, $y_2:(w_2, w_3)$, $y_1:(w_1, w_2)$, $y_0:(w_0, w_1)$, $k:(0, w_0)$. Shift=0 passes $W$ unchanged with $k=0$; Shift=1 right-shifts (LSB into $k$, MSB filled with 0).

Shift で選択する 2-to-1 mux を 5 個使う。データ線は(Shift=0, Shift=1)の順に $y_3:(w_3, 0)$、$y_2:(w_2, w_3)$、$y_1:(w_1, w_2)$、$y_0:(w_0, w_1)$、$k:(0, w_0)$ である。Shift=0 では $W$ がそのまま通り $k=0$、Shift=1 では右シフトする(LSB が $k$ へ入り、MSB は 0 で埋める)。

4.43E

每個輸出 $y_i$ 取旋轉後的位元 $w_{(i+S)\bmod 4}$。使用四個 4-to-1 mux,全部共用選擇端 $S$:$y_0$ 的資料為 $\{w_0,w_1,w_2,w_3\}$、$y_1$ 為 $\{w_1,w_2,w_3,w_0\}$、$y_2$ 為 $\{w_2,w_3,w_0,w_1\}$、$y_3$ 為 $\{w_3,w_0,w_1,w_2\}$。

Each output $y_i$ takes the rotated bit $w_{(i+S)\bmod 4}$. Use four 4-to-1 muxes, all sharing select $S$: $y_0$ data $\{w_0,w_1,w_2,w_3\}$, $y_1$ data $\{w_1,w_2,w_3,w_0\}$, $y_2$ data $\{w_2,w_3,w_0,w_1\}$, $y_3$ data $\{w_3,w_0,w_1,w_2\}$.

各出力 $y_i$ は回転後のビット $w_{(i+S)\bmod 4}$ を取る。選択入力 $S$ を共有する 4-to-1 mux を 4 個使う:$y_0$ のデータは $\{w_0,w_1,w_2,w_3\}$、$y_1$ は $\{w_1,w_2,w_3,w_0\}$、$y_2$ は $\{w_2,w_3,w_0,w_1\}$、$y_3$ は $\{w_3,w_0,w_1,w_2\}$ である。

Verilog(明確寫出四個 MUX 的形式):

Verilog (explicit four-MUX form):

Verilog(4 個の MUX を明示する形):

module barrel_rot4 (
  input  [3:0] W,
  input  [1:0] S,
  output reg [3:0] Y
);
  always @(*) begin
    case (S)
      2'b00: Y = {W[3], W[2], W[1], W[0]};   // no rotation
      2'b01: Y = {W[0], W[3], W[2], W[1]};   // rotate right by 1
      2'b10: Y = {W[1], W[0], W[3], W[2]};   // rotate right by 2
      2'b11: Y = {W[2], W[1], W[0], W[3]};   // rotate right by 3
    endcase
  end
endmodule

Verilog(精簡的旋轉寫法):

Verilog (compact rotate idiom):

Verilog(簡潔なローテートのイディオム):

module barrel_rot4 (
  input  [3:0] W,
  input  [1:0] S,
  output [3:0] Y
);
  // right-rotate: bits shifted off the bottom re-enter at the top
  assign Y = (W >> S) | (W << (4 - S));   //very smart
endmodule

兩種寫法都會合成出同一個 4 位元桶形旋轉器(四個並聯的 4-to-1 MUX 共用 $S$ 作為選擇端)。不論移位量多少都只有單一個 MUX 延遲 — 這正是桶形移位器相對於循序移位暫存器的意義所在。

Both versions synthesize to the same 4-bit barrel rotator (four parallel 4-to-1 MUXes sharing $S$ as select). Single MUX-delay regardless of shift amount — that's the whole point of a barrel shifter vs. a sequential shift register.

どちらの記述も同じ 4 ビットのバレルローテータに合成される($S$ を選択入力として共有する 4-to-1 MUX 4 個の並列)。シフト量によらず MUX 1 段分の遅延ですむ — これこそがバレルシフタを逐次シフトレジスタの代わりに使う理由である。

4.44E
module mux4to1(input [3:0] W, input [1:0] S, output f);
  wire [3:0] D;
  dec2to4 g(.W(S), .En(1'b1), .Y(D));
  assign f = | (D & W);
endmodule
4.45E
// Style 1: explicit if-else
module shr1(input [3:0] W, input Shift, output reg [3:0] Y, output reg k);
  always @(*) if (Shift) {Y, k} = {1'b0, W};
              else       {Y, k} = {W, 1'b0};
endmodule

// Style 2: shift operator
module shr2(input [3:0] W, input Shift, output [3:0] Y, output k);
  assign {Y, k} = Shift ? {1'b0, W} : {W, 1'b0};
endmodule
4.46E
module barrel4(input [3:0] W, input [1:0] S, output [3:0] Y);
  wire [7:0] T;
  assign T = {W, W};
  assign Y = T >> S;
endmodule
Doubling $W$ in concatenation makes the right-shift behave as a rotation on the lower 4 bits.
4.47E
module evenparity(input [6:0] b_in, output [7:0] b_out);
  assign b_out[6:0] = b_in;
  assign b_out[7]   = ^b_in;        // XOR-reduction = even parity bit
endmodule
$b_7 = b_6\oplus b_5\oplus\cdots\oplus b_0$ ensures the total count of 1s in $b_7\ldots b_0$ is even.
第 5 章 — 正反器與循序電路Chapter 5 — Flip-Flops & Sequential Circuits第 5 章 — フリップフロップと順序回路
5.1

用兩個交叉耦合的 NOR 閘構成的 SR 閂鎖:

SR latch using two cross-coupled NOR gates:

交差結合した NOR ゲート 2 個で構成する SR ラッチ:

Q = NOR(R, Q̄); Q̄ = NOR(S, Q)

SRQ(t+1)狀態State状態
00Q(t)Hold
010Reset
101Set
11禁止(兩個輸出皆為 0)Forbidden (both outputs 0)禁止(両出力とも 0)
5.2

閂鎖:位準敏感;時脈/致能為高時呈穿透狀態 — 致能期間輸出跟隨輸入。可能有時序問題(一個時脈週期內出現多次變化)。

Latch: Level-sensitive; transparent when clock/enable is high — output follows input while enabled. Can have timing issues (multiple transitions per clock cycle).

ラッチ:レベルセンシティブであり、クロック/イネーブルが H の間は透過する — イネーブル中は出力が入力に追従する。タイミング上の問題が起こりうる(1 クロック周期に何度も遷移する)。

正反器:邊緣觸發;只在時脈邊緣(上升或下降)取樣輸入。輸出每個週期只變化一次。

Flip-flop: Edge-triggered; samples input only at clock edge (rising or falling). Output changes only once per cycle.

フリップフロップ:エッジトリガであり、クロックエッジ(立上りまたは立下り)でのみ入力を取り込む。出力は 1 周期に 1 回しか変化しない。

為何偏好邊緣觸發:

Why edge-triggered preferred:

エッジトリガが好まれる理由:

  • 可預測:資料在已知的時刻、每個週期擷取一次。
  • Predictable: data captured once per cycle at known time.
  • 予測しやすい:データは既知の時刻に 1 周期 1 回だけ取り込まれる。
  • 簡化時序分析(setup/hold 限制定義明確)。
  • Simplifies timing analysis (setup/hold constraints well-defined).
  • タイミング解析が簡単になる(setup/hold 制約が明確に定義される)。
  • 避免組合邏輯中可能造成振盪的回授迴路。
  • Prevents feedback loops that can cause oscillation in combinational logic.
  • 組合せ回路で発振を引き起こしうる帰還ループを防ぐ。
  • 使管線化設計成為可能,各級的邊界都有明確定義。
  • Enables pipelined design with well-defined stage boundaries.
  • 段の境界が明確に定義されたパイプライン設計を可能にする。
5.3

D 輸入序列(在每個時脈週期內維持不變):0,1,1,0,1,0,0,1。Q 從 0 開始。

D input sequence (held during each clock cycle): 0,1,1,0,1,0,0,1. Q starts at 0.

D の入力系列(各クロックサイクル中は保持される):0,1,1,0,1,0,0,1。Q は 0 から始まる。

D 型正反器會在結束週期 n 的那個上升緣,擷取該週期期間的 D 值,因此週期 n+1 期間的 Q 等於週期 n 期間的 D — 也就是一個週期的延遲:

The D flip-flop captures D's value during cycle n at the rising edge that ends that cycle, so Q during cycle n+1 equals D during cycle n — the one-cycle delay:

D フリップフロップは、サイクル n終わらせる立上りエッジで、そのサイクルの D の値を取り込む。したがってサイクル n+1 中の Q はサイクル n 中の D に等しい — 1 サイクルの遅延である:

Cycle: 0     1     2     3     4     5     6     7     8
Clk:        ↑     ↑     ↑     ↑     ↑     ↑     ↑     ↑
D:     0     1     1     0     1     0     0     1     -
Q:     0     0     1     1     0     1     0     0     1

逐欄閱讀:在週期 n 與週期 n+1 之間的上升緣,Q 閂鎖住來自週期 n 的 D 值。因此 Q 那一列就是 D 那一列向右移一欄 — 也就是看得見的「一個時脈週期延遲」。

Read column-by-column: at the rising edge between cycle n and cycle n+1, Q latches D's value from cycle n. So Q's row is D's row shifted right by one column — the visible "one clock cycle delay."

列ごとに読む:サイクル n とサイクル n+1 の間の立上りエッジで、Q はサイクル n の D の値をラッチする。したがって Q の行は D の行を右へ 1 列ずらしたものであり、これが目に見える「1 クロックサイクルの遅延」である。

教科書式時序圖:D 在每個週期內維持不變,Q 落後一個週期

Textbook-style timing diagram: D held during each cycle, Q lags by one cycle

教科書風のタイミング図:D は各サイクル中に保持され、Q は 1 サイクル遅れる

Time cycle 0 cycle 1 cycle 2 cycle 3 cycle 4 cycle 5 cycle 6 cycle 7 cycle 8 Clk D 0 1 1 0 1 0 0 1 Q 0 0 1 1 0 1 0 0 1 第 n 週期的 D → 第 n+1 週期的 Q(延遲一個週期)D in cycle n → Q in cycle n+1 (one-cycle delay)サイクル n の D → サイクル n+1 の Q(1 サイクル遅延)
5.4

以 D 型正反器構成 T 型正反器:D = T⊕Q(把 T 與目前的輸出做 XOR)。

T flip-flop from D flip-flop: D = T⊕Q (XOR T with current output).

D フリップフロップから T フリップフロップを作る:D = T⊕Q(T と現在の出力の XOR)。

  • T=0: D=Q → holds state
  • T=1: D=Q̄ → toggles state

Characteristic equation: Q(t+1) = T⊕Q(t)

TQQ(t+1)
000
011
101
110
5.5

使用 T 型正反器的 3 位元同步上數計數器:

3-bit synchronous up counter using T flip-flops:

T フリップフロップを用いた 3 ビット同期アップカウンタ:

T₀ = 1(永遠翻轉 — LSB)

T₀ = 1 (always toggles — LSB)

T₀ = 1(常にトグルする — LSB)

T₁ = Q₀ (toggle when Q₀=1)

T₂ = Q₁·Q₀ (toggle when Q₁Q₀=11)

State sequence: 000→001→010→011→100→101→110→111→000

所有 T 型正反器同時受同一時脈驅動 — 同步設計。

All T FFs clocked simultaneously — synchronous design.

すべての T FF が同時にクロックされる — 同期設計である。

5.6

假設每個正反器的 t_FF = 5 ns,每個閘 = 1 ns。

Assume each FF has t_FF = 5 ns and each gate = 1 ns.

各 FF は t_FF = 5 ns、各ゲートは 1 ns とする。

漣波計數器:每個正反器由前一級正反器的輸出提供時脈。通過全部 4 個正反器的關鍵路徑:4 × 5 ns = 20 ns。最高頻率 = 1/20 ns = 50 MHz

Ripple counter: Each FF clocked by previous FF output. Critical path through all 4 FFs: 4 × 5 ns = 20 ns. Max freq = 1/20 ns = 50 MHz.

リプルカウンタ:各 FF は前段の FF の出力でクロックされる。4 個の FF すべてを通るクリティカルパスは 4 × 5 ns = 20 ns。最高周波数 = 1/20 ns = 50 MHz

同步計數器:所有正反器共用時脈。關鍵路徑 = t_FF + t_AND(T₃ 的邏輯)≈ 5 + 1 = 6 ns。最高頻率 = 1/6 ns ≈ 167 MHz

Synchronous counter: All FFs share clock. Critical path = t_FF + t_AND (for T₃ logic) ≈ 5 + 1 = 6 ns. Max freq = 1/6 ns ≈ 167 MHz.

同期カウンタ:すべての FF がクロックを共有する。クリティカルパス = t_FF + t_AND(T₃ の論理)≈ 5 + 1 = 6 ns。最高周波数 = 1/6 ns ≈ 167 MHz

4 位元時同步計數器約快 3 倍;位元寬度越大,優勢越明顯。

Synchronous counter is ~3× faster for 4-bit; advantage grows with bit width.

4 ビットでは同期カウンタが約 3 倍速い。ビット幅が増えるほど有利さは大きくなる。

5.7
module counter_updown (
    input        clk, rst, up,
    output reg [3:0] count
);
    always @(posedge clk or posedge rst) begin
        if (rst)
            count <= 4'd0;
        else if (up)
            count <= count + 1;
        else
            count <= count - 1;
    end
endmodule
5.8

阻塞式 (=):在 always 區塊內依序執行;每個指定敘述會立即對下一個敘述生效。

Blocking (=): Executes sequentially within always block; each assignment takes effect immediately for the next statement.

ブロッキング代入 (=):always ブロック内で逐次実行され、各代入は次の文に対して直ちに反映される。

非阻塞式 (<=):先計算所有右式的值,再於該時間步結束時同時更新所有左式。可正確描述暫存器的行為。

Non-blocking (<=): All RHS evaluated first, then all LHS updated simultaneously at end of time step. Models register behavior correctly.

ノンブロッキング代入 (<=):まずすべての右辺が評価され、そのタイムステップの最後にすべての左辺が同時に更新される。レジスタの動作を正しくモデル化する。

用錯型別的例子 — 以阻塞式做交換:

Wrong type example — swap with blocking:

誤った種類の例 — ブロッキング代入によるスワップ:

// WRONG: blocking swap in sequential logic
always @(posedge clk) begin
    a = b;   // a gets b's new value
    b = a;   // b gets a's NEW value (a already changed)
end
// CORRECT: non-blocking
always @(posedge clk) begin
    a <= b;  // RHS evaluated simultaneously
    b <= a;  // b gets original a
end
5.9
module dff_srst_en (
    input  clk, srst, en, d,
    output reg q
);
    always @(posedge clk) begin
        if (srst)
            q <= 1'b0;
        else if (en)
            q <= d;
        // else q holds
    end
endmodule

同步重置:重置只在時脈上升緣生效。Enable 則閘控資料輸入。

Synchronous reset: reset takes effect only on rising clock edge. Enable gates the data input.

同期リセット:リセットはクロックの立上りエッジでのみ有効になる。Enable がデータ入力をゲートする。

5.10

建立時間 (t_su):為了可靠擷取,資料輸入 D 必須在有效時脈邊緣之前保持穩定的最短時間。

Setup time (t_su): Minimum time the data input D must be stable before the active clock edge for reliable capture.

セットアップ時間 (t_su):確実に取り込むために、データ入力 D が有効クロックエッジより前に安定していなければならない最小時間。

保持時間 (t_h):在有效時脈邊緣之後,D 必須繼續維持穩定的最短時間。

Hold time (t_h): Minimum time D must remain stable after the active clock edge.

ホールド時間 (t_h):有効クロックエッジのあと D が安定を保たなければならない最小時間。

時脈到輸出延遲 (t_cQ):從有效時脈邊緣到輸出 Q 達到新的穩定值所需的時間。

Clock-to-Q delay (t_cQ): Time from active clock edge until the output Q reaches its new stable value.

クロック~Q 遅延 (t_cQ):有効クロックエッジから出力 Q が新しい安定値に達するまでの時間。

違反的後果:建立時間違反 → 亞穩態(輸出不確定);保持時間違反 → 不論時脈週期多長,資料都會被錯誤擷取。

Violations: setup violation → metastability (indeterminate output); hold violation → data captured incorrectly regardless of clock period.

違反した場合:セットアップ違反 → メタスタビリティ(出力が不定)、ホールド違反 → クロック周期によらずデータが誤って取り込まれる。

5.11

主從式 D 正反器:兩個閂鎖串接(先主後從),分別由 CLK 與 CLK̄ 提供時脈。

Master-slave D FF: Two latches in series (master then slave), clocked by CLK and CLK̄ respectively.

マスタスレーブ D FF:2 つのラッチを直列に接続し(マスタのあとにスレーブ)、それぞれ CLK と CLK̄ でクロックする。

  • CLK=0 時:主閂鎖穿透(擷取 D),從閂鎖保持。
  • When CLK=0: master is transparent (captures D), slave is held.
  • CLK=0 のとき:マスタが透過して D を取り込み、スレーブは保持される。
  • CLK=1 時:主閂鎖保持(鎖住擷取到的值),從閂鎖穿透(把值傳到 Q)。
  • When CLK=1: master is held (locks captured value), slave is transparent (propagates to Q).
  • CLK=1 のとき:マスタは保持され(取り込んだ値を固定し)、スレーブが透過して Q へ伝える。

資料在時脈上升緣被擷取(主閂鎖關閉、從閂鎖開啟)— 效果上就是邊緣觸發。

Data is captured at the rising clock edge (master closes, slave opens) — effectively edge-triggered.

データはクロックの立上りエッジで取り込まれる(マスタが閉じ、スレーブが開く)— 実質的にエッジトリガである。

為何是邊緣觸發:雙閂鎖結構使輸入只能在時脈邊緣的短暫過渡窗口內影響輸出,因而提供完整的邊緣觸發行為。

Why edge-triggered: The double-latch structure means input can only affect output during a brief transition window at the clock edge, providing full edge-triggered behavior.

なぜエッジトリガなのか:二重ラッチ構造のため、入力が出力に影響できるのはクロックエッジのごく短い遷移窓の間だけであり、完全なエッジトリガ動作が得られる。

5.12

亞穩態:當正反器的建立時間或保持時間被違反時,輸出可能停在 0 與 1 之間的不確定電壓準位,且持續時間無法預測。這會使錯誤在電路中擴散。

Metastability: When a flip-flop's setup or hold time is violated, the output may settle to an indeterminate voltage level between 0 and 1 for an unpredictable time. This can propagate errors through the circuit.

メタスタビリティ:フリップフロップのセットアップ時間またはホールド時間が破られると、出力が 0 と 1 の間の不定な電圧レベルに、予測できない時間だけとどまることがある。これは回路中に誤りを伝播させうる。

同步器:由兩個以上正反器串成的鏈,讓亞穩態訊號在被使用之前有時間收斂。多數情況下第二個正反器看到的已是穩定的輸入。單一個正反器並不足夠,因為後續邏輯取樣時,它的輸出仍可能處於亞穩態。

Synchronizer: A chain of two or more flip-flops that allows a metastable signal time to resolve before use. The second FF sees a stable input in most cases. A single FF is insufficient because its output could still be metastable when sampled by subsequent logic.

シンクロナイザ:2 個以上のフリップフロップをつないだ鎖で、メタスタブルな信号が使われる前に収束する時間を与える。ほとんどの場合、2 段目の FF は安定した入力を見る。FF が 1 個では不十分である。後続の論理がサンプリングする時点で、その出力がまだメタスタブルでありうるからである。

每增加一級同步器,MTBF(平均故障間隔時間)就以指數方式改善。

MTBF (mean time between failures) improves exponentially with each additional synchronizer stage.

同期段を 1 段増やすごとに、MTBF(平均故障間隔)は指数関数的に改善する。

5.36
module counter_load (
    input        clk, arst, load, en,
    input  [3:0] d,
    output reg [3:0] q
);
    always @(posedge clk or posedge arst) begin
        if (arst)
            q <= 4'd0;
        else if (load)
            q <= d;
        else if (en)
            q <= q + 1;
    end
endmodule

非同步重置在 arst 的邊緣清除,與時脈無關。Load 在時脈邊緣載入並列資料。Enable 控制是否計數。

Async reset clears on arst edge regardless of clock. Load takes parallel data on clock edge. Enable controls counting.

非同期リセットはクロックに関係なく arst のエッジでクリアする。Load はクロックエッジでパラレルデータを取り込む。Enable が計数を制御する。

5.37
JKQ(t+1)動作Action動作
00Q(t)Hold
010Reset
101Set
11Q̄(t)Toggle

Characteristic equation: Q(t+1) = J·Q̄ + K̄·Q

5.38

4 位元 SISO(Serial-In Serial-Out,串入串出)移位暫存器:4 個 D 型正反器串接。輸入 1,0,1,1(MSB 先)。

4-bit SISO (Serial-In Serial-Out) shift register: 4 D flip-flops in series. Input 1,0,1,1 (MSB first).

4 ビット SISO(Serial-In Serial-Out、直列入力直列出力)シフトレジスタ:D フリップフロップ 4 個の直列接続である。入力は 1,0,1,1(MSB から)。

Clk  In   Q₀  Q₁  Q₂  Q₃(out)
 0   -     0   0   0   0
 1   1     1   0   0   0
 2   0     0   1   0   0
 3   1     1   0   1   0
 4   1     1   1   0   1  ← first bit out

經過 4 個時脈後,輸入序列 1,0,1,1 會依序出現在 Q₃。

After 4 clocks, the input sequence 1,0,1,1 appears at Q₃ in order.

4 クロック後、入力系列 1,0,1,1 が順に Q₃ に現れる。

5.39

4 位元環形計數器,初值 = 1000。每來一個時脈,那唯一的 1 位元就向右(或向左)旋轉一位。

4-bit ring counter, init = 1000. Each clock, the single 1 bit rotates right (or left).

4 ビットリングカウンタ、初期値 = 1000。クロックごとに、ただ 1 つの 1 のビットが右(または左)へ回転する。

Cycle:  Q₃Q₂Q₁Q₀
  0:    1  0  0  0
  1:    0  1  0  0
  2:    0  0  1  0
  3:    0  0  0  1
  4:    1  0  0  0  (repeats)

週期 = 4。16 個狀態中只用到 4 個。

Period = 4. Only 4 of 16 states are used.

周期 = 4。16 状態のうち 4 状態しか使わない。

5.40

4 位元 Johnson 計數器:把 Q₃ 的補數回授到 D₀(或把 Q₃ 送到最右端)。初值 = 0000。

4-bit Johnson counter: complement of Q₃ fed back to D₀ (or Q₃ fed to rightmost). Init = 0000.

4 ビットジョンソンカウンタ:Q₃ の補数を D₀ へ帰還させる(あるいは Q₃ を最右端へ送る)。初期値 = 0000。

Cycle:  Q₃Q₂Q₁Q₀
  0:    0  0  0  0
  1:    1  0  0  0
  2:    1  1  0  0
  3:    1  1  1  0
  4:    1  1  1  1
  5:    0  1  1  1
  6:    0  0  1  1
  7:    0  0  0  1
  8:    0  0  0  0  (repeats)

Johnson 計數器有 2n = 8 個有效狀態(n=4 個正反器時);其餘 8 個狀態未使用/無效。

Johnson counter has 2n = 8 valid states (for n=4 FFs); the other 8 states are unused/invalid.

ジョンソンカウンタの有効な状態は 2n = 8 個である(FF が n=4 個の場合)。残り 8 状態は未使用/無効である。

5.41
module shift_reg8 (
    input        clk, s0, s1,  // mode: s1s0
    input        si_l, si_r,   // serial in left/right
    input  [7:0] d,
    output reg [7:0] q
);
    // 00=hold, 01=shift right, 10=shift left, 11=parallel load
    always @(posedge clk) begin
        case ({s1,s0})
            2'b00: q <= q;
            2'b01: q <= {si_r, q[7:1]};  // shift right
            2'b10: q <= {q[6:0], si_l};  // shift left
            2'b11: q <= d;
        endcase
    end
endmodule
5.42
module bcd_counter (
    input  clk, rst,
    output reg [3:0] count
);
    always @(posedge clk) begin
        if (rst || count == 4'd9)
            count <= 4'd0;
        else
            count <= count + 1;
    end
endmodule

計數 0-9;到達 9 時或 rst 被 assert 時同步重置為 0。

Counts 0-9; synchronous reset to 0 when reaching 9 or when rst is asserted.

0-9 を数える。9 に達したとき、または rst がアサートされたときに同期的に 0 へリセットする。

5.43
module counter_async_rst (
    input        clk, arst,
    output reg [3:0] q
);
    always @(posedge clk or posedge arst) begin
        if (arst)
            q <= 4'd0;
        else
            q <= q + 1;
    end
endmodule

非同步重置:敏感度列表中的 posedge arst 會造成與時脈無關的立即重置。

Async reset: the posedge arst in sensitivity list causes immediate reset independent of clock.

非同期リセット:センシティビティリスト中の posedge arst により、クロックとは無関係に直ちにリセットされる。

5.44
module shift_detect (
    input  clk, rst, si,
    output detected
);
    reg [3:0] sr;
    always @(posedge clk or posedge rst) begin
        if (rst) sr <= 4'b0;
        else     sr <= {sr[2:0], si};
    end
    assign detected = (sr == 4'b1011);
endmodule

移位暫存器保存最近的 4 個位元。當暫存器中出現樣式 1011 時,輸出即 assert。

Shift register captures last 4 bits. Output asserts when pattern 1011 is in the register.

シフトレジスタは直近の 4 ビットを保持する。レジスタ内がパターン 1011 になったとき出力がアサートされる。

5.45

模 6 計數器的序列:000→001→010→011→100→101→000。

Modulo-6 counter sequences: 000→001→010→011→100→101→000.

モジュロ 6 カウンタの系列:000→001→010→011→100→101→000。

狀態 110 與 111 未使用。以 D 型正反器實作,透過 K-map 推導下一狀態方程式:

State 110 and 111 unused. Using D FFs, derive next-state equations via K-maps:

状態 110 と 111 は未使用である。D FF を用い、カルノー図から次状態方程式を導く:

D₂:對目前狀態畫 K-map(6、7 處為 don't-care):D₂ = Q₂Q̄₀ + Q₁Q₀

D₂: K-map over present states (with don't cares at 6,7): D₂ = Q₂Q̄₀ + Q₁Q₀

D₂:現在状態についてのカルノー図(6、7 は don't-care):D₂ = Q₂Q̄₀ + Q₁Q₀

D₁:D₁ = Q₁⊕Q₀(位元 1 的標準計數器規則)

D₁: D₁ = Q₁⊕Q₀ (standard counter rule for bit 1)

D₁:D₁ = Q₁⊕Q₀(ビット 1 に対する標準的なカウンタの規則)

D₀: D₀ = Q̄₂Q̄₁Q̄₀ + Q₂Q̄₁Q̄₀... simplified: D₀ = Q̄₀·(Q̄₂+Q̄₁)

輸出可以是計數值,也可以是終端計數 = Q₂Q̄₁Q₀ ... 追蹤全部 6 個狀態即可驗證。

Output can be count value or a terminal count = Q₂Q̄₁Q₀ ... Verify by tracing all 6 states.

出力は計数値でもよいし、ターミナルカウント = Q₂Q̄₁Q₀ ... でもよい。6 状態すべてをたどって検証する。

5.46

已知:t_su=2 ns、t_h=1 ns、t_cQ=3 ns、t_logic=5 ns、t_skew=0.5 ns。

Given: t_su=2 ns, t_h=1 ns, t_cQ=3 ns, t_logic=5 ns, t_skew=0.5 ns.

与えられた値:t_su=2 ns、t_h=1 ns、t_cQ=3 ns、t_logic=5 ns、t_skew=0.5 ns。

時序限制:T_clk ≥ t_cQ + t_logic + t_su + t_skew

Timing constraint: T_clk ≥ t_cQ + t_logic + t_su + t_skew

タイミング制約:T_clk ≥ t_cQ + t_logic + t_su + t_skew

T_clk ≥ 3 + 5 + 2 + 0.5 = 10.5 ns

最高時脈頻率 = 1 / 10.5 ns ≈ 95.2 MHz

Max clock frequency = 1 / 10.5 ns ≈ 95.2 MHz

最大クロック周波数 = 1 / 10.5 ns ≈ 95.2 MHz

保持限制:t_cQ + t_logic_min ≥ t_h + t_skew → 這一項也必須另外驗證。

Hold constraint: t_cQ + t_logic_min ≥ t_h + t_skew → must also be verified separately.

ホールド制約:t_cQ + t_logic_min ≥ t_h + t_skew → これも別途検証しなければならない。

5.47

多項式為 x³+x+1 的 LFSR(分接點在位置 3 與 1)。回授 = Q₃⊕Q₁。從 001 開始:

LFSR with polynomial x³+x+1 (taps at positions 3 and 1). Feedback = Q₃⊕Q₁. Starting from 001:

多項式 x³+x+1 の LFSR(タップは位置 3 と 1)。帰還は Q₃⊕Q₁。001 から始める:

State (Q₃Q₂Q₁): feedback = Q₃⊕Q₁
001 → fb=0⊕1=1 → 100...
Wait, standard LFSR: Q₁←Q₂, Q₂←Q₃, Q₃←fb
001: fb=Q₁⊕Q₃=1⊕0=1 → next: Q₃=1,Q₂=0,Q₁=0 → 100
100: fb=0⊕1=1 → 110
110: fb=0⊕1=1 → 111
111: fb=1⊕1=0 → 011... wait recheck taps x³+x+1: feedback into position 0 = Q₃⊕Q₁?
For right-shift LFSR: new_bit = Q[3]⊕Q[1]:
001→100→110→111→011→101→010→001 (7 states)

週期 = 7 = 2³−1。是的,屬於最大長度 LFSR(n=3 時 2ⁿ−1 = 7)。

Period = 7 = 2³−1. Yes, maximal-length LFSR (2ⁿ−1 = 7 for n=3).

周期 = 7 = 2³−1。はい、最大長 LFSR である(n=3 では 2ⁿ−1 = 7)。

5.48

工作週期 50% 的除以 6:計數 0-5,輸出在 0-2 為高、在 3-5 為低(如此正好得到 3/6 = 50%)。

Divide-by-6 with 50% duty cycle: count 0-5, output high for 0-2, low for 3-5 (but this gives 3/6 = 50%).

デューティ比 50% の 1/6 分周:0-5 を数え、0-2 で出力を H、3-5 で L とする(これで 3/6 = 50% になる)。

module div6 (
    input  clk, rst,
    output reg out
);
    reg [2:0] cnt;
    always @(posedge clk or posedge rst) begin
        if (rst) begin cnt <= 0; out <= 0; end
        else if (cnt == 3'd5) begin cnt <= 0; out <= ~out; end
        else if (cnt == 3'd2) begin cnt <= cnt+1; out <= ~out; end
        else cnt <= cnt + 1;
    end
endmodule

或者利用兩個邊緣:在計數 0 與計數 3 時翻轉,即可在 f_clk/6 得到 50% 的工作週期。

Alternatively use two edges: toggle on count 0 and count 3 to achieve 50% duty cycle at f_clk/6.

あるいは 2 つのエッジを使う:カウント 0 とカウント 3 でトグルすれば、f_clk/6 でデューティ比 50% が得られる。

5.13E
module D_latch(input D, Clk, output reg Q);
  always @(D, Clk)
    if (Clk) Q = D;
endmodule
The if-without-else and level-sensitive sensitivity list infer a transparent latch: $Q$ tracks $D$ while Clk=1 and holds when Clk=0.
5.14E
module flipflop(input D, Clock, output reg Q);
  always @(posedge Clock)
    Q <= D;
endmodule
5.15E

always @(posedge Clock) 內使用阻塞式指定時,敘述會依序執行,因此 $Q1$ 會先被更新為 $D$,接著 $Q2$ 被設成新的 $Q1$ — 也就是兩個暫存器在同一個邊緣都收到 $D$。合成器會推論出一個由 $D$ 驅動的正反器,其輸出同時扇出到 $Q1$ 與 $Q2$(或推論出兩個 D 輸入接在一起的正反器)。

With blocking assignments inside always @(posedge Clock), the statements execute in order, so $Q1$ is updated first to $D$, then $Q2$ is set to the new $Q1$ — i.e. both registers receive $D$ on the same edge. The synthesizer infers a single flip-flop driven by $D$ whose output fans out to both $Q1$ and $Q2$ (or two flip-flops with their D inputs tied together).

always @(posedge Clock) の中でブロッキング代入を使うと、文は順に実行されるので、まず $Q1$ が $D$ に更新され、次に $Q2$ が新しい $Q1$ の値になる — つまり両方のレジスタが同じエッジで $D$ を受け取る。合成器は、$D$ で駆動され出力が $Q1$ と $Q2$ の両方へファンアウトする 1 個のフリップフロップ(あるいは D 入力どうしを結んだ 2 個のフリップフロップ)を推論する。

5.16E

非阻斷式指派會在邊緣時先計算所有 RHS,再更新 LHS。因此 $Q2$ 取樣到的是舊的 $Q1$(本次邊緣之前的值),接著 $Q1$ 才接收 $D$。這正是兩級串接正反器的行為:$D \to Q1 \to Q2$ — 一個 2 級移位暫存器。

Non-blocking assignments evaluate all RHS at the edge, then update LHS. So $Q2$ samples the old $Q1$ (the value before this edge), then $Q1$ receives $D$. This is exactly the behavior of two cascaded flip-flops: $D \to Q1 \to Q2$ — a 2-stage shift register.

ノンブロッキング代入は、エッジで右辺をすべて評価してから左辺を更新する。したがって $Q2$ は古い $Q1$(このエッジ以前の値)を取り込み、そのあとで $Q1$ が $D$ を受け取る。これはまさに 2 段縦続接続したフリップフロップの動作である:$D \to Q1 \to Q2$ — 2 段のシフトレジスタである。

5.17E

阻斷式指派會依序執行,因此當合成器看到 $f = x_1\,\&\, x_2$ 後面接著 $g = f\,|\, x_3$ 時,變數 $f$ 會被當成一條 wire(其值就是本週期的 AND 結果)。結果是:$f$ 有被暫存,但 $g$ 的正反器是由 $(x_1 x_2)\,|\, x_3$ 驅動 — 也就是 AND 閘輸出先與 $x_3$ 做 OR 才進入 $g$ 的正反器,這條路徑上兩者之間沒有暫存器。

Blocking assignments execute sequentially, so when the synthesizer sees $f = x_1\,\&\, x_2$ followed by $g = f\,|\, x_3$, the variable $f$ is treated as a wire (its value is the AND result on this cycle). The result: $f$ is registered, but $g$'s flip-flop is fed by $(x_1 x_2)\,|\, x_3$ — i.e. the AND gate output goes through an OR with $x_3$ before the $g$ flip-flop, with no register between them on this path.

ブロッキング代入は順に実行されるので、合成器が $f = x_1\,\&\, x_2$ に続いて $g = f\,|\, x_3$ を見ると、変数 $f$ はワイヤとして扱われる(その値はこのサイクルの AND 結果である)。結果として $f$ はレジスタ化されるが、$g$ のフリップフロップは $(x_1 x_2)\,|\, x_3$ で駆動される — つまり AND ゲートの出力は $g$ のフリップフロップの手前で $x_3$ との OR を通り、この経路には両者の間にレジスタがない。

5.18E

改用非阻斷式時,$g \le f \,|\, x_3$ 使用的是 $f$ 的前一個值(正反器輸出)。因此驅動 $g$ 正反器的 OR 閘,其來源是已暫存的 $f$,而不是即時的 $x_1 x_2$ AND 輸出。實際效果是 $g$ 比阻斷式版本延遲一個週期,而且 AND 輸出不再直接餵給 OR。

With non-blocking, $g \le f \,|\, x_3$ uses the previous value of $f$ (the flip-flop output). So the OR gate that feeds the $g$ flip-flop is driven by the registered $f$, not the live $x_1 x_2$ AND output. Effectively $g$ is one cycle delayed relative to the blocking version, and the AND output no longer feeds OR directly.

ノンブロッキングでは、$g \le f \,|\, x_3$ は $f$ の前の値(フリップフロップの出力)を使う。したがって $g$ のフリップフロップを駆動する OR ゲートには、生の $x_1 x_2$ の AND 出力ではなく、レジスタ化された $f$ が入る。実質的に $g$ はブロッキング版に対して 1 サイクル遅れ、AND 出力が OR に直接つながることもなくなる。

5.19E
module dff_async_reset(input D, Clock, Resetn, output reg Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= 1'b0;
    else         Q <= D;
endmodule
5.20E
module dff_sync_reset(input D, Clock, Resetn, output reg Q);
  always @(posedge Clock)
    if (!Resetn) Q <= 1'b0;
    else         Q <= D;
endmodule
5.21E
module regn #(parameter n=8)(input [n-1:0] R, input Clock, Resetn,
                              output reg [n-1:0] Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= {n{1'b0}};
    else         Q <= R;
endmodule
5.22E
module muxdff(input D0, D1, Sel, Clock, output reg Q);
  always @(posedge Clock) Q <= Sel ? D1 : D0;
endmodule

module shift4(input [3:0] R, input L, w, Clock, output [3:0] Q);
  muxdff s3(Q[3], R[3], L, Clock, Q[3]);  // bit 3: serial-in is w? -> see below
  // Correct wiring (left-shift serial-in = w):
  // bit3 D0 = Q[2] (shift), D1 = R[3] (load)
  muxdff u3(Q[2], R[3], L, Clock, Q[3]);
  muxdff u2(Q[1], R[2], L, Clock, Q[2]);
  muxdff u1(Q[0], R[1], L, Clock, Q[1]);
  muxdff u0(w,    R[0], L, Clock, Q[0]);
endmodule
Each muxdff picks parallel data $R[i]$ when $L=1$; otherwise it shifts in the lower neighbor (or $w$ for the LSB).
5.23E
module shift4(input [3:0] R, input L, w, Clock, output reg [3:0] Q);
  always @(posedge Clock) begin
    if (L) Q <= R;
    else   Q <= {Q[2:0], w};   // shift left, w in at LSB
  end
endmodule
5.24E
module shiftn #(parameter n=8)(input [n-1:0] R, input L, w, Clock,
                                 output reg [n-1:0] Q);
  integer k;
  always @(posedge Clock) begin
    if (L) Q <= R;
    else begin
      for (k = n-1; k > 0; k = k-1) Q[k] <= Q[k-1];
      Q[0] <= w;
    end
  end
endmodule
5.25E
module upcnt4(input Clock, Resetn, E, output reg [3:0] Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= 4'b0;
    else if (E)  Q <= Q + 1;
endmodule
5.26E
module upcnt4_load(input [3:0] R, input Clock, Resetn, L, E,
                    output reg [3:0] Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= 4'b0;
    else if (L)  Q <= R;
    else if (E)  Q <= Q + 1;
endmodule
5.27E
module dncnt #(parameter n=4)(input [n-1:0] R, input Clock, Resetn, L, E,
                                output reg [n-1:0] Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= {n{1'b0}};
    else if (L)  Q <= R;
    else if (E)  Q <= Q - 1;
endmodule
5.28E
module updncnt #(parameter n=4)(input [n-1:0] R, input Clock, Resetn, L, E,
                                  input up_down, output reg [n-1:0] Q);
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) Q <= {n{1'b0}};
    else if (L)  Q <= R;
    else if (E)  Q <= up_down ? Q + 1 : Q - 1;
endmodule
5.29E

令 $t_{skew} = \delta_2 - \delta_1$。資料在 $Q_1$ 的發射時間為 $\delta_1 + t_{cQ}$;資料必須在 $\delta_2 + T - t_{su}$ 之前抵達 $Q_2$。(a) setup:$\delta_1 + t_{cQ} + t_L + t_{su} \le \delta_2 + T$,故 $T_{min} = t_{cQ} + t_L + t_{su} - t_{skew}$。(b) hold:同一個邊緣送出的資料,不得在該邊緣之後的 hold 時間內就抵達 $Q_2$:$\delta_1 + t_{cQ} + t_l \ge \delta_2 + t_h$,即 $t_{cQ} + t_l \ge t_h + t_{skew}$。負的 skew 會加重 hold time 的壓力。

Let $t_{skew} = \delta_2 - \delta_1$. The data launch time at $Q_1$ is $\delta_1 + t_{cQ}$; data must reach $Q_2$ before $\delta_2 + T - t_{su}$. (a) Setup: $\delta_1 + t_{cQ} + t_L + t_{su} \le \delta_2 + T$, so $T_{min} = t_{cQ} + t_L + t_{su} - t_{skew}$. (b) Hold: data from the same edge must not reach $Q_2$ before its hold time after the edge: $\delta_1 + t_{cQ} + t_l \ge \delta_2 + t_h$, i.e. $t_{cQ} + t_l \ge t_h + t_{skew}$. Negative skew increases the hold-time pressure.

$t_{skew} = \delta_2 - \delta_1$ とおく。$Q_1$ でのデータ発射時刻は $\delta_1 + t_{cQ}$ であり、データは $\delta_2 + T - t_{su}$ より前に $Q_2$ へ届かなければならない。(a) setup:$\delta_1 + t_{cQ} + t_L + t_{su} \le \delta_2 + T$、よって $T_{min} = t_{cQ} + t_L + t_{su} - t_{skew}$。(b) hold:同じエッジから出たデータが、そのエッジ後の hold 時間より前に $Q_2$ へ到達してはならない:$\delta_1 + t_{cQ} + t_l \ge \delta_2 + t_h$、すなわち $t_{cQ} + t_l \ge t_h + t_{skew}$。負のスキューは hold 時間の余裕をいっそう厳しくする。

5.30E

每個閘各增加 $\Delta$ 的延遲,因此內部節點 $A$(經過一個閘)比 $C$ 落後 $\Delta$;$B$(經過兩個閘)落後 $2\Delta$。當 AND/OR 讓延遲不等的路徑重新匯合時,$C$ 上落在寬度 $\Delta$ 視窗內的邊緣就會在 $B$ 上產生突波(冒險)。波形圖顯示 $A$ 與 $B$ 就是 $C$ 分別相移 $\Delta$ 與 $2\Delta$ 的結果,而任何突波的寬度都等於路徑延遲差。

With each gate adding delay $\Delta$, internal node $A$ (after one gate) lags $C$ by $\Delta$; $B$ (after two gates) lags by $2\Delta$. Edges that occur within a window of width $\Delta$ on $C$ produce glitches (hazards) on $B$ when an AND/OR re-converges paths of unequal delay. The waveforms show $A$ and $B$ as $C$ with phase shifts of $\Delta$ and $2\Delta$, and any glitch widths equal to the path-delay difference.

各ゲートが遅延 $\Delta$ を加えるので、内部ノード $A$(ゲート 1 段後)は $C$ より $\Delta$ 遅れ、$B$(2 段後)は $2\Delta$ 遅れる。AND/OR が遅延の異なる経路を再合流させるとき、$C$ 上で幅 $\Delta$ の窓に入るエッジは $B$ にグリッチ(ハザード)を生じさせる。波形は、$A$ と $B$ が $C$ をそれぞれ $\Delta$、$2\Delta$ だけ位相シフトしたものであること、そしてグリッチの幅が経路遅延差に等しいことを示す。

5.31E

依給定的輸入 $J_0=w$、$K_0=w$、$J_1=w Q_0$、$K_1=w$(圖 5.71 的典型接法)建立這對 JK 的激勵表。從 $Q_1 Q_0 = 00$ 開始:一個脈衝 → $01$;再一個脈衝 → $10$;再一個脈衝 → $00$;… 序列為 $00 \to 01 \to 10 \to 00 \dots$ — 一個模 3(除以 3)計數器。輸出 $Q_1 Q_0$ 共取 3 個相異狀態。

Build the excitation table for the JK pair given inputs $J_0=w$, $K_0=w$, $J_1=w Q_0$, $K_1=w$ (typical Figure 5.71 wiring). Starting at $Q_1 Q_0 = 00$: pulse → $01$; pulse → $10$; pulse → $00$; … sequence $00 \to 01 \to 10 \to 00 \dots$ — a modulo-3 (divide-by-3) counter. Output $Q_1 Q_0$ takes 3 distinct states.

与えられた入力 $J_0=w$、$K_0=w$、$J_1=w Q_0$、$K_1=w$(図 5.71 の典型的な結線)に対して、JK 対の励振表を作る。$Q_1 Q_0 = 00$ から始めると、パルスで → $01$、パルスで → $10$、パルスで → $00$、… 系列は $00 \to 01 \to 10 \to 00 \dots$ — モジュロ 3(3 分周)カウンタである。出力 $Q_1 Q_0$ は 3 つの相異なる状態をとる。

5.32E

資料路徑:以一個 6 位元暫存器 $S$ 累加總額。每來一個 Coin 脈衝,就把 $\{N,D,Q\}$ 編碼成 5 位元的值 $V \in \{5,10,25\}$:$V = N\cdot 5 + D\cdot 10 + Q\cdot 25$。一個 6 位元加法器算出 $S + V$,並在 Coin 的負緣把結果打回 $S$。達到 30 的偵測:當 $S \ge 30$ 時 $Z = 1$。由於 $30 = 011110_2$,$Z = s_5 + s_4 s_3 s_2 s_1$ 可涵蓋可達範圍內所有 $\ge 30$ 的值。Resetn 以非同步方式把暫存器清為 0。

Datapath: a 6-bit register $S$ accumulates the running total. On each Coin pulse, encode $\{N,D,Q\}$ to a 5-bit value $V \in \{5,10,25\}$: $V = N\cdot 5 + D\cdot 10 + Q\cdot 25$. A 6-bit adder forms $S + V$ and clocks the result back into $S$ on the negative edge of Coin. Reach-30 detection: $Z = 1$ when $S \ge 30$. Since $30 = 011110_2$, $Z = s_5 + s_4 s_3 s_2 s_1$ covers all values $\ge 30$ in the achievable range. Resetn asynchronously zeros the register.

データパス:6 ビットのレジスタ $S$ に合計を累算する。Coin パルスごとに $\{N,D,Q\}$ を 5 ビットの値 $V \in \{5,10,25\}$ へ符号化する:$V = N\cdot 5 + D\cdot 10 + Q\cdot 25$。6 ビット加算器が $S + V$ を作り、その結果を Coin の立下りで $S$ に書き戻す。30 到達の検出:$S \ge 30$ のとき $Z = 1$。$30 = 011110_2$ なので、$Z = s_5 + s_4 s_3 s_2 s_1$ が到達可能な範囲の $\ge 30$ をすべて覆う。Resetn はレジスタを非同期にゼロクリアする。

5.33E
module vending(input N, D, Q, Coin, Resetn, output Z);
  reg [5:0] S;
  wire [4:0] inc = N ? 5'd5 : D ? 5'd10 : Q ? 5'd25 : 5'd0;
  always @(negedge Resetn, negedge Coin)
    if (!Resetn) S <= 6'd0;
    else         S <= S + {1'b0, inc};
  assign Z = S[5] | (S[4] & S[3] & S[2] & S[1]);
endmodule
5.34E

直接的設計在 $Q_0$ 與最高位 XOR 之間有一串串接的 AND,延遲為 $(n-1)t_{AND}$。改成每個切換位元各配一個 XOR,並以直接由 $Q_0\dots Q_{i-1}$ 驅動的扇入 2 AND 樹重構,如此最長路徑就只剩一個 AND 接一個 XOR。於是 $T_{min} = t_{cQ} + t_{AND} + t_{XOR} + t_{su} = 1.0 + 1.4 + 1.2 + 0.6 = 4.2$ ns,故 $F_{max} = 1/4.2\,\text{ns} \approx 238$ MHz。

The straight design has cascaded ANDs with delay $(n-1)t_{AND}$ between $Q_0$ and the highest XOR. Refactor by using an XOR for each toggle bit and an AND tree of fan-in 2 driven directly from $Q_0\dots Q_{i-1}$, so the longest path is one AND followed by one XOR. Then $T_{min} = t_{cQ} + t_{AND} + t_{XOR} + t_{su} = 1.0 + 1.4 + 1.2 + 0.6 = 4.2$ ns, so $F_{max} = 1/4.2\,\text{ns} \approx 238$ MHz.

素直な設計では、$Q_0$ から最上位の XOR までに縦続接続された AND があり、遅延は $(n-1)t_{AND}$ となる。トグルするビットごとに XOR を置き、$Q_0\dots Q_{i-1}$ から直接駆動されるファンイン 2 の AND ツリーを使って作り直すと、最長経路は AND 1 段と XOR 1 段だけになる。すると $T_{min} = t_{cQ} + t_{AND} + t_{XOR} + t_{su} = 1.0 + 1.4 + 1.2 + 0.6 = 4.2$ ns となり、$F_{max} = 1/4.2\,\text{ns} \approx 238$ MHz である。

5.35E

通過 FSM 的最壞情況路徑:$T_{min}(i\to j) = t_{cQ} + t_{path} + t_{su} - (\delta_j - \delta_i)$。hold 檢查:$t_{cQ} + t_{min\,path} \ge t_h + (\delta_j - \delta_i)$。(i) 零 skew:典型的 $T_{min}\approx 1.0+t_{path}+0.6$。(ii) $\delta_2$ 上有 skew:進入 FF2 的路徑多得 $0.7$ ns 餘裕,離開 FF2 的路徑則損失 $0.7$ ns。算出最壞路徑;某一條資料路徑很可能成為瓶頸,使 $F_{max}$ 略為降低。(iii) $\delta_1=1, \delta_2=0, \delta_3=0.5$:$1\to 2$ 的路徑 $t_{skew}=-1$ ns(罰則),$2\to 3$ 的路徑則多得 $+0.5$ ns 餘裕。最壞情況路徑收緊了時脈;檢查 hold:$0.8 + t_{l} \ge 0.4 + (\delta_j-\delta_i)$ — 對於 skew 為 $-1$ 的 $1\to 2$,hold 自動成立。再由主導路徑分別算出各個 $F_{max}$。

Worst-case path through the FSM: $T_{min}(i\to j) = t_{cQ} + t_{path} + t_{su} - (\delta_j - \delta_i)$. Hold check: $t_{cQ} + t_{min\,path} \ge t_h + (\delta_j - \delta_i)$. (i) zero skew: typical $T_{min}\approx 1.0+t_{path}+0.6$. (ii) skew on $\delta_2$: paths into FF2 gain $0.7$ ns slack, paths out of FF2 lose $0.7$ ns. Compute worst path; one of the data paths probably becomes the bottleneck, producing a slightly slower $F_{max}$. (iii) $\delta_1=1, \delta_2=0, \delta_3=0.5$: paths $1\to 2$ have $t_{skew}=-1$ ns (penalty), paths $2\to 3$ get +0.5 ns slack. The worst-case path tightens the clock; check hold: $0.8 + t_{l} \ge 0.4 + (\delta_j-\delta_i)$ — for $1\to 2$ with skew $-1$, hold is automatic. Compute each $F_{max}$ from the dominant path.

FSM を通る最悪経路:$T_{min}(i\to j) = t_{cQ} + t_{path} + t_{su} - (\delta_j - \delta_i)$。hold のチェック:$t_{cQ} + t_{min\,path} \ge t_h + (\delta_j - \delta_i)$。(i) スキューなし:典型的には $T_{min}\approx 1.0+t_{path}+0.6$。(ii) $\delta_2$ にスキューがある場合:FF2 へ入る経路は $0.7$ ns の余裕を得て、FF2 から出る経路は $0.7$ ns を失う。最悪経路を計算する。データ経路のどれかがボトルネックになり、$F_{max}$ はわずかに下がるだろう。(iii) $\delta_1=1, \delta_2=0, \delta_3=0.5$:$1\to 2$ の経路は $t_{skew}=-1$ ns(ペナルティ)、$2\to 3$ の経路は $+0.5$ ns の余裕を得る。最悪経路がクロックを制約する。hold を確認すると $0.8 + t_{l} \ge 0.4 + (\delta_j-\delta_i)$ — スキュー $-1$ の $1\to 2$ では hold は自動的に満たされる。支配的な経路からそれぞれの $F_{max}$ を求める。

第 6 章 — 有限狀態機Chapter 6 — Finite State Machines第 6 章 — 有限状態機械
6.1

Moore FSM detecting 101 (overlapping). States: S0(initial), S1(got 1), S2(got 10), S3(got 101, output=1). *必背*memorise*要暗記

S0 --1--> S1 --0--> S2 --1--> S3(out=1)
S0 --0--> S0
S1 --1--> S1
S2 --0--> S0
S3 --1--> S1 (overlap: 101, last 1 starts new)
S3 --0--> S2 (overlap: 1010...)

只有在 S3 時輸出 z=1(Moore:輸出取決於狀態,而非轉移)。

Output z=1 only in S3 (Moore: output on state, not transition).

出力 z=1 となるのは S3 のときだけである(Moore:出力は遷移ではなく状態で決まる)。

6.2

狀態編碼:S0=00, S1=01, S2=10, S3=11。使用 D 型正反器:

State encoding: S0=00, S1=01, S2=10, S3=11. Using D FFs:

状態符号化:S0=00, S1=01, S2=10, S3=11。D フリップフロップを使うと:

狀態State状態w下一狀態Next次状態D₁D₀z
00000000
00101010
01010100
01101010
10000000
10111110
11010101
11101011

D₁ = Q₁Q̄₀w + Q̄₁Q₀w̄ + Q₁Q₀w̄; D₀ = Q̄₁w + Q₀; z = Q₁Q₀

6.3

Moore FSM:當輸入 $w$ 上出現連續三個(或更多)1 之後,輸出 $z=1$。狀態用來計數連續的 1 — A(0)、B(1)、C(2)、D(≥3,輸出=1)。輸出只取決於狀態,因此必須有一個專用的 D 狀態來登錄「偵測到」這件事。

Moore FSM: output $z=1$ after three (or more) consecutive 1s on input $w$. States count consecutive 1s — A(0), B(1), C(2), D(≥3, output=1). Output depends only on state, so a dedicated D state is required to register the "detection".

Moore FSM:入力 $w$ に 1 が 3 個以上連続したあと、出力 $z=1$ となる。状態は連続する 1 の個数を数える — A(0)、B(1)、C(2)、D(≥3、出力=1)。出力は状態だけで決まるため、「検出した」ことを記憶する専用の状態 D が必要である。

ABCD01111000

Verilog(Moore,4 個狀態;輸出僅為狀態的函數):

Verilog (Moore, 4 states; output is a function of state only):

Verilog(Moore、4 状態。出力は状態のみの関数):

module moore_three_ones (
  input  clock, resetn, w,
  output z
);
  reg [1:0] y;
  parameter A = 2'b00, B = 2'b01, C = 2'b10, D = 2'b11;

  // single always: state register only (Moore output is combinational on y)
  always @(posedge clock or negedge resetn) begin
    if (!resetn) y <= A;
    else case (y)
      A:       y <= (w ? B : A);
      B:       y <= (w ? C : A);
      C:       y <= (w ? D : A);
      D:       y <= (w ? D : A);
      default: y <= A;
    endcase
  end

  // Moore output: depends only on state
  assign z = (y == D);
endmodule

為何需要 4 個狀態(相對於 6.4 的 Mealy 版本只要 3 個):在 Moore 形式中,輸出是狀態暫存器的純函數,所以「恰好看到 3 個」不能與「看到 2 個」混為一談;必須有一個獨立的偵測狀態 D。Mealy 則可以把「第三個 1」摺進 C→C 轉移的輸出裡,因而省下一個狀態。

Why 4 states (vs 3 for the Mealy version in 6.4): in Moore form the output is a pure function of the state register, so "saw exactly 3" cannot be conflated with "saw 2"; a separate detection state D is required. Mealy can fold "third 1" into the C→C transition output, eliminating one state.

なぜ 4 状態必要か(6.4 の Mealy 版は 3 状態):Moore 形式では出力が状態レジスタだけの関数なので、「ちょうど 3 個見た」と「2 個見た」を同一視できない。独立した検出状態 D が要る。Mealy なら「3 個目の 1」を C→C 遷移の出力に畳み込めるので、状態を 1 つ減らせる。

6.4

偵測三個連續 1 的 Mealy FSM:在完成第三個 1 的那次轉移上輸出 $z=1$。

Mealy FSM for three consecutive 1s: output $z=1$ on the transition that completes the third 1.

1 が 3 個連続するのを検出する Mealy FSM:3 個目の 1 を完成させる遷移で出力 $z=1$ となる。

狀態:A(0 個 1)、B(1 個 1)、C(連續 2 個以上的 1)。只有在 $w=1$ 的 C→C 轉移上 $z=1$。

States: A (0 ones), B (1 one), C (2+ consecutive 1s). $z=1$ only on the C→C transition when $w=1$.

状態は A(1 が 0 個)、B(1 が 1 個)、C(1 が 2 個以上連続)。$z=1$ となるのは $w=1$ のときの C→C 遷移だけである。

ABC0/01/11/01/00/00/0

Verilog(Mealy,3 個狀態):

Verilog (Mealy, 3 states):

Verilog(Mealy、状態 3 個):

module mealy_three_ones (
  input  clock, resetn, w,
  output reg z
);
  reg [1:0] y;
  parameter A = 2'b00, B = 2'b01, C = 2'b10;

  // single always block: state register + registered Mealy output
  always @(posedge clock or negedge resetn) begin
    if (!resetn) begin
      y <= A;
      z <= 1'b0;
    end else begin
      case (y)
        A:       begin y <= (w ? B : A); z <= 1'b0; end
        B:       begin y <= (w ? C : A); z <= 1'b0; end
        C:       begin y <= (w ? C : A); z <= w;    end  // z=1 on C&&w=1
        default: begin y <= A;         z <= 1'b0; end
      endcase
    end
  end
endmodule

狀態數比較:Mealy 需要 3 個狀態;Moore 需要 4 個。Mealy 把「剛偵測到」這個事件摺進轉移輸出,因而省下一個狀態。

State count comparison: Mealy needs 3 states; Moore needs 4. Mealy folds the "just detected" event into the transition output, saving one state.

状態数の比較:Mealy は 3 状態、Moore は 4 状態を要する。Mealy は「今検出した」という事象を遷移出力に畳み込むので、状態が 1 つ少なくて済む。

6.5

Moore FSM:輸出只取決於目前狀態。輸出在整個時脈週期內都保持穩定;分析較簡單。

Moore FSM: Output depends only on current state. Output is stable for entire clock period; simpler to analyze.

Moore FSM:出力は現在の状態だけで決まる。出力はクロック周期の全体にわたって安定しており、解析が容易である。

Mealy FSM:輸出取決於目前狀態「與」目前輸入。輸入若改變,輸出可能在週期中途變化;通常需要較少狀態;對同一個序列,輸出比 Moore 早一個週期出現。

Mealy FSM: Output depends on current state AND current input. Output can change mid-cycle if input changes; typically needs fewer states; output arrives one cycle earlier than Moore for same sequence.

Mealy FSM:出力は現在の状態と現在の入力の両方で決まる。入力が変われば出力がサイクルの途中で変化しうる。ふつう状態数は少なくて済み、同じ系列に対して出力は Moore より 1 サイクル早く現れる。

Moore 的優點:輸出無突波(已暫存),時序分析較容易。

Moore advantages: Glitch-free outputs (registered), easier timing analysis.

Moore の利点:出力にグリッチがなく(レジスタ化されている)、タイミング解析が容易である。

Mealy 的優點:狀態較少(較精簡),反應較快(輸出與輸入在同一週期)。

Mealy advantages: Fewer states (more compact), faster response (output same cycle as input).

Mealy の利点:状態数が少なく(コンパクト)、応答が速い(出力が入力と同じサイクルに出る)。

6.6

one-hot 編碼:每個狀態各配一個正反器;任一時刻恰好只有一個 FF 為 1。下一狀態邏輯很簡單(每個狀態就直接是某個 FF 的輸出)。

One-hot encoding: One flip-flop per state; exactly one FF is 1 at any time. Simple next-state logic (each state is directly a FF output).

one-hot 符号化:状態ごとにフリップフロップを 1 個ずつ置き、どの時点でもちょうど 1 個の FF だけが 1 になる。次状態論理は単純である(各状態がそのまま FF の出力になる)。

5-state comparison:

  • 二進位編碼: ⌈log₂5⌉ = 3 個正反器。
  • Binary encoding: ⌈log₂5⌉ = 3 flip-flops.
  • 2 進符号化: ⌈log₂5⌉ = 3 個のフリップフロップ。
  • one-hot 編碼:5 個正反器(每個狀態一個)。
  • One-hot encoding: 5 flip-flops (one per state).
  • one-hot 符号化:フリップフロップ 5 個(状態ごとに 1 個)。

one-hot 用掉較多 FF,但降低了組合邏輯的複雜度;在 FF 充裕而 LUT 才是稀缺資源的 FPGA 上,這樣比較划算。

One-hot uses more FFs but reduces combinational logic complexity, which is preferable on FPGAs where FFs are plentiful and LUTs are the scarce resource.

one-hot は FF を多く使うが、組合せ論理の複雑さを下げる。FF が潤沢で LUT のほうが希少な資源である FPGA では、このほうが好ましい。

6.7
module seq_detect_101 (
    input  clk, rst, w,
    output z
);
    parameter S0=2'd0, S1=2'd1, S2=2'd2, S3=2'd3;
    reg [1:0] state, next;
    always @(posedge clk or posedge rst)
        state <= rst ? S0 : next;
    always @(*) begin
        case (state)
            S0: next = w ? S1 : S0;
            S1: next = w ? S1 : S2;
            S2: next = w ? S3 : S0;
            S3: next = w ? S1 : S2;
            default: next = S0;
        endcase
    end
    assign z = (state == S3);
endmodule
6.8

Mealy FSM — 另一種標記方式($A$ = 上一個輸入是 0,$B$ = 上一個輸入是 1/重置)。偵測用的箭頭是 $w{=}1/z{=}1$ 上的 $A \to B$:

Mealy FSM — alternative labeling ($A$ = last input was 0, $B$ = last input was 1 / reset). The detection arrow is $A \to B$ on $w{=}1/z{=}1$:

Mealy FSM — 別のラベル付け($A$ = 直前の入力が 0、$B$ = 直前の入力が 1/リセット)。検出の矢印は $w{=}1/z{=}1$ の $A \to B$ である:

A last = 0 B last = 1 (init) reset 0/0 1/0 1 / 1 "01" detected — z fires 0 / 0

$\delta(A, 0)=A$、$\delta(A, 1)=B$(此時 $z=1$);$\delta(B, 0)=A$、$\delta(B, 1)=B$。重置 → B。

$\delta(A, 0)=A$, $\delta(A, 1)=B$ (with $z=1$); $\delta(B, 0)=A$, $\delta(B, 1)=B$. Reset → B.

$\delta(A, 0)=A$、$\delta(A, 1)=B$(このとき $z=1$)、$\delta(B, 0)=A$、$\delta(B, 1)=B$。リセット → B。

Verilog(精簡形式 — 組合式 Mealy 輸出):

Verilog (compact form — combinational Mealy output):

Verilog(コンパクト形式 — 組合せ的な Mealy 出力):

module mealy_01detect (
    input  clk, rst, w,
    output z
);
    parameter A = 1'b0,   // last input was 0
              B = 1'b1;   // last input was 1 / reset
    reg state;

    always @(posedge clk or posedge rst) begin
        if (rst) state <= B;            // initial = B
        else case (state)
            A: state <= w ? B : A;       // A→B on w=1 (detection!), A→A on w=0
            B: state <= w ? B : A;       // B→B on w=1, B→A on w=0
        endcase
    end

    // Mealy output: z=1 only on A→B transition driven by w=1
    assign z = (state == A) & w;   // 非常重要 要用組合電路// very important — must use combinational logic// 非常に重要 — 組合せ回路で書くこと
endmodule

Verilog(冗長形式 — 已暫存的輸出,單一 always 區塊):

Verilog (verbose form — registered output, single always block):

Verilog(冗長形式 — レジスタ化した出力、always ブロック 1 つ):

module mealy_01detect (
    input  clk, reset, w,
    output reg z
);
    parameter S1 = 1'b0,    // last input was 0
              S2 = 1'b1;    // last input was 1 / reset
    reg y;

    always @(posedge clk or posedge reset) begin
        if (reset) begin
            y <= S2;        // initial = S2 (so first w=1 doesn't false-detect)
            z <= 1'b0;
        end else case (y)
            S1: begin
                if (w == 1'b1) begin
                    y <= S2;
                    z <= 1'b1;          // ← "01" detected!  z = 1
                end else begin
                    y <= S1;
                    z <= 1'b0;
                end
            end
            S2: begin
                if (w == 1'b1) begin
                    y <= S2;
                    z <= 1'b0;
                end else begin
                    y <= S1;
                    z <= 1'b0;
                end
            end
            default: begin y <= S2; z <= 1'b0; end
        endcase
    end
endmodule

兩者的差別:精簡形式對 z 使用連續指派 assign(組合式 Mealy — z 會在週期內隨 w 的變化而反應)。冗長形式則把 z 登錄在同一個時脈 always 區塊裡,因此 z 在整個週期都保持穩定(等同 Moore 的時序),但功能上仍然偵測「01」。對任何輸入序列,兩者都在相同的時脈週期產生 z=1。

Difference between the two: the compact form uses a continuous assign for z (combinational Mealy — z reacts to w changes within the cycle). The verbose form registers z inside the same clocked always block, so z stays stable for a full cycle (Moore-equivalent timing) but functionally still detects "01". Both produce z=1 at the same clock cycles for any input sequence.

両者の違い:コンパクト形式は z に連続代入 assign を使う(組合せ的な Mealy — z はサイクル内で w の変化に反応する)。冗長形式は同じクロック always ブロックの中で z をレジスタ化するので、z は 1 サイクルまるごと安定する(Moore 相当のタイミング)が、機能としては変わらず「01」を検出する。どんな入力系列に対しても、両者は同じクロックサイクルで z=1 を出す。

與交換標記後的版本等價:教科書原本的程式用 A =「上一個是 1」並在 B→A 上偵測;此版本用 A =「上一個是 0」並在 A→B 上偵測。兩者的輸入輸出行為完全相同,選哪一種只是風格偏好。以輸入 1,0,1,0,1(初始狀態 B)驗證:第 3 與第 5 週期正好在「01」完成時觸發 z=1

Equivalent to the swapped labeling: the original code in the textbook uses A = "last was 1" and detects on B→A; this version uses A = "last was 0" and detects on A→B. Both produce identical input-output behavior; choice is a stylistic preference. Verify with input 1,0,1,0,1 (initial state B): cycles 3 and 5 fire z=1 exactly when "01" completes.

ラベルを入れ替えた版と等価:教科書のもとのコードは A =「直前は 1」として B→A で検出する。この版は A =「直前は 0」として A→B で検出する。両者の入出力動作はまったく同じで、どちらを選ぶかは好みの問題である。入力 1,0,1,0,1(初期状態 B)で確かめると、3 サイクル目と 5 サイクル目に、ちょうど「01」が完成したところで z=1 が立つ。

6.9

給定一張含狀態、輸入、下一狀態與輸出的狀態表,依下列步驟推導方程式:

Given a state table with states, inputs, next states, and outputs, derive equations by:

状態、入力、次状態、出力を含む状態表が与えられたら、次の手順で方程式を導く:

  1. 為各狀態指派二進位碼。
  2. Assign binary codes to states.
  3. 各状態に 2 進符号を割り当てる。
  4. 建立下一狀態表(2 個正反器的 D₁、D₀)。
  5. Build next-state table (D₁, D₀ for 2 FFs).
  6. 次状態表を作る(フリップフロップ 2 個分の D₁、D₀)。
  7. 以卡諾圖化簡每一個 D 函數。
  8. Minimize each D function via K-map.
  9. 各 D 関数をカルノー図で最小化する。
  10. 由輸出欄建立輸出方程式。
  11. Build output equation from output column.
  12. 出力の列から出力方程式を作る。

對某張特定的表(例如 3 個狀態、1 個輸入的例子):把狀態位元與輸入都視為變數,直接對每一欄(D₁、D₀、z)做卡諾圖化簡,方程式就出來了。

For a specific table (example with 3 states, 1 input): the equations emerge directly from K-map minimization of each column (D₁, D₀, z) treating state bits and input as variables.

ある特定の表(たとえば 3 状態・入力 1 本の例)では、状態ビットと入力を変数とみなして各列(D₁、D₀、z)をカルノー図で簡単化すれば、方程式がそのまま得られる。

6.10

以分割法做狀態極小化(Myhill-Nerode/蘊涵表):

State minimization via partitioning (Myhill-Nerode / implication chart):

分割による状態最小化(Myhill-Nerode/含意表):

  1. 初始分割:依輸出值把狀態分組。
  2. Initial partition: group states by output values.
  3. 初期分割:出力値によって状態をグループ分けする。
  4. 細分:在每一組之內,若兩個狀態在同一輸入下轉移到不同的組,就把它們拆開。
  5. Refine: within each group, if two states have transitions to different groups under same input, split them.
  6. 細分:各グループ内で、同じ入力に対して異なるグループへ遷移する 2 状態があれば、それらを分割する。
  7. 重複進行,直到無法再分割為止。
  8. Repeat until no more splits.
  9. これ以上分割できなくなるまで繰り返す。
  10. 最後仍留在同一分割類別中的狀態彼此等價 — 予以合併。
  11. States remaining in same partition class are equivalent — merge them.
  12. 最後まで同じ分割クラスに残った状態どうしは等価である — それらを併合する。

對狀態 A–F:建立蘊涵表,標出不相容的狀態對(輸出不同者),再傳播蘊涵關係。剩下未被標記的狀態對即為等價。合併後得到最小狀態機。

For states A–F: build implication chart, mark incompatible pairs (different outputs), propagate implications. Remaining unmarked pairs are equivalent. Merge to minimal state machine.

状態 A〜F については、含意表を作り、両立しない対(出力が異なるもの)に印を付け、含意を伝播させる。印が付かずに残った対が等価である。併合して最小の状態機械を得る。

6.11

販賣機 ASM:接受 5 分硬幣 (N) 與 10 分硬幣 (D);商品售價 15¢;並找零。

Vending machine ASM: accepts nickels (N) and dimes (D); item costs 15¢; dispenses change.

自動販売機の ASM:5 セント硬貨 (N) と 10 セント硬貨 (D) を受け付ける。商品は 15¢ で、釣り銭を出す。

States: S0(0¢), S5(5¢), S10(10¢), S15(dispense)
ASM blocks:
S0: if N→S5; if D→S10
S5: if N→S10; if D→S15(no change)
S10: if N→S15(no change); if D→S15+change(5¢)
S15: dispense item; if change needed→output nickel; →S0

對 N、D 輸入設置決策方塊;對商品與找零設置條件輸出;每個金額各有一個狀態方塊。ASM 圖以矩形表示狀態、菱形表示決策、橢圓表示條件輸出。

Decision boxes for N, D inputs; conditional outputs for item and change; state boxes for each amount. ASM chart uses rectangles (states), diamonds (decisions), ovals (conditional outputs).

N、D の入力に対する判定ボックス、商品と釣り銭に対する条件出力、金額ごとの状態ボックスを置く。ASM チャートは長方形(状態)、ひし形(判定)、楕円(条件出力)で表す。

6.12
module traffic_light (
    input  clk, rst,
    output reg [1:0] light  // 00=red,01=green,10=yellow
);
    reg [4:0] cnt;
    // Green 20 cycles, Yellow 5, Red 20
    always @(posedge clk or posedge rst) begin
        if (rst) begin cnt<=0; light<=2'b01; end
        else begin
            cnt <= cnt + 1;
            case (light)
                2'b01: if(cnt==19) begin light<=2'b10; cnt<=0; end
                2'b10: if(cnt==4)  begin light<=2'b00; cnt<=0; end
                2'b00: if(cnt==19) begin light<=2'b01; cnt<=0; end
            endcase
        end
    end
endmodule
6.31

偵測 1001 或 1111(可重疊)。建立一台狀態機,追蹤輸入中「同時是兩個目標樣式之一的前綴」的最長後綴:

Detect 1001 or 1111 (overlapping). Build a state machine tracking the longest suffix of the input that is a prefix of either target:

1001 または 1111 を検出する(重なりを許す)。入力の接尾辞のうち、どちらかの目標パターンの接頭辞になっている最長のものを追跡する状態機械を作る:

States: S0, S1(1), S2(10), S3(100), S4(11), S5(111)
S0: 0→S0, 1→S1
S1: 0→S2, 1→S4
S2: 0→S0, 1→S3
S3: 0→S0, 1→S4; on completing 1001 at S3+input 1: output=1, goto S1
S4: 0→S2, 1→S5; completing 1001: S3→w=1→output+goto S1
S5: 0→S2, 1→S1; completing 1111: S5+1→output=1, goto S4

完成 1001(狀態 S3、輸入 1)或 1111(狀態 S5 以後、輸入 1)時輸出 1。也可以加一個接受狀態來得到 Moore 輸出。

Output 1 when completing 1001 (state S3, input 1) or 1111 (state S5+, input 1). Moore output can be added with an accepting state.

1001(状態 S3、入力 1)または 1111(状態 S5 以降、入力 1)が完成したときに 1 を出力する。受理状態を追加すれば Moore 出力にもできる。

6.32

有限狀態機是一個 5 元組 M = (Q, Σ, δ, q₀, F),其中:

A finite state machine is a 5-tuple M = (Q, Σ, δ, q₀, F) where:

有限状態機械は 5 つ組 M = (Q, Σ, δ, q₀, F) であり、各要素は次のとおりである:

  • Q — 有限的狀態集合
  • Q — finite set of states
  • Q — 状態の有限集合
  • Σ — 有限的輸入字母集
  • Σ — finite input alphabet
  • Σ — 有限の入力アルファベット
  • δ: Q × Σ → Q — 轉移函數(下一狀態函數)
  • δ: Q × Σ → Q — transition function (next-state function)
  • δ: Q × Σ → Q — 遷移関数(次状態関数)
  • q₀ ∈ Q — initial state
  • F ⊆ Q — 接受/輸出狀態的集合(Moore:輸出函數 λ: Q → Λ;Mealy:λ: Q × Σ → Λ)
  • F ⊆ Q — set of accepting/output states (for Moore: output function λ: Q → Λ; for Mealy: λ: Q × Σ → Λ)
  • F ⊆ Q — 受理/出力状態の集合(Moore なら出力関数 λ: Q → Λ、Mealy なら λ: Q × Σ → Λ)
6.33

給定:D₁ = x⊕Q₂、D₂ = Q₁(以 Q₁、Q₂ 為狀態,x 為輸入)。

Given: D₁ = x⊕Q₂, D₂ = Q₁ (using Q₁,Q₂ as state, x as input).

与えられた式:D₁ = x⊕Q₂、D₂ = Q₁(Q₁、Q₂ を状態、x を入力とする)。

Next state: Q₁⁺=x⊕Q₂, Q₂⁺=Q₁.

Q₁Q₂x=0: Q₁⁺Q₂⁺x=1: Q₁⁺Q₂⁺
000010
011000
100111
111101

狀態圖:4 個狀態,每個各有兩條轉移。未指定輸出 → 分析時計算狀態數/週期數,或另外加上輸出函數。

State diagram: 4 states, each with two transitions. No output specified → count states/cycles for analysis or add output function.

状態図:状態は 4 つで、それぞれに遷移が 2 本ある。出力は指定されていない → 解析では状態数やサイクル数を数えるか、出力関数を別に加える。

6.34

針對 r₁、r₂ 的仲裁器 FSM:一次只授權一方存取。

Arbiter FSM for r₁, r₂: grants access one at a time.

r₁、r₂ に対するアービタ FSM:一度に一方だけにアクセスを許可する。

States: IDLE, GRANT1, GRANT2
IDLE: if r₁&r₂→GRANT1 (r₁ priority); if r₁ only→GRANT1; if r₂ only→GRANT2; else→IDLE
GRANT1: g₁=1; if ~r₁→IDLE (r₁ releases); else hold
GRANT2: g₂=1; if ~r₂→IDLE; else hold

輸出:GRANT1 時 g₁=1,GRANT2 時 g₂=1。仲裁器確保互斥:任一時刻只有一個授權有效。當兩者同時 assert 時,優先權給 r₁。

Outputs: g₁=1 in GRANT1, g₂=1 in GRANT2. The arbiter ensures mutual exclusion: only one grant active at a time. Priority given to r₁ when both assert simultaneously.

出力:GRANT1 で g₁=1、GRANT2 で g₂=1。アービタは相互排除を保証する:許可が有効になるのは一度に 1 つだけである。両方が同時にアサートされた場合は r₁ を優先する。

6.35

ASM 圖相對於狀態圖的優點:

Advantages of ASM charts over state diagrams:

状態図に対する ASM チャートの利点:

  • 清楚地把資料操作(暫存器轉移)與控制流一併呈現。
  • Clearly show data operations (register transfers) alongside control flow.
  • データ操作(レジスタ転送)を制御フローと並べて明示できる。
  • 條件輸出(標在弧線/菱形上)表達明確,又不會讓狀態泡泡變得雜亂。
  • Conditional outputs (on arcs/diamonds) are explicit without cluttering state bubbles.
  • 条件出力(矢印や菱形の上に置かれる)が明示され、状態バブルを煩雑にしない。
  • 對熟悉流程圖的硬體設計者而言更容易閱讀。
  • More readable for hardware designers familiar with flowcharts.
  • フローチャートに慣れたハードウェア設計者にとって読みやすい。
  • 直接建模資料路徑與控制之間的互動;由 ASM 區塊結構推導 RTL 也更容易。
  • Directly model datapath+control interactions; easier to derive RTL from ASM block structure.
  • データパスと制御の相互作用を直接モデル化できる。ASM ブロック構造から RTL を導くのも容易である。
  • 時序是隱含的:每個 ASM 區塊在一個時脈週期內執行完畢。
  • Timing is implicit: each ASM block executes in one clock cycle.
  • タイミングは暗黙である:各 ASM ブロックは 1 クロックサイクルで実行される。
6.36
  1. 狀態圖/狀態表:以狀態、輸入、轉移與輸出描述所要的行為。
  2. State diagram / state table: Capture desired behavior with states, inputs, transitions, outputs.
  3. 状態遷移図/状態表:状態、入力、遷移、出力によって望む動作を記述する。
  4. 狀態最小化:合併等價狀態以減少硬體。
  5. State minimization: Merge equivalent states to reduce hardware.
  6. 状態最小化:等価な状態を併合してハードウェアを削減する。
  7. 狀態指派:為各狀態指派二進位碼(二進位、格雷碼、one-hot)。
  8. State assignment: Assign binary codes to states (binary, Gray, one-hot).
  9. 状態割当て:各状態に 2 進符号を割り当てる(バイナリ、グレイ符号、one-hot)。
  10. 正反器選擇:選定 FF 的型式(D、JK、T),並推導激勵方程式。
  11. Flip-flop selection: Choose FF type (D, JK, T); derive excitation equations.
  12. フリップフロップの選択:FF の種類(D、JK、T)を選び、励振方程式を導く。
  13. 最小化:最小化下一狀態方程式與輸出方程式(用 K-map 或 Quine-McCluskey)。
  14. Minimization: Minimize next-state and output equations (K-maps or Quine-McCluskey).
  15. 最小化:次状態方程式と出力方程式を最小化する(K-map または Quine-McCluskey)。
  16. 電路實作:以邏輯閘與 FF 實現這些方程式,並用模擬驗證。
  17. Circuit implementation: Realize equations with gates and FFs; verify with simulation.
  18. 回路実装:ゲートと FF で方程式を実現し、シミュレーションで検証する。
6.37
// Binary encoding (3 FFs for 8 states)
parameter [2:0] S0=3'd0, S1=3'd1, ..., S7=3'd7;

// Gray encoding (3 FFs, adjacent states differ by 1 bit - reduces glitches)
parameter [2:0] S0=3'b000, S1=3'b001, S2=3'b011, S3=3'b010,
                S4=3'b110, S5=3'b111, S6=3'b101, S7=3'b100;

// One-hot (8 FFs, simplest next-state logic - preferred for FPGAs)
parameter [7:0] S0=8'b00000001, S1=8'b00000010, S2=8'b00000100,
                S3=8'b00001000, S4=8'b00010000, S5=8'b00100000,
                S6=8'b01000000, S7=8'b10000000;

One-hot:需要 8 個 FF,但下一狀態 = 所有進入該狀態之 FF 的 OR(不需解碼)。最適合 FPGA。二進位:只要 3 個 FF,但解碼複雜。格雷碼:可減少計數器的輸出突波。

One-hot: 8 FFs but next-state = OR of incoming state FFs (no decoding needed). Best for FPGAs. Binary: 3 FFs but complex decode. Gray: reduces output glitches for counters.

One-hot:FF は 8 個必要だが、次状態は入ってくる状態の FF の OR で済む(デコード不要)。FPGA に最適である。バイナリ:FF は 3 個だがデコードが複雑。グレイ符号:カウンタの出力グリッチを減らせる。

6.38

以循序邏輯設計法實作模 8 上數計數器。狀態為 000–111,下一狀態 = 現在狀態 + 1(模 8)。使用 D FF:

Modulo-8 up counter via sequential design. States 000–111, next state = present state + 1 (mod 8). Using D FFs:

順序回路設計による法 8 のアップカウンタ。状態は 000–111 で、次状態 = 現在状態 + 1(mod 8)である。D FF を使うと:

狀態表與二進位計數器相同。D₂,D₁,D₀ 的卡諾圖:

State table same as binary counter. K-maps for D₂,D₁,D₀:

状態表は 2 進カウンタと同じである。D₂,D₁,D₀ のカルノー図:

D₀ = Q̄₀(每個週期都翻轉)

D₀ = Q̄₀ (toggles every cycle)

D₀ = Q̄₀(毎サイクルトグルする)

D₁ = Q₁⊕Q₀

D₂ = Q₂⊕(Q₁Q₀)

輸出 = 狀態值(Q₂Q₁Q₀)。實作:D₀=NOT Q₀;D₁=XOR(Q₁,Q₀);D₂=XOR(Q₂,AND(Q₁,Q₀))。

Output = state value (Q₂Q₁Q₀). Implementation: D₀=NOT Q₀; D₁=XOR(Q₁,Q₀); D₂=XOR(Q₂,AND(Q₁,Q₀)).

出力は状態値(Q₂Q₁Q₀)である。実装:D₀=NOT Q₀、D₁=XOR(Q₁,Q₀)、D₂=XOR(Q₂,AND(Q₁,Q₀))。

6.39

以 JK FF 實作模 8 計數器。JK 激勵表:J=0,K=x(保持 0);J=x,K=0(保持 1);J=1,K=x(設定);J=x,K=1(重置)。

Mod-8 counter with JK FFs. JK excitation table: J=0,K=x (hold 0); J=x,K=0 (hold 1); J=1,K=x (set); J=x,K=1 (reset).

JK FF による法 8 カウンタ。JK の励振表:J=0,K=x(0 を保持)、J=x,K=0(1 を保持)、J=1,K=x(セット)、J=x,K=1(リセット)。

J₀=1, K₀=1(LSB 永遠翻轉)。

J₀=1, K₀=1 (always toggle for LSB).

J₀=1, K₀=1(LSB は常にトグルする)。

J₁=Q₀, K₁=Q₀ (toggle when Q₀=1).

J₂=Q₁Q₀, K₂=Q₁Q₀ (toggle when Q₁Q₀=1).

閘數比較:JK 實作使用相同的 XOR 結構,只是改以 J/K 表達。D FF 版本需要明確的 XOR 閘;JK 版本的激勵方程式較簡單(J₀=K₀=1 只要直接接線即可)。總閘數相近;當不需要 J≠K 時,JK 可以省下一些閘。

Gate count comparison: JK implementation uses same XOR structure but expressed as J/K. D FF version needs explicit XOR gates; JK version has simpler excitation equations (J₀=K₀=1 is trivially wired). Total gates similar; JK can save gates when J≠K not needed.

ゲート数の比較:JK 実装も同じ XOR 構造を使うが、それを J/K の形で表す。D FF 版には明示的な XOR ゲートが要る。JK 版は励振方程式がより簡単である(J₀=K₀=1 は単に配線するだけでよい)。総ゲート数は同程度だが、J≠K が不要な場合には JK でゲートを節約できる。

6.40

當 w₁=w₂ 連續成立四個週期時輸出 1。狀態記錄連續相等的週期數:0,1,2,3,4(輸出)。

Output 1 when w₁=w₂ for four consecutive cycles. States track count of consecutive equal cycles: 0,1,2,3,4(output).

w₁=w₂ が 4 サイクル連続したときに 1 を出力する。状態は等しいサイクルが連続した回数 0,1,2,3,4(出力)を追跡する。

5 個狀態、2 個輸入。令 eq = (w₁ XNOR w₂)。

5 states, 2 inputs. Let eq = (w₁ XNOR w₂).

状態 5 個、入力 2 個。eq = (w₁ XNOR w₂) とおく。

S0 --eq=1--> S1, --eq=0--> S0
S1 --eq=1--> S2, --eq=0--> S0
S2 --eq=1--> S3, --eq=0--> S0
S3 --eq=1--> S4, --eq=0--> S0
S4 --eq=1--> S4, --eq=0--> S0

Moore 輸出:在 S4 時 z=1。需要 3 個 FF(⌈log₂5⌉=3)。注意到這個計數器只是在計算 eq=1 連續出現的週期數,即可據此化簡。

Moore output: z=1 in S4. Need 3 FFs (⌈log₂5⌉=3). Reduce by noting the counter simply counts eq=1 consecutive cycles.

Moore 出力:S4 で z=1 となる。FF は 3 個必要である(⌈log₂5⌉=3)。このカウンタが eq=1 の連続サイクル数を数えているだけだと気づけば、簡単化できる。

6.41

序列加法器 FSM:把兩串序列位元流 A、B 相加。狀態 = 進位。輸入:aᵢ、bᵢ。輸出:sᵢ = aᵢ⊕bᵢ⊕carry。

Serial adder FSM: Adds two serial bit streams A, B. State = carry. Inputs: aᵢ, bᵢ. Output: sᵢ = aᵢ⊕bᵢ⊕carry.

直列加算器の FSM:2 本の直列ビット列 A、B を加算する。状態は桁上げである。入力は aᵢ、bᵢ。出力は sᵢ = aᵢ⊕bᵢ⊕carry。

Moore 版本:2 個狀態(carry=0、carry=1)。但輸出 sᵢ 也必須取決於輸入,因此純 Moore 需要 4 個狀態。用 Mealy 較為自然。

Moore version: 2 states (carry=0, carry=1). Output sᵢ must depend on input too, so pure Moore would need 4 states. Mealy is more natural.

Moore 版:状態は 2 つ(carry=0、carry=1)。ただし出力 sᵢ は入力にも依存しなければならないので、純粋な Moore では 4 状態が必要になる。Mealy のほうが自然である。

Mealy 版本(2 個狀態):

Mealy version (2 states):

Mealy 版(状態 2 個):

進位Carry桁上げab下一個進位Next carry次の桁上げs (output)
00000
001/1001
01110
10001
101/1010
11111
6.42

把 Mealy FSM 轉換成 Moore FSM:

Converting Mealy FSM to Moore FSM:

Mealy FSM を Moore FSM に変換する:

  1. 對每一組會產生輸出 z 的 Mealy 狀態—輸入配對 (s, i),建立一個新的 Moore 狀態 s_z。
  2. For each Mealy state-input pair (s, i) that produces output z, create a new Moore state s_z.
  3. 出力 z を生じる Mealy の状態・入力の組 (s, i) ごとに、新しい Moore 状態 s_z を作る。
  4. 原本在輸入 i 之下通往 s 的每一條轉移,現在都改為通往 s_z;s_z 的輸出為 z。
  5. Any transition leading to s under input i now leads to s_z; s_z has output z.
  6. 入力 i のもとで s へ向かっていた遷移は、すべて s_z へ向かうようにする。s_z の出力は z である。
  7. s_z 對所有輸入的轉移,都與 Mealy 機器中 s 的轉移相同。
  8. Transitions from s_z for all inputs are the same as from s in the Mealy machine.
  9. s_z からの遷移は、すべての入力について Mealy 機械における s からの遷移と同じである。

結果:Moore FSM 的狀態數通常較多(每一種相異的(狀態, 輸出)組合各一個)。若 Mealy FSM 有 n 個狀態、2 種輸出,則 Moore FSM 最多可能有 2n 個狀態。

Result: Moore FSM typically has more states (one per unique (state, output) combination). If the Mealy FSM has n states and 2 outputs, the Moore FSM can have up to 2n states.

結果:Moore FSM は状態数が多くなるのがふつうである(相異なる(状態, 出力)の組合せごとに 1 つ)。Mealy FSM が n 状態で出力が 2 種類なら、Moore FSM の状態は最大 2n 個になり得る。

6.43

偵測 110 或 101(可重疊)。狀態記錄目前後綴與這兩種樣式的比對情形:

Detect 110 or 101 (overlapping). States track suffix matching either pattern:

110 または 101 を検出する(重なりを許す)。状態は、いずれかのパターンに一致する接尾部を追跡する:

S0: initial
S1: saw 1
S2: saw 11
S3: saw 10
S0 --1--> S1, --0--> S0
S1 --1--> S2, --0--> S3
S2 --1--> S2(output), --0--> S3(output for 110)
S3 --1--> S1(output for 101), --0--> S0

Moore 輸出:在樣式完成時所到達的狀態中 z=1。最少:4 個狀態。作法是另加一個輸出狀態,或把 Moore 輸出放在 S2(w=0) 與 S3(w=1) 上。

Moore output: z=1 in states reached when pattern completed. Minimal: 4 states. Output state added or Moore output on S2(w=0) and S3(w=1).

Moore 出力:パターンが完成したときに到達する状態で z=1 とする。最小で 4 状態。出力用の状態を 1 つ追加するか、S2(w=0) と S3(w=1) に Moore 出力を置く。

若用 Mealy:把輸出放在轉移 S2→(0) 與 S3→(1) 上。

For Mealy: output on transitions S2→(0) and S3→(1).

Mealy の場合:出力は遷移 S2→(0) と S3→(1) に置く。

6.13E

四個狀態 $A, B, C, D$。狀態 $A$ 為閒置;$w=1$ 時前往 $B$,接著無條件依序到 $C$、$D$,再回到 $A$。輸出(Moore):$B$:$R2_{out}=R3_{in}=1$(把 R2 複製到 R3);$C$:$R1_{out}=R2_{in}=1$(R1→R2);$D$:$R3_{out}=R1_{in}=Done=1$(R3→R1)。狀態指派 $A=00, B=01, C=10, D=11$。以 $y_2 y_1$ 作為狀態位元:$Y_1 = w\overline{y_2}\overline{y_1} + y_2$、$Y_2 = y_1 + y_2\overline{y_1}$(其餘類推)。這四個週期的序列以 R3 作為暫存空間完成交換。

Four states $A, B, C, D$. State $A$ idles; on $w=1$ go to $B$, then $C$, then $D$ unconditionally, then back to $A$. Outputs (Moore): $B$: $R2_{out}=R3_{in}=1$ (copy R2→R3); $C$: $R1_{out}=R2_{in}=1$ (R1→R2); $D$: $R3_{out}=R1_{in}=Done=1$ (R3→R1). State assignment $A=00, B=01, C=10, D=11$. With $y_2 y_1$ as state bits: $Y_1 = w\overline{y_2}\overline{y_1} + y_2$, $Y_2 = y_1 + y_2\overline{y_1}$ (and so on). The four-cycle sequence performs the swap via R3 as scratch.

状態は $A, B, C, D$ の 4 つ。状態 $A$ は待機で、$w=1$ で $B$ へ進み、続いて無条件に $C$、$D$ と進んで $A$ に戻る。出力(Moore):$B$ では $R2_{out}=R3_{in}=1$(R2 を R3 へ複写)、$C$ では $R1_{out}=R2_{in}=1$(R1→R2)、$D$ では $R3_{out}=R1_{in}=Done=1$(R3→R1)。状態割当ては $A=00, B=01, C=10, D=11$。$y_2 y_1$ を状態ビットとすると $Y_1 = w\overline{y_2}\overline{y_1} + y_2$、$Y_2 = y_1 + y_2\overline{y_1}$(以下同様)となる。この 4 サイクルの手順は、R3 を作業用に使って交換を行う。

resetAidleBR2out=R3in=1CR1out=R2in=1DR3out=R1in=Done=1w=0w=1

Moore 型 FSM:每個狀態都列出它所 assert 的控制訊號。「−」表示無條件轉移(忽略輸入)。

Moore-type FSM: each state lists the control signals it asserts. "−" = unconditional transition (input ignored).

Moore 型 FSM:各状態は、そこでアサートする制御信号を列挙している。「−」は無条件遷移(入力を無視)を表す。

Verilog(Moore;單一循序 always 區塊 + 組合輸出):

Verilog (Moore, single sequential always block + combinational outputs):

Verilog(Moore、順序 always ブロック 1 つ + 組合せ出力):

module swap_fsm (
  input  Clock, Resetn, w,
  output R1in, R1out, R2in, R2out, R3in, R3out, Done
);
  reg [1:0] y;
  parameter A = 2'b00, B = 2'b01, C = 2'b10, D = 2'b11;

  // single always: state register, async-low reset to A
  always @(posedge Clock or negedge Resetn) begin
    if (!Resetn) y <= A;
    else case (y)
      A:       y <= (w ? B : A);
      B:       y <= C;
      C:       y <= D;
      D:       y <= A;
      default: y <= A;
    endcase
  end

  // Moore outputs — pure functions of state
  assign R2out = (y == B), R3in  = (y == B);   // R3 <- R2
  assign R1out = (y == C), R2in  = (y == C);   // R2 <- R1
  assign R3out = (y == D), R1in  = (y == D);   // R1 <- old R2 (was in R3)
  assign Done  = (y == D);
endmodule

資料路徑外殼(n 位元暫存器 + 共用匯流排):上面的 FSM 只產生致能訊號;這裡是一個參數化的頂層模組,接上實際的 N 位元暫存器檔。寬度由 parameter N 控制(預設 8)。共用匯流排由 R*out 這些致能訊號多工選擇;R*in 這些致能訊號則決定下一個時脈邊緣由哪個暫存器載入匯流排上的值。

Datapath wrapper (n-bit registers + shared bus): the FSM above only generates the enables; here is a parameterized top module that hooks up an actual N-bit register file. Width is controlled by the parameter N (default 8). The shared bus is multiplexed by the R*out enables; the R*in enables select which register loads the bus on the next clock edge.

データパスのラッパ(n ビットレジスタ + 共有バス):上の FSM はイネーブルを生成するだけである。ここでは実際の N ビットレジスタファイルを接続する、パラメータ化したトップモジュールを示す。幅は parameter N(既定値 8)で決まる。共有バスは R*out のイネーブルで多重化され、R*in のイネーブルは次のクロックエッジでどのレジスタがバスを取り込むかを選ぶ。

module swap_top #(parameter N = 8) (
  input  Clock, Resetn, w,
  input  [N-1:0] init_R1, init_R2,   // initial values loaded on reset
  output [N-1:0] R1, R2, R3,
  output Done
);
  reg [N-1:0] r1, r2, r3;
  wire R1in, R1out, R2in, R2out, R3in, R3out;

  // shared bus: whichever register has *out asserted drives it
  wire [N-1:0] bus = R1out ? r1 :
                     R2out ? r2 :
                     R3out ? r3 : {N{1'b0}};

  always @(posedge Clock or negedge Resetn) begin
    if (!Resetn) begin
      r1 <= init_R1;
      r2 <= init_R2;
      r3 <= {N{1'b0}};
    end else begin
      if (R1in) r1 <= bus;
      if (R2in) r2 <= bus;
      if (R3in) r3 <= bus;
    end
  end

  assign R1 = r1;
  assign R2 = r2;
  assign R3 = r3;

  // controller from above
  swap_fsm ctrl (
    .Clock(Clock), .Resetn(Resetn), .w(w),
    .R1in(R1in),   .R1out(R1out),
    .R2in(R2in),   .R2out(R2out),
    .R3in(R3in),   .R3out(R3out),
    .Done(Done)
  );
endmodule

與寬度無關。這個 FSM 既不知道也不在乎 N 是多少 — 不論暫存器多寬,交換都需要 4 個時脈週期。要做單一位元的交換就把 N 設為 1,要做一個字組的交換就設為 32,依此類推。

Width-independence. The FSM doesn't know or care what N is — the swap takes 4 clock cycles regardless of register width. Set N to 1 for a single-bit swap, 32 for a word swap, etc.

幅に依存しない。FSM は N がいくつかを知らないし、気にもしない — レジスタ幅によらず交換には 4 クロックサイクルかかる。1 ビットの交換なら N を 1 に、ワード単位の交換なら 32 に設定すればよい。

6.14E

把 $C$ 與 $D$ 對調,即指派 $C=11, D=10$。重算下一狀態的卡諾圖:$Y_1$ 現在為了 $A\to B$ 需要 $w\overline{y_2}\overline{y_1}$,還得為 $B\to D$ 與 $C\to A$ 加上額外的項,而這些項不再能漂亮地合併。輸出式也變得更複雜。與原本直觀的指派相比,總閘輸入成本約增加 3 個輸入,可見狀態指派的選擇確實有影響。

Swapping $C$ and $D$ assigns $C=11, D=10$. Recompute next-state K-maps: $Y_1$ now requires $w\overline{y_2}\overline{y_1}$ for $A\to B$ and additional terms for $B\to D$ and $C\to A$ that no longer combine as nicely. Output expressions also become more complex. The total gate-input cost rises by ~3 inputs versus the straightforward assignment, illustrating that state-assignment choice matters.

$C$ と $D$ を入れ替えると $C=11, D=10$ という割当てになる。次状態のカルノー図を計算し直すと、$Y_1$ には $A\to B$ のための $w\overline{y_2}\overline{y_1}$ に加え、$B\to D$ と $C\to A$ のための項が必要になり、それらはもはやうまくまとまらない。出力式もより複雑になる。素直な割当てと比べてゲート入力数の総コストはおよそ 3 入力増えており、状態割当ての選び方が効くことを示している。

6.15E

One-hot:$y_1=A, y_2=B, y_3=C, y_4=D$。下一狀態:$Y_1 = (y_1\overline{w}) + y_4$、$Y_2 = w y_1$、$Y_3 = y_2$、$Y_4 = y_3$。輸出可直接取得:例如 $R1_{out} = y_3$、Done = $y_4$。每一條轉移就是一個乘積項。取捨:正反器較多(4 個對 2 個),但組合邏輯較簡單、速度也較快。

One-hot: $y_1=A, y_2=B, y_3=C, y_4=D$. Next-state: $Y_1 = (y_1\overline{w}) + y_4$, $Y_2 = w y_1$, $Y_3 = y_2$, $Y_4 = y_3$. Outputs come directly: e.g. $R1_{out} = y_3$, Done = $y_4$. Each transition is one product term. Trade-off: more flip-flops (4 vs 2), but simpler combinational logic and faster speed.

One-hot:$y_1=A, y_2=B, y_3=C, y_4=D$。次状態は $Y_1 = (y_1\overline{w}) + y_4$、$Y_2 = w y_1$、$Y_3 = y_2$、$Y_4 = y_3$。出力は直接得られる:たとえば $R1_{out} = y_3$、Done = $y_4$。各遷移がちょうど 1 つの積項になる。トレードオフ:フリップフロップは増える(4 個対 2 個)が、組合せ回路は簡単になり、速度も上がる。

reset A y₁=1, idle B y₂=1 R2out, R3in C y₃=1 R1out, R2in D y₄=1 R3out, R1in, Done w=0 w=1

One-hot 編碼:每個狀態各自擁有一個正反器;「−」表示無條件轉移(忽略輸入)。

One-hot encoding: each state owns one flip-flop; "−" = unconditional transition (input ignored).

One-hot 符号化:各状態が 1 個ずつフリップフロップを持つ。「−」は無条件遷移(入力を無視)を表す。

6.16E

Mealy 版本用 3 個狀態 $A, B, C$。在 $A$ 中,$w=1$ 時輸出 $R2_{out}=R3_{in}=1$ 並前往 $B$。在 $B$ 中輸出 $R1_{out}=R2_{in}=1$ 並前往 $C$。在 $C$ 中輸出 $R3_{out}=R1_{in}=Done=1$ 並回到 $A$。輸出隨轉移以組合邏輯產生(比 Moore 早一個時脈週期),因此省下一個週期。總計 3 個週期,而非 4 個。必須小心,別讓輸出在組合輸入變化時產生突波。

Mealy version uses 3 states $A, B, C$. In $A$, on $w=1$, output $R2_{out}=R3_{in}=1$ and go to $B$. In $B$, output $R1_{out}=R2_{in}=1$ and go to $C$. In $C$, output $R3_{out}=R1_{in}=Done=1$ and go to $A$. The output is generated combinationally with the transition (one clock cycle earlier than Moore), saving one cycle. Total: 3 cycles instead of 4. Care must be taken so outputs do not glitch on combinational input changes.

Mealy 版は $A, B, C$ の 3 状態を使う。$A$ では $w=1$ のとき $R2_{out}=R3_{in}=1$ を出力して $B$ へ進む。$B$ では $R1_{out}=R2_{in}=1$ を出力して $C$ へ、$C$ では $R3_{out}=R1_{in}=Done=1$ を出力して $A$ へ戻る。出力は遷移と同時に組合せ回路で生成されるので(Moore より 1 クロック早い)、1 サイクル節約できる。合計は 4 サイクルではなく 3 サイクルである。ただし、組合せ的な入力変化で出力がグリッチしないよう注意しなければならない。

6.17E
module swap_fsm(input Clock, Resetn, w, output R1in,R1out,R2in,R2out,R3in,R3out,Done);
  reg [1:0] y, Y;
  parameter A=2'b00, B=2'b01, C=2'b10, D=2'b11;
  always @(*) case (y)
    A: Y = w ? B : A;
    B: Y = C;
    C: Y = D;
    D: Y = A;
  endcase
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) y <= A; else y <= Y;
  assign R2out = (y==B), R3in = (y==B);
  assign R1out = (y==C), R2in = (y==C);
  assign R3out = (y==D), R1in = (y==D), Done = (y==D);
endmodule
6.18E

分割細化(先依輸出分類)。$P_1$:依輸出把狀態分開 → 例如 $\{S_1, S_3, S_5\}$(輸出 0)與 $\{S_2, S_4, S_6, S_7\}$(輸出 1)。$P_2$:再依每個狀態的轉移落到哪個 $P_1$ 區塊來細分。反覆數次後 $P_3 = P_4$,等價類形成 4 個狀態。縮減後的 FSM 有 4 個狀態,且 I/O 行為相同。

Partition refinement (output classes first). $P_1$: split states by output → e.g. $\{S_1, S_3, S_5\}$ (output 0) and $\{S_2, S_4, S_6, S_7\}$ (output 1). $P_2$: refine by where each state's transitions go (which $P_1$ block). After several iterations $P_3 = P_4$ and the equivalent classes form 4 states. The reduced FSM has 4 states with the same I/O behavior.

分割の細分化(まず出力によるクラス分け)。$P_1$:出力で状態を分ける → たとえば $\{S_1, S_3, S_5\}$(出力 0)と $\{S_2, S_4, S_6, S_7\}$(出力 1)。$P_2$:各状態の遷移がどの $P_1$ ブロックへ向かうかでさらに細分する。数回の反復で $P_3 = P_4$ となり、等価類は 4 状態をなす。縮小後の FSM は 4 状態で、入出力の動作は同じである。

6.19E

狀態記錄投入金額對 25 取模的累計值(含找零額度):$S_0=0$¢、$S_5, S_{10}, S_{15}, S_{20}, S_{25}$。輸入:五分幣($n$)、一角幣($d$)。轉移:$S_0$:n→$S_5$、d→$S_{10}$;$S_5$:n→$S_{10}$、d→$S_{15}$;$S_{10}$:n→$S_{15}$、d→$S_{20}$;$S_{15}$(出貨)→$S_0$;$S_{20}$(出貨 + 5¢ 額度)前往 $S_5$。套用分割程序,若 $S_{15}$ 與 $S_{20}$ 的行為相符就把它們合併 — 但它們並不相符(下一狀態不同),因此加入出貨邏輯後最少需要 5 個狀態。

States track cumulative deposit modulo 25 (with credit): $S_0=0$¢, $S_5, S_{10}, S_{15}, S_{20}, S_{25}$. Inputs: nickel ($n$), dime ($d$). Transitions: $S_0$: n→$S_5$, d→$S_{10}$; $S_5$: n→$S_{10}$, d→$S_{15}$; $S_{10}$: n→$S_{15}$, d→$S_{20}$; $S_{15}$ (dispense)→$S_0$; $S_{20}$ (dispense + 5¢ credit) goes to $S_5$. Apply partitioning to merge $S_{15}$ and $S_{20}$ if their behaviors match — they don't (different next states), so 5 states minimum after dispense logic added.

状態は投入金額の 25 を法とした累計(つり銭のクレジットを含む)を追跡する:$S_0=0$¢、$S_5, S_{10}, S_{15}, S_{20}, S_{25}$。入力は 5 セント硬貨($n$)と 10 セント硬貨($d$)である。遷移は $S_0$:n→$S_5$、d→$S_{10}$、$S_5$:n→$S_{10}$、d→$S_{15}$、$S_{10}$:n→$S_{15}$、d→$S_{20}$、$S_{15}$(払い出し)→$S_0$、$S_{20}$(払い出し + 5¢ のクレジット)は $S_5$ へ。分割手続きを適用し、$S_{15}$ と $S_{20}$ の動作が一致するなら併合する — 実際には一致しない(次状態が違う)ので、払い出しの論理を加えた後は最低 5 状態となる。

6.20E

四個未指定的項目可以設為 0 或 1,以達到最大的狀態合併。兩者都設為 0 時:分割會得到較粗的細化,把 7 個狀態合併到(例如)4 個。兩者都設為 1 時:合併方式不同,得到(例如)5 個狀態。確切的數目要看表格而定;重點在於,有策略地補完 don't-care 可以讓狀態數最少。

Four unspecified entries can be set to 0 or 1 to maximize state merging. With both = 0: partitioning yields a coarser refinement and merges 7 states down to (e.g.) 4. With both = 1: a different merging produces (e.g.) 5 states. The exact counts depend on the table; the lesson is that completing don't-cares strategically minimizes states.

未指定の 4 つの欄は 0 にも 1 にもでき、状態の併合が最大になるよう選べる。両方 0 とすると、分割はより粗い細分となり、7 状態が(たとえば)4 状態まで併合される。両方 1 とすると別の併合になり、(たとえば)5 状態となる。正確な個数は表による。要点は、don't-care を戦略的に埋めることで状態数を最小化できるということである。

6.21E

四個狀態 $00, 01, 10, 11$。對每一組 $(y_1, y_2, w)$ 計算 $Y_1 Y_2$:代入並製表。狀態轉移的軌跡為:$00 \xrightarrow{w=1} 10 \xrightarrow{w=1} 11 \xrightarrow{w=1} 11$(此時 $z=1$)。任何狀態下若 $w=0$,就回到 $00$ 或 $01$。序列偵測:連續三個 1 會把 FSM 帶到狀態 $11$,該處 $z=1$。因此這個 FSM 偵測的是樣式 111

Four states $00, 01, 10, 11$. Compute $Y_1 Y_2$ for each $(y_1, y_2, w)$: Substitute and tabulate. The state transitions trace: $00 \xrightarrow{w=1} 10 \xrightarrow{w=1} 11 \xrightarrow{w=1} 11$ (with $z=1$). On $w=0$ from any state, return to $00$ or $01$. Sequence detection: three consecutive 1s drive the FSM to state $11$ where $z=1$. Hence the FSM detects the pattern 111.

状態は $00, 01, 10, 11$ の 4 つ。$(y_1, y_2, w)$ の各組について $Y_1 Y_2$ を計算する:代入して表にする。状態遷移をたどると $00 \xrightarrow{w=1} 10 \xrightarrow{w=1} 11 \xrightarrow{w=1} 11$(このとき $z=1$)となる。どの状態でも $w=0$ なら $00$ か $01$ に戻る。系列検出:1 が 3 回続くと FSM は状態 $11$ に至り、そこで $z=1$ となる。したがってこの FSM はパターン 111 を検出する。

6.22E

激勵式 $J_1=w$、$K_1=\overline{w}+y_2$、$J_2=wy_1$、$K_2=\overline{w}$。由 JK 規則($Q^+=J\overline{Q}+\overline{K}Q$)算出下一狀態:$y_1^+ = w\overline{y_1} + (w\overline{y_2}) y_1$、$y_2^+ = wy_1\overline{y_2} + wy_2$。把四個狀態列成表。同樣的輸入序列 $w=111\dots$ 會產生 $00\to 10\to 11\to 11$,並在狀態 $11$ 時 $z=1$ — 與 Example 6.9 相同的三個 1 偵測器。

Excitation $J_1=w$, $K_1=\overline{w}+y_2$, $J_2=wy_1$, $K_2=\overline{w}$. Compute next-state from JK rules ($Q^+=J\overline{Q}+\overline{K}Q$): $y_1^+ = w\overline{y_1} + (w\overline{y_2}) y_1$, $y_2^+ = wy_1\overline{y_2} + wy_2$. Tabulate four states. The same input sequence $w=111\dots$ produces $00\to 10\to 11\to 11$ with $z=1$ in state $11$ — the same three-1s detector as Example 6.9.

励振式は $J_1=w$、$K_1=\overline{w}+y_2$、$J_2=wy_1$、$K_2=\overline{w}$。JK の規則($Q^+=J\overline{Q}+\overline{K}Q$)から次状態を求めると $y_1^+ = w\overline{y_1} + (w\overline{y_2}) y_1$、$y_2^+ = wy_1\overline{y_2} + wy_2$ となる。4 状態を表にする。同じ入力系列 $w=111\dots$ で $00\to 10\to 11\to 11$ となり、状態 $11$ で $z=1$ — Example 6.9 と同じ、1 が 3 つ続くことを検出する回路である。

6.23E

$Y_1^+ = D_1 = w(y_1+y_2)$。至於 T 正反器,$Y_2^+ = y_2 \oplus T_2$,其中 $T_2 = \overline{w}y_2 + wy_1\overline{y_2}$。建立激勵表:從 00 出發,$w=1\to 00, 10, 11, 11$…。輸出 $z = y_1 y_2$ 在狀態 11 時 assert。FSM 行為與 6.9 及 6.10 相同 — 連續三個 1 的偵測器。

$Y_1^+ = D_1 = w(y_1+y_2)$. $Y_2^+ = y_2 \oplus T_2$ for the T flip-flop, where $T_2 = \overline{w}y_2 + wy_1\overline{y_2}$. Build the excitation table: starting at 00, with $w=1\to 00, 10, 11, 11$… The output $z = y_1 y_2$ asserts in state 11. Same FSM behavior as 6.9 and 6.10 — three consecutive 1s detector.

$Y_1^+ = D_1 = w(y_1+y_2)$。T フリップフロップについては $Y_2^+ = y_2 \oplus T_2$ で、ここで $T_2 = \overline{w}y_2 + wy_1\overline{y_2}$ である。励振表を作る:00 から始めて $w=1\to 00, 10, 11, 11$…。出力 $z = y_1 y_2$ は状態 11 でアサートされる。FSM の動作は 6.9 や 6.10 と同じ — 1 が 3 つ続くことの検出器である。

6.24E

狀態:$A$(閒置)、$B$(剛看到 0)、$C$(已看到 00,輸出 $z=1$)、$D$(剛看到 1)、$E$(已看到 11,輸出 $z=1$)。轉移:$A$:0→$B$、1→$D$。$B$:0→$C$、1→$D$。$C$:0→$C$、1→$D$。$D$:0→$B$、1→$E$。$E$:0→$B$、1→$E$。在 $C$ 與 $E$ 時輸出 $z=1$。5 個狀態的狀態指派需要 3 個正反器。以卡諾圖推導下一狀態 $Y_3 Y_2 Y_1$。

States: $A$ (idle), $B$ (just saw 0), $C$ (saw 00, output $z=1$), $D$ (just saw 1), $E$ (saw 11, output $z=1$). Transitions: $A$: 0→$B$, 1→$D$. $B$: 0→$C$, 1→$D$. $C$: 0→$C$, 1→$D$. $D$: 0→$B$, 1→$E$. $E$: 0→$B$, 1→$E$. Output $z=1$ in $C$ and $E$. State assignment for 5 states needs 3 flip-flops. Derive $Y_3 Y_2 Y_1$ next-state from K-maps.

状態:$A$(待機)、$B$(0 を見た直後)、$C$(00 を見た、出力 $z=1$)、$D$(1 を見た直後)、$E$(11 を見た、出力 $z=1$)。遷移:$A$:0→$B$、1→$D$。$B$:0→$C$、1→$D$。$C$:0→$C$、1→$D$。$D$:0→$B$、1→$E$。$E$:0→$B$、1→$E$。出力 $z=1$ となるのは $C$ と $E$ である。5 状態の状態割当てにはフリップフロップが 3 個必要である。次状態 $Y_3 Y_2 Y_1$ はカルノー図から導く。

6.25E

FSM_1(偵測 11):狀態 $A_1$(閒置)、$B_1$(已看到 1)、$C_1$(已看到 11,$z_1=1$)。FSM_2(偵測 00):與之對稱。輸出 $z = z_1 + z_2$。每個 FSM 有 3 個狀態,合計 6 個狀態,但它們各自獨立運作,組合起來比單一的 5 狀態版本更乾淨。成本上的取捨要看輸入是否共用。

FSM_1 (detect 11): states $A_1$ (idle), $B_1$ (saw 1), $C_1$ (saw 11, $z_1=1$). FSM_2 (detect 00): mirror. Output $z = z_1 + z_2$. Each FSM has 3 states, total 6 states, but they run independently and combine more cleanly than the monolithic 5-state version. The cost trade-off depends on shared inputs.

FSM_1(11 の検出):状態は $A_1$(待機)、$B_1$(1 を見た)、$C_1$(11 を見た、$z_1=1$)。FSM_2(00 の検出)はその鏡像である。出力は $z = z_1 + z_2$。各 FSM は 3 状態で合計 6 状態になるが、互いに独立に動き、一体型の 5 状態版よりもきれいに組み合わさる。コストのトレードオフは入力を共有するかどうかによる。

6.26E

Mealy:3 個狀態 $A$(閒置)、$B$(剛看到 0)、$C$(剛看到 1)。$A$:0/0→$B$、1/0→$C$。$B$:0/1→$B$、1/0→$C$。$C$:0/0→$B$、1/1→$C$。輸出在使該對完成的那個輸入邊緣上 assert。用 2 個正反器 $y_1 y_2$:$Y_1 = w$、$Y_2 = \overline{w}y_2 + wy_1\dots$(視指派而定)、$z = wy_1 + \overline{w}y_2$(目前輸入與前一個相同時輸出為高)。

Mealy: 3 states $A$ (idle), $B$ (just saw 0), $C$ (just saw 1). $A$: 0/0→$B$, 1/0→$C$. $B$: 0/1→$B$, 1/0→$C$. $C$: 0/0→$B$, 1/1→$C$. Output asserts on the input edge that completes the pair. With 2 flip-flops $y_1 y_2$: $Y_1 = w$, $Y_2 = \overline{w}y_2 + wy_1\dots$ (assignment-dependent), $z = wy_1 + \overline{w}y_2$ (output high when current input matches the previous one).

Mealy:状態は $A$(待機)、$B$(0 を見た直後)、$C$(1 を見た直後)の 3 つ。$A$:0/0→$B$、1/0→$C$。$B$:0/1→$B$、1/0→$C$。$C$:0/0→$B$、1/1→$C$。出力は、対を完成させる入力のエッジでアサートされる。フリップフロップ 2 個 $y_1 y_2$ を使うと $Y_1 = w$、$Y_2 = \overline{w}y_2 + wy_1\dots$(割当てに依存)、$z = wy_1 + \overline{w}y_2$(現在の入力が 1 つ前と一致するとき出力が高)となる。

reset A idle B saw 0 C saw 1 0/0 1/0 1/0 0/0 0/1 1/1

Mealy FSM:$z=1$ 出現在轉移 $B \xrightarrow{0/1} B$ 與 $C \xrightarrow{1/1} C$ 上(目前輸入與前一個相同)。

Mealy FSM: $z=1$ fires on the transitions $B \xrightarrow{0/1} B$ and $C \xrightarrow{1/1} C$ (current input matches the previous one).

Mealy FSM:$z=1$ は遷移 $B \xrightarrow{0/1} B$ と $C \xrightarrow{1/1} C$ で立つ(現在の入力が 1 つ前と一致する場合)。

6.27E

對每一組現在狀態/下一狀態的轉移,JK 激勵值為:$00\to 0$:J=0, K=X;$0\to 1$:J=1, K=X;$1\to 0$:J=X, K=1;$1\to 1$:J=X, K=0。依指派後的表格為 $J_1, K_1, J_2, K_2, J_3, K_3$ 畫卡諾圖。由於有 X 格,所得的式子通常比 D-FF 的情形更簡單。課本解答顯示,與 D 實作相比輸入數約可減少 30%。

For each present-state/next-state transition, JK excitation is: $00\to 0$: J=0, K=X; $0\to 1$: J=1, K=X; $1\to 0$: J=X, K=1; $1\to 1$: J=X, K=0. Build K-maps for $J_1, K_1, J_2, K_2, J_3, K_3$ from the assigned table. Resulting expressions typically simpler than D-FF case because of the X cells. The book's solution shows a ~30% input-count reduction over D realization.

現在状態/次状態の各遷移について、JK の励振値は次のとおり:$00\to 0$:J=0, K=X、$0\to 1$:J=1, K=X、$1\to 0$:J=X, K=1、$1\to 1$:J=X, K=0。割当て済みの表から $J_1, K_1, J_2, K_2, J_3, K_3$ のカルノー図を作る。X のセルがあるため、得られる式はふつう D-FF の場合より簡単になる。教科書の解答では、D による実現に比べて入力数がおよそ 30% 減っている。

6.28E
module seq_moore(input Clock, Resetn, w, output reg z);
  reg [2:0] y, Y;
  parameter A=0, B=1, C=2, D=3, E=4;
  always @(*) case (y)
    A: Y = w ? D : B;
    B: Y = w ? D : C;
    C: Y = w ? D : C;
    D: Y = w ? E : B;
    E: Y = w ? E : B;
    default: Y = A;
  endcase
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) y <= A; else y <= Y;
  always @(*) z = (y == C) || (y == E);
endmodule
6.29E
module seq_mealy(input Clock, Resetn, w, output reg z);
  reg [1:0] y, Y;
  parameter A=0, B=1, C=2;
  always @(*) begin
    z = 0;
    case (y)
      A: if (w) Y = C; else Y = B;
      B: if (w) Y = C; else begin Y = B; z = 1; end
      C: if (w) begin Y = C; z = 1; end else Y = B;
      default: Y = A;
    endcase
  end
  always @(negedge Resetn, posedge Clock)
    if (!Resetn) y <= A; else y <= Y;
endmodule
6.30E

訊框:1 個起始位元(0)+ 7 個資料位元 + 1 個停止位元(1)= 9 個位元。狀態機共 11 個狀態:idle、start、$b_0\dots b_6$、stop、done。一個計數器輪流走過各個位元位置;每個時脈,輸出線都呈現存放該位元組之移位暫存器的下一個位元。停止位元之後 Done 會 assert。Verilog 使用一個可並列載入的移位暫存器,加上一個狀態 FSM 控制器。

Frame: 1 start bit (0) + 7 data bits + 1 stop bit (1) = 9 bits. State machine with 11 states: idle, start, $b_0\dots b_6$, stop, done. A counter cycles through bit positions; on each clock the output line presents the next bit of the shift register holding the byte. Done asserts after the stop bit. Verilog uses a parallel-load shift register and a state-FSM controller.

フレームは、スタートビット 1 個(0)+ データ 7 ビット + ストップビット 1 個(1)= 9 ビットである。ステートマシンは 11 状態:idle、start、$b_0\dots b_6$、stop、done。カウンタがビット位置を順に巡り、クロックごとに出力線へ、バイトを保持するシフトレジスタの次のビットを出す。ストップビットの後に Done がアサートされる。Verilog では並列ロード可能なシフトレジスタと、状態 FSM のコントローラを使う。

第 7 章 — 資料路徑與控制器Chapter 7 — Datapaths & Controllers第 7 章 — データパスとコントローラ
7.1

三態匯流排:多個驅動器共用一條線;同一時間只有一個經由 OE(output-enable)致能。全部關閉時匯流排浮接。佈線簡單,但需要小心控制;浮接的匯流排會拾取雜訊。

Tri-state bus: Multiple drivers share a wire; only one enabled at a time via OE (output-enable). Bus floats when all disabled. Simple wiring but requires careful control; floating bus can pick up noise.

トライステートバス:複数のドライバが 1 本の線を共有し、同時に有効になるのは OE(output-enable)で選ばれた 1 つだけである。すべて無効のときバスはフローティングになる。配線は簡単だが慎重な制御が要る。フローティングのバスはノイズを拾う。

以 MUX 為基礎的匯流排:由多工器從多個來源中選出一個;不需要三態緩衝器。邏輯較乾淨,也較容易對 FPGA 合成(FPGA 內部沒有三態繞線),但需要實體的 MUX 與選擇訊號。

Mux-based bus: A multiplexer selects one of several sources; no tri-state buffers needed. Cleaner logic, easier to synthesize for FPGAs (which have no tri-state internal routing), but requires a physical mux and select signals.

MUX 方式のバス:マルチプレクサが複数のソースから 1 つを選ぶので、トライステートバッファは要らない。論理はすっきりし、FPGA 向けの合成も容易である(FPGA の内部配線にトライステートはない)が、実体の MUX と選択信号が必要になる。

FPGA 偏好 MUX 方式;PCB 上的外部匯流排則常用三態。

FPGAs prefer mux-based; external PCB buses often use tri-state.

FPGA では MUX 方式が好まれ、PCB 上の外部バスではトライステートがよく使われる。

7.2

具有 4 個暫存器 R0–R3、ALU 與匯流排的簡易處理器資料路徑:

Simple processor datapath with 4 registers R0–R3, ALU, and bus:

レジスタ R0–R3 の 4 本、ALU、バスからなる簡単なプロセッサのデータパス:

Registers R0-R3 ──┐
                  ├──► MUX_A ──► ALU_A
                  └──► MUX_B ──► ALU_B
ALU: ADD/SUB/AND/OR with opcode input
ALU result ──► Result register ──► Write-back MUX ──► Rn
Control signals: RegSel_A[2], RegSel_B[2], ALUop[2],
                 WE (write enable), RegDest[2]

控制器 FSM 的順序為:擷取運算元 → 執行 ALU 運算 → 寫回目的暫存器。

The controller FSM sequences: fetch operands → execute ALU op → write back to destination register.

コントローラ FSM は次の順に進む:オペランドの取り出し → ALU 演算の実行 → 行き先レジスタへの書き戻し。

7.3

四個 8 位元數的算術平均:先求和 A+B+C+D(10 位元結果),再除以 4(右移 2 位)。

Arithmetic mean of four 8-bit numbers: sum A+B+C+D (10-bit result), then divide by 4 (right-shift 2).

8 ビットの数 4 個の算術平均:A+B+C+D を加算し(結果は 10 ビット)、4 で割る(2 ビット右シフト)。

ASM chart:
IDLE ──start──► LOAD: Sum:=0, cnt:=4, ptr:=0
ACCUM: Sum:=Sum+Data[ptr]; ptr:=ptr+1; cnt:=cnt-1
  ──(cnt≠0)──► ACCUM
  ──(cnt=0)──► COMPUTE: Mean:=Sum>>2
COMPUTE ──► DONE: output Mean; done:=1 ──► IDLE

資料路徑:10 位元累加器、4 元素記憶體或 4 個輸入埠、2 位元右移器、done 旗標。

Datapath: 10-bit accumulator, 4-element memory or 4 input ports, 2-bit right shifter, done flag.

データパス:10 ビットのアキュムレータ、4 要素のメモリまたは入力ポート 4 本、2 ビット右シフタ、done フラグ。

7.4

為何需要消除彈跳:機械開關會彈跳 1–20 ms,產生多次轉態。若不消除彈跳,按一次會被記錄成多個脈衝。

Why debouncing is needed: Mechanical switches bounce for 1–20 ms, generating multiple transitions. Without debouncing, a single press registers as multiple pulses.

チャタリング除去が必要な理由:機械式スイッチは 1–20 ms のあいだバウンドし、何度も遷移を起こす。除去しなければ、1 回の押下が複数のパルスとして数えられてしまう。

硬體做法:用 SR 閂鎖搭配 SPDT 開關的兩個位置;一旦 set/reset 之後,後續的彈跳就不再有作用。另一種做法:RC 低通濾波器 + 施密特觸發器。

Hardware approach: SR latch with two SPDT switch positions; once set/reset, further bounces have no effect. Alternatively: RC low-pass filter + Schmitt trigger.

ハードウェアによる方法:SPDT スイッチの 2 つの接点位置と SR ラッチを組み合わせる。いったん set/reset されれば、その後のバウンドは効かない。別法として RC ローパスフィルタ + シュミットトリガでもよい。

軟體做法:對開關取樣;若連續 N 次取樣值都穩定(例如以 1 ms 間隔取樣共 20 ms),就視為一次有效的按下。可在軟體或 HDL 中用計數器實作。

Software approach: Sample the switch; if value is stable for N consecutive samples (e.g., 20 ms at 1 ms intervals), accept it as a valid press. Implemented with a counter in software or HDL.

ソフトウェアによる方法:スイッチをサンプリングし、連続 N 回のサンプルで値が安定していれば(たとえば 1 ms 間隔で 20 ms 分)、有効な押下として受け付ける。カウンタを使ってソフトウェアまたは HDL で実装する。

7.5

時脈偏斜 (clock skew):時脈訊號到達不同正反器的時間差。成因為導線延遲與緩衝器延遲。

Clock skew: Difference in arrival time of the clock signal at different flip-flops. Caused by wire delays, buffer delays.

クロックスキュー:クロック信号が各フリップフロップに到達する時刻の差である。配線遅延やバッファ遅延によって生じる。

偏斜造成的 setup 違規:若目的端 FF 的時脈比來源端 FF 的時脈早到,有效週期時間就會縮短。限制條件:T_clk + t_skew_neg ≥ t_cQ + t_logic + t_su。

Setup violation due to skew: If the destination FF clock arrives earlier than the source FF clock, the effective cycle time is reduced. Constraint: T_clk + t_skew_neg ≥ t_cQ + t_logic + t_su.

スキューによる setup 違反:行き先 FF のクロックが送り元 FF のクロックより早く着くと、実効的なサイクル時間が短くなる。制約は T_clk + t_skew_neg ≥ t_cQ + t_logic + t_su である。

偏斜造成的 hold 違規:若目的端 FF 的時脈較晚到達,資料可能在被擷取前就已改變。限制條件:t_cQ + t_logic_min ≥ t_h + t_skew_pos。hold 違規無法靠降低時脈頻率解決 — 必須在資料路徑上加入緩衝器。

Hold violation due to skew: If destination FF clock arrives later, data may change before being captured. Constraint: t_cQ + t_logic_min ≥ t_h + t_skew_pos. Hold violations cannot be fixed by slowing the clock — they require adding buffers on the data path.

スキューによる hold 違反:行き先 FF のクロックが遅れて着くと、取り込まれる前にデータが変わってしまうおそれがある。制約は t_cQ + t_logic_min ≥ t_h + t_skew_pos である。hold 違反はクロックを遅くしても直らない — データ経路にバッファを追加する必要がある。

7.6

簡易處理器的微指令(水平式微碼):

Microinstructions for a simple processor (horizontal microcode):

簡単なプロセッサのマイクロ命令(水平型マイクロコード):

指令Instruction命令微運算Microoperationsマイクロ操作
Load Rn, MMAR←PC; PC←PC+1; MDR←Mem[MAR]; Rn←MDR
Move Rd, RsRd←Rs
Add Rd, RsT←Rd+Rs; Rd←T
Sub Rd, RsT←Rd−Rs; Rd←T(使用 2 補數加法器)T←Rd−Rs; Rd←T (using 2's complement adder)T←Rd−Rs; Rd←T(2 の補数加算器を使用)

每一條微指令都指定:來源暫存器、ALU 運算、目的暫存器、記憶體運算,以及下一個微位址。

Each microinstruction specifies: source register(s), ALU operation, destination register, memory operation, and next microaddress.

各マイクロ命令は、ソースレジスタ、ALU 演算、行き先レジスタ、メモリ操作、次のマイクロアドレスを指定する。

7.7

暫存器轉移層級 (RTL) 設計把數位系統描述成:由暫存器保存資料,並在每個時脈週期由組合邏輯在暫存器之間搬移資料。

Register Transfer Level (RTL) design describes a digital system as registers storing data and combinational logic transferring data between registers in each clock cycle.

レジスタ転送レベル (RTL) 設計は、デジタルシステムを、データを保持するレジスタと、クロックサイクルごとにレジスタ間でデータを転送する組合せ回路として記述する。

重點概念:暫存器保存狀態;資料運算以暫存器轉移來描述(例如 A ← B + C);控制器 FSM 決定每個週期發生哪些轉移;資料路徑則實作出執行這些運算的硬體。

Key concepts: registers hold state; data operations described as register transfers (e.g., A ← B + C); controller FSM determines which transfers occur each cycle; datapath implements the hardware to perform those operations.

要点:レジスタが状態を保持する。データ操作はレジスタ転送として記述する(たとえば A ← B + C)。コントローラ FSM が各サイクルでどの転送を行うかを決める。データパスはそれらの演算を実行するハードウェアを実現する。

RTL 抽象層次介於演算法層級與閘級之間 — 夠高,讓合成工具能夠最佳化;也夠細,足以精確指定硬體行為。

RTL abstraction sits between algorithmic level and gate level — high enough for synthesis tools to optimize, detailed enough to specify hardware behavior precisely.

RTL の抽象度はアルゴリズムレベルとゲートレベルの中間にある — 合成ツールが最適化できるだけ高く、ハードウェアの動作を正確に指定できるだけ詳しい。

7.8

以歐幾里得演算法求 GCD:GCD(A,B) = GCD(B, A mod B)。在硬體上改用重複相減:GCD(A,B):當 A≠B 時,若 A>B 則 A←A−B,否則 B←B−A。

GCD using Euclidean algorithm: GCD(A,B) = GCD(B, A mod B). In hardware use repeated subtraction: GCD(A,B): while A≠B, if A>B then A←A−B else B←B−A.

ユークリッドの互除法による GCD:GCD(A,B) = GCD(B, A mod B)。ハードウェアでは繰り返し減算を使う:GCD(A,B):A≠B のあいだ、A>B なら A←A−B、そうでなければ B←B−A とする。

ASM chart:
IDLE ──start──► LOAD: A:=a, B:=b
TEST: if A==B → DONE: gcd:=A
      if A>B → SUBA: A:=A-B → TEST
      else → SUBB: B:=B-A → TEST

資料路徑:兩個暫存器 A、B;減法器;比較器。最壞情況的週期數:O(max(a,b))。

Datapath: two registers A, B; subtractor; comparator. Cycles for worst case: O(max(a,b)).

データパス:レジスタ A、B の 2 本、減算器、比較器。最悪の場合のサイクル数は O(max(a,b)) である。

7.9
module counter_param #(parameter N=8) (
    input              clk, rst, en, load,
    input  [N-1:0]     d,
    output reg [N-1:0] q
);
    always @(posedge clk or posedge rst) begin
        if (rst)       q <= {N{1'b0}};
        else if (load) q <= d;
        else if (en)   q <= q + 1'b1;
    end
endmodule
7.10

一個 ASM 區塊由三種元素構成:

An ASM block consists of three elements:

ASM ブロックは 3 つの要素から成る:

  1. 狀態框(矩形):代表 FSM 的一個狀態。框內寫狀態名稱以及所有 Moore(無條件)輸出。在一個時脈週期內執行。
  2. State box (rectangle): Represents one state of the FSM. Contains the state name and any Moore (unconditional) outputs. Executes in one clock cycle.
  3. 状態ボックス(長方形):FSM の 1 つの状態を表す。状態名と、Moore 型(無条件)の出力を書く。1 クロックサイクルで実行される。
  4. 判斷框(菱形):測試一個條件(輸入或狀態訊號)。有兩條出口路徑(Yes/No 或 1/0)。不消耗時脈週期 — 純組合邏輯。
  5. Decision box (diamond): Tests a condition (input or status signal). Has two exit paths (Yes/No or 1/0). Does not consume clock cycles — purely combinational.
  6. 判定ボックス(ひし形):条件(入力または状態信号)を判定する。出口は 2 本(Yes/No あるいは 1/0)である。クロックサイクルを消費しない — 純粋な組合せ回路である。
  7. 條件輸出框(橢圓/圓角矩形):框內是 Mealy 型輸出,只有在對應的判斷條件成立時才 assert。同樣是組合邏輯(不額外耗用時脈週期)。
  8. Conditional output box (oval/rounded rectangle): Contains Mealy-type outputs that are asserted only when the associated decision condition is true. Also combinational (no additional clock cycle).
  9. 条件出力ボックス(楕円/角丸長方形):対応する判定条件が真のときだけアサートされる Mealy 型の出力を書く。これも組合せ回路である(クロックサイクルは増えない)。
7.11
module bit_counter (
    input        clk, rst, start,
    input  [7:0] data,
    output reg [3:0] count,
    output reg done
);
    reg [7:0] sr;
    reg [2:0] cnt;
    reg [1:0] state; // 0=IDLE,1=LOAD,2=COUNT,3=DONE
    always @(posedge clk or posedge rst) begin
        if (rst) begin state<=0; done<=0; count<=0; end
        else case (state)
            0: if (start) begin sr<=data; cnt<=0; count<=0; state<=2; end
            2: begin
                   count <= count + sr[0];
                   sr <= sr >> 1;
                   cnt <= cnt + 1;
                   if (cnt==7) begin done<=1; state<=3; end
               end
            3: begin done<=0; state<=0; end
        endcase
    end
endmodule
7.12

移位相加乘法器的資料路徑:

Shift-and-add multiplier datapath:

シフト加算方式の乗算器のデータパス:

  • 暫存器 A(8 位元):累加器,初始化為 0。
  • Register A (8-bit): accumulator, initialized to 0.
  • レジスタ A(8 ビット):アキュムレータ。0 に初期化する。
  • 暫存器 Q(4 位元):乘數,載入 B。
  • Register Q (4-bit): multiplier, loaded with B.
  • レジスタ Q(4 ビット):乗数。B を読み込む。
  • 暫存器 M(4 位元):被乘數 A。
  • Register M (4-bit): multiplicand A.
  • レジスタ M(4 ビット):被乗数 A。
  • 移位暫存器:A:Q 每個週期右移 1 位元。
  • Shift register: A:Q shifted right 1 bit each cycle.
  • シフトレジスタ:A:Q をサイクルごとに 1 ビット右へシフトする。
  • Adder: A + M when Q[0]=1.

ASM 圖:INIT 狀態 → LOAD A:=0, Q:=B, cnt:=4;LOOP:若 Q[0]=1 則 A:=A+M;將 A:Q 右移;cnt:=cnt−1;若 cnt=0 → DONE,否則 → LOOP。

ASM chart: INIT state → LOAD A:=0, Q:=B, cnt:=4; LOOP: if Q[0]=1 then A:=A+M; shift A:Q right; cnt:=cnt−1; if cnt=0 → DONE else → LOOP.

ASM チャート:INIT 状態 → LOAD A:=0, Q:=B, cnt:=4。LOOP:Q[0]=1 なら A:=A+M、A:Q を右へシフト、cnt:=cnt−1、cnt=0 なら → DONE、そうでなければ → LOOP。

經過 4 次迭代後,乘積 = A:Q。

Product = A:Q after 4 iterations.

4 回の繰り返しののち、積 = A:Q となる。

7.18

系統:讀入八個 4 位元數值、加以儲存,並計算總和與平均。

System: read eight 4-bit values, store them, compute sum and average.

システム:4 ビットの値を 8 個読み込んで保存し、合計と平均を求める。

Datapath: 8×4-bit memory (or shift reg), 7-bit accumulator, 3-bit counter
Controller ASM:
IDLE ──start──► INIT: acc:=0, cnt:=0
READ: store data[cnt]; acc:=acc+data[cnt]; cnt:=cnt+1
  ──(cnt<8)──► READ
  ──(cnt=8)──► COMPUTE: sum:=acc; avg:=acc>>3 (divide by 8)
DONE: output sum, avg; done:=1 ──► IDLE

平均 = sum/8,以 3 位元右移實作(若是 8 的倍數則為精確值,否則會被截斷)。

Average = sum/8 implemented as 3-bit right shift (exact for multiples of 8, truncated otherwise).

平均は sum/8 であり、3 ビット右シフトで実装する(8 の倍数なら正確、それ以外は切り捨てとなる)。

7.19
module tristate_bus (
    input      [7:0] data_in,
    input            oe,       // output enable
    output     [7:0] bus
);
    assign bus = oe ? data_in : 8'bz;
endmodule

oe=1 時,以 data_in 驅動匯流排。當 oe=0 時,匯流排為高阻抗 (Z)。只要同一時間僅有一個模組的 oe=1,多個這樣的模組就可以共用同一條匯流排線。

When oe=1, drives bus with data_in. When oe=0, bus is high-impedance (Z). Multiple such modules can share the same bus wire provided only one has oe=1 at a time.

oe=1 のとき data_in でバスを駆動する。oe=0 のときバスはハイインピーダンス (Z) になる。同時に oe=1 となるモジュールが 1 つだけであれば、このようなモジュールを複数、同じバス線に接続して共有できる。

7.20

把三個 4 位元數 A、B、C 排成 X≤Y≤Z 的排序網路:

Sorting network for three 4-bit numbers A, B, C into sorted order X≤Y≤Z:

4 ビットの数 A、B、C の 3 個を X≤Y≤Z の順に並べるソーティングネットワーク:

Step 1: Compare-swap (A,B): if A>B, swap → ensures min(A,B) in A
Step 2: Compare-swap (B,C): if B>C, swap → ensures max in C (= Z)
Step 3: Compare-swap (A,B): if A>B, swap → ensures A≤B (= X≤Y)

總共 3 個比較–交換元件。每個比較器是一個 4 位元大小比較器,每個輸出各配一個 4 位元 2 對 1 MUX。全部為組合邏輯,深度 = 3 層比較器。

3 compare-swap elements total. Each comparator is a 4-bit magnitude comparator with a 4-bit 2-to-1 mux for each output. Fully combinational, depth = 3 comparator levels.

比較・交換素子は全部で 3 個である。各比較器は 4 ビットの大小比較器で、出力ごとに 4 ビットの 2-to-1 MUX を伴う。全体が組合せ回路であり、深さは比較器 3 段である。

7.21

ASM 中的 Moore:輸出寫在狀態框(矩形)之內。不論輸入為何,輸出在整個時脈週期都有效。例如:狀態 S2 的框內寫著「z=1」。

Moore in ASM: Outputs are listed inside the state box (rectangle). Output active for the entire clock cycle regardless of input. Example: state S2 box contains "z=1".

ASM における Moore:出力は状態ボックス(長方形)の中に書く。入力によらず、出力はクロックサイクル全体にわたって有効である。例:状態 S2 のボックスに「z=1」と書く。

ASM 中的 Mealy:輸出寫在弧上、緊鄰判斷菱形的橢圓形條件輸出框裡。輸出同時取決於狀態與輸入。例如:在 w=1 時由 S1 出發的那條弧上,有一個橢圓框寫著「z=1」。

Mealy in ASM: Outputs are listed in oval conditional output boxes on arcs, adjacent to the decision diamond. Output is conditional on both state and input. Example: on the arc from S1 when w=1, an oval box contains "z=1".

ASM における Mealy:出力は、判定のひし形に隣接する枝の上の楕円形の条件出力ボックスに書く。出力は状態と入力の両方に依存する。例:w=1 のときに S1 から出る枝の上の楕円ボックスに「z=1」と書く。

兩種表示法都維持「每個 ASM 區塊一個時脈」的時序關係。

Both representations preserve the one-clock-per-ASM-block timing relationship.

どちらの表現でも、ASM ブロック 1 つにつき 1 クロックというタイミング関係は保たれる。

7.22

同步器電路:兩個串接的 D 正反器,由目的時脈域驅動。第一個 FF 擷取非同步輸入(可能進入亞穩態);第二個 FF 在整整一個時脈週期之後才取樣第一個 FF 的輸出 — 到那時第一個 FF 幾乎必然已經收斂。

Synchronizer circuit: Two cascaded D flip-flops clocked by the destination domain. The first FF captures the asynchronous input (may go metastable); the second FF samples the first FF's output after a full clock period — by which time the first FF has almost certainly resolved.

同期化回路:行き先クロックドメインで駆動される D フリップフロップ 2 段の縦続接続である。1 段目の FF が非同期入力を取り込み(準安定状態になり得る)、2 段目の FF はクロック 1 周期後に 1 段目の出力をサンプルする — その頃には 1 段目はほぼ確実に収束している。

為何單一個 FF 不夠:當下一級邏輯取樣時,第一個 FF 的輸出可能仍處於亞穩態(尚未收斂成有效的 0 或 1),於是把無效值傳播出去。加上第二個 FF,就給了第一個 FF 整整一個時脈週期去化解亞穩態,使失效機率呈指數下降。

Why a single FF is insufficient: The first FF's output may still be metastable (not fully resolved to a valid 0 or 1) when the next logic stage samples it, propagating an invalid value. Adding a second FF gives the first FF a full clock period to resolve its metastable state, reducing the probability of failure exponentially.

FF が 1 段では足りない理由:次段の論理がサンプルする時点で 1 段目の FF の出力がまだ準安定(有効な 0 か 1 に収束しきっていない)かもしれず、無効な値がそのまま伝播してしまう。2 段目の FF を加えれば、1 段目は準安定状態を解消するのにクロック 1 周期を丸ごと使えるので、失敗確率は指数関数的に下がる。

7.23

重複相減除法:商 Q=0;當被除數 ≥ 除數時:被除數−=除數,Q++。

Repeated-subtraction division: quotient Q=0; while dividend ≥ divisor: dividend−=divisor, Q++.

繰り返し減算による除算:商 Q=0 とし、被除数 ≥ 除数のあいだ、被除数−=除数、Q++ を繰り返す。

Pseudo-code:
  Q := 0
  R := dividend  // 255
  D := divisor   // 7
  while R >= D:
      R := R - D
      Q := Q + 1
  // result: Q=36, R=3 (255 = 36×7 + 3)

255÷7 的週期數:商 = 36,因此迴圈執行 36 次,再加上初始設定 = 37 個時脈週期(36 次相減 + 最後一次比較)。在硬體上,每次相減耗用 1 個時脈週期。

Cycles for 255÷7: quotient = 36, so loop executes 36 times plus setup = 37 clock cycles (36 subtractions + final comparison). In hardware, each subtraction takes 1 clock cycle.

255÷7 のサイクル数:商は 36 なので、ループは 36 回 実行され、初期設定を加えて 37 クロックサイクル となる(減算 36 回 + 最後の比較)。ハードウェアでは減算 1 回につき 1 クロックサイクルかかる。

7.24

移位相加乘法器的週期數 = 乘數的位元數:

Shift-and-add multiplier cycles = number of bits in multiplier:

シフト・加算方式の乗算器のサイクル数 = 乗数のビット数:

4 位元乘法器:4 次疊代 + 1 個初始化週期 + 1 個 done 週期 = 4 個時脈週期(不計 load/done)。

4-bit multiplier: 4 iterations + 1 cycle for initialization + 1 cycle for done = 4 clock cycles (excluding load/done).

4 ビット乗算器:反復 4 回 + 初期化 1 サイクル + done 1 サイクル = 4 クロックサイクル(load/done を除く)。

8 位元乘法器:移位相加迴圈需要 8 個時脈週期

8-bit multiplier: 8 clock cycles for the shift-and-add loop.

8 ビット乗算器:シフト・加算のループに 8 クロックサイクル かかる。

一般而言:n 位元 × n 位元的乘法器,在循序的移位相加演算法下需要 n 個時脈週期。組合式(陣列)乘法器不需要任何時脈週期,但會用掉 O(n²) 個閘。

Generally: n-bit × n-bit multiplier requires n clock cycles for the sequential shift-and-add algorithm. A combinational (array) multiplier requires 0 clock cycles but uses O(n²) gates.

一般に、n ビット × n ビットの乗算器は、逐次のシフト・加算アルゴリズムでは n クロックサイクル を要する。組合せ回路(アレイ)乗算器はクロックサイクルを 0 で済ませるが、O(n²) 個のゲートを使う。

7.25

以 SR 閂鎖搭配 SPDT 開關與提升電阻構成的消除彈跳電路:

Debouncing circuit using SR latch with SPDT switch and pull-up resistors:

SR ラッチに SPDT スイッチとプルアップ抵抗を組み合わせたチャタリング除去回路:

Vcc
 |
R1 (pull-up)
 |──────── S input of SR latch
 |   ← switch common
R2 (pull-up)
 |──────── R input of SR latch
GND

當開關撥到 S 位置:S 線接地 → SR 閂鎖被 Set。S 側的彈跳只是重複施加 Set — 沒有作用(已經被 set)。當開關撥到 R:R 線接地 → Reset。結果:不論接點如何彈跳,Q 輸出在每次撥動開關時都只乾淨地變化一次。

When switch moves to S position: S line is grounded → SR latch Set. Bounces on S side re-apply Set — no effect (already set). When switch moves to R: R line grounded → Reset. Result: Q output changes cleanly once per switch throw, regardless of bouncing contacts.

スイッチが S 側に入ると、S 線が接地されて SR ラッチが Set される。S 側のバウンドは Set をかけ直すだけで効果はない(すでに set 済みである)。R 側に入ると R 線が接地されて Reset される。結果として、接点がバウンドしても Q 出力はスイッチ 1 回の切り替えにつき 1 回きれいに変化する。

7.26

時脈分佈的難處:長導線會為不同的 FF 帶來不一樣的延遲(時脈偏斜)。偏斜會造成 setup/hold 違規。

Clock distribution challenges: Long interconnects introduce varying delays to different FFs (clock skew). Skew causes setup/hold violations.

クロック分配の難しさ:長い配線は FF ごとに異なる遅延をもたらす(クロックスキュー)。スキューは setup/hold 違反を引き起こす。

降低時脈偏移的技巧:

Techniques to minimize skew:

スキューを最小化する手法:

  • 時脈樹合成 (CTS):由 CAD 工具平衡時脈樹,使所有葉端 FF 的時脈接腳看到相同的延遲。採 H 樹或平衡二元樹拓撲。
  • Clock tree synthesis (CTS): CAD tool balances the clock tree so all leaf FF clock pins see equal delay. H-tree or balanced binary tree topology.
  • クロックツリー合成 (CTS):CAD ツールがクロックツリーをバランスさせ、末端の FF のクロックピンがすべて等しい遅延になるようにする。H ツリーや平衡二分木のトポロジを用いる。
  • 時脈緩衝器:在每一層對稱地擺放相同驅動能力的緩衝器。
  • Clock buffers: Symmetric placement of equal-strength buffers at each level.
  • クロックバッファ:各段に同じ駆動能力のバッファを対称に配置する。
  • 低偏斜時脈網路:FPGA 具備專用的全域時脈繞線,到所有 CLB 的延遲都經過匹配。
  • Low-skew clock networks: FPGAs have dedicated global clock routing with matched delays to all CLBs.
  • 低スキュークロック網:FPGA には専用のグローバルクロック配線があり、すべての CLB への遅延が揃えてある。
  • 時脈域:限制每個同步域的規模;在跨域處使用同步器。
  • Clock domains: Limit the size of each synchronous domain; use synchronizers at domain crossings.
  • クロックドメイン:各同期ドメインの規模を抑え、ドメイン境界では同期化回路を使う。
  • 降低時脈負載:避免時脈網路上過大的扇出;以時脈致能取代閘控時脈。
  • Minimize clock loading: Avoid excessive fan-out on clock net; use clock enable instead of gated clocks.
  • クロック負荷を減らす:クロック網の過大なファンアウトを避け、ゲーテッドクロックの代わりにクロックイネーブルを使う。
7.27

回復式除法器:8 位元 ÷ 4 位元。

Restoring divider: 8-bit ÷ 4-bit.

復元型除算器:8 ビット ÷ 4 ビット。

資料路徑:8 位元的部分餘數暫存器 P、4 位元的除數 D。

Datapath: 8-bit partial remainder register P, 4-bit divisor D.

データパス:8 ビットの部分剰余レジスタ P、4 ビットの除数 D。

每一步:P_shifted = P 左移 1 位(帶入下一個被除數位元);試減 P_trial = P_shifted − D;若 P_trial ≥ 0:商位元 = 1,P = P_trial;否則:商位元 = 0,P 還原(P 維持不變)。

Each step: P_shifted = P left-shifted by 1 (bring in next dividend bit); attempt subtraction P_trial = P_shifted − D; if P_trial ≥ 0: quotient bit = 1, P = P_trial; else: quotient bit = 0, P restored (P remains).

各ステップ:P_shifted = P を 1 ビット左シフト(次の被除数ビットを取り込む)、試し減算 P_trial = P_shifted − D、P_trial ≥ 0 なら商ビット = 1 で P = P_trial、そうでなければ商ビット = 0 で P を復元(P はそのまま)。

ASM 圖:INIT(把被除數載入 P[7:0]、除數載入除數暫存器,cnt=4)→ SHIFT(P=P<<1)→ SUBTRACT(P_trial=P−D)→ 判斷(P_trial[MSB]=0 → 商位元=1,P=P_trial,否則位元=0)→ cnt−1 → 若 cnt≠0 則重複 → DONE。

ASM chart: INIT(load dividend into P[7:0], D into divisor reg, cnt=4) → SHIFT(P=P<<1) → SUBTRACT(P_trial=P−D) → decision(P_trial[MSB]=0 → quotient bit=1, P=P_trial else bit=0) → cnt−1 → if cnt≠0 repeat → DONE.

ASM チャート:INIT(被除数を P[7:0] に、除数を除数レジスタにロード、cnt=4)→ SHIFT(P=P<<1)→ SUBTRACT(P_trial=P−D)→ 判定(P_trial[MSB]=0 なら商ビット=1、P=P_trial、そうでなければビット=0)→ cnt−1 → cnt≠0 なら繰り返し → DONE。

7.28
module multiplier (
    input        clk, rst, start,
    input  [3:0] A, B,
    output reg [7:0] product,
    output reg done
);
    reg [7:0] acc; reg [3:0] mplier; reg [2:0] cnt;
    always @(posedge clk or posedge rst) begin
        if (rst) begin done<=0; acc<=0; end
        else if (start) begin
            acc<=0; mplier<=B; cnt<=4; done<=0;
        end else if (cnt>0) begin
            if (mplier[0]) acc <= acc + {4'b0,A};
            mplier <= mplier>>1; acc[7:1]<=acc[6:0]; // shift
            // actually: {acc,mplier} >>= 1 with add to upper half
            cnt <= cnt-1;
            if (cnt==1) begin product<=acc+(mplier[0]?{4'b0,A}:0); done<=1; end
        end
    end
endmodule
// Testbench: 13*11=143
// A=4'd13, B=4'd11; expect product=8'd143
7.29

對於有號數(2 補數)乘法:

For signed (2's complement) multiplication:

符号付き(2 の補数)乗算の場合:

  • Baugh-Wooley 或 Booth 演算法可直接處理有號數乘法。
  • The Baugh-Wooley or Booth algorithm handles signed multiplication directly.
  • Baugh-Wooley 法や Booth のアルゴリズムは符号付き乗算を直接扱える。
  • 簡單的修改:把兩個運算元的 MSB 視為權重 −2^(n−1) 的符號位元。
  • Simple modification: treat the MSB of both operands as sign bits with weight −2^(n−1).
  • 簡単な修正:両オペランドの MSB を重み −2^(n−1) の符号ビットとして扱う。
  • Booth 編碼:對乘數重新編碼以減少部分積的數量;並自動處理符號。
  • Booth encoding: recode the multiplier to reduce the number of partial products; handles sign automatically.
  • Booth 符号化:乗数を再符号化して部分積の個数を減らす。符号は自動的に処理される。
  • 對於移位相加法:以算術(符號延伸)右移取代邏輯右移;若乘數的 MSB 為 1,則將最後一個部分積取負。
  • For shift-and-add: use arithmetic (sign-extending) right shift instead of logical shift; negate the last partial product if the MSB of the multiplier is 1.
  • シフト加算方式では、論理右シフトではなく算術(符号拡張)右シフトを使う。乗数の MSB が 1 なら最後の部分積を負にする。
7.30

UART 傳送器:送出 8 位元資料,並附上起始位元 (0) 與停止位元 (1)。

UART transmitter: sends 8-bit data with start (0) and stop (1) bits.

UART 送信器:8 ビットのデータを、スタートビット (0) とストップビット (1) を付けて送出する。

ASM: IDLE(tx=1) ──send──► START: tx:=0; cnt:=8
BIT: tx:=data[0]; data:=data>>1; cnt:=cnt-1
  ──(cnt≠0)──► BIT
  ──(cnt=0)──► STOP: tx:=1 ──► IDLE
module uart_tx (
    input       clk, rst, send,
    input [7:0] data,
    output reg  tx, busy
);
    reg [7:0] sr; reg [3:0] cnt;
    reg [1:0] state;
    always @(posedge clk or posedge rst) begin
        if (rst) begin tx<=1; state<=0; busy<=0; end
        else case (state)
            0: if(send) begin sr<=data;cnt<=8;tx<=0;busy<=1;state<=1; end
            1: begin tx<=sr[0];sr<=sr>>1;cnt<=cnt-1;
                     if(cnt==1) state<=2; end
            2: begin tx<=1; busy<=0; state<=0; end
        endcase
    end
endmodule
7.13E

資料路徑:$n$ 位元移位暫存器保存輸入(MSB 移出)、$\lceil\log_2 n\rceil$ 位元的計數器累計 1 的個數,以及一個 $n$ 週期計數器。控制訊號:loadshiftincrdone。ASM 圖:狀態 $S_1$ 於 Start 時載入輸入。$S_2$ 迴圈 $n$ 次:移位暫存器;若移出的位元為 1 就讓計數加一;週期計數器減一。當週期計數器歸 0 時進入 $S_3$,由它 assert done。

Datapath: $n$-bit shift register holding the input (MSB shifts out), $\lceil\log_2 n\rceil$-bit counter accumulating ones, and an $n$-bit-cycle counter. Control signals: load, shift, incr, done. ASM chart: state $S_1$ loads input on Start. $S_2$ loops $n$ times: shift the register; if the shifted-out bit is 1, increment the count; decrement the cycle counter. When the cycle counter reaches 0, go to $S_3$ which asserts done.

データパス:入力を保持する $n$ ビットのシフトレジスタ(MSB から押し出す)、1 の個数を数える $\lceil\log_2 n\rceil$ ビットのカウンタ、そして $n$ サイクル用のカウンタ。制御信号は loadshiftincrdone。ASM チャート:状態 $S_1$ で Start により入力をロードする。$S_2$ は $n$ 回ループする:レジスタをシフトし、押し出されたビットが 1 ならカウントを増やし、サイクルカウンタを減らす。サイクルカウンタが 0 になったら $S_3$ へ移り、そこで done をアサートする。

module bitcount #(parameter n=8)(input Clk, Rst, Start, input [n-1:0] D,
                                  output reg [3:0] cnt, output reg done);
  reg [n-1:0] sr; reg [3:0] k; reg [1:0] s;
  always @(posedge Clk, posedge Rst)
    if (Rst) begin s<=0; cnt<=0; done<=0; end
    else case (s)
      0: if (Start) begin sr<=D; cnt<=0; k<=n; s<=1; done<=0; end
      1: if (k==0) begin done<=1; s<=2; end
         else begin if (sr[n-1]) cnt<=cnt+1; sr<=sr<<1; k<=k-1; end
      2: if (!Start) s<=0;
    endcase
endmodule

7.14E

資料路徑:$n$ 位元被乘數暫存器 $M$、$n$ 位元乘數暫存器(每週期移出 LSB)、初值為 0 的 $2n$ 位元累加器 $A$。ASM:狀態 $S_1$ 載入運算元。$S_2$(迴圈 $n$ 次):若乘數 LSB = 1,就把 $M$ 加到 $A$ 的高半部;把 $A$ 右移一位(取得下一個乘積位元);乘數右移。$n$ 次迭代後乘積便落在 $A$ 中。狀態 $S_3$ assert Done。

Datapath: $n$-bit multiplicand register $M$, $n$-bit multiplier register (LSB shifted out each cycle), $2n$-bit accumulator $A$ initially 0. ASM: in state $S_1$ load operands. In $S_2$ (looping $n$ times): if multiplier LSB = 1, add $M$ to upper half of $A$; right-shift $A$ by one (capturing the next product bit); shift multiplier right. After $n$ iterations the product sits in $A$. State $S_3$ asserts Done.

データパス:$n$ ビットの被乗数レジスタ $M$、$n$ ビットの乗数レジスタ(毎サイクル LSB を押し出す)、初期値 0 の $2n$ ビットのアキュムレータ $A$。ASM:状態 $S_1$ でオペランドをロードする。$S_2$($n$ 回ループ):乗数の LSB が 1 なら $M$ を $A$ の上半分に加え、$A$ を 1 ビット右シフトし(次の積のビットを取り込む)、乗数を右シフトする。$n$ 回の繰り返しののち、積は $A$ に入っている。状態 $S_3$ で Done をアサートする。

module shift_add #(parameter n=4)(input Clk, Rst, Start, input [n-1:0] M, Q,
                                    output reg [2*n-1:0] P, output reg done);
  reg [2*n-1:0] A; reg [n-1:0] q; reg [3:0] k; reg [1:0] s;
  always @(posedge Clk, posedge Rst)
    if (Rst) begin s<=0; done<=0; end
    else case (s)
      0: if (Start) begin A<=0; q<=Q; k<=n; s<=1; done<=0; end
      1: begin
          if (q[0]) A[2*n-1:n-1] <= A[2*n-1:n-1] + {1'b0,M};
          A <= A>>1; q <= q>>1; k<=k-1;
          if (k==1) begin s<=2; done<=1; P<=A; end
        end
    endcase
endmodule

7.15E

還原式除法器:$n$ 位元除數 $B$、$2n$ 位元暫存器 $\{R, Q\}$,被除數載入 $Q$,$R$ 初值為 0。ASM:每個週期把 $\{R, Q\}$ 左移 1 位(MSB 進入 $R$);由 $R$ 減去 $B$;若結果 $\ge 0$,就把 1 放進 $Q$ 的 LSB;否則還原(把 $B$ 加回去)並在 $Q$ 的 LSB 放 0。經過 $n$ 個週期後,$R$ 存放餘數,$Q$ 存放商。Verilog:以 case 為基礎的 FSM,包含移位、減法或還原的條件判斷,以及一個週期計數器。

Restoring divider: $n$-bit divisor $B$, $2n$-bit register $\{R, Q\}$ where dividend loaded into $Q$ and $R$ initially 0. ASM: each cycle, shift $\{R, Q\}$ left by 1 (MSB into $R$); subtract $B$ from $R$; if result $\ge 0$, place 1 into $Q$'s LSB; else restore (add $B$ back) and place 0 in $Q$'s LSB. After $n$ cycles, $R$ holds the remainder and $Q$ holds the quotient. Verilog: case-based FSM with shift, subtract-or-restore conditional, and a cycle counter.

復元型除算器:$n$ ビットの除数 $B$、$2n$ ビットのレジスタ $\{R, Q\}$(被除数を $Q$ にロードし、$R$ の初期値は 0)。ASM:毎サイクル $\{R, Q\}$ を 1 ビット左シフトし(MSB が $R$ へ入る)、$R$ から $B$ を引く。結果が $\ge 0$ なら $Q$ の LSB に 1 を入れ、そうでなければ復元し($B$ を足し戻し)$Q$ の LSB に 0 を入れる。$n$ サイクル後、$R$ に剰余、$Q$ に商が入る。Verilog:case 文による FSM に、シフト、減算または復元の条件分岐、そしてサイクルカウンタを組み合わせる。

7.16E

資料路徑:一個累加器(寬度 $n+\lceil\log_2 k\rceil$)、一個計算已接收輸入個數的計數器,以及一個除法器(若 $k$ 為 2 的冪次,則改用右移 $\log_2 k$ 位)。ASM:狀態 $S_1$ 等待 Start。$S_2$:每來一次輸入選通就把輸入加進累加器並讓計數器加一;迴圈直到計數器 = $k$。$S_3$:把累加器除以 $k$(若 $k$ 不是 2 的冪次就用除法器 FSM,是的話就右移)。$S_4$:assert Done,並以平均值為輸出。

Datapath: an accumulator (width $n+\lceil\log_2 k\rceil$), a counter for the number of inputs received, and a divider (or shift-by-$\log_2 k$ if $k$ is a power of 2). ASM: in state $S_1$ wait for Start. $S_2$: on each input strobe, add input to accumulator and increment counter; loop until counter = $k$. $S_3$: divide accumulator by $k$ (use the divider FSM if $k$ is not a power of 2, or right-shift if it is). $S_4$: assert Done with the mean as output.

データパス:アキュムレータ(幅 $n+\lceil\log_2 k\rceil$)、受け取った入力の個数を数えるカウンタ、そして除算器($k$ が 2 のべき乗なら $\log_2 k$ ビットの右シフトでよい)。ASM:状態 $S_1$ で Start を待つ。$S_2$:入力ストローブごとに入力をアキュムレータへ加え、カウンタを増やす。カウンタが $k$ になるまでループする。$S_3$:アキュムレータを $k$ で割る($k$ が 2 のべき乗でなければ除算器 FSM を使い、べき乗なら右シフトする)。$S_4$:平均値を出力として Done をアサートする。

7.17E

資料路徑:$k$ 筆 × $n$ 位元的暫存器檔,兩個讀取埠、一個寫入埠;以及一個比較器與交換機制。選擇排序 ASM:外層迴圈 $i = 0\dots k-2$;內層迴圈在 $RF[i\dots k-1]$ 中找出最小值的索引,並與 $RF[i]$ 交換。每次迭代用到兩個暫存器(目前最小值索引、目前掃描索引)與一個比較器。Verilog 以雙計數器的巢狀迴圈 FSM 實作,交換與否由比較器決定。總時間:$O(k^2)$ 個時脈週期。

Datapath: a register file of $k$ entries × $n$ bits, two read ports, one write port; a comparator and a swap mechanism. Selection-sort ASM: outer loop $i = 0\dots k-2$; inner loop finds index of minimum in $RF[i\dots k-1]$ and swaps with $RF[i]$. Each iteration uses two registers (current min index, current scan index) and a comparator. Verilog uses a 2-counter nested-loop FSM with comparator-driven conditional swaps. Total time: $O(k^2)$ clock cycles.

データパス:$k$ エントリ × $n$ ビットのレジスタファイル(読み出しポート 2、書き込みポート 1)、比較器、そして交換機構。選択ソートの ASM:外側ループは $i = 0\dots k-2$、内側ループは $RF[i\dots k-1]$ の最小値のインデックスを求めて $RF[i]$ と交換する。各繰り返しでレジスタを 2 つ(現在の最小インデックスと走査インデックス)と比較器を使う。Verilog では 2 つのカウンタによる入れ子ループの FSM を用い、比較器の結果で交換の有無を決める。総時間は $O(k^2)$ クロックサイクル。

第 8 章 — 最佳化Chapter 8 — Optimization第 8 章 — 最適化
8.1

f = x₁x₃ + x₁x₄ + x₂x₃ + x₂x₄ = x₃(x₁+x₂) + x₄(x₁+x₂) = (x₁+x₂)(x₃+x₄)

SOP 成本:4 個 AND 閘(2 輸入)+ 1 個 OR 閘(4 輸入)= 8 個閘輸入 + 5 個閘。

SOP cost: 4 AND gates (2-input) + 1 OR gate (4-input) = 8 gate inputs + 5 gates.

SOP のコスト:AND ゲート 4 個(2 入力)+ OR ゲート 1 個(4 入力)= ゲート入力 8 個 + ゲート 5 個。

因式分解形式的成本:2 個 OR 閘(2 輸入)+ 1 個 AND 閘(2 輸入)= 3 個閘、6 個閘輸入。

Factored form cost: 2 OR gates (2-input) + 1 AND gate (2-input) = 3 gates, 6 gate inputs.

因数分解形のコスト:OR ゲート 2 個(2 入力)+ AND ゲート 1 個(2 入力)= ゲート 3 個、ゲート入力 6 個。

節省:2 個閘;對這個函數而言,多層實作既便宜又快。

Saving: 2 gates, multilevel is cheaper and faster for this function.

節約:ゲート 2 個。この関数では多段構成のほうが安く、しかも速い。

因式分解恆等式 — 為何 $x_1x_3 + x_1x_4 + x_2x_3 + x_2x_4 = (x_1+x_2)(x_3+x_4)$?Factoring identity — why is $x_1x_3 + x_1x_4 + x_2x_3 + x_2x_4 = (x_1+x_2)(x_3+x_4)$?因数分解の恒等式 — なぜ $x_1x_3 + x_1x_4 + x_2x_3 + x_2x_4 = (x_1+x_2)(x_3+x_4)$ なのか?

純粹是分配律連用兩次。先把含 $x_3$ 的兩項與含 $x_4$ 的兩項分組:

It is simply the distributive law applied twice. First group the two terms containing $x_3$ and the two containing $x_4$:

分配則を 2 回使うだけである。まず $x_3$ を含む 2 項と $x_4$ を含む 2 項をまとめる:

$x_1x_3 + x_1x_4 + x_2x_3 + x_2x_4 = (x_1x_3 + x_2x_3) + (x_1x_4 + x_2x_4) = x_3(x_1+x_2) + x_4(x_1+x_2)$

此時 $(x_1+x_2)$ 是兩項共同因子,再提一次即得:

Now $(x_1+x_2)$ is a common factor of both terms; factoring it out once more gives:

すると $(x_1+x_2)$ が両項の共通因子になるので、もう一度くくり出せば次が得られる:

$= (x_1+x_2)(x_3+x_4)$

與一般代數的恆等式 $ac+ad+bc+bd = (a+b)(c+d)$ 相同;Boolean 代數的 $\cdot$ 對 $+$ 同樣具備分配律。

It is the same identity as $ac+ad+bc+bd = (a+b)(c+d)$ in ordinary algebra; in Boolean algebra $\cdot$ distributes over $+$ in just the same way.

通常の代数における恒等式 $ac+ad+bc+bd = (a+b)(c+d)$ と同じである。ブール代数でも $\cdot$ は $+$ に対して同じように分配する。

8.2

f = ac+ad+bc+bd+e = (a+b)(c+d)+e。轉換成 NAND-NAND:

f = ac+ad+bc+bd+e = (a+b)(c+d)+e. Convert to NAND-NAND:

f = ac+ad+bc+bd+e = (a+b)(c+d)+e。NAND-NAND へ変換する:

使用雙重反相:f = (a+b)(c+d) · e

Use double inversion: f = (a+b)(c+d) · e

二重否定を使う:f = (a+b)(c+d) · e

NAND 的 NAND(套用狄摩根定律):

NAND of NAND (applying DeMorgan):

NAND の NAND(DeMorgan の法則を適用):

t1 = NAND(a,c); t2=NAND(a,d); t3=NAND(b,c); t4=NAND(b,d)
t5 = NAND(t1,t2,t3,t4)  // = ac+ad+bc+bd
ne = NAND(e,e)            // = ē  (not needed if e uncomplemented)
f  = NAND(t5, NAND(e,e)̄)  // adjust...

更直接地:f = NAND(NAND(a,c), NAND(a,d), NAND(b,c), NAND(b,d), NAND(e,e)̄) — 以 e 的自身 NAND 做反相,最後再用一個 5 輸入 NAND 當作 OR 層。

More directly: f = NAND(NAND(a,c), NAND(a,d), NAND(b,c), NAND(b,d), NAND(e,e)̄) — using e with self-NAND for inversion, then a 5-input NAND for the final OR layer.

より直接的には:f = NAND(NAND(a,c), NAND(a,d), NAND(b,c), NAND(b,d), NAND(e,e)̄) — e は自分自身との NAND で反転し、最後の OR 層を 5 入力 NAND で作る。

8.3

f = Σm(0,1,2,5,6,7,8,9,14)。依 1 的個數做 Quine-McCluskey 分組:

f = Σm(0,1,2,5,6,7,8,9,14). Quine-McCluskey grouping by number of 1s:

f = Σm(0,1,2,5,6,7,8,9,14)。1 の個数で Quine-McCluskey のグループ分けをする:

Group 0: 0000(0)
Group 1: 0001(1), 0010(2), 1000(8)
Group 2: 0101(5), 0110(6), 1001(9)
Group 3: 0111(7), 1110(14)
Combine:
(0,1)=000-, (0,2)=00-0, (0,8)=-000
(1,5)=0-01, (1,9)=-001, (2,6)=0-10
(8,9)=100-
(5,7)=01-1, (6,7)=011-
(9,...)  check (1,9)=-001 ✓
Second pass:
(0,1,8,9)=-00-, (0,2,1,...)...

質蘊涵項:-00- (0,1,8,9)0-0- (0,2)? 0-1- (5,7)=0-1-? 011- (6,7)0-10 (2,6)-001 (1,9)1110 (14)。要得到精確的集合,需要完整的 QM 表。

Prime implicants: -00- (0,1,8,9); 0-0- (0,2)? ; 0-1- (5,7)=0-1-? ; 011- (6,7); 0-10 (2,6); -001 (1,9); 1110 (14). Full QM table needed for exact set.

主項:-00- (0,1,8,9)0-0- (0,2)? 0-1- (5,7)=0-1-? 011- (6,7)0-10 (2,6)-001 (1,9)1110 (14)。正確な集合を求めるには完全な QM 表が必要である。

8.4

f = x₁x₂ + x̄₁x₃,變數順序為 x₁ < x₂ < x₃。

f = x₁x₂ + x̄₁x₃, order x₁ < x₂ < x₃.

f = x₁x₂ + x̄₁x₃、変数順序は x₁ < x₂ < x₃。

         x₁
        /   \
       0     1
      x₃    x₂
     / \    / \
    0   1  0   1
    0   1  0   1

建立 Shannon 展開樹。化簡後:

Build Shannon expansion tree. After reduction:

Shannon 展開木を作る。簡約後:

  • 根節點:x₁。左邊(x₁=0):f = x₃。右邊(x₁=1):f = x₂。
  • Root: x₁. Left (x₁=0): f = x₃. Right (x₁=1): f = x₂.
  • 根:x₁。左(x₁=0):f = x₃。右(x₁=1):f = x₂。
  • 左子節點:x₃ 節點,0→0、1→1。
  • Left child: x₃ node, 0→0, 1→1.
  • 左の子:x₃ ノード、0→0、1→1。
  • 右子節點:x₂ 節點,0→0、1→1。
  • Right child: x₂ node, 0→0, 1→1.
  • 右の子:x₂ ノード、0→0、1→1。

經 ROBDD 化簡後(x₃ 與 x₂ 兩個節點都對映到恆等函數,但變數不同 — 無法合併)。共 4 個節點:根 x₁、左 x₃、右 x₂,以及終端 0 與 1。

After ROBDD reduction (x₃ and x₂ nodes both map to identity, but different variables — cannot merge). 4 nodes: root x₁, left x₃, right x₂, terminal 0 and 1.

ROBDD 簡約後(x₃ と x₂ のノードはどちらも恒等写像になるが、変数が違うので併合できない)。ノードは 4 つ:根の x₁、左の x₃、右の x₂、そして終端の 0 と 1。

8.5

對 n 個變數而言,K-map 有 2ⁿ 格。5 個以上變數時的實務問題:

For n variables, the K-map has 2ⁿ cells. Practical issues with 5+ variables:

変数が n 個なら K-map のセルは 2ⁿ 個である。5 変数以上での実際上の問題:

  • 5 變數的圖有 32 格 — 通常畫成兩張 4 變數圖;相鄰規則會橫跨兩張圖,使得用眼睛圈選很容易出錯。
  • A 5-variable map has 32 cells — displayed as two 4-variable maps; adjacency rules extend across the maps, making visual grouping error-prone.
  • 5 変数の図は 32 セルあり、4 変数の図 2 枚として描かれる。隣接の規則は 2 枚をまたいで成り立つため、目で見てグループ化すると誤りやすい。
  • 6 個變數:64 格、四張 4 變數圖 — 基本上無法用手處理。
  • 6 variables: 64 cells, four 4-variable maps — essentially unmanageable by hand.
  • 6 変数では 64 セル、4 変数の図 4 枚となり、手作業ではほぼ扱えない。

Alternatives:

  • Quine-McCluskey:表格化、系統化,可擴展到任意變數個數。
  • Quine-McCluskey: Tabular, systematic, scalable to any number of variables.
  • Quine-McCluskey:表形式で系統的、変数がいくつでも適用できる。
  • BDD:用於驗證與最佳化的標準形表示法。
  • BDDs: Canonical representation for verification and optimization.
  • BDD:検証と最適化のための標準形表現である。
  • Espresso:CAD 工具中用來處理大型函數的啟發式最小化演算法。
  • Espresso: Heuristic minimization algorithm used in CAD tools for large functions.
  • Espresso:大規模な関数のために CAD ツールで使われるヒューリスティックな最小化アルゴリズム。
8.6

f = Σm(0,3,4,7,9,10,13,14)。在扇入 ≤ 2 的限制下做 K-map 圈選,代表只能使用 2 輸入的閘。

f = Σm(0,3,4,7,9,10,13,14). K-map grouping with fan-in ≤ 2 constraint means only 2-input gates.

f = Σm(0,3,4,7,9,10,13,14)。ファンイン ≤ 2 の制約下で K-map をグループ化するということは、2 入力ゲートしか使えないということである。

標準卡諾圖:{0,3,4,7}=x̄₂x̄₃·?不對:0=0000,3=0011,4=0100,7=0111 → x̄₁(x̄₂x̄₃x̄₄+x̄₂x₃x₄+x₂x̄₃x̄₄+x₂x₃x₄)... 分組 {0,3,4,7}= x̄₁(x₃⊙x₄)... {0,3,4,7}=x̄₁·(x₂⊕x₃x₄)?

Standard K-map: {0,3,4,7}=x̄₂x̄₃·? No: 0=0000,3=0011,4=0100,7=0111 → x̄₁(x̄₂x̄₃x̄₄+x̄₂x₃x₄+x₂x̄₃x̄₄+x₂x₃x₄)... group {0,3,4,7}= x̄₁(x₃⊙x₄)... {0,3,4,7}=x̄₁·(x₂⊕x₃x₄)?

標準的なカルノー図:{0,3,4,7}=x̄₂x̄₃·? いや:0=0000,3=0011,4=0100,7=0111 → x̄₁(x̄₂x̄₃x̄₄+x̄₂x₃x₄+x₂x̄₃x̄₄+x₂x₃x₄)... グループ {0,3,4,7}= x̄₁(x₃⊙x₄)... {0,3,4,7}=x̄₁·(x₂⊕x₃x₄)?

群組:{0,4,9,13}?不行。最佳的 K-map 覆蓋:{0,3,4,7}=x̄₁(x̄₂x̄₃+x₂x₃)... ={x̄₁(x₂⊙x₃)}... 其實 {0,3,4,7}:位元差異出現在 x₂,x₃,x₄ — 這些是 x̄₁x̄₄(x̄₂x̄₃ 不可能,因為 3=0011,7=0111)。在扇入≤2 的限制下:改用 2 輸入閘構成的樹來分解。

Groups: {0,4,9,13}? No. Best K-map cover: {0,3,4,7}=x̄₁(x̄₂x̄₃+x₂x₃)... ={x̄₁(x₂⊙x₃)}... Actually {0,3,4,7}: bits differ in x₂,x₃,x₄ — these are x̄₁x̄₄(x̄₂x̄₃ impossible since 3=0011,7=0111). With fan-in≤2: decompose using a tree of 2-input gates.

グループ:{0,4,9,13}?いや違う。最良の K-map 被覆:{0,3,4,7}=x̄₁(x̄₂x̄₃+x₂x₃)... ={x̄₁(x₂⊙x₃)}... 実のところ {0,3,4,7} はビットが x₂,x₃,x₄ で異なる — これは x̄₁x̄₄(x̄₂x̄₃ は 3=0011,7=0111 なのであり得ない)。ファンイン≤2 の下では、2 入力ゲートの木に分解する。

8.7

兩層邏輯的優點:結構單純(SOP/POS);最小化方法成熟(K-map、QM);延遲可預測(剛好 2 層);易於用 PLA 實作。

Two-level logic advantages: Simple structure (SOP/POS); well-understood minimization (K-map, QM); predictable delay (exactly 2 levels); easy to implement with PLAs.

2 レベル論理の利点:構造が単純(SOP/POS)、最小化手法が確立している(K-map、QM)、遅延が予測しやすい(ちょうど 2 段)、PLA で実装しやすい。

兩層邏輯的缺點:複雜函數可能需要很大的扇入;無法共用共同子運算式;閘數可能隨變數個數呈指數成長。

Two-level disadvantages: Can have large fan-in for complex functions; cannot share common sub-expressions; gate count can be exponential in the number of variables.

2 レベルの欠点:複雑な関数ではファンインが大きくなりうる、共通部分式を共有できない、ゲート数が変数の個数に対して指数的になりうる。

多層邏輯的優點:可共用子運算式 → 閘數/文字數較少;能配合任意的扇入限制;對複雜函數的面積效率較佳。

Multilevel advantages: Shares sub-expressions → fewer gates/literals; supports any fan-in constraint; more area-efficient for complex functions.

多段構成の利点:部分式を共有できる → ゲート数・リテラル数が少ない、任意のファンイン制約に対応できる、複雑な関数では面積効率が高い。

多層邏輯的缺點:邏輯層數較多 → 關鍵路徑較長;不易系統化地最佳化;時序較難預測。

Multilevel disadvantages: More logic levels → longer critical path; harder to optimize systematically; less predictable timing.

多段構成の欠点:論理段数が増える → クリティカルパスが長くなる、系統的な最適化が難しい、タイミングが読みにくい。

8.8

f = abd + abe + acd + ace。用代數除法做因式分解:

f = abd + abe + acd + ace. Factor using algebraic division:

f = abd + abe + acd + ace。代数的除算で因数分解する:

= a(bd + be + cd + ce) = a·(b+c)(d+e)

Extract t₁ = (b+c), t₂ = (d+e):

f = a · t₁ · t₂ = a·(b+c)·(d+e)

原式:4 個乘積項 × 3 個文字 = 12 個文字 + 1 個 OR 閘。

Original: 4 product terms × 3 literals = 12 literals + 1 OR gate.

もとの式:積項 4 個 × リテラル 3 個 = リテラル 12 個 + OR ゲート 1 個。

因式分解後:2 個 OR 閘 + 1 個 3 輸入 AND 閘(或 2 個 2 輸入 AND)= 3 個閘、6 個文字。省下不少。

Factored: 2 OR gates + 3-input AND gate (or 2 two-input ANDs) = 3 gates, 6 literals. Significant saving.

因数分解後:OR ゲート 2 個 + 3 入力 AND ゲート 1 個(または 2 入力 AND 2 個)= ゲート 3 個、リテラル 6 個。大幅な節約である。

8.9

ROBDD(Reduced Ordered Binary Decision Diagram):一種有向無環圖,每個內部節點標上一個變數,並有兩個子節點(low=0、high=1),且變數順序在所有從根到葉的路徑上都一致。

ROBDD (Reduced Ordered Binary Decision Diagram): A directed acyclic graph where each internal node is labeled with a variable, has two children (low=0, high=1), and the variable ordering is consistent along all root-to-leaf paths.

ROBDD(Reduced Ordered Binary Decision Diagram):各内部ノードに変数のラベルが付き、子を 2 つ(low=0、high=1)もつ有向非巡回グラフで、根から葉へのすべての経路で変数順序が一貫しているもの。

兩條化簡規則:

Two reduction rules:

2 つの簡約規則:

  1. 合併規則:若兩個節點的變數相同、low 子節點相同、high 子節點也相同 → 合併成一個節點(共用完全相同的子圖)。
  2. Merge rule: If two nodes have the same variable, same low-child, and same high-child → merge into one node (share identical sub-graphs).
  3. 併合規則:2 つのノードの変数が同じで、low の子も high の子も同じなら → 1 つのノードに併合する(同一の部分グラフを共有する)。
  4. 消去規則:若某節點的 low 子節點與 high 子節點完全相同 → 移除該節點,並把它的父節點改指向那個子節點(該變數對這個子函數無關緊要)。
  5. Elimination rule: If a node's low-child and high-child are identical → remove the node and redirect its parents to the child (variable is irrelevant for this sub-function).
  6. 消去規則:あるノードの low の子と high の子が同一なら → そのノードを取り除き、親をその子へつなぎ替える(その変数はこの部分関数に無関係である)。

標準形的重要性:在固定的變數順序下,每個布林函數的 ROBDD 都是唯一的。這使得等價判斷只需 O(1)(指標相同 = 函數相同),BDD 的各種運算也因此高效。

Canonical form importance: For a fixed variable ordering, the ROBDD is unique for each Boolean function. This enables O(1) equality checking (same pointer = same function) and efficient BDD operations.

標準形が重要な理由:変数順序を固定すれば、ROBDD は各ブール関数に対して一意である。これにより等価判定が O(1) で済み(ポインタが同じ = 同じ関数)、BDD 演算も効率よく行える。

8.10

技術映射 (technology mapping) 把與製程無關(一般閘)的網表,轉換成使用特定單元庫中單元的網表(ASIC 用標準單元,FPGA 用 LUT)。

Technology mapping transforms a technology-independent (generic gate) netlist into one using cells from a specific cell library (standard cells for ASIC, or LUTs for FPGA).

テクノロジマッピングは、技術非依存の(汎用ゲートによる)ネットリストを、特定のセルライブラリのセル(ASIC なら標準セル、FPGA なら LUT)を使ったものへ変換する。

Steps:

  1. 把電路表示成由簡單閘(INV、AND、OR、NAND、NOR)構成的樹或 DAG。
  2. Represent the circuit as a tree or DAG of simple gates (INV, AND, OR, NAND, NOR).
  3. 回路を単純なゲート(INV、AND、OR、NAND、NOR)の木または DAG として表す。
  4. 以動態規劃或遞迴分割,把子樹與可用的庫單元做樣式比對。
  5. Pattern-match sub-trees to available library cells using dynamic programming or recursive partitioning.
  6. 動的計画法または再帰的な分割によって、部分木を利用可能なライブラリセルにパターンマッチングする。
  7. 選出最佳匹配的單元,以最小化面積或延遲。
  8. Select the best-matching cells to minimize area or delay.
  9. 面積または遅延が最小になるよう、最も適合するセルを選ぶ。
  10. 藉由切分成樹來處理扇出再匯聚的情形。
  11. Handle fan-out reconvergence by partitioning into trees.
  12. ファンアウトの再収束は、木に分割することで扱う。

結果會是一份映射後的網表,其中放的是具體的單元實例而非一般閘。

The result is a mapped netlist with specific cell instances rather than generic gates.

結果として得られるのは、汎用ゲートではなく具体的なセルインスタンスからなるマップ済みネットリストである。

8.11

Mux f = s·d₁ + s̄·d₀. Variables: s, d₀, d₁.

順序 1:s < d₀ < d₁

Ordering 1: s < d₀ < d₁

順序 1:s < d₀ < d₁

Root: s
  s=0: d₀ (output = d₀)
  s=1: d₁ (output = d₁)
BDD has 3 nodes: s, d₀, d₁ plus terminals 0,1.

順序 2:d₀ < d₁ < s

Ordering 2: d₀ < d₁ < s

順序 2:d₀ < d₁ < s

Root: d₀; must branch on d₁ then s → more nodes needed.
Effectively 7 nodes in worst case.

排序 1(s 在前)產生較小的 BDD,因為 s 是 mux 函數的「控制」變數。

Ordering 1 (s first) gives the smaller BDD because s is the "controlling" variable for the mux function.

順序 1(s を先にする)のほうが BDD は小さくなる。s が mux 関数の「制御」変数だからである。

8.12

函數分解:把 f(x₁..x₅) 表示成 h(g(x₁,x₂,x₃), x₄, x₅),其中 g 是較簡單的子函數。

Functional decomposition: express f(x₁..x₅) = h(g(x₁,x₂,x₃), x₄, x₅) where g is a simpler sub-function.

関数分解:f(x₁..x₅) を h(g(x₁,x₂,x₃), x₄, x₅) の形で表す。ここで g はより簡単な部分関数である。

找出「束縛集合 (bound set)」(例如 {x₁,x₂,x₃})與「自由集合 (free set)」({x₄,x₅})。

Identify a "bound set" (e.g., {x₁,x₂,x₃}) and "free set" ({x₄,x₅}).

「束縛集合 (bound set)」(たとえば {x₁,x₂,x₃})と「自由集合 (free set)」({x₄,x₅})を定める。

對 x₄,x₅ 的每一種組合,列出所需的 x₁,x₂,x₃ 函數。若有多組 (x₄,x₅) 需要相同的 x₁,x₂,x₃ 子函數,它們就共用同一個 g 輸出行。

For each combination of x₄,x₅, list the required function of x₁,x₂,x₃. If multiple (x₄,x₅) combinations require the same sub-function of x₁,x₂,x₃, they share the same g output column.

x₄,x₅ の各組合せについて、必要となる x₁,x₂,x₃ の関数を列挙する。複数の (x₄,x₅) の組合せが x₁,x₂,x₃ の同じ部分関数を必要とするなら、それらは同じ g の出力列を共有する。

若相異行數 ≤ 2ᵏ(k 個位元),分解就存在。取出 g(3 輸入函數)與 h(3 輸入:g 的輸出 + x₄ + x₅)。

A decomposition exists if the number of distinct columns ≤ 2ᵏ for k bits. Extract g (3-input function) and h (3-input: g-output + x₄ + x₅).

相異なる列の個数が k ビットに対して 2ᵏ 以下なら分解が存在する。g(3 入力関数)と h(3 入力:g の出力 + x₄ + x₅)を取り出す。

8.39

f = Σm(0,2,3,5,7,8,10,11,14,15,24,26,27,29,31) — 5 variable function.

QM 法:依二進位表示中 1 的個數分組,接著合併成對(相差 1 個位元)的項,再合併四項組,依此類推。5 個變數(00000–11111)時,有系統地合併到無法再化簡為止。

QM: Group by number of 1s in binary representation, then combine pairs (differ by 1 bit), then quads, etc. With 5 variables (00000–11111), systematically combine until no further reduction possible.

QM 法:2 進表現に含まれる 1 の個数でグループ分けし、次に対(1 ビットだけ異なるもの)を、続いて 4 個組を、というように結合していく。5 変数(00000–11111)では、これ以上簡約できなくなるまで系統的に結合する。

規律:最小項 (0,2,8,10,24,26)=−−0−0;(3,7,11,15,27,31)=−−111;(5,7,29,31)=−10−1;依此類推。完整列舉可得到所有質蘊涵項,再由 PI 表選出最小覆蓋。

Pattern: minterms (0,2,8,10,24,26)=−−0−0; (3,7,11,15,27,31)=−−111; (5,7,29,31)=−10−1; etc. Full enumeration yields prime implicants from which minimum cover is selected via PI chart.

パターン:最小項 (0,2,8,10,24,26)=−−0−0、(3,7,11,15,27,31)=−−111、(5,7,29,31)=−10−1 など。すべて列挙すると主項が得られ、そこから PI チャートによって最小被覆を選ぶ。

8.40

以 NOR 閘實作 f = (a+b)(c+d)+e:

f = (a+b)(c+d)+e using NOR gates:

NOR ゲートで f = (a+b)(c+d)+e を実現する:

NOR-NOR 實作的是 POS。f' = f = (a+b)(c+d)+e

NOR-NOR implements POS. f' = f = (a+b)(c+d)+e.

NOR-NOR は POS を実現する。f' = f = (a+b)(c+d)+e

f' = NOR(NOR(a,b), NOR(c,d), e) — 反覆套用 De Morgan 定律。

f' = NOR(NOR(a,b), NOR(c,d), e) — using De Morgan repeatedly.

f' = NOR(NOR(a,b), NOR(c,d), e) — De Morgan の定理を繰り返し適用する。

其實是:先把函數取補,再用 NOR-NOR 實作補數的補數:

Actually: complement the function and implement complement of complement with NOR-NOR:

正確には:関数を補元にし、その補元の補元を NOR-NOR で実装する:

NOR(a,b) → nor_ab = ā·b̄
NOR(c,d) → nor_cd = c̄·d̄
NOR(nor_ab, nor_cd, ē) → f

這需要補數輸入(ā,b̄,c̄,d̄,ē),或為每個輸入各配一個 NOR 反相器。

This requires complemented inputs (ā,b̄,c̄,d̄,ē) or NOR inverters for each.

これには補元の入力(ā,b̄,c̄,d̄,ē)か、各入力ごとの NOR 反転器が必要である。

8.41

f = x̄₁x₂ + x₁x̄₃。立方體 (cubical) 表示法 — 每個立方體都是一個乘積項,以三值向量表示(0 = 取補、1 = 不取補、− = don't-care):

f = x̄₁x₂ + x₁x̄₃. Cubical representation — each cube is a product term represented as a ternary vector (0=complemented, 1=uncomplemented, −=don't care):

f = x̄₁x₂ + x₁x̄₃。キューブ表現 — 各キューブは積項であり、三値ベクトルで表す(0 = 補元、1 = 非補元、− = don't-care):

CubeCubeCubex₁x₂x₃
x̄₁x₂01
x₁x̄₃10

覆蓋(立方體集合)= {(0,1,−), (1,−,0)}。每個立方體代表一組最小項:立方體 (0,1,−) = 最小項 {010, 011}={2,3};立方體 (1,−,0)={100,110}={4,6}。

The cover (set of cubes) = {(0,1,−), (1,−,0)}. Each cube represents a set of minterms: cube (0,1,−) = minterms {010, 011}={2,3}; cube (1,−,0)={100,110}={4,6}.

被覆(キューブの集合)= {(0,1,−), (1,−,0)}。各キューブは最小項の集合を表す:キューブ (0,1,−) = 最小項 {010, 011}={2,3}、キューブ (1,−,0)={100,110}={4,6}。

8.42

對於複雜的 5 變數函數,多層合成會抽出共同的子運算式:

For a complex 5-variable function, multilevel synthesis extracts common sub-expressions:

複雑な 5 変数関数では、多段合成が共通部分式を取り出す:

  1. 把 f 表示成 SOP 形式。
  2. Express f in SOP form.
  3. f を SOP 形式で表す。
  4. 用代數除法找出核心運算式 (kernel),也就是共同因式。
  5. Identify kernel expressions (common factors) using algebraic division.
  6. 代数的除算によってカーネル式(共通因子)を見つける。
  7. 把核心運算式抽出成中間訊號 t₁、t₂ 等。
  8. Extract kernels as intermediate signals t₁, t₂, etc.
  9. カーネルを中間信号 t₁、t₂ などとして取り出す。
  10. 用抽取出的訊號重寫 f。
  11. Rewrite f using extracted signals.
  12. 抽出した信号を使って f を書き直す。

例如:若 f = abcd + abce + fgh,取出 t₁=ab:f = t₁(cd+ce)+fgh = t₁·c·(d+e)+fgh。這使文字數從 9 降到 7(一個 ab → 一個 t₁ 用兩次,省下文字)。

Example: if f = abcd + abce + fgh, extract t₁=ab: f = t₁(cd+ce)+fgh = t₁·c·(d+e)+fgh. This reduces the literal count from 9 to 7 (one ab → one t₁ used twice, saving literals).

例:f = abcd + abce + fgh なら t₁=ab を取り出して f = t₁(cd+ce)+fgh = t₁·c·(d+e)+fgh とする。これでリテラル数は 9 から 7 に減る(1 つの ab → 2 回使う 1 つの t₁ となり、リテラルが節約される)。

8.43

f = Σm(4,7,8,11) + D(12,15). K-map (4-var):

       x₃x₄
x₁x₂  00 01 11 10
  00:   0  0  0  0
  01:   1  0  1  0
  11:   d  0  d  0
  10:   1  0  1  0

分組:{4,8,12d}=x̄₃x̄₄?不對,4=0100,8=1000,12=1100 → 在 x₁,x₂ 上不同。{4,12d}=x̄₃x̄₄·x₂?{4,8}=x̄₂x̄₄?不對..

Groups: {4,8,12d}=x̄₃x̄₄? No, 4=0100,8=1000,12=1100 → differ in x₁,x₂. {4,12d}=x̄₃x̄₄·x₂? {4,8}=x̄₂x̄₄? No..

グループ:{4,8,12d}=x̄₃x̄₄? いや、4=0100,8=1000,12=1100 → x₁,x₂ が異なる。{4,12d}=x̄₃x̄₄·x₂? {4,8}=x̄₂x̄₄? いや..

Minterms: 4=0100, 7=0111, 8=1000, 11=1011, DC 12=1100, 15=1111.

Groups: {4,12}=?x100; {7,15d}=?111; {8,12d}=1?00; {11,15d}=1?11.

最小 SOP:f = x̄₃x̄₄ + x₃x₄(涵蓋 4,8,12dc,0?— 待確認)。重新檢查:{4,8,12,0}:x₃=0,x₄=0 → 涵蓋 0,4,8,12 — 但 0 不在 f 中。改用 {4,12}:x₂=1,x₃=0,x₄=0→x₂x̄₃x̄₄;{8}:x₁=1,x₂=0,x₃=0,x₄=0→x₁x̄₂x̄₃x̄₄;{7,15d}:x₂x₃x₄;{11,15d}:x₁x₃x₄。

Min SOP: f = x̄₃x̄₄ + x₃x₄ (covers 4,8,12dc,0? — check). Recheck: {4,8,12,0}: x₃=0,x₄=0 → covers 0,4,8,12 — but 0 not in f. Use {4,12}: x₂=1,x₃=0,x₄=0→x₂x̄₃x̄₄; {8}: x₁=1,x₂=0,x₃=0,x₄=0→x₁x̄₂x̄₃x̄₄; {7,15d}: x₂x₃x₄; {11,15d}: x₁x₃x₄.

最小 SOP:f = x̄₃x̄₄ + x₃x₄(4,8,12dc,0 を覆う? — 要確認)。再検討:{4,8,12,0}:x₃=0,x₄=0 → 0,4,8,12 を覆う — しかし 0 は f に含まれない。{4,12} を使う:x₂=1,x₃=0,x₄=0→x₂x̄₃x̄₄、{8}:x₁=1,x₂=0,x₃=0,x₄=0→x₁x̄₂x̄₃x̄₄、{7,15d}:x₂x₃x₄、{11,15d}:x₁x₃x₄。

最小 SOP:x₂x̄₃x̄₄ + x₁x̄₂x̄₃x̄₄ + x₁x₃x₄。因式分解後:(x₂+x₁x̄₂)x̄₃x̄₄ + x₁x₃x₄ = (x₁+x₂)x̄₃x̄₄ + x₁x₃x₄

Min SOP: x₂x̄₃x̄₄ + x₁x̄₂x̄₃x̄₄ + x₁x₃x₄. Factored: (x₂+x₁x̄₂)x̄₃x̄₄ + x₁x₃x₄ = (x₁+x₂)x̄₃x̄₄ + x₁x₃x₄.

最小 SOP:x₂x̄₃x̄₄ + x₁x̄₂x̄₃x̄₄ + x₁x₃x₄。因数分解すると:(x₂+x₁x̄₂)x̄₃x̄₄ + x₁x₃x₄ = (x₁+x₂)x̄₃x̄₄ + x₁x₃x₄

8.44

立方體表示法的定義:

Cubical representation definitions:

キューブ表現の定義:

  • 文字 (Literal):單一變數或其補數;在立方體的某個位置上以三值(0、1 或 −)表示。
  • Literal: A single variable or its complement; represented as a ternary value (0, 1, or −) in one position of a cube.
  • リテラル:単一の変数またはその補元。キューブの 1 つの位置における三値(0、1、−)で表される。
  • 立方體 (Cube):以三值向量表示的乘積項;含 k 個「−」位置的立方體涵蓋 2ᵏ 個最小項。
  • Cube: A product term represented as a ternary vector; a cube with k "−" positions covers 2ᵏ minterms.
  • キューブ:三値ベクトルで表した積項。「−」の位置が k 個あるキューブは 2ᵏ 個の最小項を覆う。
  • 覆蓋 (Cover):一組立方體,其聯集涵蓋所有 on-set 最小項(f=1 的位置)。
  • Cover: A set of cubes whose union covers all the on-set minterms (positions where f=1).
  • 被覆:その和集合が on-set の最小項(f=1 となる位置)をすべて覆うキューブの集合。
  • 質蘊涵項 (Prime implicant):不被覆蓋中任何其他立方體所包含的立方體(在保持有效的前提下無法再擴大)。
  • Prime implicant: A cube not contained in any other cube in the cover (cannot be enlarged while remaining valid).
  • 主項 (Prime implicant):被覆中の他のどのキューブにも含まれないキューブ(正当なまま拡大することができない)。
  • 必要質蘊涵項 (Essential PI):至少有一個最小項只由它涵蓋的質蘊涵項;必定出現在每一個最小覆蓋中。
  • Essential PI: A prime implicant that is the only cube covering at least one minterm; must be in every minimum cover.
  • 必須主項 (Essential PI):少なくとも 1 つの最小項を覆う唯一のキューブとなっている主項。あらゆる最小被覆に必ず含まれる。
8.45

在 Quine-McCluskey 法中,當某個群組裡的最小項項目成功與另一個最小項合併時,就在它旁邊打上「勾號」(✓)。最後沒有勾號的列即為質蘊涵項(無法再合併)。

In Quine-McCluskey, a "check mark" (✓) is placed next to a minterm entry in a group when it has been successfully combined with another minterm. Any row without a check mark at the end is a prime implicant (cannot be combined further).

Quine-McCluskey 法では、あるグループ内の最小項の項目が別の最小項とうまく結合できたとき、その横に「チェックマーク」(✓) を付ける。最後までチェックマークの付かない行が主項である(これ以上結合できない)。

質蘊涵項表的選取:

PI chart selection:

主項表による選択:

  1. 建立表格:橫列 = PI,直行 = 最小項。
  2. Build table: rows=PIs, columns=minterms.
  3. 表を作る:行 = PI、列 = 最小項。
  4. 標出每個質蘊涵項所涵蓋的最小項。
  5. Mark each PI's covered minterms.
  6. 各主項が覆う最小項に印を付ける。
  7. 找出必要 PI(某一直行只有一個標記)— 這些一定要選。
  8. Identify essential PIs (single mark in a column) — these must be selected.
  9. 必須 PI(列にマークが 1 つだけのもの)を見つける — これらは必ず選ぶ。
  10. 移除已涵蓋的最小項;若還有最小項剩下,就使用 Petrick 法或啟發式做法(挑選能涵蓋最多剩餘最小項的 PI)。
  11. Remove covered minterms; if minterms remain, use Petrick's method or heuristic (choose PI covering the most remaining minterms).
  12. 覆われた最小項を取り除く。最小項が残っていれば、Petrick の方法かヒューリスティック(残りの最小項を最も多く覆う PI を選ぶ)を使う。
  13. 重複進行,直到所有最小項都被涵蓋為止。
  14. Repeat until all minterms covered.
  15. すべての最小項が覆われるまで繰り返す。
8.46

f = x₁x₂ + x₃x₄ + x₅x₆.

交錯排序 (x₁,x₂,x₃,x₄,x₅,x₆):每一對 xᵢxᵢ₊₁ 都相鄰;BDD 可以精簡地共用每一對的 AND 結構。BDD 大小 = O(n) 個節點。

Interleaved ordering (x₁,x₂,x₃,x₄,x₅,x₆): Each pair xᵢxᵢ₊₁ is adjacent; BDD can share the AND-structure for each pair compactly. BDD size = O(n) nodes.

インタリーブ順序 (x₁,x₂,x₃,x₄,x₅,x₆):各対 xᵢxᵢ₊₁ が隣り合う。BDD は対ごとの AND 構造をコンパクトに共有できる。BDD のサイズ = O(n) ノード。

分組排序 (x₁,x₃,x₅,x₂,x₄,x₆):每個乘積項的變數被拆散;BDD 無法在前半部之間共用結構 — 可能出現指數級爆炸。BDD 大小 = O(2^(n/2))。

Grouped ordering (x₁,x₃,x₅,x₂,x₄,x₆): Each product term's variables are separated; the BDD cannot share structure between the first halves — exponential blowup possible. BDD size = O(2^(n/2)).

グループ順序 (x₁,x₃,x₅,x₂,x₄,x₆):各積項の変数が離れてしまう。BDD は前半どうしで構造を共有できず、指数的な膨張が起こりうる。BDD のサイズ = O(2^(n/2))。

通則:對於由獨立變數對之和所構成的函數,把每一對的成員交錯排列可使 BDD 最小。變數排序的最佳化是 NP-hard;實務上採用動態變數重排的啟發式做法(sifting)。

General rule: For a function that is a sum of independent pairs, interleaving the pair members minimizes BDD size. Variable ordering is NP-hard to optimize optimally; dynamic variable reordering heuristics (sifting) are used in practice.

一般則:独立な対の和からなる関数では、対の要素をインタリーブすると BDD のサイズが最小になる。変数順序を最適に決めるのは NP-hard であり、実務では動的変数並べ替えのヒューリスティック(sifting)が使われる。

8.47

PI 表:直行 = 最小項,橫列 = 質蘊涵項。把每個 PI 所涵蓋的最小項一一標記。

PI chart: columns = minterms, rows = prime implicants. Mark each minterm covered by each PI.

PI チャート:列 = 最小項、行 = 主項。各 PI が覆う最小項に印を付ける。

找出必要 PI:只有一個標記的直行 → 該 PI 為必要。選出所有必要 PI,移除已涵蓋的最小項,剩下的再用 Petrick 法或貪婪選取處理。

Find essential PIs: columns with only one mark → that PI is essential. Select all essential PIs, remove covered minterms, then use Petrick's method or greedy selection for remaining.

必須 PI を見つける:マークが 1 つだけの列 → その PI が必須である。必須 PI をすべて選び、覆われた最小項を取り除いたうえで、残りには Petrick の方法か貪欲な選択を使う。

以 8.5 的 f 為例:PI -00- 涵蓋 {0,1,8,9};若 0,1,8,9 之中有任一個只由 -00- 涵蓋,它就是必要的。持續進行直到所有最小項都被涵蓋。最小覆蓋 = 必要 PI + 為未涵蓋最小項所需的最少額外 PI。

For f from 8.5: PI -00- covers {0,1,8,9}; if any of 0,1,8,9 is only covered by -00-, it's essential. Continue until all minterms covered. The minimum cover = essential PIs + minimum additional PIs for uncovered minterms.

8.5 の f では:PI -00- が {0,1,8,9} を覆う。0,1,8,9 のいずれかが -00- だけで覆われているなら、それは必須である。すべての最小項が覆われるまで続ける。最小被覆 = 必須 PI + 未被覆の最小項のための最小限の追加 PI。

8.48

n 位元加法器的進位函數:cₙ = f(a₁,b₁,...,aₙ,bₙ,c₀)。

Carry function for n-bit adder: cₙ = f(a₁,b₁,...,aₙ,bₙ,c₀).

n ビット加算器の桁上げ関数:cₙ = f(a₁,b₁,...,aₙ,bₙ,c₀)。

交錯排序 (a₁,b₁,a₂,b₂,...aₙ,bₙ):BDD 大小為多項式 O(n) — 每個進位位元只取決於本位元與較低位元的 a,b 對;BDD 能有效地共用節點。

Interleaved ordering (a₁,b₁,a₂,b₂,...aₙ,bₙ): BDD size is polynomial O(n) — each carry bit depends on its and lower bits' a,b pairs; BDD can share nodes efficiently.

インタリーブ順序 (a₁,b₁,a₂,b₂,...aₙ,bₙ):BDD のサイズは多項式 O(n) である — 各桁上げビットは自分と下位ビットの a,b の対に依存するので、BDD はノードを効率よく共有できる。

分組排序 (a₁,...,aₙ,b₁,...,bₙ):BDD 大小呈指數成長 O(2ⁿ),因為當變數被拆成兩個分離的群組時,cₙ 對所有 aᵢ 與 bᵢ 的依賴方式需要指數多的節點。

Grouped ordering (a₁,...,aₙ,b₁,...,bₙ): BDD size grows exponentially O(2ⁿ) because cₙ depends on all aᵢ and bᵢ in a way that requires exponentially many nodes when variables are split into two separate groups.

グループ順序 (a₁,...,aₙ,b₁,...,bₙ):BDD のサイズは指数的に O(2ⁿ) で増える。変数を 2 つの別々のグループに分けると、cₙ がすべての aᵢ と bᵢ に依存する形になり、指数個のノードが必要になるからである。

心得:變數排序會大幅影響 BDD 的大小;對加法器的進位而言,交錯排序是最佳的。

Lesson: variable ordering dramatically affects BDD size; interleaved is optimal for adder carry.

教訓:変数順序は BDD のサイズを大きく左右する。加算器の桁上げにはインタリーブが最適である。

8.49

f = Σm(0,4,8,13,14,15),且只能使用未取補的輸入(沒有反相器)。

f = Σm(0,4,8,13,14,15) with uncomplemented inputs only (no inverters).

f = Σm(0,4,8,13,14,15) を、補元でない入力だけ(反転器なし)で実現する。

沒有補數時,我們只能用未取補的變數組成乘積項。需要變數全為 1 的最小項很容易;含有 0 的最小項則需要補數。

Without complements, we can only form product terms using uncomplemented variables. Minterms requiring all-1 variables are easy; minterms with 0s require complements.

補元がなければ、非補元の変数だけで積項を作るしかない。変数がすべて 1 の最小項は容易だが、0 を含む最小項には補元が要る。

最小項 0 = x̄₁x̄₂x̄₃x̄₄ 需要全部取補 → 只用未取補的輸入無法實現。

Minterm 0 = x̄₁x̄₂x̄₃x̄₄ requires all complements → not realizable with uncomplemented inputs only.

最小項 0 = x̄₁x̄₂x̄₃x̄₄ はすべて補元を要する → 非補元の入力だけでは実現できない。

在這個限制下:改用 NAND/NOR 分解,或接受某些最小項(0,4,8)無法直接實作;也可考慮替代做法:用未取補的輸入實作 f̄ 再反相,或改用以 XOR 為基礎的形式。

For this constraint: use NAND/NOR decomposition, or accept that some minterms (0,4,8) are not directly implementable; consider alternative: implement f̄ using uncomplemented inputs and invert, or use XOR-based form.

この制約のもとでは:NAND/NOR による分解を用いるか、一部の最小項(0,4,8)が直接は実装できないことを受け入れる。代替案として、非補元の入力で f̄ を実装してから反転する、あるいは XOR を基にした形を使うことも考えられる。

若只涵蓋最小項 13,14,15:f_partial = x₁x₂x₃x̄₄ + x₁x₂x̄₃x₄ + x₁x₂x₃x₄ = x₁x₂(x₃+x₄)。最小項 0,4,8 則以其他分解方式補上。

If only minterms 13,14,15 covered: f_partial = x₁x₂x₃x̄₄ + x₁x₂x̄₃x₄ + x₁x₂x₃x₄ = x₁x₂(x₃+x₄). Add minterms 0,4,8 by alternative decomposition.

最小項 13,14,15 だけを覆う場合:f_partial = x₁x₂x₃x̄₄ + x₁x₂x̄₃x₄ + x₁x₂x₃x₄ = x₁x₂(x₃+x₄)。最小項 0,4,8 は別の分解で追加する。

8.50

f = ab+cd。單元庫範例:{INV, NAND2, NOR2, AND2, OR2, AOI21 (AND-OR-Invert)}。

f = ab+cd. Cell library example: {INV, NAND2, NOR2, AND2, OR2, AOI21 (AND-OR-Invert)}.

f = ab+cd。セルライブラリの例:{INV, NAND2, NOR2, AND2, OR2, AOI21 (AND-OR-Invert)}。

面積最小化:f = ab+cd = NAND(NAND(a,b), NAND(c,d))。用掉 3 個 NAND2 閘(面積 = 3 單位)。另一種做法:AND2+AND2+OR2 = 3 個單元,但面積可能較大。

Minimize area: f = ab+cd = NAND(NAND(a,b), NAND(c,d)). Uses 3 NAND2 gates (area = 3 units). Alternatively: AND2+AND2+OR2 = 3 cells but likely larger area.

面積の最小化:f = ab+cd = NAND(NAND(a,b), NAND(c,d))。NAND2 ゲートを 3 個使う(面積 = 3 単位)。別案として AND2+AND2+OR2 = 3 セルだが、面積はおそらく大きくなる。

延遲最小化:若有 AOI21 單元,f 可用單一 AOI21 實作: ̄f = AOI(a,b,c,d) 之後再接 INV。或用 NAND-NAND:2 層 × t_NAND 的延遲 — 與任何兩層實作相同。

Minimize delay: f can be implemented as single AOI21 cell if available: ̄f = AOI(a,b,c,d) then INV. Or NAND-NAND: 2 levels × t_NAND delay — same as any 2-level implementation.

遅延の最小化:AOI21 セルが使えるなら、f は 1 個の AOI21 で実装できる: ̄f = AOI(a,b,c,d) としてから INV を通す。あるいは NAND-NAND:2 段 × t_NAND の遅延 — どの 2 レベル実装とも同じである。

8.51

Circuit: t₁=a+b, t₂=c·d, t₃=t₁·e, f=t₂+t₃ = c·d + (a+b)·e

分析:f = cd + ae + be。文字數 = 5。閘數 = AND(c,d) + AND(a,b→OR) + 2 個 AND + OR = 4 個閘。

Analysis: f = cd + ae + be. Literal count = 5. Gate count = AND(c,d) + AND(a,b→OR) + 2 ANDs + OR = 4 gates.

解析:f = cd + ae + be。リテラル数 = 5。ゲート数 = AND(c,d) + AND(a,b→OR) + AND 2 個 + OR = 4 ゲート。

重新因式分解:f = cd + e(a+b)。這已經是因式分解過的形式。其他選擇:由於 cd 與 e(a+b) 沒有共同因式,不存在更簡單的形式。

Re-factor: f = cd + e(a+b). This is already factored. Alternative: no simpler form exists since cd and e(a+b) share no common factor.

再因数分解:f = cd + e(a+b)。これはすでに因数分解された形である。代替案:cd と e(a+b) に共通因子がないため、これより簡単な形は存在しない。

也可以寫成 f = c·d + (a+b)·e — 兩者相同。驗證:展開後得到 cd+ae+be,與原本的列舉一致。

Could also write f = c·d + (a+b)·e — same. Verify: expanding gives cd+ae+be which matches original enumeration.

f = c·d + (a+b)·e と書いてもよい — 同じである。検証:展開すると cd+ae+be となり、もとの列挙と一致する。

8.13E

注意 $f_2 = (x_1+x_2)(x_3+x_4)$ 已經是因式分解形式。再看 $f_1$:它等於 $f_2$ 扣掉 $x_1=x_2=0$ 這個情形,在該情形下它應為 $\overline{x_1}\overline{x_2}(x_3+x_4)$ — 也就是 $f_1 = (x_1+x_2)(x_3 x_4) + \overline{x_1}\overline{x_2}(x_3+x_4)$。兩者共用子運算式 $g = x_3+x_4$ 與 $h = x_1+x_2$。總成本:$g, h$ 共用;接著 $f_2 = h\cdot g$、$f_1 = h\cdot x_3 x_4 + \overline{h}\cdot g$。共用 $g$ 與 $h$,比起各輸出獨立建構可省下數個閘輸入。

Note $f_2 = (x_1+x_2)(x_3+x_4)$ already factored. Examine $f_1$: it equals $f_2$ minus the case $x_1=x_2=0$ where it should be $\overline{x_1}\overline{x_2}(x_3+x_4)$ — i.e. $f_1 = (x_1+x_2)(x_3 x_4) + \overline{x_1}\overline{x_2}(x_3+x_4)$. Both share the subexpression $g = x_3+x_4$ and $h = x_1+x_2$. Total cost: $g, h$ shared; then $f_2 = h\cdot g$, $f_1 = h\cdot x_3 x_4 + \overline{h}\cdot g$. Sharing $g$ and $h$ saves several gate-inputs versus building each output independently.

$f_2 = (x_1+x_2)(x_3+x_4)$ はすでに因数分解された形であることに注意する。$f_1$ を調べる:これは $f_2$ から $x_1=x_2=0$ の場合を除いたものに等しく、その場合は $\overline{x_1}\overline{x_2}(x_3+x_4)$ となるべきである — すなわち $f_1 = (x_1+x_2)(x_3 x_4) + \overline{x_1}\overline{x_2}(x_3+x_4)$ である。両者は部分式 $g = x_3+x_4$ と $h = x_1+x_2$ を共有する。総コスト:$g, h$ を共有し、$f_2 = h\cdot g$、$f_1 = h\cdot x_3 x_4 + \overline{h}\cdot g$ とする。$g$ と $h$ を共有すると、各出力を独立に作る場合よりゲート入力がいくつか節約できる。

8.14E

依卡諾圖的直行來分組:在 01($\overline{x_3}x_4$)與 10($x_3\overline{x_4}$)這兩行,函數的值為 $x_1 \oplus \overline{x_2}$;在 00 與 11 兩行則為 0。因此 $g(x_3, x_4) = x_3 \oplus x_4$(在中間兩行 assert)。於是 $f = g \cdot (x_1 \oplus \overline{x_2})$ — 一個兩層的 XOR 乘積,兩個 XOR 饋入一個 AND。成本:3 個各 2 輸入的閘,相對於 SOP 形式的四個 3 輸入 AND。

Group on the K-map columns: in columns 01 ($\overline{x_3}x_4$) and 10 ($x_3\overline{x_4}$) the function takes value $x_1 \oplus \overline{x_2}$; in columns 00 and 11 it is 0. So $g(x_3, x_4) = x_3 \oplus x_4$ (asserts in the two middle columns). Then $f = g \cdot (x_1 \oplus \overline{x_2})$ — a 2-level XOR product, two XORs feeding one AND. Cost: 3 gates with 2 inputs each, vs four 3-input ANDs in the SOP form.

カルノー図の列でグループ化する:列 01($\overline{x_3}x_4$)と 10($x_3\overline{x_4}$)では関数の値が $x_1 \oplus \overline{x_2}$ となり、列 00 と 11 では 0 である。したがって $g(x_3, x_4) = x_3 \oplus x_4$(中央の 2 列でアサートする)。すると $f = g \cdot (x_1 \oplus \overline{x_2})$ — 2 レベルの XOR 積であり、2 個の XOR が 1 個の AND に入る。コスト:2 入力のゲート 3 個であり、SOP 形式の 3 入力 AND 4 個と比べられる。

8.15E

觀察卡諾圖可知,當 $g(x_1,x_2,x_5)=0$ 的各橫列都呈現同一種行樣式,而 $g=1$ 的各橫列呈現另一種樣式時,就把 $g$ 定義為列指標。同理,把 $k(x_3,x_4)$ 定義為行索引。課本的例子得到 $f = g \oplus k$ 或 $f = g\overline{k} + \overline{g}k$。成本:3 個小型子函數 + 1 個 XOR ≈ 8 個輸入,相對於最小 SOP 的 ≈ 18 個輸入 — 節省相當可觀。

By inspection of the K-map, when rows where $g(x_1,x_2,x_5)=0$ all have one column pattern and rows where $g=1$ have a different pattern, define $g$ as the row indicator. Similarly $k(x_3,x_4)$ as the column index. The book's example produces $f = g \oplus k$ or $f = g\overline{k} + \overline{g}k$. Cost: 3 small subfunctions + 1 XOR ≈ 8 inputs, versus minimum SOP ≈ 18 inputs — a substantial saving.

カルノー図を観察して、$g(x_1,x_2,x_5)=0$ となる行がすべて同じ列パターンを持ち、$g=1$ の行が別のパターンを持つとき、$g$ を行の指標として定義する。同様に $k(x_3,x_4)$ を列の索引とする。教科書の例では $f = g \oplus k$ または $f = g\overline{k} + \overline{g}k$ が得られる。コスト:小さな部分関数 3 個 + XOR 1 個 ≈ 入力 8 本に対し、最小 SOP は ≈ 入力 18 本 — かなりの節約である。

8.16E

以 5 個 NAND 構成的 XOR(標準做法):

5-NAND XOR (standard):

NAND 5 個による XOR(標準形):

g1 = NAND(x1,x2)
g2 = NAND(x1,g1)
g3 = NAND(g1,x2)
f  = NAND(g2,g3)
(That's actually 4 NANDs.) The 4-NAND version uses $g = \text{NAND}(x_1, x_2)$ shared among the next stages:
g  = NAND(x1, x2)
f1 = NAND(x1, g)
f2 = NAND(x2, g)
f  = NAND(f1, f2)
This realizes $x_1 \oplus x_2$ in 4 NAND gates.

8.17E

泡泡對插入法:AND-OR 各層交替出現,因此在相鄰兩層之間的每條訊號上放一對泡泡。把每個泡泡吸收進它所接觸的閘之後:每個 AND 變成 NAND,每個 OR(輸入與輸出都帶泡泡)也變成 NAND — 於是得到 (a) 全 NAND。至於 (b) 全 NOR:改用不同方式插入泡泡對 — 把 AND 閘變成 NOR(輸入端帶泡泡),把 OR 閘變成 NOR(輸出端的泡泡被吸收)。結構會在 AND-OR-AND-OR 與 OR-AND-OR-AND 兩種拓撲之間翻轉。

Bubble-pair insertion: AND-OR levels alternate, so place a bubble pair at every signal between adjacent levels. After absorbing each bubble into the gate it touches: every AND becomes NAND and every OR (with bubbles on inputs and output) becomes NAND too — yielding (a) all-NAND. For (b) all-NOR: insert bubble pairs differently — turn the AND gates into NORs (with bubbled inputs) and the ORs into NORs (with bubbled outputs absorbed). The structure flips between AND-OR-AND-OR and OR-AND-OR-AND topology.

バブル対の挿入:AND-OR の段が交互に現れるので、隣接する段の間のすべての信号にバブルを 1 対ずつ置く。各バブルを接する側のゲートに吸収させると、AND はすべて NAND になり、OR も(入力と出力にバブルが付いて)NAND になる — こうして (a) の全 NAND が得られる。(b) の全 NOR では、バブル対の入れ方を変える — AND ゲートを(入力にバブルの付いた)NOR に、OR ゲートを(出力のバブルを吸収した)NOR にする。構造は AND-OR-AND-OR と OR-AND-OR-AND のトポロジーの間で反転する。

8.18E

在圖 8.12 中把中間節點標為 $P_1, P_2, P_3$。從輸出往回追:$f = P_1 + P_2$;$P_1 = x_1 P_3$、$P_3 = x_2 + x_3$;$P_2 = \overline{x_1} x_4$。因此 $f = x_1(x_2+x_3) + \overline{x_1}x_4 = x_1 x_2 + x_1 x_3 + \overline{x_1}x_4$。SOP 成本:3 個 AND + 1 個 OR = 4 個閘、9 個輸入。

Label intermediate nodes $P_1, P_2, P_3$ inside Figure 8.12. Trace from output back: $f = P_1 + P_2$; $P_1 = x_1 P_3$, $P_3 = x_2 + x_3$; $P_2 = \overline{x_1} x_4$. So $f = x_1(x_2+x_3) + \overline{x_1}x_4 = x_1 x_2 + x_1 x_3 + \overline{x_1}x_4$. SOP cost: 3 ANDs + 1 OR = 4 gates, 9 inputs.

図 8.12 の中間ノードを $P_1, P_2, P_3$ とラベル付けする。出力から逆にたどる:$f = P_1 + P_2$、$P_1 = x_1 P_3$、$P_3 = x_2 + x_3$、$P_2 = \overline{x_1} x_4$。したがって $f = x_1(x_2+x_3) + \overline{x_1}x_4 = x_1 x_2 + x_1 x_3 + \overline{x_1}x_4$。SOP のコストは AND 3 個 + OR 1 個 = ゲート 4 個、入力 9 本である。

8.19E

把範例 8.3 中的 XOR/XNOR 閘換成等價的 SOP($x \oplus y = x\overline{y}+\overline{x}y$)。標出內部節點並逐一追蹤:多層電路的每一支都會收斂成原本的某個乘積項。整個式子重建後得到 $f = $ 原本的規格 — 驗證了功能等價。

Replace the XOR/XNOR gates of Example 8.3 by their SOP equivalents ($x \oplus y = x\overline{y}+\overline{x}y$). Label internal nodes and trace: each leg of the multilevel circuit collapses to one of the original product terms. The expression reconstructs to $f = $ the original specification — verifying functional equivalence.

例題 8.3 の XOR/XNOR ゲートを等価な SOP($x \oplus y = x\overline{y}+\overline{x}y$)に置き換える。内部ノードにラベルを付けてたどると、多段回路の各枝はもとの積項のいずれかに帰着する。式を組み直すと $f = $ もとの仕様となり、機能的に等価であることが確かめられる。

8.20E

標記 $P_1=$ NAND($x_1, x_2$)、$P_2=$ NAND($x_3, x_4$)、$P_3=$ NAND($P_1, P_2, x_5$)。對每一個套用狄摩根定律:$P_1 = \overline{x_1 x_2}$、$P_2 = \overline{x_3 x_4}$,但把它們送進下一層 NAND 並吸收泡泡後,會得到 OR-of-AND 的結構。課本的化簡結果為 $f = x_1 x_2 x_4 + \overline{x_3} x_4 + x_5$。

Label $P_1=$ NAND($x_1, x_2$), $P_2=$ NAND($x_3, x_4$), $P_3=$ NAND($P_1, P_2, x_5$). Apply DeMorgan to each: $P_1 = \overline{x_1 x_2}$, $P_2 = \overline{x_3 x_4}$, but feeding into the next-level NAND with bubble absorption gives an OR-of-AND structure. The textbook reduction yields $f = x_1 x_2 x_4 + \overline{x_3} x_4 + x_5$ after simplification.

$P_1=$ NAND($x_1, x_2$)、$P_2=$ NAND($x_3, x_4$)、$P_3=$ NAND($P_1, P_2, x_5$) とラベルを付ける。それぞれにド・モルガンの定理を適用すると $P_1 = \overline{x_1 x_2}$、$P_2 = \overline{x_3 x_4}$ となるが、次段の NAND に入れてバブルを吸収させると AND の OR という構造になる。教科書どおりに簡単化すると $f = x_1 x_2 x_4 + \overline{x_3} x_4 + x_5$ が得られる。

8.21E

在各閘輸出處標上 $P_1\dots P_4$。NAND 的輸出等於 $\overline{\prod}$,NOR 的輸出等於 $\overline{\sum}$。用狄摩根定律傳遞泡泡,直到所有泡泡互相抵消。經代數化簡後:$f = x_5(x_1 + x_2 + \overline{x_3} + x_4) = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$。✓

Label $P_1\dots P_4$ at gate outputs. NAND outputs equal $\overline{\prod}$; NOR outputs equal $\overline{\sum}$. Propagate bubbles by DeMorgan until all bubbles cancel. After algebraic simplification: $f = x_5(x_1 + x_2 + \overline{x_3} + x_4) = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$. ✓

各ゲートの出力に $P_1\dots P_4$ とラベルを付ける。NAND の出力は $\overline{\prod}$、NOR の出力は $\overline{\sum}$ に等しい。ド・モルガンの定理でバブルを伝播させ、すべてのバブルが打ち消し合うまで続ける。代数的に簡単化すると:$f = x_5(x_1 + x_2 + \overline{x_3} + x_4) = x_1 x_5 + x_2 x_5 + \overline{x_3} x_5 + x_4 x_5$。✓

8.22E

對原 BDD 的每個端點,在 $(x_1, x_2)$ 上建一張小真值表,記下交換邊界處的邊分別指向何處。接著以 $x_1$ 在 $x_2$ 之上重建 BDD。若函數對這兩個變數對稱,許多邊會合併。結果會是一個大小相等或更小的 BDD,端視變數排序而定。

Build a small truth table over $(x_1, x_2)$ for each terminal of the original BDD, recording where edges from the swap-boundary go. Then re-create the BDD with $x_1$ above $x_2$. Many edges merge if the function is symmetric in those variables. Result is a BDD of equivalent or smaller size depending on the variable ordering.

もとの BDD の各終端について $(x_1, x_2)$ 上の小さな真理値表を作り、入替え境界から出る辺の行き先を記録する。次に $x_1$ を $x_2$ の上に置いて BDD を作り直す。関数がその 2 変数について対称なら、多くの辺が併合される。結果として得られる BDD の大きさは、変数順序に応じて同じか、より小さくなる。

8.23E

對 $x_1$ 做 Shannon 展開:$f|_{x_1=0} = x_2 x_3 + x_2 x_4 + \overline{x_2}\overline{x_3}\overline{x_4}$、$f|_{x_1=1} = x_3 + x_4 + x_2 x_3 + x_2 x_4 = x_3 + x_4$。再對 $x_2$ 展開 $f|_{x_1=1}$:兩邊都是 $x_3+x_4$(與 $x_2$ 無關)。對 $x_2$ 展開 $f|_{x_1=0}$:$x_2=1$ 得 $x_3+x_4$,$x_2=0$ 得 $\overline{x_3}\overline{x_4}$。BDD:根節點為 $x_1$,兩個子節點都指向一個 $x_2$ 節點(若相等則合併)。$x_3+x_4$ 這個子圖出現多次 — 把它合併。由 BDD 得到的多層 SOP:$f = x_1(x_3+x_4) + \overline{x_1}[\,x_2(x_3+x_4) + \overline{x_2}\overline{x_3}\overline{x_4}\,]$。

Shannon on $x_1$: $f|_{x_1=0} = x_2 x_3 + x_2 x_4 + \overline{x_2}\overline{x_3}\overline{x_4}$, $f|_{x_1=1} = x_3 + x_4 + x_2 x_3 + x_2 x_4 = x_3 + x_4$. Shannon $f|_{x_1=1}$ on $x_2$: same $x_3+x_4$ either way (independent of $x_2$). For $f|_{x_1=0}$ on $x_2$: $x_2=1$ gives $x_3+x_4$; $x_2=0$ gives $\overline{x_3}\overline{x_4}$. BDD: root $x_1$, both children point to an $x_2$ node (or merge if equal). The $x_3+x_4$ subgraph appears multiple times — merge it. Multilevel SOP from BDD: $f = x_1(x_3+x_4) + \overline{x_1}[\,x_2(x_3+x_4) + \overline{x_2}\overline{x_3}\overline{x_4}\,]$.

$x_1$ で Shannon 展開する:$f|_{x_1=0} = x_2 x_3 + x_2 x_4 + \overline{x_2}\overline{x_3}\overline{x_4}$、$f|_{x_1=1} = x_3 + x_4 + x_2 x_3 + x_2 x_4 = x_3 + x_4$。$f|_{x_1=1}$ を $x_2$ で展開すると、どちらも同じ $x_3+x_4$ である($x_2$ に依存しない)。$f|_{x_1=0}$ を $x_2$ で展開すると、$x_2=1$ では $x_3+x_4$、$x_2=0$ では $\overline{x_3}\overline{x_4}$ となる。BDD:根は $x_1$ で、両方の子が $x_2$ ノードを指す(等しければ併合する)。$x_3+x_4$ の部分グラフが何度も現れる — これを併合する。BDD から得られる多段 SOP:$f = x_1(x_3+x_4) + \overline{x_1}[\,x_2(x_3+x_4) + \overline{x_2}\overline{x_3}\overline{x_4}\,]$。

8.24E

對 $\sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$ 施行 Quine-McCluskey 法:把最小項依 1 的個數分組,逐輪合併相鄰者,直到無法再合併為止。所得的質蘊涵項(標記出未合併者之後)通常是 $\{\overline{x_2}\overline{x_3}\overline{x_4}, x_2 x_4, x_2 x_3, x_1\overline{x_3}, x_1 x_4\}$ 之類。就必要最小項建立覆蓋表,消去被支配的列與行,再做選取。最小覆蓋(其中一個有效解):$f = x_2 x_4 + x_2 x_3 + \overline{x_2}\overline{x_3}\overline{x_4} + x_1\overline{x_3}$。

Quine-McCluskey on $\sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$: Group minterms by 1-count, combine adjacent ones across iterations until no more merges. Resulting prime implicants (after marking unmerged): typically $\{\overline{x_2}\overline{x_3}\overline{x_4}, x_2 x_4, x_2 x_3, x_1\overline{x_3}, x_1 x_4\}$ or similar. Build cover table over essential minterms, eliminate dominated rows/columns, and select. Minimum cover (one valid result): $f = x_2 x_4 + x_2 x_3 + \overline{x_2}\overline{x_3}\overline{x_4} + x_1\overline{x_3}$.

$\sum m(0,2,5,6,7,8,9,13) + D(1,12,15)$ に Quine-McCluskey 法を適用する:最小項を 1 の個数で分類し、これ以上併合できなくなるまで隣接するものを反復的に併合する。得られる主項は(併合されなかったものに印を付けたのち)ふつう $\{\overline{x_2}\overline{x_3}\overline{x_4}, x_2 x_4, x_2 x_3, x_1\overline{x_3}, x_1 x_4\}$ などとなる。必須の最小項について被覆表を作り、支配される行・列を除いてから選択する。最小被覆(有効な解の一つ):$f = x_2 x_4 + x_2 x_3 + \overline{x_2}\overline{x_3}\overline{x_4} + x_1\overline{x_3}$。

8.25E

套用表格法:質蘊涵項包含數個 2-cube 與 1-cube,沒有必要質蘊涵項。覆蓋表中既無列支配也無行支配。改用 Petrick 法或分支法:任選一個質蘊涵項,遞迴下去,再挑成本最低的覆蓋。典型結果:$f = $ 4 個各含 2 個文字的質蘊涵項,閘輸入成本 $\approx 12$。

Apply tabular method: prime implicants include several 2-cubes and 1-cubes, no essential primes. Cover table has no row or column dominance. Use Petrick's method or branching: select an arbitrary prime, recurse, choose minimum-cost cover. Typical result: $f = $ 4 prime implicants of 2 literals each, gate-input cost $\approx 12$.

表形式の手法を適用する:主項には 2-cube と 1-cube がいくつか含まれ、必須主項はない。被覆表には行支配も列支配もない。そこで Petrick の方法か分岐法を用いる:主項を任意に 1 つ選んで再帰し、コスト最小の被覆を選ぶ。典型的な結果は $f = $ 2 リテラルの主項 4 個で、ゲート入力コストは $\approx 12$ である。

8.26E

$\star$ 乘積會把恰好只有一個位置不同的立方體配對,並把該位置換成 x。$C_0 = \{000, 001, 010, 011, 111\}$。$C_1$:$000\star 001 = 00x$、$000\star 010 = 0x0$、$001\star 011 = 0x1$、$010\star 011 = 01x$、$011\star 111 = x11$。$C_2$:$00x\star 01x = 0xx$。無法再合併。移除被涵蓋的立方體後,質蘊涵項為 $\{0xx, x11\}$。✓

$\star$-product pairs cubes that differ in exactly one position, replacing that position with x. $C_0 = \{000, 001, 010, 011, 111\}$. $C_1$: $000\star 001 = 00x$, $000\star 010 = 0x0$, $001\star 011 = 0x1$, $010\star 011 = 01x$, $011\star 111 = x11$. $C_2$: $00x\star 01x = 0xx$. No further merges. After removing covered cubes, primes are $\{0xx, x11\}$. ✓

$\star$ 積は、ちょうど 1 か所だけ異なるキューブどうしを組にし、その位置を x に置き換える。$C_0 = \{000, 001, 010, 011, 111\}$。$C_1$:$000\star 001 = 00x$、$000\star 010 = 0x0$、$001\star 011 = 0x1$、$010\star 011 = 01x$、$011\star 111 = x11$。$C_2$:$00x\star 01x = 0xx$。これ以上は併合できない。覆われたキューブを取り除くと、主項は $\{0xx, x11\}$ である。✓

8.27E

對 $C_0=\{0101,1101,1110,011x,x01x\}$ 施行 $\star$ 乘積。$0101\star 1101 = x101$。$011x \star x01x$:兩個位置不同 → 不合併。$0101\star 011x = 01x1$(第 1 位不同,以 x 合併)。$1101\star 1110$:兩處不同 → 不合併。$C_1 = \{x101, 01x1, 1110, 011x, x01x\}$。繼續:$x101 \star 01x1$:兩處不同,不合併。最終質蘊涵項:$x101, 01x1, 1110, 011x, x01x$。以代數式表示:$\{x_2\overline{x_3}x_4, \overline{x_1}x_2 x_4, x_1 x_2 x_3\overline{x_4}, \overline{x_1}x_2 x_3, \overline{x_2}x_3\}$。

Apply $\star$-product to $C_0=\{0101,1101,1110,011x,x01x\}$. $0101\star 1101 = x101$. $011x \star x01x$: differ in two positions → no merge. $0101\star 011x = 01x1$ (differ in bit 1, x merge). $1101\star 1110$: two diff → no. $C_1 = \{x101, 01x1, 1110, 011x, x01x\}$. Continue: $x101 \star 01x1$: two diff, no. Final primes: $x101, 01x1, 1110, 011x, x01x$. Algebraic: $\{x_2\overline{x_3}x_4, \overline{x_1}x_2 x_4, x_1 x_2 x_3\overline{x_4}, \overline{x_1}x_2 x_3, \overline{x_2}x_3\}$.

$C_0=\{0101,1101,1110,011x,x01x\}$ に $\star$ 積を適用する。$0101\star 1101 = x101$。$011x \star x01x$:2 か所異なる → 併合しない。$0101\star 011x = 01x1$(ビット 1 が異なり、x で併合)。$1101\star 1110$:2 か所異なる → 併合しない。$C_1 = \{x101, 01x1, 1110, 011x, x01x\}$。続けて $x101 \star 01x1$:2 か所異なるので併合しない。最終的な主項は $x101, 01x1, 1110, 011x, x01x$。代数形では $\{x_2\overline{x_3}x_4, \overline{x_1}x_2 x_4, x_1 x_2 x_3\overline{x_4}, \overline{x_1}x_2 x_3, \overline{x_2}x_3\}$。

8.28E

$\#$ 運算:$A \# B$ 傳回在 $A$ 中而不在 $B$ 中的最小項。對每個質蘊涵項 $p$,在 on-set 上計算 $p \# (P \setminus \{p\})$。若結果非空,$p$ 即為必要質蘊涵項(它涵蓋了其他質蘊涵項都涵蓋不到的最小項)。以圖 2.56 的函數與 $\{x11, 0xx\}$ 為例:$x11 \# 0xx = 111$(非空)→ 必要。$0xx \# x11 = \{000, 001, 010\}$(非空)→ 必要。兩個質蘊涵項都是必要的。

The $\#$-operation: $A \# B$ returns minterms in $A$ not in $B$. For each prime $p$, compute $p \# (P \setminus \{p\})$ over the on-set. If non-empty, $p$ is essential (covers a minterm no other prime covers). For $\{x11, 0xx\}$ on the function of Figure 2.56: $x11 \# 0xx = 111$ (non-empty) → essential. $0xx \# x11 = \{000, 001, 010\}$ (non-empty) → essential. Both primes are essential.

$\#$ 演算:$A \# B$ は $A$ に含まれて $B$ に含まれない最小項を返す。各主項 $p$ について、on-set 上で $p \# (P \setminus \{p\})$ を計算する。空でなければ $p$ は必須主項である(ほかのどの主項も覆わない最小項を覆う)。図 2.56 の関数と $\{x11, 0xx\}$ の場合:$x11 \# 0xx = 111$(空でない)→ 必須。$0xx \# x11 = \{000, 001, 010\}$(空でない)→ 必須。どちらの主項も必須である。

8.29E

對每個 $p \in P$ 計算 $p \# (P\setminus\{p\})$。$x01x \#$ 其餘:$\{0010, 0011\}$ → 必要。$x101$:只被 $x101$ 自己涵蓋 — 扣掉自己後為空 → 非必要。$01x1$:$\{0101\}$ — 必要。$0x1x \#$ 其餘:$\{0010, 0011\}$ — 已被 $x01x$ 涵蓋 → 再檢查:實際上 $0x1x \# x01x = \{0110, 0111\}$ — 必要。$xx10$:多數格子已被其他項涵蓋 → 非必要。必要質蘊涵項:$x01x, 01x1, 0x1x$。(確切的集合取決於該函數的最小項涵蓋情形。)

For each $p \in P$, compute $p \# (P\setminus\{p\})$. $x01x \#$ rest: $\{0010, 0011\}$ → essential. $x101$: subset of $x101$ alone — empty after removing self → not essential. $01x1$: $\{0101\}$ — essential. $0x1x \#$ rest: $\{0010, 0011\}$ — already covered by $x01x$ → check: actually $0x1x \# x01x = \{0110, 0111\}$ — essential. $xx10$: most cells covered by others → not essential. Essentials: $x01x, 01x1, 0x1x$. (Exact set depends on minterm coverage in the function.)

各 $p \in P$ について $p \# (P\setminus\{p\})$ を計算する。$x01x \#$ 残り:$\{0010, 0011\}$ → 必須。$x101$:$x101$ 自身だけの部分集合 — 自分を除くと空 → 必須ではない。$01x1$:$\{0101\}$ — 必須。$0x1x \#$ 残り:$\{0010, 0011\}$ — すでに $x01x$ が覆っている → 確かめると、実際には $0x1x \# x01x = \{0110, 0111\}$ — 必須。$xx10$:ほとんどのセルがほかの項に覆われる → 必須ではない。必須主項は $x01x, 01x1, 0x1x$ である。(正確な集合は、その関数における最小項の被覆状況による。)

8.30E

用 $\star$ 乘積求質蘊涵項(這個 5 變數函數經過數輪後會產生很多立方體)。再用 $\#$ 運算找出各自涵蓋獨有最小項的必要質蘊涵項。選定必要項之後,對剩下的覆蓋表做分支以最小化成本。最終的最小 SOP(示意):$f = \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} + x_4 x_5(x_1\oplus x_2) + x_2 x_3 x_4 + \overline{x_3}\overline{x_5}$(或等價的約 4 項覆蓋,取決於 don't-care 的指定方式)。

Apply $\star$-product to find primes (many cubes after several iterations on the 5-var function). Use $\#$-op to identify essentials covering minterms unique to each. After essentials are chosen, branch on the remaining cover table to minimize cost. Final minimum SOP (illustrative): $f = \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} + x_4 x_5(x_1\oplus x_2) + x_2 x_3 x_4 + \overline{x_3}\overline{x_5}$ (or equivalent ~4-term cover, depending on don't-care assignments).

$\star$ 積で主項を求める(この 5 変数関数では数回の反復で多数のキューブが出る)。$\#$ 演算で、それぞれに固有の最小項を覆う必須主項を特定する。必須主項を選んだあと、残りの被覆表に対して分岐しコストを最小化する。最終的な最小 SOP(例示):$f = \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} + x_4 x_5(x_1\oplus x_2) + x_2 x_3 x_4 + \overline{x_3}\overline{x_5}$(あるいは don't-care の割当てに応じた同等の 4 項程度の被覆)。

8.31E

直接的 3-LUT 對映:LUT1 = $x_1 x_2\overline{x_4}$、LUT2 = $\overline{x_2} x_3 x_4$、LUT3 = $x_1 x_2 x_3$、LUT4 = 前三者的 OR — 共 4 個 LUT。改用分解:把 $x_1 x_2(\overline{x_4} + x_3) = x_1 x_2(x_3 + \overline{x_4})$ 放進一個 3-LUT,$\overline{x_2}x_3 x_4$ 放進另一個,再用第三個把兩者 OR 起來 — 共 3 個 LUT

Straightforward 3-LUT mapping: LUT1 = $x_1 x_2\overline{x_4}$, LUT2 = $\overline{x_2} x_3 x_4$, LUT3 = $x_1 x_2 x_3$, LUT4 = OR of these — total 4 LUTs. Decomposition: factor $x_1 x_2(\overline{x_4} + x_3) = x_1 x_2(x_3 + \overline{x_4})$ in one 3-LUT, $\overline{x_2}x_3 x_4$ in another, OR them in a third — total 3 LUTs.

素直な 3-LUT へのマッピング:LUT1 = $x_1 x_2\overline{x_4}$、LUT2 = $\overline{x_2} x_3 x_4$、LUT3 = $x_1 x_2 x_3$、LUT4 = これらの OR — 合計 4 個の LUT。分解を使う場合:$x_1 x_2(\overline{x_4} + x_3) = x_1 x_2(x_3 + \overline{x_4})$ を 1 つの 3-LUT に、$\overline{x_2}x_3 x_4$ をもう 1 つに入れ、3 つ目で両者を OR する — 合計 3 個の LUT

8.32E

分組:$f = (x_1+x_2)(x_3+x_4) + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$。利用 $x_1+x_2=0$ 時 $\overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} = (\overline{x_1+x_2})(\overline{x_3+x_4}) = \overline{x_3}\overline{x_4}\cdot(\overline{x_1+x_2}) = \overline{x_3}\overline{x_4}$。結果:$f = \overline{x_3}\overline{x_4} + (x_1+x_2)(x_3+x_4)$。✓(此恆等式可用展開驗證:$x_3+x_4=0$ 時只剩第一項;$x_3+x_4=1$ 時由 AND 項涵蓋。)

Group: $f = (x_1+x_2)(x_3+x_4) + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$. Use $\overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} = (\overline{x_1+x_2})(\overline{x_3+x_4}) = \overline{x_3}\overline{x_4}\cdot(\overline{x_1+x_2}) = \overline{x_3}\overline{x_4}$ when $x_1+x_2=0$. Net: $f = \overline{x_3}\overline{x_4} + (x_1+x_2)(x_3+x_4)$. ✓ (Identity verified by expansion: when $x_3+x_4=0$, only the first term remains; when $x_3+x_4=1$, the AND term covers it.)

グループ化する:$f = (x_1+x_2)(x_3+x_4) + \overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4}$。$x_1+x_2=0$ のとき $\overline{x_1}\overline{x_2}\overline{x_3}\overline{x_4} = (\overline{x_1+x_2})(\overline{x_3+x_4}) = \overline{x_3}\overline{x_4}\cdot(\overline{x_1+x_2}) = \overline{x_3}\overline{x_4}$ となることを使う。結果は $f = \overline{x_3}\overline{x_4} + (x_1+x_2)(x_3+x_4)$。✓(展開すれば恒等式であることが確かめられる:$x_3+x_4=0$ なら第 1 項だけが残り、$x_3+x_4=1$ なら AND の項がそれを覆う。)

8.33E

對 $x_1$ 做 Shannon 展開:$f|_{x_1=0} = x_2 x_4$、$f|_{x_1=1} = x_3 + x_2 x_4$。再對 $x_2$ 展開 $f|_{x_1=1}$:$f|_{x_1=1, x_2=0} = x_3$、$f|_{x_1=1, x_2=1} = x_3 + x_4$。BDD:根節點為 $x_1$。右分支($x_1=1$)連到一個 $x_2$ 節點,帶有兩個餘因子(一個是 $x_3$,一個是 $x_3+x_4$)。左分支($x_1=0$)連到一個測試 $x_2$ 的節點 — 只有 $x_2 x_4$ 這一支。接著往下鋪 $x_3$ 與 $x_4$ 層,並合併重複的子圖。

Shannon on $x_1$: $f|_{x_1=0} = x_2 x_4$, $f|_{x_1=1} = x_3 + x_2 x_4$. Shannon $f|_{x_1=1}$ on $x_2$: $f|_{x_1=1, x_2=0} = x_3$, $f|_{x_1=1, x_2=1} = x_3 + x_4$. BDD: root $x_1$. Right branch ($x_1=1$) goes to $x_2$ node with two cofactors (one is $x_3$, one is $x_3+x_4$). Left branch ($x_1=0$) goes to a node testing $x_2$ — only $x_2 x_4$ branch. Continue with $x_3$ then $x_4$ levels, merging duplicate subgraphs.

$x_1$ で Shannon 展開する:$f|_{x_1=0} = x_2 x_4$、$f|_{x_1=1} = x_3 + x_2 x_4$。$f|_{x_1=1}$ を $x_2$ で展開すると $f|_{x_1=1, x_2=0} = x_3$、$f|_{x_1=1, x_2=1} = x_3 + x_4$。BDD:根は $x_1$。右の枝($x_1=1$)は 2 つの余因子(一方は $x_3$、他方は $x_3+x_4$)をもつ $x_2$ ノードへ向かう。左の枝($x_1=0$)は $x_2$ を判定するノードへ向かい、$x_2 x_4$ の枝だけをもつ。以下 $x_3$、$x_4$ の段へ続け、重複する部分グラフを併合する。

8.34E

對每個跨越交換處的子圖,追蹤 $(x_2, x_3)$ 上真值表的 4 個項目。把內層的 $x_2$ 與 $x_3$ 互換後,重建一個依序為 $x_1$、$x_3$、$x_2$、$x_4$ 的新 BDD。有些子圖的合併方式會不同。對稱函數的新 BDD 通常節點數相同,但一般而言變數排序可以大幅改變 BDD 的大小。

Track the 4 entries of the truth table over $(x_2, x_3)$ at each subgraph crossing the swap. After swapping inner $x_2$ and $x_3$, build a new BDD with root $x_1$, then $x_3$, then $x_2$, then $x_4$. Some subgraphs merge differently. The new BDD usually has the same node count for symmetric functions, but variable ordering can change BDD size dramatically in general.

入替えをまたぐ部分グラフごとに、$(x_2, x_3)$ 上の真理値表の 4 項目を追う。内側の $x_2$ と $x_3$ を入れ替えたのち、根から $x_1$、$x_3$、$x_2$、$x_4$ の順の新しい BDD を作る。部分グラフの併合のされ方が変わるものもある。対称な関数なら新しい BDD のノード数はふつう同じだが、一般には変数順序によって BDD の大きさは大きく変わりうる。

8.35E

$f$ 的最小項:$\sum m(0,1,2,4,5,8,9,13) + D(9,12,14)$(由給定的 SOP 形式展開而得)。表格法:依 1 的個數分組後合併。產生的立方體:$\{00x0, 0x0x, 1x01, 10x1, 1101\}$,移除被涵蓋者後即得質蘊涵項。覆蓋表:只有單一標記的列即為必要項。最小成本 SOP:$f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$(同 2.38)。

Minterms of $f$: $\sum m(0,1,2,4,5,8,9,13) + D(9,12,14)$ (after expanding, given the SOP form). Tabular method: group by 1-count, combine. Generated cubes: $\{00x0, 0x0x, 1x01, 10x1, 1101\}$ and primes after removal of covered ones. Cover table: essentials from rows with single mark. Minimum-cost SOP: $f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$ (as in 2.38).

$f$ の最小項は $\sum m(0,1,2,4,5,8,9,13) + D(9,12,14)$(与えられた SOP 形を展開したもの)。表形式の手法で 1 の個数ごとに分類して併合する。生成されるキューブは $\{00x0, 0x0x, 1x01, 10x1, 1101\}$ で、覆われたものを除くと主項が残る。被覆表では、印が 1 つだけの行から必須主項が決まる。最小コストの SOP は $f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$(2.38 と同じ)。

8.36E

$C_0$ 由最小項加上 don't-care 構成。透過 $\star$ 乘積得到的 $C_1$ 為 2-cube,$C_2$ 為 3-cube。約 3 輪後收斂。所得質蘊涵項(以立方體記法 $x_1 x_2 x_3 x_4$ 表示):$\{xx00, x0x1, 1x01, 1xx1\}$ — 代數式為 $\{\overline{x_3}\overline{x_4}, \overline{x_2}x_4, x_1\overline{x_3}x_4, x_1 x_4\}$。課本的最小成本覆蓋挑出的是與 8.35 相符的子集合。

$C_0$ from minterms+don't-cares. $C_1$ via $\star$-product yields 2-cubes; $C_2$ yields 3-cubes. Convergence after ~3 iterations. Resulting primes (in cube notation, $x_1 x_2 x_3 x_4$): $\{xx00, x0x1, 1x01, 1xx1\}$ — algebraically $\{\overline{x_3}\overline{x_4}, \overline{x_2}x_4, x_1\overline{x_3}x_4, x_1 x_4\}$. The book's minimum-cost cover selects a subset matching 8.35.

$C_0$ は最小項と don't-care から作る。$\star$ 積による $C_1$ は 2-cube、$C_2$ は 3-cube を与える。3 回ほどの反復で収束する。得られる主項(キューブ記法 $x_1 x_2 x_3 x_4$):$\{xx00, x0x1, 1x01, 1xx1\}$ — 代数形では $\{\overline{x_3}\overline{x_4}, \overline{x_2}x_4, x_1\overline{x_3}x_4, x_1 x_4\}$。教科書の最小コスト被覆は、8.35 に一致する部分集合を選ぶ。

8.37E

(a) 最小 SOP $f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$:3 個 AND + 1 個 OR,11 個閘輸入。(b) 最小 POS $f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$:3 個 OR + 1 個 AND,約 12 個輸入。(c) 多層:分解為 $f = \overline{x_3}\overline{x_4} + x_4(x_1+\overline{x_2})$:第二項用 2 層,再加最後的 OR — 約 8 個輸入,但深度為 3 層。取捨:SOP 最快(2 層)但要 11 個輸入;多層省面積(8 個輸入),代價是 3 層的延遲。

(a) Minimum SOP $f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$: 3 ANDs + 1 OR, 11 gate-inputs. (b) Minimum POS $f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$: 3 ORs + 1 AND, ~12 inputs. (c) Multilevel: factor $f = \overline{x_3}\overline{x_4} + x_4(x_1+\overline{x_2})$: 2 levels for the second term + final OR — about 8 inputs but 3 levels deep. Trade-off: SOP is fastest (2 levels) at 11 inputs; multilevel saves area (8 inputs) at the cost of 3 levels of delay.

(a) 最小 SOP $f = \overline{x_3}\overline{x_4} + x_1 x_4 + \overline{x_2} x_4$:AND 3 個 + OR 1 個、ゲート入力 11 本。(b) 最小 POS $f = (\overline{x_2}+\overline{x_3})(\overline{x_3}+x_4)(x_1+\overline{x_3}+\overline{x_4})$:OR 3 個 + AND 1 個、入力は約 12 本。(c) 多段:$f = \overline{x_3}\overline{x_4} + x_4(x_1+\overline{x_2})$ と因数分解すると、第 2 項に 2 段と最後の OR — 入力は約 8 本だが深さは 3 段になる。トレードオフ:SOP は最速(2 段)だが入力 11 本、多段は面積を節約できる(入力 8 本)代わりに 3 段分の遅延がかかる。

8.38E

$h[g(x_1,x_2,x_3,x_4), x_5, x_6, x_7]$ — 第一個 LUT 可算出任意 4 變數函數 $g$,第二個可算出以 $g$ 與另外三個變數為引數的任意 4 變數函數 $h$。$f_1 = x_1 x_2 x_3 x_4 x_5 x_6 x_7$:取 $g = x_1 x_2 x_3 x_4$、$h = g \cdot x_5 x_6 x_7$ — 可行。$f_2 = x_1+\dots+x_7$:$g = x_1+x_2+x_3+x_4$、$h = g + x_5+x_6+x_7$ — 可行。但例如 $f = x_1 x_5 + x_2 x_6 + x_3 x_7 + x_4$ 要求 LUT2 個別知道 $x_1\dots x_4$ 的全部 — 而可用的只有 $g$(把它們概括成的一個位元)。因此這個 $f$ 沒有 2-LUT 的實現方式。

$h[g(x_1,x_2,x_3,x_4), x_5, x_6, x_7]$ — first LUT computes any 4-var function $g$, second computes any 4-var function $h$ of $g$ and three other vars. $f_1 = x_1 x_2 x_3 x_4 x_5 x_6 x_7$: set $g = x_1 x_2 x_3 x_4$, $h = g \cdot x_5 x_6 x_7$ — works. $f_2 = x_1+\dots+x_7$: $g = x_1+x_2+x_3+x_4$, $h = g + x_5+x_6+x_7$ — works. But e.g. $f = x_1 x_5 + x_2 x_6 + x_3 x_7 + x_4$ requires LUT2 to know all of $x_1\dots x_4$ individually — only $g$ (one bit summarizing them) is available. So no 2-LUT realization exists for this $f$.

$h[g(x_1,x_2,x_3,x_4), x_5, x_6, x_7]$ — 1 つ目の LUT は任意の 4 変数関数 $g$ を計算し、2 つ目は $g$ と他の 3 変数からなる任意の 4 変数関数 $h$ を計算する。$f_1 = x_1 x_2 x_3 x_4 x_5 x_6 x_7$:$g = x_1 x_2 x_3 x_4$、$h = g \cdot x_5 x_6 x_7$ とすれば実現できる。$f_2 = x_1+\dots+x_7$:$g = x_1+x_2+x_3+x_4$、$h = g + x_5+x_6+x_7$ — 実現できる。しかし、たとえば $f = x_1 x_5 + x_2 x_6 + x_3 x_7 + x_4$ では LUT2 が $x_1\dots x_4$ を個別に知る必要があるのに、使えるのは $g$(それらを 1 ビットにまとめたもの)だけである。したがって、この $f$ を LUT 2 個で実現することはできない。

第 9 章 — 非同步電路Chapter 9 — Asynchronous Circuits第 9 章 — 非同期回路
9.1

基本模式 (fundamental mode):非同步電路的運作假設 — 輸入只在電路處於穩定狀態時才改變,也就是一次只變一個輸入,且在下一次輸入變化之前先讓電路穩定下來。

Fundamental mode: Asynchronous circuit operating assumption where inputs change only when the circuit is in a stable state — i.e., one input changes at a time, and the circuit is allowed to settle before the next input change.

基本モード (fundamental mode):入力は回路が安定状態にあるときにのみ変化する、という非同期回路の動作上の仮定 — すなわち、入力は一度に 1 つだけ変化し、次の入力変化までに回路が落ち着くだけの時間が与えられる。

Input constraints:

  • 一次只有一個輸入變數改變(不會同時變化)。
  • Only one input variable changes at a time (no simultaneous changes).
  • 一度に変化する入力変数は 1 つだけである(同時変化はない)。
  • 電路必須在下一次輸入轉態之前到達穩定狀態。
  • The circuit must reach a stable state before the next input transition.
  • 次の入力遷移が起こる前に、回路は安定状態に達していなければならない。
  • 沒有時脈;電路直接對輸入變化做出反應。
  • No clock; the circuit responds directly to input changes.
  • クロックはない。回路は入力の変化に直接応答する。

這些限制可避免競爭,並確保行為有明確的定義。

These constraints prevent races and ensure well-defined behavior.

これらの制約が競合を防ぎ、明確に定義された動作を保証する。

9.2

交叉耦合的 NOR 閘(SR 閂鎖):Q = NOR(R,Q̄)、Q̄ = NOR(S,Q)。流程表(輸入為 S,R;穩定狀態以圓圈標示):

Cross-coupled NOR gates (SR latch): Q = NOR(R,Q̄), Q̄ = NOR(S,Q). Flow table (S,R inputs; stable states circled):

交差結合した NOR ゲート(SR ラッチ):Q = NOR(R,Q̄)、Q̄ = NOR(S,Q)。フロー表(入力は S,R、安定状態は丸で囲む):

狀態State状態SR=00SR=01SR=11SR=10
Q=00001
Q=11011

穩定狀態(圓圈標示者):SR=00,01 時 Q=0;SR=00,10 時 Q=1。SR=11 是禁止輸入(兩個輸出都會試圖變成 0)。當 SR=11→00 時,輸出不確定(競爭)。

Stable states (circled): Q=0 with SR=00,01; Q=1 with SR=00,10. SR=11 is the forbidden input (both outputs attempt to become 0). When SR=11→00, output is indeterminate (race).

安定状態(丸で囲んだもの):SR=00,01 で Q=0、SR=00,10 で Q=1。SR=11 は禁止入力である(両方の出力が 0 になろうとする)。SR=11→00 のとき、出力は不定となる(競合)。

9.3

穩定狀態:在目前的輸入組合下,下一狀態等於現在狀態的狀態 — 電路已完成轉態,不會再有變化。Y = y(回授變數等於驅動它的函數)。

Stable state: A state where the next state equals the present state for the current input combination — the circuit has finished transitioning and no further changes occur. Y = y (feedback variable equals its driving function).

安定状態:現在の入力組合せに対して次状態が現状態と等しい状態 — 回路は遷移を終え、それ以上の変化は起こらない。Y = y(帰還変数がそれを駆動する関数と等しい)。

不穩定狀態:Y ≠ y 的狀態 — 電路的下一狀態與目前狀態不同。電路會持續轉態(可能經過多個不穩定狀態),直到抵達穩定狀態為止。這一串由不穩定到穩定的變化稱為一次轉移 (transition)。

Unstable state: A state where Y ≠ y — the circuit's next state differs from its current state. The circuit will continue transitioning (may pass through multiple unstable states) until reaching a stable state. The sequence of unstable-to-stable transitions is called a transition.

不安定状態:Y ≠ y となる状態 — 回路の次状態が現状態と異なる。回路は安定状態に達するまで遷移を続ける(複数の不安定状態を経ることもある)。この不安定から安定へ至る一連の変化を遷移 (transition) と呼ぶ。

9.4

臨界競爭:多個狀態變數必須同時改變,而結果取決於哪一個先變。不同的順序會導向不同的最終狀態 — 也就是不確定的行為。

Critical race: When multiple state variables must change simultaneously, and the outcome depends on which changes first. Different orderings lead to different final states — non-deterministic behavior.

臨界競合:複数の状態変数が同時に変化しなければならず、どれが先に変わるかで結果が決まってしまう場合をいう。順序が違えば最終状態も違ってしまう — 非決定的な動作である。

例:狀態 00→11 的轉移。若 y₁ 先變:00→10→11(正確)。若 y₂ 先變:00→01→11(也可能正確)。但若 10 或 01 在目前輸入下是穩定狀態,電路就可能卡在那裡。

Example: State 00→11 transition. If y₁ changes first: 00→10→11 (correct). If y₂ changes first: 00→01→11 (may be correct). But if 10 or 01 are stable states for the current input, the circuit may get stuck there.

例:状態 00→11 の遷移。y₁ が先に変われば 00→10→11(正しい)。y₂ が先に変われば 00→01→11(正しいこともある)。しかし現在の入力に対して 10 や 01 が安定状態であれば、回路はそこで止まってしまうことがある。

修法:採用無競爭的狀態指派(例如讓任何轉移都只改變一個變數的編碼),或在非同步電路中使用 one-hot 編碼。

Fix: Use race-free state assignment (e.g., assign codes so any transition changes only one variable) or use one-hot encoding for asynchronous circuits.

対策:競合のない状態割当てを用いる(たとえば、どの遷移でも変数が 1 つしか変わらない符号を割り当てる)か、非同期回路に one-hot 符号化を用いる。

9.5

f = x₁x₂ + x̄₂x₃。當 x₁x₂ 與 x̄₂x₃ 同時 0→1 時會出現靜態 1 冒險 — 也就是 x₁=1、x₃=1 而 x₂ 由 1→0 時:從 x₁x₂=1 轉到 x̄₂x₃=1,中間會有一瞬間兩個項都不是 1。

f = x₁x₂ + x̄₂x₃. Static 1-hazard occurs when both x₁x₂ and x̄₂x₃ are 0→1 simultaneously — when x₂ transitions from 1→0 with x₁=1, x₃=1: transition from x₁x₂=1 to x̄₂x₃=1, momentarily neither term is 1.

f = x₁x₂ + x̄₂x₃。静的 1 ハザードは x₁x₂ と x̄₂x₃ が同時に 0→1 となるときに生じる — すなわち x₁=1、x₃=1 のもとで x₂ が 1→0 と変化するときで、x₁x₂=1 から x̄₂x₃=1 へ移る途中、一瞬どちらの項も 1 でなくなる。

冒險條件:在 x₁=1、x₃=1 之下,當 x₂ 轉態時。最小項 110 與 011 並不落在同一個 K-map 群組裡。

Hazard condition: At x₁=1, x₃=1, as x₂ transitions. The two minterms 110 and 011 are not in the same K-map group.

ハザードの条件:x₁=1、x₃=1 のもとで x₂ が遷移するとき。最小項 110 と 011 は同じ K-map のグループに入っていない。

消除:加入共識項 x₁x₃(涵蓋相鄰的最小項 110 與 011,把缺口橋接起來):

Eliminate: Add the consensus term x₁x₃ (covers the adjacent minterms 110 and 011, bridging the gap):

除去:合意項 x₁x₃ を加える(隣接する最小項 110 と 011 を覆い、隙間を橋渡しする):

f = x₁x₂ + x̄₂x₃ + x₁x₃ (hazard-free)

9.6

靜態 1 冒險:輸出本該維持 1,卻在輸入轉態期間瞬間掉到 0。

Static 1-hazard: Output should remain 1 but momentarily glitches to 0 during an input transition.

静的 1 ハザード:出力は 1 のままであるべきなのに、入力の遷移中に一瞬 0 へグリッチする。

靜態 0 冒險:輸出本該維持 0,卻在輸入轉態期間瞬間跳到 1。出現在 POS 實作中;加入額外的和項即可消除。

Static 0-hazard: Output should remain 0 but momentarily glitches to 1 during an input transition. Occurs in POS implementations; eliminated by adding extra sum terms.

静的 0 ハザード:出力は 0 のままであるべきなのに、入力の遷移中に一瞬 1 へグリッチする。POS の実装で生じ、和項を追加することで除去できる。

動態冒險:輸出本該只變化一次(0→1 或 1→0),卻變化了 3 次以上(例如 0→1→0→1)。成因是存在再匯合路徑時,多條路徑的延遲各不相同。消除起來比較複雜 — 必須拿掉再匯合的拓撲,或把各路徑的延遲調成一致。

Dynamic hazard: Output should change once (0→1 or 1→0) but transitions 3 or more times (e.g., 0→1→0→1). Caused by multiple paths of different delays when there are reconvergent paths. More complex to eliminate — requires removing the reconvergent topology or balancing delays.

動的ハザード:出力は 1 回だけ変化する(0→1 または 1→0)はずなのに、3 回以上遷移してしまう(たとえば 0→1→0→1)。再収斂する経路があるときに、遅延の異なる複数の経路があることが原因である。除去はより厄介で、再収斂するトポロジーをなくすか、遅延を揃える必要がある。

9.7

相容狀態:兩個狀態 sᵢ 與 sⱼ 相容的條件是:(1) 在兩者皆有定義的所有輸入組合下輸出相同,且 (2) 對所有輸入而言,它們的後繼狀態對也相容(或兩者皆未定義)。

Compatible states: Two states sᵢ and sⱼ are compatible if (1) they have the same output for all input combinations where both are defined, and (2) their successor state pairs are also compatible (or both undefined) for all inputs.

両立状態:2 つの状態 sᵢ と sⱼ が両立するのは、(1) 両方が定義されているすべての入力組合せで出力が同じであり、かつ (2) すべての入力に対して後続状態の対もまた両立する(あるいは両方とも未定義である)ときである。

合併圖:一張以狀態為節點、以無向邊連接相容狀態對的圖。彼此兩兩相容的狀態群組可以合併成單一狀態。

Merger diagram: A graph where nodes are states and undirected edges connect compatible state pairs. Groups of mutually compatible states can be merged into a single state.

マージャ図:状態をノードとし、両立する状態対を無向辺で結んだグラフである。互いに両立する状態のグループは 1 つの状態に併合できる。

步驟:找出所有相容對(由蘊涵表求得),畫出合併圖,找出最大相容群組(團),再選出能涵蓋所有原始狀態的最少合併狀態數。

Process: find all compatible pairs (from implication table), draw merger diagram, find maximum compatible groups (cliques), select minimum number of merged states that covers all original states.

手順:(含意表から)両立する対をすべて求め、マージャ図を描き、最大の両立グループ(クリーク)を見つけ、もとの状態をすべて覆う併合状態の個数が最小になるように選ぶ。

9.8

f = Σm(1,2,3,5,7). K-map groups: {1,3,5,7}=x₃; {2,3}=x̄₁x₂; {3,7}=x₂x₃.

最小 SOP = x₃ + x̄₁x₂。檢查靜態 1 冒險:是否有相鄰的 1 不在同一個群組裡?

Min SOP = x₃ + x̄₁x₂. Check for static 1-hazard: adjacent 1s not in same group?

最小 SOP = x₃ + x̄₁x₂。静的 1 ハザードを調べる:同じグループに入っていない隣接した 1 はあるか。

最小項 2(010) 與 3(011):分別由 x̄₁x₂ 與 x₃ 涵蓋。在 x₁=0、x₂=1 之下的轉移 m2→m3(x₃:0→1):起初 x̄₁x₂=1,最後 x₃=1。轉態期間會不會有一瞬間兩者皆非 1?不會 — x̄₁x₂ 全程都是 1(x₁、x₂ 保持不變)。這條路徑上沒有冒險。

Minterms 2(010) and 3(011): covered by x̄₁x₂ and x₃ respectively. Transition m2→m3 (x₃: 0→1) with x₁=0,x₂=1: initially x̄₁x₂=1, finally x₃=1. During transition: momentarily neither? No — x̄₁x₂=1 throughout (x₁,x₂ constant). No hazard on this path.

最小項 2(010) と 3(011) は、それぞれ x̄₁x₂ と x₃ に覆われる。x₁=0、x₂=1 のもとでの遷移 m2→m3(x₃:0→1)では、初めは x̄₁x₂=1、最後は x₃=1 である。遷移中に一瞬どちらも 1 でなくなるか。ならない — x₁、x₂ は変わらないので x̄₁x₂=1 が全区間で成り立つ。この経路にハザードはない。

檢查 m5(101)→m7(111):x₁=1、x₃=1 之下 x₂:0→1。之前:x₃=1(涵蓋)。之後:x₃=1 且 x₂x₃=1。沒有冒險。

Check m5(101)→m7(111): x₂:0→1 with x₁=1,x₃=1. Before: x₃=1(covers). After: x₃=1 and x₂x₃=1. No hazard.

m5(101)→m7(111) を調べる:x₁=1、x₃=1 のもとで x₂:0→1。変化前は x₃=1(覆っている)。変化後は x₃=1 かつ x₂x₃=1。ハザードはない。

m2(010) 與 m3(011) 之間存在冒險:x̄₁x₂ 涵蓋 m2,x₃ 涵蓋 m3。加入 x̄₁x₂x₃ 作為橋接項,或加入額外的 PI x₂x₃:f = x₃ + x̄₁x₂ + x̄₁x₃ 即為無冒險(多出來的項起了橋接作用)。

Hazard exists between m2(010) and m3(011): x̄₁x₂ covers m2; x₃ covers m3. Adding x̄₁x₂x₃ as bridge or the extra PI x₂x₃: f = x₃ + x̄₁x₂ + x̄₁x₃ is hazard-free (extra term bridges).

m2(010) と m3(011) の間にはハザードがある:m2 は x̄₁x₂ が、m3 は x₃ が覆っている。橋渡しとして x̄₁x₂x₃ を、あるいは追加の PI x₂x₃ を加えると、f = x₃ + x̄₁x₂ + x̄₁x₃ はハザードフリーになる(追加の項が橋渡しをする)。

9.9

Y₁ = x̄₁(x₂+y₁);Y₂ = x₁(x̄₂+y₂)。建立流程表:狀態 = (y₁y₂),輸入 = (x₁x₂)。

Y₁ = x̄₁(x₂+y₁); Y₂ = x₁(x̄₂+y₂). Build flow table: states = (y₁y₂), inputs = (x₁x₂).

Y₁ = x̄₁(x₂+y₁)、Y₂ = x₁(x̄₂+y₂)。フロー表を作る:状態 = (y₁y₂)、入力 = (x₁x₂)。

y₁y₂x₁x₂=00011110
0000→0001→0,00000
0101→0,001→0101→0,100
1010→1,010→1,010→1,110→10
111011→1,111→1110

穩定狀態(Y=y):(00,x=00)、(01,x=01)、(10,x=10)、(11,x=11)。轉移由對每個 (y₁y₂,x₁x₂) 組合計算 Y₁、Y₂ 而定。

Stable states (Y=y): (00,x=00), (01,x=01), (10,x=10), (11,x=11). Transitions determined by evaluating Y₁,Y₂ for each (y₁y₂,x₁x₂) combination.

安定状態(Y=y):(00,x=00)、(01,x=01)、(10,x=10)、(11,x=11)。遷移は、各 (y₁y₂,x₁x₂) の組合せについて Y₁、Y₂ を評価して決まる。

9.10
面向Aspect観点同步Synchronous同期非同步Asynchronous非同期
Speed受時脈週期限制Limited by clock periodクロック周期に制限される可能較快(沒有時脈的額外開銷)Can be faster (no clock overhead)高速にできる場合がある(クロックのオーバーヘッドがない)
Power時脈樹持續切換Clock tree always switchingクロックツリーが常にスイッチしている取決於活動量;有機會更低Activity-dependent; potentially lower動作量に依存する。より低くできる可能性がある
Testability容易:可用掃描鏈,狀態可控Easy: scan chains, controllable states容易:スキャンチェーン、状態を制御できる困難:行為與時序相關Difficult: timing-dependent behavior困難:動作がタイミングに依存する
Design effort已充分理解;CAD 支援豐富Well-understood; rich CAD support十分に確立している。CAD の支援も豊富複雜;有競爭與冒險,工具有限Complex; races, hazards, limited tools複雑。競合やハザードがあり、ツールも限られる
Noise時脈邊緣的同時切換雜訊Simultaneous switching noise at clock edgesクロックエッジにおける同時スイッチングノイズ分散開來;EMI 較低Spread out; less EMI分散するため EMI が少ない
9.11

本質冒險:非同步順序電路中固有的冒險,無法藉由增刪閘來消除。當單一輸入變化使電路循環經過多個不穩定狀態,而狀態變數改變所需的先後順序又無法僅靠組合邏輯的延遲匹配來保證時,就會出現這種冒險。

Essential hazard: An inherent hazard in an asynchronous sequential circuit that cannot be eliminated by adding or removing gates. It arises when a single input change causes the circuit to cycle through multiple unstable states, and the required ordering of state variable changes cannot be guaranteed by pure combinational logic delay matching.

本質ハザード:非同期順序回路に固有のハザードで、ゲートを追加・削除しても除去できない。単一の入力変化によって回路が複数の不安定状態を巡り、状態変数の変化に必要な順序が純粋な組合せ論理の遅延整合だけでは保証できないときに生じる。

與靜態/動態冒險的差別:靜態/動態冒險發生在組合邏輯中,可藉由加入冗餘項消除。本質冒險則是順序性的 — 它源自回授迴路與輸入變化之間的交互作用。

Differs from static/dynamic hazards: Static/dynamic hazards occur in combinational logic and can be eliminated by adding redundant terms. Essential hazards are sequential — they result from the interaction between feedback loops and input changes.

静的/動的ハザードとの違い:静的・動的ハザードは組合せ論理で生じ、冗長項を加えれば除去できる。本質ハザードは順序的なものであり、帰還ループと入力変化の相互作用から生じる。

加閘能解決嗎?加冗餘項是沒有用的。本質冒險必須在特定的回授線上刻意插入延遲(例如 RC 電路或緩衝器鏈),以確保狀態變數更新的先後順序正確。

Can gates fix it? Not by adding redundant terms. Instead, essential hazards require introducing deliberate delays (e.g., RC circuits or buffer chains) on specific feedback lines to ensure the proper sequencing of state variable updates.

ゲートで直せるか?冗長項を加えても直らない。本質ハザードには、特定の帰還線に意図的な遅延(たとえば RC 回路やバッファ列)を挿入し、状態変数の更新順序を正しく保つことが必要である。

9.12

Muller C 元件:只有當所有輸入一致時,輸出 C 才會跟著輸入改變;否則保持前一個值。

Muller C-element: output C changes to match inputs only when all inputs agree; holds previous value otherwise.

Muller C 素子:すべての入力が一致したときにだけ出力 C が入力に合わせて変化し、それ以外では前の値を保持する。

對 2 輸入的 C 元件:C(t+1) = AB + (A+B)·C = AB + AC + BC(A、B、C_current 的多數決函數)。

For 2-input C-element: C(t+1) = AB + (A+B)·C = AB + AC + BC (majority function of A, B, C_current).

2 入力の C 素子では:C(t+1) = AB + (A+B)·C = AB + AC + BC(A、B、C_current の多数決関数)。

以非同步技巧實作:

Implementation using async techniques:

非同期の手法による実装:

Y = A·B + Y·(A + B)
  = A·B + Y·A + Y·B

電路:兩個 AND 閘產生 AB 以及 YA 與 YB;一個 OR 閘產生 Y。這是一個無冒險的方程式,因為回授的 Y 確保 A≠B 時 C 會保持原值。

Circuit: two AND gates for AB and YA and YB; one OR gate for Y. This is a hazard-free equation since the feedback Y ensures that C holds its value when A≠B.

回路:AND ゲート 2 個で AB と YA・YB を作り、OR ゲート 1 個で Y を作る。帰還の Y によって A≠B のとき C が値を保持するので、これはハザードのない式である。

C 元件是握手式非同步協定(Micropipelines、NULL convention logic)的基礎元件。

The C-element is fundamental to handshaking asynchronous protocols (Micropipelines, NULL convention logic).

C 素子は、ハンドシェイク型の非同期プロトコル(Micropipelines、NULL convention logic)の基礎となる要素である。

9.36

由原始流程表合成 SR 閂鎖:

SR latch synthesis from primitive flow table:

原始フロー表からの SR ラッチの合成:

原始流程表:2 列(Q=0、Q=1),4 個輸入欄位(SR:00,01,10,11)。令 y=Q。

Primitive flow table: 2 rows (Q=0, Q=1), 4 input columns (SR: 00,01,10,11). Assign y=Q.

原始フロー表:2 行(Q=0、Q=1)、入力列 4 つ(SR:00,01,10,11)。y=Q と割り当てる。

由流程表得到的激勵 Y(下一狀態):

Excitation Y (next state) from the flow table:

フロー表から得られる励振 Y(次状態):

Y = S + R̄·y(標準的 SR 閂鎖方程式,假設 SR≠11)。

Y = S + R̄·y (standard SR latch equation, SR≠11 assumed).

Y = S + R̄·y(標準的な SR ラッチの式。SR≠11 を仮定する)。

輸出 Q = y(直接就是狀態變數)。

Output Q = y (state variable directly).

出力 Q = y(状態変数そのもの)。

實作:Y = NOR(R, NOR(S,Y)) — 交叉耦合的 NOR 閘很自然地實現了這個回授方程式。

Implementation: Y = NOR(R, NOR(S,Y)) — cross-coupled NOR gates realize this feedback equation naturally.

実装:Y = NOR(R, NOR(S,Y)) — 交差結合した NOR ゲートがこの帰還方程式をそのまま実現する。

9.37

非同步流程表的狀態化簡:

State reduction on an async flow table:

非同期フロー表の状態縮小:

  1. 為狀態 A–D 建立蘊涵表 (implication chart)。
  2. Build implication chart for states A–D.
  3. 状態 A–D について含意表 (implication chart) を作る。
  4. 把輸出不同的狀態對標記為不相容。
  5. Mark pairs with different outputs as incompatible.
  6. 出力が異なる対は両立しないと印を付ける。
  7. 對其餘的狀態對,檢查它們的蘊涵對是否相容。
  8. For remaining pairs, check if their implied pairs are compatible.
  9. 残りの対については、その含意対が両立するかどうかを調べる。
  10. 反覆傳播不相容關係,直到不再有變化為止。
  11. Propagate incompatibilities until no more changes.
  12. 変化がなくなるまで、両立しない関係を伝播させる。
  13. 相容的狀態對可以合併。
  14. Compatible pairs can be merged.
  15. 両立する対は併合できる。

例如:若 A 與 C 的輸出相同,且它們在所有輸入下的後繼狀態也都是相容對 → A≡C,可合併為單一狀態。這能減少流程表的列數,使實作更為簡化。

Example: if A and C have same outputs and their successors under all inputs are also compatible pairs → A≡C, merge to a single state. Reduces the flow table rows, simplifying the implementation.

例:A と C の出力が同じで、すべての入力に対する後続状態もまた両立対であれば → A≡C となり、1 つの状態に併合できる。フロー表の行数が減り、実装が簡単になる。

9.38

3 狀態非同步 FSM 的 one-hot 狀態編碼:每個狀態配一個 SR 閂鎖(或正反器)。

One-hot state encoding for 3-state async FSM: one SR latch (or FF) per state.

3 状態の非同期 FSM に対する one-hot 状態符号化:状態ごとに SR ラッチ(またはフリップフロップ)を 1 個割り当てる。

狀態 S₁,S₂,S₃ → y₁,y₂,y₃,任何時刻只有一個 yᵢ=1。

States S₁,S₂,S₃ → y₁,y₂,y₃ with only one yᵢ=1 at a time.

状態 S₁,S₂,S₃ → y₁,y₂,y₃ とし、常にどれか 1 つだけが yᵢ=1 となる。

轉移的控制方式,是設定目標狀態的閂鎖並重置目前狀態的閂鎖。由於每次轉移只有一個變數改變(被設定或被重置的那一個),one-hot 對非同步電路而言本質上就是無競爭的。

Transitions are controlled by setting the target state latch and resetting the current state latch. Since only one variable changes per transition (the one being set or reset), one-hot is inherently race-free for asynchronous circuits.

遷移は、行き先の状態のラッチをセットし、現在の状態のラッチをリセットすることで制御する。1 回の遷移で変化する変数は 1 つだけ(セットまたはリセットされるもの)なので、one-hot は非同期回路にとって本質的に競合のない方式である。

優點:沒有臨界競爭。缺點:用掉較多狀態變數(3 個狀態要用 3 個而不是 2 個)。

Advantage: no critical races. Disadvantage: uses more state variables (3 instead of 2 for 3 states).

利点:臨界競合が生じない。欠点:状態変数を多く使う(3 状態に対して 2 個ではなく 3 個)。

9.39

非同步電路設計的三大挑戰:

Three challenges of async circuit design:

非同期回路設計における 3 つの課題:

  1. 競爭:當多個狀態變數同時改變時,結果是不確定的。必須小心進行狀態指派,或改用 one-hot 編碼,才能確保轉移無競爭。
  2. Races: When multiple state variables change simultaneously, the outcome is non-deterministic. Requires careful state assignment or one-hot encoding to ensure race-free transitions.
  3. 競合:複数の状態変数が同時に変化すると、結果が非決定的になる。競合のない遷移にするには、慎重な状態割当てか one-hot 符号化が必要である。
  4. 冒險:組合邏輯中的突波(靜態 1/0、動態)由於沒有時脈可以遮蔽,可能造成假的狀態轉移。所有冒險都必須靠加入冗餘邏輯來消除。
  5. Hazards: Glitches in combinational logic (static 1/0, dynamic) can cause spurious state transitions since there is no clock to mask them. All hazards must be eliminated by adding redundant logic.
  6. ハザード:組合せ論理のグリッチ(静的 1/0、動的)は、それを覆い隠すクロックがないため、誤った状態遷移を引き起こしうる。すべてのハザードは冗長な論理を加えて除去しなければならない。
  7. 基本模式的違反:設計假設一次只有一個輸入改變,且電路會在下一次變化前穩定下來。一旦違反,行為就是未定義的。要測試並驗證這些時序假設相當困難。
  8. Fundamental mode violations: Design assumes one input changes at a time and circuit settles before next change. If violated, behavior is undefined. Testing and verifying these timing assumptions is difficult.
  9. 基本モード違反:設計は、入力が一度に 1 つだけ変化し、次の変化までに回路が落ち着くことを前提とする。これが破られると動作は未定義になる。こうしたタイミング前提のテストと検証は難しい。
9.40

原始流程表:每個穩定狀態各佔一列。該列中的每個輸入組合恰有一個穩定狀態(即目前狀態),並顯示各輸入組合下的下一狀態。列不做合併 — 每列只有一個唯一的穩定狀態。

Primitive flow table: One row per stable state. Each input combination in that row has exactly one stable state (the current state) and shows the next state for each input combination. Rows are not merged — one unique stable state per row.

原始フロー表:安定状態ごとに 1 行を置く。その行の各入力組合せはちょうど 1 つの安定状態(現在の状態)を持ち、入力組合せごとの次状態を示す。行は併合しない — 1 行につき固有の安定状態が 1 つである。

合併流程表:把多個相容的穩定狀態併入同一列,藉此減少狀態變數的數目(需要的正反器變少)。

Merged flow table: Multiple compatible stable states combined into one row, reducing the number of state variables (fewer FFs needed).

併合フロー表:両立する複数の安定状態を 1 行にまとめ、状態変数の数を減らす(必要なフリップフロップが少なくなる)。

為什麼需要合併:有 N 個穩定狀態的原始流程表需要 ⌈log₂N⌉ 個狀態變數,或 N 個狀態變數(one-hot)。合併相容狀態可減少列數(因而也減少狀態變數),得到更精簡的實作,並簡化激勵方程式。

Why merging is needed: A primitive flow table with N stable states requires ⌈log₂N⌉ state variables or N state variables (one-hot). Merging compatible states reduces the number of rows (and thus state variables), yielding a more compact implementation and simplifying the excitation equations.

併合が必要な理由:安定状態が N 個の原始フロー表には ⌈log₂N⌉ 個の状態変数、あるいは N 個の状態変数(one-hot)が要る。両立する状態を併合すれば行数(したがって状態変数)が減り、より小さな実装が得られ、励振方程式も簡単になる。

9.41

動態冒險:本該只變化一次(0→1 或 1→0)的訊號,卻因電路中存在多條延遲不同的路徑,而變化了三次以上(0→1→0→1 或 1→0→1→0)。

Dynamic hazard: A signal that should make a single transition (0→1 or 1→0) instead makes three or more transitions (0→1→0→1 or 1→0→1→0) due to multiple paths with different delays in the circuit.

動的ハザード:本来 1 回だけ遷移する(0→1 または 1→0)はずの信号が、回路内に遅延の異なる複数の経路があるために 3 回以上遷移してしまう(0→1→0→1 または 1→0→1→0)現象である。

成立條件:需要從輸入到輸出至少有三條延遲不同的相異路徑,且這些路徑會在某處再度匯合(再收斂扇出)。

Conditions: Requires at least three distinct paths from input to output with different delays, and reconvergent fan-out where the paths merge.

成立条件:入力から出力まで、遅延の異なる相異なる経路が少なくとも 3 本あり、それらが合流する再収束ファンアウトが存在することが必要である。

消除方式:動態冒險無法像靜態冒險那樣單靠加項就消除。它需要改變電路結構 — 消除再收斂路徑、確保沒有互相競爭的路徑,或採用無冒險的邏輯設計技巧,例如以單一扇入層來實作。

Elimination: Dynamic hazards cannot be eliminated simply by adding terms (unlike static hazards). They require restructuring the circuit — either eliminating reconvergent paths, ensuring that no competing paths exist, or using hazard-free logic design techniques such as implementing in a single fan-in stage.

除去法:動的ハザードは、静的ハザードと違って項を加えるだけでは除去できない。回路の構造を組み直す必要がある — 再収束経路をなくす、競合する経路が存在しないようにする、あるいは単一のファンイン段で実装するようなハザードフリーの論理設計手法を用いる。

9.42

非同步設計中的「不會發生」輸入組合,指的是實體上不可能出現的輸入狀態組合 — 或因電路限制,或因設計上的約定。

"Don't happen" input combinations in async design are input state combinations that cannot physically occur — either due to circuit constraints or by design convention.

非同期設計における「起こらない」入力組合せとは、物理的に生じ得ない入力状態の組合せのことである — 回路上の制約によるか、設計上の取り決めによる。

它們在流程表的格子裡以空白或「–」表示。例如,若輸入是閂鎖的 R 與 S,則 R=1, S=1 這個組合可以定義為「不會發生」的條件(絕不同時施加)。

They appear as blanks or "–" in the flow table cells. For example, if inputs are R and S of a latch, the combination R=1, S=1 may be defined as a "don't happen" condition (never applied simultaneously).

フロー表のセルでは空欄または「–」として現れる。たとえば入力がラッチの R と S なら、R=1, S=1 という組合せを「起こらない」条件(同時には決して与えない)と定めてよい。

在化簡激勵方程式時,這些會被當作 don't-care 條件處理 — 可自由指定為 0 或 1 以降低邏輯成本 — 前提是電路設計者保證它們真的絕不會發生。

These are treated as don't-care conditions during excitation equation minimization — may be assigned 0 or 1 freely to minimize logic cost — provided the circuit designer guarantees they never actually occur.

これらは励振方程式の最小化にあたって don't-care 条件として扱われ、論理コストを下げるように 0 でも 1 でも自由に割り当ててよい — ただし、実際に決して起こらないことを回路設計者が保証する場合に限る。

9.43

服務兩個請求者 r₁、r₂ 的非同步仲裁器。它必須達成互斥 — 任何時刻只有一個授權有效。

Async arbiter for two requestors r₁, r₂. Must grant mutual exclusion — only one grant active at a time.

2 つの要求元 r₁、r₂ のための非同期アービタ。相互排除を保証しなければならない — 同時に有効な許可は 1 つだけである。

仲裁器本質上就是一個非同步元件。最簡單的實作使用交叉耦合的 set-reset 電路:

The arbiter is an inherently asynchronous element. A simple implementation uses a cross-coupled set-reset circuit:

アービタは本質的に非同期な要素である。単純な実装では、交差結合した set-reset 回路を用いる:

g₁ = r₁ AND NOT(g₂)  // can only grant 1 if 2 not granted
g₂ = r₂ AND NOT(g₁)

但這樣會有組合迴路(當 r₁,r₂ 同時為 1 時會進入亞穩態)。正規的非同步仲裁器會使用 Muller C 元件,或使用內建亞穩態解析時間的雙穩態電路。當請求同時到達時,電路並非真正具有決定性 — 這是根本性的限制(由 Lamport 證明)。

But this has a combinational loop (metastable when both r₁,r₂=1 simultaneously). A proper async arbiter uses a Muller C-element or bistable circuit with metastability resolution time built in. The circuit is not truly deterministic when requests arrive simultaneously — this is fundamental (proven by Lamport).

しかしこれには組合せループがある(r₁,r₂ が同時に 1 のとき準安定になる)。まともな非同期アービタは、Muller C 素子か、準安定状態の解消時間を織り込んだ双安定回路を用いる。要求が同時に到着したとき、回路は真に決定的ではない — これは原理的な限界である(Lamport が証明した)。

9.44

4 狀態非同步 FSM 的無競爭狀態指派。狀態 A,B,C,D 需要一組二進位碼,使得任何必要的轉移都只改變 1 個位元(以避免臨界競爭)。

Race-free state assignment for 4-state async FSM. States A,B,C,D need binary codes such that any required transition changes only 1 bit (to avoid critical races).

4 状態の非同期 FSM に対する競合のない状態割当て。状態 A,B,C,D には、必要な遷移がどれも 1 ビットしか変化しないような 2 進符号を与える(臨界競合を避けるため)。

畫出轉移圖。必要的轉移例如:A→B、B→C、C→D、D→A。

Draw the transition diagram. Required transitions: e.g., A→B, B→C, C→D, D→A.

遷移図を描く。必要な遷移はたとえば A→B、B→C、C→D、D→A である。

指派編碼,使每次轉移只相差 1 個位元(Gray code 序列):

Assign codes so each transition differs by 1 bit (Gray code sequence):

各遷移が 1 ビットだけ異なるように符号を割り当てる(Gray code の並び):

A=00, B=01, C=11, D=10(標準格雷碼)。

A=00, B=01, C=11, D=10 (standard Gray code).

A=00, B=01, C=11, D=10(標準的なグレイ符号)。

若需要 A→C 或 B→D 這類轉移(2 個位元改變),就加入中間狀態,或使用共用列 (shared-row) 技巧(額外的狀態碼作為轉移的中介)。

If transitions A→C or B→D are needed (2-bit change), add intermediate states or use shared-row technique (extra state codes that serve as transition intermediaries).

A→C や B→D のような遷移(2 ビット変化)が必要な場合は、中間状態を追加するか、共有行 (shared-row) 手法(遷移の仲介役となる余分な状態符号)を用いる。

9.45

非同步販賣機控制器:原始流程表中,每個「穩定狀態–輸入」組合各佔一列。

Async vending machine controller: primitive flow table has one row per stable state-input combination.

非同期の自動販売機コントローラ:原始フロー表は、安定状態と入力の組合せごとに 1 行を持つ。

狀態範例:IDLE、GOT_NICKEL、GOT_DIME、DISPENSE。輸入變數:N(投入 5 分硬幣)、D(投入 10 分硬幣)。輸出:dispense、change。

Example states: IDLE, GOT_NICKEL, GOT_DIME, DISPENSE. Input variables: N (nickel inserted), D (dime inserted). Output: dispense, change.

状態の例:IDLE、GOT_NICKEL、GOT_DIME、DISPENSE。入力変数:N(5 セント投入)、D(10 セント投入)。出力:dispense、change。

原始流程表:每一列都是一組唯一的(狀態, 輸入)配對,並帶有一個穩定狀態。相鄰且相容的列,用合併圖加以合併。合併後指派無競爭的狀態碼,再用卡諾圖推導各狀態變數的激勵方程式。

Primitive flow table: each row is a unique (state, input) pair with a stable state. Adjacent rows that are compatible are merged using the merger diagram. After merging, assign race-free state codes and derive excitation equations for each state variable using K-maps.

原始フロー表:各行は安定状態を 1 つ持つ固有の(状態, 入力)の対である。隣り合う両立可能な行は、マージャ図を使って併合する。併合後、競合のない状態符号を割り当て、カルノー図で各状態変数の励振方程式を導く。

9.46

對 5 狀態的非同步 FSM,若必要的轉移涉及多位元變化,則以 ⌈log₂5⌉=3 個位元可能不存在無競爭的指派。

For a 5-state async FSM, a race-free assignment may not exist with ⌈log₂5⌉=3 bits if required transitions involve multi-bit changes.

5 状態の非同期 FSM では、必要な遷移に複数ビットの変化が含まれる場合、⌈log₂5⌉=3 ビットでは競合のない割当てが存在しないことがある。

共用列技巧:在有問題的轉移之間加入「額外的」(中間)狀態。這些額外狀態具有唯一的編碼,與來源和目的地都只相差 1 個位元,於是把一次 2 位元的轉移換成連續兩次 1 位元的轉移。

Shared-row technique: Add "extra" (intermediate) states between problematic transitions. The extra states have unique codes that differ by 1 bit from both the source and destination, converting a 2-bit transition into two consecutive 1-bit transitions.

共有行 (shared-row) 手法:問題のある遷移の間に「余分な」(中間)状態を加える。余分な状態には、始点と終点のどちらからも 1 ビットだけ異なる固有の符号を与え、2 ビットの遷移を連続する 2 回の 1 ビット遷移に置き換える。

例如,轉移 A(001)→C(110) 需要 3 個位元改變。加入中間狀態 X(011) 或 (101):A→X→C,每一步只改變 1 個位元。對相關的輸入而言 X 是不穩定狀態 — 電路在前往 C 的途中會瞬間通過 X。

For example, transition A(001)→C(110) requires 3-bit change. Add intermediate state X(011) or (101): A→X→C, each step changes 1 bit. X is an unstable state for the relevant input — the circuit passes through X instantaneously on its way to C.

たとえば遷移 A(001)→C(110) は 3 ビットの変化を要する。中間状態 X(011) または (101) を加えれば A→X→C となり、各段は 1 ビットずつ変化する。X は当該入力に対して不安定状態であり、回路は C へ向かう途中で瞬間的に X を通過する。

9.47

對於 6 列的流程表(6 個穩定狀態):

For a 6-row flow table (6 stable states):

6 行のフロー表(安定状態 6 個)について:

  1. 建立合併圖 (merger diagram):把彼此相容的狀態對連起來。
  2. Build merger diagram: connect compatible state pairs.
  3. マージャ図 (merger diagram) を作る:両立する状態対どうしを結ぶ。
  4. 在合併圖中找出最大團 (maximum clique) — 也就是彼此兩兩相容的狀態群組。
  5. Find maximum cliques in the merger diagram — groups of mutually compatible states.
  6. マージャ図の最大クリークを求める — 互いに両立する状態のグループである。
  7. 挑出能涵蓋所有狀態的最少組數(團數)。
  8. Select minimum number of groups (cliques) that cover all states.
  9. すべての状態を覆う最小個数のグループ(クリーク)を選ぶ。
  10. 對合併後的列指派二進位碼;務必做到無競爭 (race-free) 指派。
  11. Assign binary codes to merged rows; ensure race-free assignment.
  12. 併合後の各行に 2 進符号を割り当てる。競合のない (race-free) 割当てにすること。
  13. 以卡諾圖從合併後的流程表推導激勵方程式 Y₁、Y₂ 與輸出方程式。
  14. Derive excitation equations Y₁, Y₂ and output equations from the merged flow table using K-maps.
  15. 併合したフロー表から、カルノー図を用いて励振方程式 Y₁、Y₂ と出力方程式を導く。

共 6 個狀態時,理想上可合併到 2–3 列(2 個狀態變數),但受限制影響可能需要更多。

With 6 states, ideally merge to 2–3 rows (2 state variables), though constraints may require more.

状態が 6 個なら理想的には 2–3 行(状態変数 2 個)まで併合できるが、制約によってはそれ以上必要になることもある。

9.48

證明:兩層 SOP 不會有靜態 0 冒險

Proof that two-level SOP has no static 0-hazards:

証明:2 レベル SOP に静的 0 ハザードは生じない

靜態 0 冒險是指輸出本該維持 0,卻短暫跳到 1。在兩層 SOP 中,只有當至少一個乘積項為 1 時輸出才會是 1。若輸出應維持 0,則所有乘積項在轉態前後都必須為 0。轉態過程中,每個乘積項都是各個閘延遲的靜態函數 — 乘積項只有在其所有輸入同時為 1 時才可能出現 0→1 的突波,但那代表函數值其實是 1 而非 0。因此,前後值皆為 0 的乘積項不可能產生 1 突波。故 SOP 中不存在靜態 0 冒險。∎

A static 0-hazard occurs when the output should remain 0 but briefly goes to 1. In a two-level SOP, the output is 1 only when at least one product term is 1. If the output should remain 0, all product terms must be 0 both before and after the transition. During the transition, each product term is a static function of individual gate delays — a product term can only glitch 0→1 if both its inputs are 1 simultaneously, but that would mean the function value is actually 1, not 0. Therefore, a product term cannot produce a 1-glitch when both its pre- and post-transition values are 0. Hence no static 0-hazard in SOP. ∎

静的 0 ハザードとは、出力が 0 のままであるべきなのに一瞬 1 になってしまう現象である。2 レベル SOP では、少なくとも 1 つの積項が 1 のときにのみ出力が 1 になる。出力が 0 のままであるべきなら、遷移の前後いずれでもすべての積項が 0 でなければならない。遷移中、各積項は個々のゲート遅延の静的な関数である — 積項が 0→1 のグリッチを起こせるのは、その入力がすべて同時に 1 になるときだけだが、それは関数値が実際には 0 ではなく 1 であることを意味する。したがって、遷移の前後とも値が 0 である積項が 1 のグリッチを出すことはあり得ない。ゆえに SOP に静的 0 ハザードは存在しない。∎

那靜態 0 冒險何時會出現? 出現在兩層 POS(積之和的對偶,和項之積)實作中 — 和項裡的冒險會在輸出本該維持 0 時,於輸出上產生 0 突波。

When do static 0-hazards appear? In two-level POS (product of sums) implementations — hazards in the sum terms can produce 0-glitches on the output when the output should remain 0.

では静的 0 ハザードはいつ現れるのか? 2 レベル POS(和項の積)による実装で現れる — 和項側のハザードが、出力が 0 のままであるべきときに 0 のグリッチを生じさせる。

9.13E

把 $C, D$ 視為輸入,$y$(閂鎖狀態)是唯一的狀態變數。下一狀態:$Y = CD + \overline{C}y$($C=1$ 時 $Y=D$;$C=0$ 時 $Y=y$)。$(C,D,y)$ 上的激勵表:$(00,0),(01,0),(10,0),(11,0)$ 時 $Y = 0$;$(00,1),(01,1),(10,1),(11,1)$ 時 $Y=1$ — 也就是 $C=0$ 時不論 $D$ 為何都保持穩定,$C=1$ 時則為穿透 (transparent)。流程表:2 個穩定狀態 $S_1$($y=0$)與 $S_2$($y=1$);$CD=11$ 時 $S_1\to S_2$,$CD=10$ 時 $S_2\to S_1$。

Treat $C, D$ as inputs and $y$ (latch state) as the only state variable. Next-state: $Y = CD + \overline{C}y$ (when $C=1$, $Y=D$; when $C=0$, $Y=y$). Excitation table over $(C,D,y)$: $Y = 0$ for $(00,0),(01,0),(10,0),(11,0)$; $Y=1$ for $(00,1),(01,1),(10,1),(11,1)$ — i.e. stable when $C=0$ regardless of $D$, transparent when $C=1$. Flow table: 2 stable states $S_1$ ($y=0$) and $S_2$ ($y=1$); $S_1\to S_2$ when $CD=11$; $S_2\to S_1$ when $CD=10$.

$C, D$ を入力、$y$(ラッチの状態)を唯一の状態変数とみなす。次状態は $Y = CD + \overline{C}y$($C=1$ のとき $Y=D$、$C=0$ のとき $Y=y$)。$(C,D,y)$ 上の励振表:$(00,0),(01,0),(10,0),(11,0)$ で $Y = 0$、$(00,1),(01,1),(10,1),(11,1)$ で $Y=1$ — すなわち $C=0$ なら $D$ によらず安定、$C=1$ なら透過 (transparent) となる。フロー表:安定状態は $S_1$($y=0$)と $S_2$($y=1$)の 2 つ。$CD=11$ で $S_1\to S_2$、$CD=10$ で $S_2\to S_1$。

9.14E

兩個狀態變數 $y_m, y_s$。$Y_m = CD + \overline{C}y_m$($C=1$ 時主閂鎖穿透);$Y_s = Cy_m + \overline{C}y_s$($C=0$ 時從閂鎖穿透,$C=1$ 時複製 $y_m$ — 實際上從閂鎖是在 $C=0$ 時複製,故 $Y_s = \overline{C}y_m + Cy_s$)。請以課本的確切形式為準。四個狀態 $S_1\ldots S_4$ 對應 $(y_m, y_s) \in \{00, 01, 10, 11\}$。激勵表追蹤輸入變化下的每一次轉移;流程表顯示主閂鎖在 $C=1$ 時載入、從閂鎖在 $C=0$ 時輸出 — 也就是正確的邊緣觸發行為。

Two state variables $y_m, y_s$. $Y_m = CD + \overline{C}y_m$ (master latch transparent when $C=1$); $Y_s = Cy_m + \overline{C}y_s$ (slave transparent when $C=0$, copies $y_m$ when $C=1$ — actually, slave copies when $C=0$, so $Y_s = \overline{C}y_m + Cy_s$). Use the textbook's exact form. Four states $S_1\ldots S_4$ correspond to $(y_m, y_s) \in \{00, 01, 10, 11\}$. Excitation table tracks each transition under input changes; flow table shows the master loads on $C=1$, slave outputs on $C=0$ — i.e. proper edge-triggered behavior.

状態変数は $y_m, y_s$ の 2 つ。$Y_m = CD + \overline{C}y_m$($C=1$ でマスタラッチが透過)、$Y_s = Cy_m + \overline{C}y_s$($C=0$ でスレーブが透過し、$C=1$ で $y_m$ を写す — 正確にはスレーブが写すのは $C=0$ のときなので $Y_s = \overline{C}y_m + Cy_s$)。教科書どおりの形を用いること。4 つの状態 $S_1\ldots S_4$ は $(y_m, y_s) \in \{00, 01, 10, 11\}$ に対応する。励振表は入力変化ごとの遷移を追い、フロー表は $C=1$ でマスタが取り込み、$C=0$ でスレーブが出力すること — すなわち正しいエッジトリガ動作を示す。

9.15E

用給定的方程式,對每一組 $(w_1, w_2, y_1, y_2)$ 列出 $(Y_1, Y_2)$。找出穩定狀態($Y_i = y_i$ 之處):也就是沒有變化的列。輸出 $z = y_1\overline{y_2}$。狀態:$(00)$ 閒置、$(01)$ 投入第一枚硬幣、$(10)$ 投入第二枚硬幣(出貨脈衝),再回到 $(00)$。輸入 $w_1$(一枚硬幣)時 FSM 前進;輸入 $w_2$(另一枚硬幣)時亦然。狀態圖:3 個可達狀態,$z=1$ 出現在狀態 $10$ — 投入兩枚硬幣後出貨的販賣機。

Tabulate $(Y_1, Y_2)$ for each $(w_1, w_2, y_1, y_2)$ combination using the given equations. Stable states (where $Y_i = y_i$): identify rows with no change. Output $z = y_1\overline{y_2}$. States: $(00)$ idle, $(01)$ first coin, $(10)$ second coin (vend pulse), back to $(00)$. On input $w_1$ (a coin), the FSM advances; on $w_2$ (a separate coin) likewise. State diagram: 3 reachable states, $z=1$ in state $10$ — vending machine that dispenses after two coins.

与えられた式を使い、$(w_1, w_2, y_1, y_2)$ の各組合せについて $(Y_1, Y_2)$ を表にする。安定状態($Y_i = y_i$ となるところ)を見つける:変化のない行である。出力は $z = y_1\overline{y_2}$。状態は $(00)$ 待機、$(01)$ 1 枚目のコイン、$(10)$ 2 枚目のコイン(払い出しパルス)、そして $(00)$ へ戻る。入力 $w_1$(コイン 1 枚)で FSM は進み、$w_2$(別のコイン)でも同様である。状態図:到達可能な状態は 3 つで、状態 $10$ で $z=1$ — コイン 2 枚で商品を出す自動販売機である。

9.16E

四個狀態 $A, B, C, D$(偶數/奇數脈衝的上升緣與下降緣之間的狀態)。$A$($w=0$、$z=0$、偶數計數),$w$ 上升時 → $B$;$B$($w=1$、$z=1$、奇數計數),$w$ 下降時 → $C$;$C$($w=0$、$z=1$),$w$ 上升時 → $D$;$D$($w=1$、$z=0$),$w$ 下降時 → $A$。無競爭指派:$A=00, B=01, C=11, D=10$(格雷碼,繞一圈每次只變一個位元)。下一狀態式:$Y_1 = w y_2 + y_1 w$(其餘由卡諾圖推導),輸出 $z = y_2 \oplus y_1$(或類似的簡單式子)。

Four states $A, B, C, D$ (states between rising and falling edges of even/odd pulses). $A$ ($w=0$, $z=0$, even count), on $w$ rising → $B$; $B$ ($w=1$, $z=1$, odd count), on $w$ falling → $C$; $C$ ($w=0$, $z=1$), on $w$ rising → $D$; $D$ ($w=1$, $z=0$), on $w$ falling → $A$. Race-free assignment: $A=00, B=01, C=11, D=10$ (Gray code, single-bit changes around the loop). Next-state expressions: $Y_1 = w y_2 + y_1 w$ (etc., derive from K-map), output $z = y_2 \oplus y_1$ (or similar simple expression).

状態は $A, B, C, D$ の 4 つ(偶数/奇数パルスの立上りと立下りの間の状態)。$A$($w=0$、$z=0$、偶数カウント)は $w$ の立上りで → $B$、$B$($w=1$、$z=1$、奇数カウント)は $w$ の立下りで → $C$、$C$($w=0$、$z=1$)は $w$ の立上りで → $D$、$D$($w=1$、$z=0$)は $w$ の立下りで → $A$。競合のない割当て:$A=00, B=01, C=11, D=10$(グレイ符号。ループを一周する間、常に 1 ビットずつしか変わらない)。次状態式は $Y_1 = w y_2 + y_1 w$(残りはカルノー図から導く)、出力は $z = y_2 \oplus y_1$(あるいは同程度に簡単な式)。

9.17E

八個狀態(4 種計數各對應一組上升緣與下降緣)。採用 3 位元格雷碼指派,使每次轉移只變動一個位元:$S_0 = 000, S_1 = 001, S_2 = 011, S_3 = 010, S_4 = 110, S_5 = 111, S_6 = 101, S_7 = 100$。下一狀態方程式 $Y_3, Y_2, Y_1$ 由 $w$ 交替邊緣所驅動的環 $S_0\to S_1\to S_2\to\dots\to S_7\to S_0$ 推得。輸出 $z_2 z_1$ 編碼計數對 4 取模:$\{S_0, S_1\}$ 為 $z_2 z_1 = 00$、$\{S_2, S_3\}$ 為 $01$、$\{S_4, S_5\}$ 為 $10$、$\{S_6, S_7\}$ 為 $11$。

Eight states (rising and falling edge pair for each of 4 counts). Use a 3-bit Gray-code assignment so each transition changes one bit: $S_0 = 000, S_1 = 001, S_2 = 011, S_3 = 010, S_4 = 110, S_5 = 111, S_6 = 101, S_7 = 100$. Next-state equations $Y_3, Y_2, Y_1$ derived from the cycle $S_0\to S_1\to S_2\to\dots\to S_7\to S_0$ on alternating $w$ edges. Outputs $z_2 z_1$ encode the count modulo 4: $z_2 z_1 = 00$ in $\{S_0, S_1\}$, $01$ in $\{S_2, S_3\}$, $10$ in $\{S_4, S_5\}$, $11$ in $\{S_6, S_7\}$.

状態は 8 つ(4 通りのカウントそれぞれに立上りと立下りの対がある)。遷移ごとに 1 ビットだけ変わるよう 3 ビットのグレイ符号を割り当てる:$S_0 = 000, S_1 = 001, S_2 = 011, S_3 = 010, S_4 = 110, S_5 = 111, S_6 = 101, S_7 = 100$。次状態方程式 $Y_3, Y_2, Y_1$ は、$w$ の交互のエッジで進む環 $S_0\to S_1\to S_2\to\dots\to S_7\to S_0$ から導かれる。出力 $z_2 z_1$ はカウントの 4 を法とした値を符号化する:$\{S_0, S_1\}$ で $z_2 z_1 = 00$、$\{S_2, S_3\}$ で $01$、$\{S_4, S_5\}$ で $10$、$\{S_6, S_7\}$ で $11$。

9.18E

狀態:閒置 $A$、已授權給 1 的 $B$、已授權給 2 的 $C$。當 $r_1$ 下降與 $r_2$ 上升同時發生時的對角轉移 $B \to C$ 並不安全。插入一個暫態狀態 $D$:$\overline{r_1}$ 時 $B \to D$,$r_2$ 時 $D \to C$。狀態指派 $A=00, B=01, C=11, D=10$(格雷碼)。輸出(Moore):只有在 $B$ 時 $g_1=1$;只有在 $C$ 時 $g_2=1$;$D$ 的 $g_1=g_2=0$(暫態期間的安全值)。

States: idle $A$, granted-1 $B$, granted-2 $C$. Diagonal transition $B \to C$ when $r_1$ falls and $r_2$ rises simultaneously is unsafe. Insert state $D$ (transient): $B \to D$ on $\overline{r_1}$, $D \to C$ on $r_2$. State assignment $A=00, B=01, C=11, D=10$ (Gray code). Outputs (Moore): $g_1=1$ in $B$ only; $g_2=1$ in $C$ only; $D$ has $g_1=g_2=0$ (safe value during transient).

状態は待機 $A$、1 番に許可を出した $B$、2 番に許可を出した $C$。$r_1$ の立下りと $r_2$ の立上りが同時に起こるときの対角遷移 $B \to C$ は安全ではない。過渡状態 $D$ を挿入する:$\overline{r_1}$ で $B \to D$、$r_2$ で $D \to C$。状態割当ては $A=00, B=01, C=11, D=10$(グレイ符号)。出力(Moore):$g_1=1$ は $B$ のみ、$g_2=1$ は $C$ のみ、$D$ では $g_1=g_2=0$(過渡中の安全値)。

9.19E

原始流程表有很多列(每個狀態、每種輸入組合各一列)。套用分割程序:把輸出相同且下一狀態樣式相同的列分為一組。接著畫出合併圖,標示哪些列彼此相容(即在有定義處都一致);再合併最大團。結果為 4 列,代表狀態 $A$(閒置,0¢)、$B$(5¢)、$C$(10¢ → 出貨)、$D$(必要時的暫態)。輸出在 $C$ 時 assert。

Primitive flow table has many rows (one per input combination per state). Apply partitioning: group rows with the same outputs and same next-state pattern. Then build the merger diagram showing which rows have compatible (i.e., agreeing-where-defined) entries; merge maximal cliques. Result: 4 rows representing states $A$ (idle, 0¢), $B$ (5¢), $C$ (10¢ → dispense), $D$ (transient if needed). Output asserts in $C$.

原始フロー表は行数が多い(状態ごと・入力組合せごとに 1 行)。分割手続きを適用し、出力が同じで次状態のパターンも同じ行をまとめる。次にマージャ図を描いて、どの行どうしが両立するか(定義されている箇所で一致するか)を示し、最大クリークを併合する。結果は 4 行となり、状態 $A$(待機、0¢)、$B$(5¢)、$C$(10¢ → 払い出し)、$D$(必要なら過渡状態)を表す。出力は $C$ でアサートされる。

9.20E

先套用分割程序:把 12 列依輸出等價分開,再依下一狀態等價反覆細分。分割穩定後,畫出合併圖(頂點 = 剩下的列,邊 = 相容關係)。找一組團覆蓋 (clique cover),把每個團合併成一列。經過 2–3 次縮減,表格通常會從 12 → 6 → 4 列。

Apply partitioning first: split the 12 rows by output equivalence, then by next-state equivalence iteratively. Once partitioning stabilizes, draw the merger diagram (vertices = remaining rows, edges = compatibility). Find a clique cover; merge each clique into one row. After 2-3 reductions the table typically shrinks from 12 → 6 → 4 rows.

まず分割手続きを適用する:12 行を出力の等価性で分け、続いて次状態の等価性で反復的に細分する。分割が安定したらマージャ図を描く(頂点 = 残った行、辺 = 両立関係)。クリーク被覆を見つけ、各クリークを 1 行に併合する。2〜3 回の縮小で、表はふつう 12 → 6 → 4 行と縮む。

9.21E

Moore 式合併:輸出必須逐列一致。Mealy 式合併:暫態轉移上的輸出可以不同,因此更多列彼此相容。先套用分割程序,再分別計算 Moore 合併圖與 Mealy 合併圖。Mealy 得到的狀態較少,因為輸出上的彈性讓更多列對可以合併;例如 8 列可縮到 5 列(Moore)或 3 列(Mealy)。當輸出強烈依賴輸入轉移時,Mealy 勝出。

Moore-style merging: outputs must agree row-by-row. Mealy-style merging: outputs may differ on transient transitions, so more rows are compatible. Apply partitioning first. Then compute Moore merger graph and Mealy merger graph. Mealy yields fewer states because flexibility on outputs lets more row-pairs merge; e.g., 8 rows reduce to 5 (Moore) or 3 (Mealy). Mealy wins when outputs depend strongly on input transitions.

Moore 流の併合:出力が行ごとに一致していなければならない。Mealy 流の併合:過渡的な遷移では出力が違ってもよいので、より多くの行が両立する。まず分割手続きを適用し、そのうえで Moore のマージャグラフと Mealy のマージャグラフを求める。出力に融通が利く分だけ多くの行対が併合できるので、Mealy のほうが状態数は少なくなる。たとえば 8 行が 5 行(Moore)または 3 行(Mealy)に減る。出力が入力遷移に強く依存する場合は Mealy が有利である。

9.22E

依輸出等價把 8 列分割。建立 Mealy 合併圖;找出能覆蓋所有列的 2-團(只有在放寬 don't-care 項後所有列兩兩相容時才可能)。合併成 2 列。縮減後的 FSM 只有 2 個狀態;輸入輸出序列則由轉移上不同的 Mealy 輸出還原出來。

Partition the 8 rows by output-equivalence. Build Mealy merger graph; identify a 2-clique that covers all rows (only possible if all rows are pairwise compatible after relaxing on don't-care entries). Merge to 2 rows. The reduced FSM has only 2 states; the input-output sequence is recovered by the Mealy outputs differing on transitions.

8 行を出力の等価性で分割する。Mealy のマージャグラフを作り、すべての行を覆う 2-クリークを見つける(don't-care 項を緩めたうえで全行が両立する場合にのみ可能)。2 行に併合する。縮小後の FSM は状態が 2 つしかなく、入出力系列は遷移ごとに異なる Mealy 出力によって復元される。

9.23E

在 2-cube 上頂點為 $00, 01, 10, 11$。指派 $A=00, B=01, C=10, D=11$ 時,轉移 $B\to C$ 是從 $01$ 到 $10$ — 對角線(漢明距離 2)。改採 $A=00, B=01, C=11, D=10$:轉移 $A\to B$($00\to 01$,距離 1)、$B\to C$($01\to 11$,距離 1)、$C\to D$($11\to 10$,距離 1)、$D\to A$($10\to 00$,距離 1)。全部都是單一位元變化 — 無競爭。

On a 2-cube vertices $00, 01, 10, 11$. Assignment $A=00, B=01, C=10, D=11$: transition $B\to C$ goes from $01$ to $10$ — diagonal (Hamming distance 2). Alternative $A=00, B=01, C=11, D=10$: transitions $A\to B$ ($00\to 01$, dist 1), $B\to C$ ($01\to 11$, dist 1), $C\to D$ ($11\to 10$, dist 1), $D\to A$ ($10\to 00$, dist 1). All single-bit changes — race free.

2-cube の頂点は $00, 01, 10, 11$ である。$A=00, B=01, C=10, D=11$ と割り当てると、遷移 $B\to C$ は $01$ から $10$ への対角線(ハミング距離 2)になる。代わりに $A=00, B=01, C=11, D=10$ とすれば、$A\to B$($00\to 01$、距離 1)、$B\to C$($01\to 11$、距離 1)、$C\to D$($11\to 10$、距離 1)、$D\to A$($10\to 00$、距離 1)となる。すべて 1 ビット変化であり、競合はない。

9.24E

3 個狀態至少需要 2 個狀態變數。2-cube 上的頂點為 $00, 01, 10, 11$。只用其中 3 個時,未使用的頂點會孤立掉某一組轉移對。必有某一對狀態落在對角線上 — 漢明距離 2 — 因而產生競爭。加入不穩定狀態 $D$ 來打斷對角線:轉移 $B\to D\to C$ 每一步都是漢明距離 1。流程表也要跟著修改:原本讓 $B\to C$ 的那個輸入,改成 $D$ 的下一狀態為 $C$,並把輸出設為安全值(例如兩個授權皆為 0)。

3 states need at least 2 state variables. Vertices on 2-cube: $00, 01, 10, 11$. With 3 used, the unused vertex isolates one transition pair. Some pair of states must lie on a diagonal — Hamming-distance-2 — causing race. Add unstable state $D$ to break the diagonal: transitions $B\to D\to C$ each Hamming distance 1. Modify the flow table accordingly: $D$ has next-state $C$ on the input that previously took $B\to C$, with output set to a safe value (e.g., both grants 0).

状態が 3 つなら状態変数は最低 2 個必要である。2-cube の頂点は $00, 01, 10, 11$ で、そのうち 3 つを使うと、使わない頂点のせいである遷移対が孤立する。どこかで 2 状態が対角線上(ハミング距離 2)に置かれ、競合が生じる。不安定状態 $D$ を加えて対角線を断ち切る:遷移 $B\to D\to C$ はどちらもハミング距離 1 である。フロー表もそれに合わせて直す:以前 $B\to C$ を起こしていた入力に対して $D$ の次状態を $C$ とし、出力は安全な値(たとえば両方の許可を 0)にしておく。

9.25E

流程表在 4 個邏輯狀態與 4 個輸入欄位上共有 7 個穩定狀態。把每個穩定狀態實例分別重新標記($S_1@col_1, S_1@col_2,\dots$)以列舉這 7 個位置。畫出 4 個邏輯狀態之間的轉移圖;找出未指定的項目作為可自由運用的位置。用它把某個對角轉移改繞經空格來打斷。狀態指派把 4 個狀態放到 2-cube 上而不出現對角線。在不穩定格中指定 Mealy 輸出,使其與目的地穩定狀態的輸出一致。

Flow table has 7 stable states across 4 logical states and 4 input columns. Relabel each stable instance separately ($S_1@col_1, S_1@col_2,\dots$) to enumerate 7 placements. Draw a transition diagram between the 4 logical states; identify the unspecified entry as a free placement. Use it to break a diagonal transition by routing through an empty cell. State assignment maps the 4 states onto a 2-cube without diagonals. Specify Mealy outputs in unstable cells to match the destination's stable output.

フロー表には、4 つの論理状態と 4 つの入力列にわたって安定状態が 7 個ある。安定状態の各インスタンスに別々のラベルを付け($S_1@col_1, S_1@col_2,\dots$)、7 か所を列挙する。4 つの論理状態間の遷移図を描き、未指定の欄を自由に使える置き場所として見つける。それを使って対角遷移を空きセット経由に迂回させ、断ち切る。状態割当てでは 4 状態を対角線が出ないように 2-cube 上へ配置する。不安定セルの Mealy 出力は、行き先の安定状態の出力と一致するよう指定する。

9.26E

4 個狀態彼此都可達 → 在 2-cube 上必然有些轉移是對角的。在 3-cube 上加入 3 個不穩定狀態 $E, F, G$ 來打斷每一條對角線。在 3-cube(8 個頂點)上,把 4 個邏輯狀態放在彼此漢明距離 2 的獨立集位置,再讓每條對角線繞經 $E, F, G$ 其中之一。新的流程表有 7 列(4 個邏輯狀態 + 3 個不穩定狀態),而 $Y_1, Y_2, Y_3$ 的激勵表以單一位元變化實現所有轉移。

4 states all pairwise reachable → in 2-cube some transitions must be diagonal. Add 3 unstable states $E, F, G$ on the 3-cube to break each diagonal. On a 3-cube (8 vertices), place 4 logical states at vertices forming an independent-set pattern (Hamming distance 2 apart), then route each diagonal through one of $E, F, G$. The new flow table has 7 rows (4 logical + 3 unstable), and the excitation table for $Y_1, Y_2, Y_3$ implements all transitions with single-bit changes.

4 つの状態が互いにすべて到達可能 → 2-cube ではどうしても対角の遷移が生じる。3-cube 上に不安定状態 $E, F, G$ を 3 つ加えて、各対角線を断ち切る。3-cube(頂点 8 個)では、4 つの論理状態を互いにハミング距離 2 の独立集合をなす頂点に置き、各対角線を $E, F, G$ のいずれか経由で迂回させる。新しいフロー表は 7 行(論理状態 4 + 不安定状態 3)となり、$Y_1, Y_2, Y_3$ の励振表はすべての遷移を 1 ビット変化で実現する。

9.27E

把 4 個狀態各換成一對(例如 $A\to A_1, A_2$)。如此 8 個狀態剛好填滿 3-cube。安排轉移使每一步都是單一位元的漢明變化。所得的轉移圖沒有任何對角路徑 — 邏輯狀態之間原本的每一次轉移,都對映成經由某一對新頂點的兩步路徑。修改流程表,把每一對中的第二個成員指定為輸出相同的暫態。

Replace each of the 4 states with a pair (e.g., $A\to A_1, A_2$). Now 8 states fill the 3-cube. Arrange transitions so each move is single-bit Hamming. The resulting transition diagram has no diagonal paths — every original transition between logical states maps to a 2-step path through one of the new vertex pairs. Modify the flow table to specify the second member of each pair as a transient with the same outputs.

4 つの状態をそれぞれ 2 つ 1 組に置き換える(たとえば $A\to A_1, A_2$)。これで 8 状態が 3-cube をちょうど埋める。各移動が 1 ビットのハミング変化になるよう遷移を配置する。得られる遷移図に対角の経路はなく、論理状態間のもとの遷移はいずれも、新しい頂点対の一方を経由する 2 段の経路に写る。フロー表を修正し、各対の 2 番目のメンバを、出力が同じ過渡状態として指定する。

9.28E

當 $C$ 由 1 降到 0 時,主閂鎖輸出 $Y_m$ 本應保持已擷取的 $D$ 值,但 $CD$ 與 $\overline{C}y_m$ 兩條路徑延遲不同,會造成 $Y_m=0$ 的瞬間突波。從閂鎖取樣到這個突波,就會停在錯誤的狀態。修法:在 $Y_m$ 加上冗餘質蘊涵項 $D y_m$(涵蓋跨越 $C$ 邊界的相鄰 1 格),並在 $Y_s$ 加上 $y_m y_s$。無冒險的式子為:$Y_m = CD + \overline{C}y_m + D y_m$、$Y_s = Cy_m + \overline{C}y_s + y_m y_s$。

When $C$ falls from 1 to 0, the master output $Y_m$ should hold the captured $D$ value, but the unequal delays on the $CD$ vs $\overline{C}y_m$ paths cause a momentary $Y_m=0$ glitch. The slave samples this glitch and settles into the wrong state. Fix: add the redundant prime implicants $D y_m$ to $Y_m$ (covering the adjacent 1-cells across the $C$ boundary) and $y_m y_s$ to $Y_s$. The hazard-free expressions: $Y_m = CD + \overline{C}y_m + D y_m$, $Y_s = Cy_m + \overline{C}y_s + y_m y_s$.

$C$ が 1 から 0 へ落ちるとき、マスタの出力 $Y_m$ は取り込んだ $D$ の値を保持すべきだが、$CD$ の経路と $\overline{C}y_m$ の経路で遅延が異なるため、$Y_m=0$ の一瞬のグリッチが生じる。スレーブがこのグリッチを取り込むと、誤った状態に落ち着いてしまう。対策:$Y_m$ に冗長な主項 $D y_m$($C$ の境界をまたぐ隣接 1 セルを覆う)を、$Y_s$ に $y_m y_s$ を加える。ハザードのない式は $Y_m = CD + \overline{C}y_m + D y_m$、$Y_s = Cy_m + \overline{C}y_s + y_m y_s$ である。

9.29E

靜態 1 冒險發生在:輸入變化使得原本唯一涵蓋某最小項的乘積項瞬間落下,而另一個項還來不及接手。要做到無冒險覆蓋,只需要那些在卡諾圖上涵蓋「相鄰 1 格對」(含變動變數)的乘積項 — 並不需要全部的質蘊涵項。以圖 9.64 為例,變動變數所形成的相鄰關係由 $\{x_1\overline{x_3}, \overline{x_2}\overline{x_3}, x_3 x_4\}$ 涵蓋。因此 $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$ 無冒險。

A static-1 hazard arises when an input change causes the only product term covering a minterm to drop momentarily before another term takes over. Only product terms covering pairs of adjacent 1s in the K-map (with the changing variable) are needed for hazard-free coverage — not all primes. For Figure 9.64, the changing-variable adjacencies are covered by $\{x_1\overline{x_3}, \overline{x_2}\overline{x_3}, x_3 x_4\}$. So $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$ is hazard-free.

静的 1 ハザードは、入力変化によって、ある最小項を覆う唯一の積項が一瞬落ち、別の項が引き継ぐのが間に合わないときに生じる。ハザードのない被覆に必要なのは、カルノー図上で(変化する変数をまたぐ)隣接した 1 セルの対を覆う積項だけであり、すべての主項が要るわけではない。図 9.64 では、変化する変数による隣接関係は $\{x_1\overline{x_3}, \overline{x_2}\overline{x_3}, x_3 x_4\}$ で覆われる。したがって $f = x_1\overline{x_3} + \overline{x_2}\overline{x_3} + x_3 x_4$ はハザードフリーである。

9.30E

當 $x_1=x_3=0$ 而 $x_2$ 上升時,和項 $(x_1+\overline{x_2}+\dots)$ 由 1 落到 0;另一個和項延遲後才接手,於是在 AND 輸出上產生 $0\to 1\to 0$ 的突波。修法:加入涵蓋跨越 $x_2$ 邊界那對 0 格的和項 — 通常是 $(x_1+\overline{x_2}+x_3)$(或以 POS 卡諾圖上的相鄰 0 格類推)。無冒險的 POS 就包含這個額外因子。

When $x_1=x_3=0$ and $x_2$ rises, sum term $(x_1+\overline{x_2}+\dots)$ drops from 1 to 0; another sum term takes over with delay, producing a $0\to 1\to 0$ glitch on the AND output. Fix: add the sum term that covers the 0-cell pair across the $x_2$ boundary — typically $(x_1+\overline{x_2}+x_3)$ (or analogous, using POS K-map adjacent zeros). The hazard-free POS includes that extra factor.

$x_1=x_3=0$ の状態で $x_2$ が立ち上がると、和項 $(x_1+\overline{x_2}+\dots)$ が 1 から 0 へ落ち、別の和項が遅れて引き継ぐため、AND の出力に $0\to 1\to 0$ のグリッチが出る。対策:$x_2$ の境界をまたぐ 0 セルの対を覆う和項を加える — ふつうは $(x_1+\overline{x_2}+x_3)$ である(POS のカルノー図上の隣接する 0 から同様に求める)。ハザードのない POS はこの余分な因子を含む。

9.31E

把給定的式子代入 $(w_1, w_2, y_1, y_2)$ 上的激勵表。找出穩定格($Y_i = y_i$ 之處),標上狀態名稱。有些轉移會讓 $y_1$ 與 $y_2$ 同時改變(競爭)。對每一個這種情況,檢查不論哪個變數先變、目的地是否相同 — 相同者即為安全競爭。輸出 $z=y_2$ 追蹤 FSM 目前處於哪個狀態。

Substitute the given expressions into the excitation table over $(w_1, w_2, y_1, y_2)$. Identify stable cells (where $Y_i = y_i$). Label states. Some transitions cause both $y_1$ and $y_2$ to change simultaneously (race). For each, check if the destination is the same regardless of which variable changes first — these are safe races. The output $z=y_2$ tracks which state the FSM is in.

与えられた式を $(w_1, w_2, y_1, y_2)$ 上の励振表に代入する。安定セル($Y_i = y_i$ となるところ)を見つけ、状態名を付ける。遷移によっては $y_1$ と $y_2$ が同時に変わる(競合する)。その各々について、どちらの変数が先に変わっても行き先が同じかどうかを確かめる — 同じなら安全な競合である。出力 $z=y_2$ は FSM がどの状態にいるかを示す。

9.32E

把 $Y_1$ 與 $Y_2$ 畫在卡諾圖上。找出圖上相鄰、卻由不同乘積項涵蓋的 1 格。成對涵蓋規則指出:無冒險的 SOP 必須用某一個單一乘積項涵蓋每一組這樣的相鄰關係。若缺少能涵蓋某個必要相鄰關係的質蘊涵項,就把它補上。以 $Y_1$ 為例,補上 $w_1 y_1$ 這個缺漏的蘊涵項;$Y_2$ 亦同。最終無冒險的式子包含所有最小質蘊涵項,再加上為涵蓋相鄰關係而補的那些。

Plot $Y_1$ and $Y_2$ on K-maps. Identify 1-cells that are adjacent in the K-map but covered by different product terms. The pair-coverage rule says a hazard-free SOP must cover every such adjacency with some single product term. If a prime implicant is missing that covers a needed adjacency, add it. For $Y_1$, add e.g. $w_1 y_1$ as the missing implicant. For $Y_2$ similarly. Resulting hazard-free expressions include all minimum primes plus the extra ones for adjacency coverage.

$Y_1$ と $Y_2$ をカルノー図に描く。図上で隣接しているのに別々の積項で覆われている 1 セルを見つける。対被覆の規則によれば、ハザードのない SOP はそうした隣接関係のそれぞれを 1 つの積項で覆わなければならない。必要な隣接を覆う主項が欠けているなら、それを追加する。$Y_1$ ならたとえば $w_1 y_1$ が欠けている内項である。$Y_2$ も同様。最終的なハザードフリーの式は、最小の主項すべてに加えて、隣接被覆のための追加項を含む。

9.33E

4 個狀態 — $S_0$(閒置,偶數計數)、$S_1$(剛看到第 1 個脈衝的上升緣)、$S_2$(第 1 個脈衝之後,偶數計數,無輸出)、$S_3$(剛看到第 2 個脈衝的上升緣,輸出 assert)。$S_3$ 及其下降緣期間 $z=1$。無競爭的格雷碼:$S_0=00, S_1=01, S_2=11, S_3=10$。由卡諾圖推導 $Y_1, Y_2$;輸出 $z = y_1\overline{y_2}$(或類似式子)。

4 states — $S_0$ (idle, even count), $S_1$ (just saw rising edge of 1st pulse), $S_2$ (after 1st pulse, even count, no output), $S_3$ (just saw rising edge of 2nd pulse, output asserted). Output $z=1$ in $S_3$ and during its falling edge. Race-free Gray code: $S_0=00, S_1=01, S_2=11, S_3=10$. Derive $Y_1, Y_2$ from K-map; output $z = y_1\overline{y_2}$ (or similar).

状態は 4 つ — $S_0$(待機、偶数カウント)、$S_1$(1 発目のパルスの立上りを見た直後)、$S_2$(1 発目のあと、偶数カウント、出力なし)、$S_3$(2 発目のパルスの立上りを見た直後、出力アサート)。$z=1$ となるのは $S_3$ とその立下りの間である。競合のないグレイ符号:$S_0=00, S_1=01, S_2=11, S_3=10$。カルノー図から $Y_1, Y_2$ を導き、出力は $z = y_1\overline{y_2}$(あるいは同様の式)とする。

9.34E

套用分割程序:先依輸出把列分開,再依下一狀態等價細分。假設 8 列在分割後變成 4 列。建立 Moore 合併圖,找出相容列的團。合併後大約剩下 4 個邏輯狀態。在 3-cube 上做狀態指派:讓有轉移關係的狀態對彼此漢明距離為 1(部分情況需要加入不穩定的中間狀態)。再由指派後的下一狀態值推導激勵表。

Apply partitioning: split rows by output, then refine by next-state equivalence. Suppose 8 rows → 4 after partitioning. Build Moore merger diagram; find compatible-row cliques. After merging, ~4 logical states remain. State assignment on a 3-cube: pick vertices with Hamming distance 1 between transitioning pairs (some require unstable intermediate states). Derive excitation table from the assigned next-state values.

分割手続きを適用する:まず出力で行を分け、次に次状態の等価性で細分する。8 行が分割後に 4 行になったとしよう。Moore のマージャ図を作り、両立する行のクリークを見つける。併合すると論理状態はおよそ 4 つ残る。3-cube 上での状態割当てでは、遷移する対どうしのハミング距離が 1 になる頂点を選ぶ(場合によっては不安定な中間状態が必要になる)。割り当てた次状態の値から励振表を導く。

9.35E

把 $f$ 畫在 5 變數卡諾圖上($\sum m + D$)。找出最小質蘊涵項覆蓋:典型的覆蓋是 $\{\overline{x_1}\overline{x_2}x_3, x_1\overline{x_2}x_4 x_5, x_1 x_2\overline{x_4}x_5, x_1\overline{x_3}x_4\}$(4 個質蘊涵項)。接著檢查「相鄰 1 格對」的涵蓋情形:找出未被單一質蘊涵項涵蓋的相鄰關係,並補上額外的質蘊涵項。最終無冒險的 SOP 就包含這些補項。

Plot $f$ on a 5-var K-map ($\sum m + D$). Find minimum prime cover: a typical cover is $\{\overline{x_1}\overline{x_2}x_3, x_1\overline{x_2}x_4 x_5, x_1 x_2\overline{x_4}x_5, x_1\overline{x_3}x_4\}$ (4 primes). Then check pair-of-adjacent-1s coverage: identify any adjacency not covered by a single prime and add an extra prime implicant to cover it. Final hazard-free SOP includes those extras.

$f$ を 5 変数のカルノー図に描く($\sum m + D$)。最小の主項被覆を求める:典型的な被覆は $\{\overline{x_1}\overline{x_2}x_3, x_1\overline{x_2}x_4 x_5, x_1 x_2\overline{x_4}x_5, x_1\overline{x_3}x_4\}$(主項 4 個)である。続いて隣接する 1 セル対の被覆を確認し、単一の主項で覆われていない隣接があれば、それを覆う主項を追加する。最終的なハザードフリーの SOP はその追加項を含む。