Algorithm Search⌘K

Techniqueadvanced

FSM decomposition

Also called finite state machine decomposition, general decomposition of FSMs.

Splits a finite state machine into interacting smaller machines, by Hartmanis-Stearns partitions or by Devadas and Newton's factorization, to cut logic and delay.

FSM decomposition builds one finite state machine from two or more smaller machines that run together and read each other's state. The pieces are easier to encode and to optimize, each piece has fewer inputs to its next-state logic, and a piece that is idle can be stopped. The classic theory of Hartmanis and Stearns (1966) says exactly when a machine splits without any loss: a serial decomposition, in which the second machine reads the state of the first, exists when the machine has a nontrivial partition of its states with the substitution property, and a parallel decomposition, in which neither reads the other, exists when it has two such partitions that together tell every state apart. Logic synthesis in the late 1980s added looser forms: general decomposition, in which each piece may read the other, and factorization, in which a pattern of states that occurs several times in the state graph is built once (Devadas and Newton 1989).

In plain words

A clock that shows hours and minutes is one machine with 1440 states, but nobody builds it that way. It is a minutes counter that ticks every minute and an hours counter that ticks only when the minutes wrap around. The hours counter needs to see one thing from the minutes counter, whether it is about to wrap; the minutes counter needs nothing from the hours counter. This is a serial decomposition. Decomposition looks for such splits in any machine: groups of states such that the group of the next state can be known from the group of the present state and the input alone.

When it applies

  • The machine is deterministic and completely specified, with states SS, inputs II and next-state function δ\delta, as on the partition pair page, whose notation this page uses. It should first be minimized by DFA minimization, or by incompletely specified FSM minimization when it has unspecified entries, since redundant states create splits that only reflect the redundancy.
  • For an exact serial split, the machine has an SP partition π\pi other than 00 and 11. For an exact parallel split, it has two SP partitions π1,π2\pi_1, \pi_2, both other than 00 and 11, with π1∧π2=0\pi_1 \wedge \pi_2 = 0.
  • The aim is smaller or faster logic, or lower power, at the price of more interacting pieces; the number of flip-flops can grow, as the pitfalls show.

The template

  1. DECOMPOSE(M, π, τ)
  2. 1if π is not SP, or π ∧ τ ≠ 0 then fail
  3. 2M1.states ← blocks of π
  4. 3for each block B of π and input x do M1.δ(B, x) ← the block of π that holds δ(s, x), for any s in B
  5. 4M2.states ← blocks of τ
  6. 5for each block C of τ, block B of π and input x do
  7. 6if B ∩ C = {s} then
  8. 7M2.δ(C, (x, B)) ← the block of τ that holds δ(s, x)
  9. 8λ(B, C, x) ← λ(s, x)
  10. 9else leave M2.δ(C, (x, B)) and λ(B, C, x) unspecified
  11. 10return (M1, M2, λ)

The holes are the choice of π\pi among the SP partitions, the choice of τ\tau, the codes of the blocks of each piece, and the cost that judges the result. If τ\tau is SP too, then M2.δ(C,(x,B))M_2.\delta(C, (x, B)) does not depend on BB and the decomposition is parallel. The SP partitions are listed from the generators ρst\rho_{st} of the partition pair page, and τ\tau is chosen with as few blocks as possible; it needs at least as many blocks as the largest block of π\pi, since the states of one block of π\pi must lie in different blocks of τ\tau.

Theorem (serial decomposition). If π\pi is SP and π∧τ=0\pi \wedge \tau = 0, then M1M_1 and M2M_2 run side by side, with M2M_2 reading the input and the state of M1M_1, start from Bπ(s0)B_\pi(s_0) and Bτ(s0)B_\tau(s_0), and produce the outputs of MM on every input word.

