# Lesson 25 Flashcards — Finite State Machines II

Click a question to reveal the answer.

<div data-flashcards data-deck="b2l25"></div>

<details>
<summary><strong>1. List the seven steps of FSM design.</strong></summary>
<div class="card-answer"><p>Encode the <strong>states</strong>, <strong>inputs</strong>, and <strong>outputs</strong>; create the <strong>transition diagram</strong>; create the <strong>transition table</strong>; express the <strong>logic equations</strong>; implement with <strong>flip-flops and gates</strong>.</p></div>
</details>

<details>
<summary><strong>2. How many bits do you need to encode n states?</strong></summary>
<div class="card-answer"><p><span class="math notranslate nohighlight">\(\lceil \log_2 n \rceil\)</span>. Three or four states need 2 bits — and each bit needs its own flip-flop.</p></div>
</details>

<details>
<summary><strong>3. You have 3 states encoded in 2 bits. What about the fourth code?</strong></summary>
<div class="card-answer"><p>You must <strong>define what it does</strong>. If the machine powers up or glitches into an unhandled state code with no transition out, it locks up there permanently.</p></div>
</details>

<details>
<summary><strong>4. How many rows does the binary transition table have?</strong></summary>
<div class="card-answer"><p><span class="math notranslate nohighlight">\(2^{\text{state bits} + \text{input bits}}\)</span> — every combination, including the rows for unused state codes. Three states with one input give 8 rows, not 6: Lesson 24's 6 counted <em>states</em>, while 2 bits hold four codes. (A machine with <em>many</em> inputs is listed one row per <strong>(state, condition)</strong> pair in priority order instead — the Project 2 form.)</p></div>
</details>

<details>
<summary><strong>5. How do you get logic equations from a transition table?</strong></summary>
<div class="card-answer"><p>Treat each <strong>next-state bit column</strong> as the output of a truth table whose inputs are the current state bits and the inputs, then write its SOP expression — exactly as in Objective 2.7.</p></div>
</details>

<details>
<summary><strong>6. What does a D flip-flop do?</strong></summary>
<div class="card-answer"><p>Copies its input <span class="math notranslate nohighlight">\(D\)</span> to its output <span class="math notranslate nohighlight">\(Q\)</span> at each clock edge, and <strong>holds</strong> it in between. That hold is the memory.</p></div>
</details>

<details>
<summary><strong>7. How many flip-flops does an FSM need?</strong></summary>
<div class="card-answer"><p>One per <strong>state bit</strong>. A machine encoded in 2 bits needs 2 flip-flops.</p></div>
</details>

<details>
<summary><strong>8. Describe the three blocks of a complete FSM circuit.</strong></summary>
<div class="card-answer"><p><strong>Next-state logic</strong> (combinational) reads current state and inputs; <strong>flip-flops</strong> latch the result on the clock edge; <strong>output logic</strong> produces the outputs. The feedback path from the flip-flops back to the next-state logic is what makes it a machine.</p></div>
</details>

<details>
<summary><strong>9. What sets the pace of an FSM?</strong></summary>
<div class="card-answer"><p>The <strong>clock</strong>. The machine advances exactly one transition per clock edge.</p></div>
</details>

<details>
<summary><strong>10. How do you tell from the equations that a machine is Moore?</strong></summary>
<div class="card-answer"><p>The output expression depends <strong>only on the state bits</strong>, with no input variable in it.</p></div>
</details>

<details>
<summary><strong>11. How do you implement an FSM in software instead of gates?</strong></summary>
<div class="card-answer"><p>Hold the state in a <strong>variable</strong>, <strong>switch on it</strong> with one case per state, and inside each case test the inputs in a <strong>defined priority order</strong>. The switch replaces the next-state gates; the variable replaces the flip-flops.</p></div>
</details>
