# State encoding for low power

**State encoding** assigns a unique pattern of ones and zeros to each defined state of a finite-state machine (FSM). Traditionally, design criteria for FSM synthesis were speed, area or both. Following Moore's law, with technology advancement, density and speed of integrated circuits have increased exponentially. With this, power dissipation per area has inevitably increased, which has forced designers for portable computing devices and high-speed processors to consider power dissipation as a critical parameter during design consideration.^{[1]}^{[2]}

## Contents

## Background[edit]

Synthesis of FSM involves three major steps:

**State minimization:**As the name suggests, the number of states required to represent FSM is minimized. Various techniques and algorithms like implication tables, row matching, successive partitioning algorithm, identify and remove equivalent or redundant states.**State assignment**or encoding involves choosing boolean representations of the internal states of FSM. In other words it assigns a unique binary code to each state. Selection of right encoding technique is very critical. Since wrong decision may result in FSM that uses too much logic area, is too slow or consumes more power or any combination of these.**Combinational logic minimization**uses unassigned state-codes as don't-care in order to reduce the combinational logic.

## Existing encoding techniques[edit]

Following are some of the techniques which are widely used for state encoding:

- In
**one hot encoding**, only one of the bits of the state variable is "1" (hot) for any given state. All the other bits are "0". The Hamming distance of this techniques is 2. One hot requires one flip-flop for every state in FSM. As a result, the state machine is already “decoded,” so the state of the machine is determined simply by finding out which flip-flop is active. This encoding technique reduces the width of the combinatorial logic and, as a result, the state machine requires fewer levels of logic between registers, reducing its complexity and increasing its speed. - In
**binary encoding**, the number of bits (b) per state depends on number of states (n). The relationship is defined by the equation:

b = log2(n)

In this technique, the states are assigned in binary sequence where the states are numbered starting from binary 0 and up. Clearly, the number of flip-flops used is equal to the number bits(b). Since Binary encoding uses the minimum number of bits (flip-flops) to encode a machine the flip-flops are maximally utilized. As a result, more combinatorial logic is required to decode each state when compared to One Hot. Requires less number of flip-flops when compared to One hot but hamming distance can be as worse as number of bits(b).

In Gray code, also known as reflected binary code, state are assigned such that consecutive state codes differ by only one bit. In this encoding also the relationship between number of bits and the number of states is defined by

b = log2(n)

Number of flips-flops used and the complexity of the decoding logic is same as Binary encoding. But the hamming distance in Gray code is always 1.

**Other encoding techniques**

Output based encoding, MUSTANG,^{[3]} NOVA,^{[4]}

## Motivation[edit]

The main idea in the design of state encoding for low power is to minimize the Hamming distance of the most probable state transitions, which reduces switching activity. Thus, a cost model for minimizing power consumption is to have a minimum-weighted Hamming distance(MWHD).^{[1]}^{[2]}

For counters, Gray coding gives minimum switching activity, and thus is suitable for low-power designs. Gray encoding suits best when state change are sequential. In arbitrary state changing, FSM Gray code fails for low-power designs. For such FSM, one-hot encoding guarantees switching of two bits for every state change. But since the number of state variables needed is equal to the number of states, as states increase, one-hot encoding becomes an impractical solution, mainly because with an increased number of inputs and outputs to the circuit, complexity and capacitive load increase. Binary coding is worst for low power since the maximum Hamming distance is equal to the number of state variables.

The need to have a solution for arbitrary state changing FSM has led to several state encoding techniques which focus on reducing the switching activity during state transitions.

## Techniques[edit]

### Column-based approach for low-power state assignment[edit]

^{[5]}
This approach aims to reduce power dissipation by sequential circuits by choosing state assignment which minimizes the switching activity between state transitions. Thus the combinational part of FSM has lower input transition probability and is more like to give low power dissipation when synthesized. This algorithm uses boolean matrix with rows corresponding to state codes and column corresponding to state variables. Single state variable is considered at a time and try to assign its value to each state in FSM, in a way which is likely to minimize the switching activity for the complete assignment. This procedure is repeated for the next variable. Since minimization technique is applied column by column this technique is called as Column based.

### Multi-code state assignment[edit]

Multi-code state assignment technique implements priority encoding by restraining redundant states. Thus state can be encoded using fewer state variables (bits). Further, flip-flops corresponding to those absent state variables can be clock-gated.^{[6]}

