Algorithm Search⌘K

Modelintro

Finite state machine with datapath

Also called FSMD.

Gajski's model of a register-transfer design as a controller FSM whose states issue register transfers on a datapath of registers, units and multiplexers.

A finite state machine with datapath (FSMD) describes a register transfer design as two parts that work together. The controller is a finite state machine. The datapath holds registers, functional units such as adders and comparators, and multiplexers that route values between them. In each state, the controller tells the datapath which register transfers to do, such as x←x−yx \leftarrow x - y, and the datapath gives back status bits, such as the result of x>yx > y, that choose the next state. Gajski and his coauthors use this model as the target of high-level synthesis: a schedule maps each operation of the control data flow graph to a state, and binding maps it to a unit and its values to registers.

The machine

Parts. An FSMD has a finite set of states SS with a start state s0s_0, a finite set of registers RR, where register rr has a width wrw_r in bits, a set of primary inputs and outputs, and a set of functional units. A register transfer is an assignment r←f(r1,…,rm)r \leftarrow f(r_1, \ldots, r_m), where ff is a function that one unit or a short chain of units computes. A condition is a Boolean function of the registers and the inputs.

Behavior. Each state ss has a list of guarded transfers, each of the form "if cc then r←f(…)r \leftarrow f(\ldots)", and a next state function δ(s,c1,…,ck)\delta(s, c_1, \ldots, c_k) of some conditions. In each clock cycle, in state ss:

  1. The datapath computes all conditions and all right-hand sides from the register values at the start of the cycle.
  2. At the clock edge, every transfer whose guard is true writes its register, and the controller moves to δ(s,…)\delta(s, \ldots).

All reads in a state see the old values. So x←yx \leftarrow y and y←xy \leftarrow x in one state swap the two registers. Two transfers of one state must not write the same register under guards that can both be true.

Hardware. The controller is a Moore or Mealy machine. Its inputs are the status bits and its outputs are the control lines: the select inputs of the multiplexers, the load enables of the registers and the function codes of the units. The datapath is a circuit with no state other than the registers.

Timing. The clock period TT must be at least the longest combinational delay of any state: from a register, through the multiplexers and the units that the state uses, to a register or to the controller. When a state chains two units, as in operation chaining, their delays add.

What it counts

  • Cycles. A run visits states s0,s1,…,sNs_0, s_1, \ldots, s_N, one per clock cycle, so it takes N+1N + 1 cycles. The time is (N+1) T(N + 1)\,T.
  • Clock period. The maximum over states of the combinational delay of that state.
  • Registers. At least the largest number of values that are live across one clock edge. Register binding finds how many registers suffice.
  • Units. For each type kk, at least the largest number of transfers that need type kk in one state. Resource binding maps transfers to unit instances.
  • Multiplexers. The inputs of the multiplexer in front of each unit port or register, one per distinct source. They cost area and add delay.
  • Controller size. The number of states and the control lines. State assignment gives each state a binary code.

Take the subtraction form of the Euclidean algorithm for the greatest common divisor of two positive inputs aa and bb, with registers x,yx, y and three states:

state transfers next state
s0s_0 x←ax \leftarrow a, y←by \leftarrow b s1s_1
s1s_1 if x>yx > y then x←x−yx \leftarrow x - y; if x<yx < y then y←y−xy \leftarrow y - x s2s_2 if x=yx = y, else s1s_1
s2s_2 output xx s2s_2

The datapath has one subtractor whose two inputs each have a multiplexer, so that it computes x−yx - y or y−xy - x, and one comparator that gives x>yx > y and x=yx = y. The run for a=12a = 12, b=18b = 18 is

cycle state xx yy
1 s0s_0 ? ?
2 s1s_1 12 18
3 s1s_1 12 6
4 s1s_1 6 6
5 s2s_2 6 6

The transfers in s1s_1 have guards that are never both true, so they share one subtractor. The number of cycles depends on the data, which a schedule of a data flow graph alone cannot show. The clock period is the delay of the multiplexer, the subtractor and the register setup, or the comparator and the controller logic, whichever path is longer.

Relation to other models

  • Finite state machine. If the registers are folded into the state, an FSMD is a plain Moore machine with ∣S∣⋅∏r2wr|S| \cdot \prod_r 2^{w_r} states. The FSMD keeps the registers apart, so its description stays small.
  • Control data flow graph. The CDFG is the input of synthesis, and the FSMD is the output. Each block becomes a sequence of states, one per control step, and each control edge becomes a transition that tests a status bit.
  • Register machine. With unbounded integer registers and no bound on the run, an FSMD is a register machine, a model of general computation. Hardware registers have fixed widths, which keeps the FSMD finite.
  • Register transfer level. A hardware language description at the register transfer level, with one clocked process for the controller and one for the datapath, is an FSMD written as code.
  • Processor. A microprocessor is an FSMD whose datapath is general and whose controller reads instructions from memory. High-level synthesis builds an FSMD whose datapath and controller fit one program.

Known results in the model

  • Bounded width gives a finite machine. The configuration of an FSMD is its state and the values of all registers. With fixed widths there are at most ∣S∣⋅2∑rwr|S| \cdot 2^{\sum_r w_r} configurations, and the next one is a function of the current one and the inputs. So the FSMD is a finite automaton, and questions such as "can state ss be reached" are decidable by search over configurations. The number of configurations is exponential in the total width, which is why tools reason about registers as words and not as bits.
  • Unbounded width gives general computation. If the registers hold unbounded integers and the transfers include add one, subtract one and test for zero, two registers suffice to simulate a two-counter machine, which Minsky showed can simulate a Turing machine. Then whether the FSMD reaches a state is undecidable, by the halting problem.
  • Time is cycles times period. The run time of a program on an FSMD is the number of cycles times TT. Chaining lowers the number of cycles and raises TT. So the best schedule for time is not always the one with the fewest states, and the clock period must be fixed before scheduling or found with it.
  • Registers follow lifetimes. For a schedule of one block, the values live across each edge form intervals over the steps. The least number of registers equals the largest number of intervals that overlap at one edge, and the left edge algorithm reaches it. Across loops, lifetimes become circular arcs, and the problem is NP-hard, as the high-level synthesis page shows.
  • Guarded transfers can share a unit. Two transfers in one state whose guards are never both true can use one unit, because only one of them writes its result. This is the sharing of mutually exclusive operations, used in the example above.

References

  1. Daniel D. Gajski, Nikil D. Dutt, Allen C.-H. Wu and Steve Y.-L. Lin, High-Level Synthesis, Introduction to Chip and System Design, Kluwer, 1992, the chapters on architectural models and design representations (the controller and datapath model and the FSMD)
  2. Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, Chapter 3, Hardware Modeling; Chapter 4, Architectural Synthesis (the data path and the control unit)
  3. Marvin L. Minsky, Computation, Finite and Infinite Machines, Prentice-Hall, 1967, the chapter on program machines (two counters suffice to simulate a Turing machine)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/CKYAFC/text.yaml