A Binary Counter as a State Machine

A clocked counter stores a bit pattern and replaces it with the next pattern under its enable and reset rules.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Work the wrap
  2. Define reset precedence
  3. Trace a state transition at the width boundary
  4. Derive a signal from the intended edge of the counter

Work the wrap

A three-bit up-counter can take states 110, 111, 000, and 001 on consecutive enabled updates. The arithmetic follows wraparound counters, while the circuit stores the present state.

Define reset precedence

The specification should say what happens on an edge when enable and reset are both asserted. A two-row conflict test can verify whether reset sets the initial value or an increment occurs first. See decision tables for documenting that precedence.[1]

Trace a state transition at the width boundary

A three-bit up counter adds one to its stored state on each enabled clock edge. After 110 comes 111 and then 000 if the design wraps. A low enable can hold any of those states for an extra cycle. See wraparound counters.

edge  state before  enable  state after
1     110           1       111
2     111           0       111
3     111           1       000

Derive a signal from the intended edge of the counter

Detecting state seven differs from detecting the transition from seven to zero. A wrap indicator can use both state seven and enable under this model. Test the held maximum to distinguish that signal from a simple equality check.

References

  1. Noam Nisan and Shimon Schocken, From Nand to Tetris: Course Projects ↩