Counters and Registers: State, Storage, and Clocked Updates
Counters and Registers let a digital system remember information between clock events. A counter tracks events or positions in a repeating sequence. A register stores a word of data, such as a sensor reading or a sequence of received bits. To predict either device, identify its current state, active clock edge, and control inputs before calculating the next state.
Stored state and clocked updates
An n-bit storage device has 2n possible binary patterns. A counter assigns those patterns positions in a sequence; a register treats them as stored data. Their hardware may look similar, but their update rules serve different purposes.
Use the clock-edge convention stated for the device. Here, synchronous devices update on the rising edge. Inputs are assumed stable for the required setup and hold times around that edge. Between active edges, the stored state holds unless an asynchronous control acts.
When several registers share a clock, they use the values present immediately before the edge. A value loaded into one register does not pass through another register on that same edge.
Counter sequences and timing
The modulus of a counter is the number of states in its repeating count sequence. An enabled modulo-M up-counter follows
Thus, a modulo-5 counter follows 0,1,2,3,4,0,…. An n-bit counter can represent at most 2n states, so choose the smallest integer n satisfying
A modulo-5 counter needs three bits because 22=4<5 and 23=8≥5. Its three unused patterns need a specified recovery rule; their behavior is not determined by the modulus alone.
If a counter increments at a regular rate finc, one complete cycle takes M increments. A rollover event, meaning the transition from M−1 to zero, repeats at
For a continuously enabled natural binary counter with no resets, bit Qi, numbered from Q0 at the least significant position, repeats at fclk/2i+1. This bit-frequency rule does not generally apply to truncated sequences.
In a synchronous counter, storage elements receive the same clock. In a ripple counter, a transition propagates through successive stages, so intermediate output patterns can appear before the count settles.
Register operations and controls
A register is a group of storage elements that holds a multi-bit word. Its control inputs determine which operation occurs at an active edge.
Operation | What happens at the active edge |
|---|---|
Hold | The stored word remains unchanged. |
Parallel load | All bit positions capture their corresponding data inputs. |
Shift | Each position captures a neighboring bit; an end position accepts the serial input. |
Synchronous reset | The register takes its specified reset value. |
For example, display a four-bit word as R3R2R1R0. Define a shift toward higher-numbered positions by
Every right-hand value comes from before the edge. The old R3 leaves the register, and the serial input enters R0. Always use the stated bit mapping because informal shift-direction descriptions can differ.
What to remember
- Track stored state one active edge at a time.
- A modulo-M counter repeats after M increments.
- Use the enabled increment rate when calculating rollover timing.
- Parallel loading captures a word; shifting moves bits between positions.
- Check reset priority, bit order, and propagation timing before predicting outputs.
Example: Timing and Serial Capture in a Controller
A controller uses a 6.00 kHz clock. A synchronous modulo-12 up-counter starts at zero and increments on every rising edge. It produces a rollover event whenever its count changes from 11 to zero. No resets occur during the interval considered.
The controller also has a separate four-bit serial-input register, initially 0000. Display its word as R3R2R1R0. On an enabled rising edge, it updates according to
The register is enabled for the first four rising edges. Its serial input values at those edges are, in order, 1,0,1,1. It holds after the fourth edge. All inputs meet setup and hold requirements, and observations are made after propagation has settled.
a) Find the minimum number of counter bits and the counter state after 29 rising edges. Give the state in decimal and in the minimum-width binary representation.
The counter must represent twelve distinct states, from zero through eleven. Compare the capacities of consecutive bit widths:
The minimum width is therefore four bits. Starting from zero, each complete group of twelve rising edges returns the count to zero. Divide the elapsed increments into complete cycles and a remainder:
Two cycles use ________ edges, leaving ________ increments. The count after 29 edges is therefore decimal 5, represented with four bits as 0101.
b) Find the steady rollover-event frequency and the time between consecutive rollover events. Give the results in Hz and ms.
Every clock edge increments the counter, so the increment frequency equals the clock frequency. Twelve increments separate consecutive rollovers:
The interval between rollover events is the reciprocal of that frequency:
Thus, rollover events repeat at 500 Hz, separated by 2.00 ms. These results describe the event repetition, rather than the frequency of an arbitrary counter bit.
c) Find the register word after its four enabled edges and state which bit contains the first received serial value.
At each enabled edge, the old bits move toward higher-numbered positions, and the new serial value enters R0. Update all positions from their pre-edge values:
- First edge: starting from 0000, shift the old R2R1R0=000 into R3R2R1 and append the input 1. The word becomes 0001.
- Second edge: starting from 0001, shift the old R2R1R0=001 into R3R2R1 and append the input 0. The word becomes 0010.
- Third edge: starting from 0010, shift the old R2R1R0=010 into R3R2R1 and append the input 1. The word becomes 0101.
- Fourth edge: starting from 0101, shift the old R2R1R0=101 into R3R2R1 and append the input 1. The word becomes 1011.
The final word is 1011, which is decimal
The first received value has moved from R0 to R1, then R2, and finally R3. Thus, R3 contains the first received value. Because the register is disabled afterward, it continues to hold 1011.
A packaging controller has a three-stage counter. Every stage receives the same external clock signal and responds to its rising edge. The outputs settle 4 ns, 5 ns, and 7 ns after that edge. Based on its clock connections, this is a counter.
A modulo-20 counter receives a clock with frequency 2.40 MHz. Its enable is high at every fourth rising clock edge and low at all other edges. The counter increments only when enable is high. A rollover event occurs whenever its count changes from 19 to 0. With no resets during operation, what is the long-run rollover-event frequency? Answer in kHz, to one decimal place.