Proof. M1M_1 is well defined on line L3 because π\pi is SP: all states of BB go to one block of π\pi on input xx. We show by induction on the number of steps that if MM is in state ss, then M1M_1 is in Bπ(s)B_\pi(s) and M2M_2 is in Bτ(s)B_\tau(s). This holds at the start. If it holds before input xx, then Bπ(s)∩Bτ(s)B_\pi(s) \cap B_\tau(s) contains ss, and since π∧τ=0\pi \wedge \tau = 0 it is exactly {s}\{s\}. So line L8 gives the output λ(s,x)\lambda(s, x), line L7 moves M2M_2 to Bτ(δ(s,x))B_\tau(\delta(s, x)), and line L3 moves M1M_1 to Bπ(δ(s,x))B_\pi(\delta(s, x)). The entries left unspecified on line L9 are never used. ■\blacksquare

Theorem (parallel decomposition). If π1\pi_1 and π2\pi_2 are both SP and π1∧π2=0\pi_1 \wedge \pi_2 = 0, then M/π1M/\pi_1 and M/π2M/\pi_2, each driven by the input alone, together track the state of MM: it is the single state in the meet of their two blocks. The proof is the same, with M2=M/π2M_2 = M/\pi_2 well defined because π2\pi_2 is SP.

Conversely, a serial decomposition in which the second machine reads only the state of the first gives an SP partition: group the states of MM by the state of the first machine. So a reduced machine has a nontrivial serial decomposition exactly when it has an SP partition other than 00 and 11. This is the result of Hartmanis and Stearns; their book states it with a precise notion of one machine realizing another, which this sketch of the converse takes for granted.

Classic examples

The counter modulo 4 with enable. Let δ(s,e)=s+e mod 4\delta(s, e) = s + e \bmod 4. Its SP partitions come from the subgroups of Z4\mathbb{Z}_4, as the partition pair page shows: 00, the parity partition π={0,2}{1,3}\pi = \{0, 2\}\{1, 3\}, and 11. Take π\pi and τ={0,1}{2,3}\tau = \{0, 1\}\{2, 3\}, with π∧τ=0\pi \wedge \tau = 0. Write s=2h+ps = 2h + p. Then M1M_1 holds the parity pp with p′=p⊕ep' = p \oplus e, and M2M_2 holds hh with h′=h⊕(p∧e)h' = h \oplus (p \wedge e): it reads the state pp of M1M_1 to know whether a carry comes in. This is the usual synchronous binary counter, with the carry from the low bit as the link between the two pieces. The counter has no parallel decomposition, since it has only one nontrivial SP partition.

The counter modulo 6. The subgroups {0,2,4}\{0, 2, 4\} and {0,3}\{0, 3\} of Z6\mathbb{Z}_6 give the SP partitions π2={0,2,4}{1,3,5}\pi_2 = \{0, 2, 4\}\{1, 3, 5\} (the value modulo 2) and π3={0,3}{1,4}{2,5}\pi_3 = \{0, 3\}\{1, 4\}\{2, 5\} (the value modulo 3). Their meet is 00 by the Chinese remainder theorem, so the counter is a counter modulo 2 and a counter modulo 3 that run in parallel on the same enable, with 1 + 2 = 3 flip-flops, the same as a plain encoding of 6 states.

A controller with a repeated pattern. In the controller of a finite state machine with datapath, the same sequence of states, such as a handshake or a memory access, often occurs at several places in the state graph. Factorization (Devadas and Newton 1989) builds that sequence once as a separate machine, which the main machine starts and waits for, so its states and transitions are not repeated. The main machine keeps one state per occurrence, in which it waits.

State assignment by partitions. A code in which a group of state bits encodes the blocks of an SP partition π\pi gives those bits next-state functions that depend only on themselves and the inputs; this is the serial decomposition hidden in a single encoding. Hartmanis used SP partitions and partition pairs this way for state assignment, before the symbolic methods such as KISS and MUSTANG.

