From WikiChip
counter
Revision as of 00:21, 17 August 2017 by DavidCary (talk | contribs) (rough draft)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A counter is a digital circuit that stores a value (much like a register), and additionally can increment or decrement that value.

An "up counter" increments its value on each clock pulse. A "down counter" decrements its value on each clock pulse. An "up/down counter", also called a bidirectional counter, counts both up and down (but not at the same time).

Usually the program counter (PC) is implemented as an up counter, so that it can be incremented at the same time that data is being processed by the ALU.

Many modern CPUs have a variety of "performance counters" useful in profiling.

Most modern computer systems have a timer -- a counter driven by the main clock -- to generate regular timing pulses that interrupt the CPU for pre-emptive multitasking.

Many modern microcontrollers have a few "timer/counter" peripherals that can be set up to count pulses from some external peripheral, generate PWM waveforms, or similar tasks.

Many counter circuits are "binary counters" -- it counts in natural binary -- 0, 1, 10, 11, 100, ... up to an all-ones state, and then roll over back to 0. The decade counters, also called "binary coded decimal" counters, use the same sequence, but each block of 4 bits only counts up to 1001 (9) before rolling over to 0.

A few counters use a very different counting sequence -- a linear feedback shift register (LFSR) counter, a ring counter, a Johnson counter, a gray-code counter, etc.

A binary up-counter can be seen as a simplified adder (one data input hard-wired to +1), similar to the way an adder can be seen as a simplified arithmetic logic unit (the function control input hard-wired to addition).