Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
    • Controller and Datapath
      • Split Design: Intent First
      • Signal Contract Between FSM and Datapath
      • Two-Process FSM Style
      • Coding Rules That Prevent Latent Bugs
      • Worked Example: GCD
      • FSM Bug Stories
    • Moore vs Mealy
    • State Encoding
    • Multi-Cycle Sequencers
    • UART Transmitter
    • Memory Controller
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Controller and Datapath
  1. Topics
  2. RTL Design
  3. FSM & Control
  4. Controller and Datapath
  5. Split Design: Intent First

Part 4 · FSM & Control · Intermediate

Split Design: Intent First

Deriving datapath resources and FSM states from a plain algorithm.

On this page

    Why this matters

    Mix storage, arithmetic and sequencing in one block and no one can say where a bug lives. The split gives every line of the algorithm one owner: the datapath or the controller.

    After this lesson you can: split an algorithm into a datapath and a controller, and derive the FSM from status flags and control signals.

    From algorithm to hardware

    Every line of the algorithm answers two questions. Storage and arithmetic belong to the datapath, order and conditions to the controller.

    Diagram
    gcd(a, b):                    // a, b >= 1
      while (a != b)
        if (a > b) a = a - b
        else       b = b - a
      return a

    The GCD loop needs two registers, subtractors, and comparators. Its loop and branch become states and transitions.

    Algorithm element

    Hardware

    Belongs to

    Variables a, b

    Two registers

    Datapath

    a - b and b - a

    Two subtractors (or one shared)

    Datapath

    a != b, a > b

    Comparators, producing status flags

    Datapath

    “while”, “if / else”, “return”

    States and transitions

    Controller

    Loading the inputs, signalling done

    load, done signals

    Interface

    Block diagram. Start enters the controller. The controller sends load, sub_a and sub_b down to the datapath. The datapath sends a_eq_b and a_gt_b back up. The controller drives done.
    The GCD split: the controller sends load, sub_a and sub_b to the datapath, and the datapath returns the comparator flags a_eq_b and a_gt_b

    Read the diagram as a conversation: the controller commands, the datapath reports.

    • Down the left arrow: load, sub_a and sub_b are control signals. They tell the registers what to do at the next edge.

    • Up the right arrow: a_eq_b and a_gt_b are status flags from the comparators. The FSM uses them to pick its next state.

    • Outside the boxes: start and done are the only signals the rest of the system sees.

    A five-step method

    1. Write the algorithm in plain pseudo-code.

    2. List the variables → registers, the operations → functional units, the conditions → status flags.

    3. Draw the datapath and mark which inputs are control signals (load, enable, select).

    4. Derive the FSM: one state per distinct step; transitions on the status flags.

    5. Write a table: in state S, with flags F, assert controls C and go to S′. The code is then mechanical.

    Tip

    Resist the urge to build an FSM state for every line of pseudo-code. States exist where time passes (a clock edge is needed), not where there is a statement.

    Common mistakes

    Common pitfall

    Partition by responsibility and ownership, not by whether an expression uses arithmetic. A retry counter, timeout or beat count can belong to the controller. In this GCD, operand storage, comparison and subtraction belong to the reusable datapath; sequencing and completion belong to the controller. Give each register one owner and expose the status the other block needs.

    Check yourself Why does the GCD FSM need only three states (IDLE, RUN, DONE) even though the algorithm has a loop and an if/else?

    The loop body runs once per clock in the same state (RUN); the if/else is expressed as different control signals in that state. States are needed only for distinct phases: waiting, working and reporting.

    Remember

    • Variables become registers, operations become functional units, conditions become status flags.

    • The controller sends controls down; the datapath reports flags up.

    • States exist where time passes, not at every line of pseudo-code.

    Keep going

    • Interview: run a mock interview on this topic

    Related topics

    • Signal contract

    Previous

    89 / 350

    Next: Signal Contract Between FSM and Datapath

    Up next

    Up nextSignal Contract Between FSM and Datapath

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Two-Process FSM Style
    • Coding Rules That Prevent Latent Bugs
    • Worked Example: GCD