Variations

  • Partition pairs instead of SP partitions. If (π,τ)(\pi, \tau) and (τ,π)(\tau, \pi) are partition pairs with π∧τ=0\pi \wedge \tau = 0, each piece computes its next block from the state of the other and the input, so the pieces read each other. Hartmanis and Stearns treat such loops of partition pairs as well.
  • General decomposition. Devadas and Newton (1989) split a state graph into two interacting machines that may each read the other's state, without asking for SP partitions, and judge the split by the size of the encoded logic. Ashar, Devadas and Newton (1991) give an exact algorithm and heuristics for this problem with a two-level logic cost.
  • Factorization. Devadas and Newton (1989) find factors, sets of states and transitions that occur more than once with the same shape, and implement each factor once. An exact factor gives an exact decomposition; looser factors trade some extra logic for wider use.
  • Krohn-Rhodes cascades. Repeated serial decomposition, with covers whose blocks may overlap in place of partitions, reaches components that are simple groups or reset machines. This is the Krohn-Rhodes theorem, a theoretical result rather than a synthesis tool.
  • Functional decomposition. The same idea for combinational logic is Ashenhurst-Curtis decomposition, which splits a Boolean function by a partition of its inputs rather than of states.

Pitfalls

  • More flip-flops. A decomposition into pieces with ∣π∣|\pi| and ∣τ∣|\tau| states needs ⌈log⁡2∣π∣⌉+⌈log⁡2∣τ∣⌉\lceil \log_2 |\pi| \rceil + \lceil \log_2 |\tau| \rceil flip-flops, which can be more than ⌈log⁡2∣S∣⌉\lceil \log_2 |S| \rceil. The counter modulo 15 splits into counters modulo 3 and modulo 5, with 2+3=52 + 3 = 5 flip-flops, while a plain encoding needs 4. Whether the smaller logic pays for the extra flip-flop must be checked.
  • A machine that is not minimized. Equivalent states can create SP partitions that a reduced machine does not have, and can hide the ones it does have. Minimize first.
  • Choosing τ\tau too fine. Any τ\tau with π∧τ=0\pi \wedge \tau = 0 works, and τ=0\tau = 0 always does, but then M2M_2 is as large as MM. The best τ\tau has as many blocks as the largest block of π\pi, and finding one that also keeps M2M_2 simple is itself a search problem.
  • No SP partition at all. Many machines, including every counter modulo a prime, have only the SP partitions 00 and 11, so they have no exact serial decomposition. Then general decomposition or factorization, which do not need SP partitions, are the only choices.
  • Unspecified entries. Line L9 leaves entries of M2M_2 free. They are don't cares for the logic of M2M_2, and forgetting them gives larger logic than needed.

Exercises

  1. List the SP partitions of the counter modulo 8 with enable, and decompose it serially into three machines with one flip-flop each.
  2. Show that if π\pi is SP and π∧τ=0\pi \wedge \tau = 0, then the number of blocks of τ\tau is at least the size of the largest block of π\pi, and find a τ\tau that reaches this bound for the counter modulo 6 and π=π2\pi = \pi_2.
  3. Prove the converse stated after the theorems: if a reduced machine is the serial connection of M1M_1 and M2M_2, and M2M_2 never influences M1M_1, then grouping the states by the state of M1M_1 gives an SP partition.
  4. A machine has the SP partitions 00, π1\pi_1, π2\pi_2 and 11 only, with π1∨π2=1\pi_1 \vee \pi_2 = 1 and π1∧π2≠0\pi_1 \wedge \pi_2 \neq 0. Which decompositions does it have?

References

  1. Juris Hartmanis and Richard E. Stearns, Algebraic Structure Theory of Sequential Machines, Prentice-Hall, 1966, serial and parallel decomposition of sequential machines by partitions with the substitution property and partition pairs
  2. Srinivas Devadas and A. Richard Newton, Decomposition and factorization of sequential finite state machines, IEEE Transactions on Computer-Aided Design 8(11), 1206 to 1217, 1989, general decomposition of a state graph and factorization by repeated subgraphs
  3. Pranav Ashar, Srinivas Devadas and A. Richard Newton, Optimum and heuristic algorithms for an approach to finite state machine decomposition, IEEE Transactions on Computer-Aided Design 10(3), 296 to 310, 1991, exact and heuristic algorithms for general decomposition with a two-level logic cost
  4. Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, Chapter 9 (finite state machine decomposition as part of sequential logic optimization)

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)
WritingW2 basic
  • three classic examples