2.6 有限状態機械(FSM)の導入と状態制御の基本

2.6 Introduction to Finite State Machine (FSM) and State Control


🎯 本節のねらい|Goal of This Section

本節では、これまで扱ってきた組み合わせ回路(Combinational Logic)の知識を踏まえて、
有限状態機械(FSM)の考え方と基本構成を学びます。

This section introduces the concept and structure of Finite State Machines (FSMs) based on prior knowledge of combinational logic.

FSMは時間と状態に依存して動作する順序回路であり、
SoCや制御回路設計に不可欠な中核概念です。


🔹 組み合わせ回路とFSMの違い

🔸 Difference: Combinational vs. Sequential Logic

観点 / Viewpoint 組み合わせ回路 / Combinational Logic FSM(順序回路) / FSM (Sequential Logic)
出力 / Output 入力のみに依存 / Depends only on inputs 入力と状態に依存 / Depends on inputs + state
記憶要素 / Memory なし / None 状態レジスタあり / Has state registers
/ Examples AND, OR, MUX Counter, Serial Receiver, Controller

🔹 FSMの基本構成|Basic Structure of FSM

FSMは以下の3要素から構成されます:

FSM consists of the following three components:

  1. 状態(State) / State:現在の内部動作モードを記憶
  2. 状態遷移(Transition) / Transition:条件に応じて次の状態へ移動
  3. 出力(Output) / Output:現在の状態や入力に基づいて出力が決まる

📘 図2.6-1:FSMの基本構成図|FSM Structure (Input–State–Output)
📎 GitHubでMermaidフローチャートを確認

flowchart TD
    A[📥 Input Signal] --> B[🔄 Next-State Logic]
    B --> C[🧠 State Register]
    C --> D[📤 Output Logic]
    D --> E[📶 Output Signal]
    C -.->|⏰ Clock| C

🔹 状態遷移図と状態遷移表

🔸 State Diagram and State Table

FSMの動作は次の方法で視覚化できます:

FSM behavior can be visualized using:

📘 図2.6-2:状態遷移図の例(S0 ⇄ S1)|Example State Diagram
📎 GitHubでMermaidフローチャートを確認

stateDiagram-v2
    [*] --> S0
    S0 --> S1: input = 1
    S1 --> S0: input = 0
    S0 --> S0: input = 0
    S1 --> S1: input = 1

🔹 Moore型とMealy型 FSM

🔸 Moore vs. Mealy Machine

型 / Type 出力依存 / Depends on 特徴 / Characteristics
Moore型 状態のみ / Only state 出力が安定、設計しやすい / Stable outputs, easier to design
Mealy型 状態+入力 / State + input 出力が即時反応、回路は小型化可能 / Immediate response, more compact

📘 図2.6-3:Moore型とMealy型の構成比較図(縦並び)

📎 GitHubでMermaidフローチャートを確認

🟦 Moore型 FSM

flowchart TB
    %% 📘 Moore FSM structure
    subgraph MooreFSM [📘 Moore FSM structure]
        direction TB
        M1["🟢 Input"]
        M2["🔁 Next-State Logic"]
        M3["💾 State Register"]
        M4["🔷 Output"]
        M1 --> M2 --> M3 --> M4
    end

🟧 Mealy型 FSM

flowchart TB
    %% 📘 Mealy FSM structure
    subgraph MealyFSM [📘 Mealy FSM structure]
        direction TB
        E1["🟢 Input"]
        E2["🔁 Next-State Logic"]
        E3["💾 State Register"]
        E4["⚡ Output Logic<br/>(State + Input)"]
        E5["🔷 Output"]
        E1 --> E2 --> E3 --> E4 --> E5
    end

🔹 HDL記述との接続(概要)

🔸 HDL (Verilog) Example – Basic FSM

FSMはHDL(Hardware Description Language)を使って記述されます。
以下は簡易的なFSMの例です:

always @(posedge clk) begin
  case (state)
    S0: if (in) state <= S1;
    S1: if (!in) state <= S0;
  endcase
end

※詳細なFSM設計は、第5章:RTL設計編で扱います
Detailed FSM coding will be covered in Chapter 5 (RTL Design).


✅ まとめ|Summary

🇯🇵 日本語 🇺🇸 English
FSMは状態に応じて動作する順序回路である FSM is a sequential circuit that depends on state
組み合わせ回路にクロック+レジスタ要素を加えた構成 FSM adds clock and memory to combinational logic
設計では状態図・状態表・HDL記述を活用する Use state diagrams, tables, and HDL to design FSMs
本節は概念理解が中心、実装は今後の章で学ぶ This section focuses on concept; implementation comes later

📎 前節:2.5_half_full_adder.md
📎 次節:2.7_component_relationships.md

Next: 整合的な論理ブロック設計へ – コンポーネント構造と連携設計へ


← 戻る / Back to Chapter 2: Combinational Logic Top