### Profiling-based state assignment[edit]

^{[7]}
This technique utilizes dynamic loop information extracted from FSM profiling data for state assignment in-order to reduce switching activity. Following are the steps this technique uses:

- FSM state profiling collects information about the dynamic behavior of the FSM for a relevant input data set
- Loop detection searches for loops in the state trace and each loop is stored and counted to obtain the frequency of the loops.
- State assignment assigns state variables to each state based on the data gathered in the first two steps in order to minimize the switching activity. There are three algorithm to assign state variables,

- Basic DFS state assignment algorithm
- Loop-based DFS state assignment algorithm
- Loop-based per-state heuristic state assignment algorithm

### Other techniques[edit]

- Some techniques encode state transition graph(STG) to produce two-level and multi-level implementations targeting low power
^{[8]}^{[9]} - Re-encoding of existing logic-level sequential circuits for power optimizations has been proposed
^{[10]} - Spanning tree-based state encoding,
^{[11]}Depth_First Method,^{[12]}Minimum distance Method,^{[12]}1_Level Method,^{[12]}1_level_tree Method,^{[12]}where focus is again on assigning state variables to the different states such that switching activity due to state transition is reduced. - Apart from just encoding states for Low power some techniques involve decomposition of FSM into two or more sub-machines such that only one of which is active most of the time. Taking advantage of this, other sub-machine can be either clock gated
^{[13]}or power gated.^{[14]}

## See also[edit]

## References[edit]

- ^
^{a}^{b}M. Pedram and A Abdollahi, “Low Power RT-Level Synthesis Techniques: A Tutorial” - ^
^{a}^{b}Devadas & Malik, “A Survey of Optimization Techniques targeting Low Power VLSI Circuits”, DAC 32, 1995, pp. 242–247 **^**S. Devadas et al., “MUSTANG: State Assignment of Finite State Machines Targeting Multi-Level Logic Implementations,” IEEE Trans. Computer-Aided Design, Vol. CAD-7, No. 12, Dec. 1988, pp.129@1300**^**T. Villa, A. S. Vincentell, “NOVA: State Assignment of Finite State Machines for Optimal Two-Level Logic Implementation,” IEEE transactions on CAD. VOL. 9 NO. 9. September 1990, pp. 905-924**^**L. Benini and G. De Micheli, "State assignment for low power dissipation", IEEE J. Solid-State Circuits, vol. 30, no. 3, 1995, pp. 258–268**^**X. Wu, M. Pedram, and L. Wang, Multi-code state assignment for low power design, IEEE Proceedings-Circuits, Devices and Systems, Vol. 147, No. 5, pp. 271–275, October 2000.**^**http://mmc.tudelft.nl/sites/default/files/eggermont.pdf**^**K Roy and S Prasad. SYCLOP: Synthesis of CMOS Logic for Low Power Applications. In Proceedings of the Int’l Conference on Computer Design: VLSI in Computers and Processors, pages 464–467, October 1992**^**C-Y Tsui, M Pedram, C-A Chen and A M Despain. Low Power State Assignment Targeting Two- and Multi-level Logic Implementations. In Proceedings of the Int’l Conference on Computer-Aided Design, pages 82–87, November 1994.**^**G D Hachtel, M Hermida, A Pardo, M Poncino, and F Somenzi. Re-Encoding Sequential Circuits to Reduce Power Dissipation. In Proceedings of the Int’l Conference on Computer Aided Design, pages 70–73, November 1994**^**W. Noth, and R. Kolla “Spanning Tree Based State Encoding for Low Power Dissipation,” Proceedings of DATE, pp. 168. Mar. 1999- ^
^{a}^{b}^{c}^{d}http://home.deib.polimi.it/silvano/Paperi_IEEE/ch7.pdf **^**J.C. Monteiro and A.L. Oliveira,"Implicit fsm decomposition applied to low-power design," IEEE Trans. VLSI Syst., vol.10, no.5, pp.560-565, 2002**^**S.H. Chow, Y.C. Ho, T. Hwang and C.L. Liu, "Low power realization of finite state machines-a decomposition approach," ACM Trans. Design Automat. Elect. Syst., vol.1, no.3, pp.315-340, July 1996.