All Topics  
Counter

 
Counter

   Email Print
   Bookmark   Link






 

Counter



 
 
In digital logic and computing
Computing

Computing is usually defined as the activity of using and developing computer technology, computer hardware and computer software. It is the computer-specific part of information technology....
, a counter is a device which stores (and sometimes displays) the number of times a particular event
Event (philosophy)

In philosophy, events are objects in time or instantiations of Property in objects. However, a definite definition has not been reached, as multiple theories exist concerning events....
 or process has occurred, often in relationship to a clock signal
Clock signal

In electronics and especially Synchronous logic digital circuits, a clock signal is a Signalling used to coordinate the actions of two or more Electronic circuit....
. In practice, there are two types of counters:



s counter counts both orders up and down by changing the supply. It is a counter which is formed by enclosed shift registers

Each is useful for different applications.






Discussion
Ask a question about 'Counter'
Start a new discussion about 'Counter'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In digital logic and computing
Computing

Computing is usually defined as the activity of using and developing computer technology, computer hardware and computer software. It is the computer-specific part of information technology....
, a counter is a device which stores (and sometimes displays) the number of times a particular event
Event (philosophy)

In philosophy, events are objects in time or instantiations of Property in objects. However, a definite definition has not been reached, as multiple theories exist concerning events....
 or process has occurred, often in relationship to a clock signal
Clock signal

In electronics and especially Synchronous logic digital circuits, a clock signal is a Signalling used to coordinate the actions of two or more Electronic circuit....
. In practice, there are two types of counters:

  • up counters, which increase (increment
    Increment

    An increment is an increase of some amount, either fixed or variable. For example one's salary may have a fixed annual increment or one based on a percentage of its current value....
    ) in value
  • down counters, which decrease (decrement) in value


In electronics


In electronics
Electronics

Electronics refers to the flow of charge through nonmetal electrical conductor , whereas electrical refers to the flow of charge through metal electrical conductor....
, counters can be implemented quite easily using register-type circuits such as the flip-flop
Flip-flop (electronics)

In digital circuits, a flip-flop is a term referring to an electronic circuit that has two stable states and thereby is capable of serving as one bit of computer storage....
, and a wide variety of designs exist, e.g:
  • Asynchronous (ripple) counters
  • Synchronous counters
  • Johnson counters
  • Decade counters
  • Up-Down counters
This counter counts both orders up and down by changing the supply.
  • Ring counters
It is a counter which is formed by enclosed shift registers

Each is useful for different applications. Usually, counter circuits are digital
Digital

A digital system uses discrete values, usually but not always symbolized numerically to represent information for input, processing, transmission, storage, etc....
 in nature, and count in binary
Binary code

Binary code is the system of representing text or Instruction by the use of a two-numerical digit number system. This system is composed of only the number zero, representing the Off state, and the number one, representing on state, combined in groups of 8....
, or sometimes binary coded decimal. Many types of counter circuit are available as digital building blocks, for example a number of chips in the 4000 series
4000 series

The 4000 series is a family of industry standard integrated circuits which implement a variety of logic gate functions using CMOS technology. They were introduced by RCA as CD4000 COS/MOS in 1968, as a lower power and more versatile alternative to the 7400 series of transistor-transistor logic logic chips....
 implement different counters.

Asynchronous (ripple) counter


The simplest counter circuit is a single D-type flip-flop
Flip-flop (electronics)

In digital circuits, a flip-flop is a term referring to an electronic circuit that has two stable states and thereby is capable of serving as one bit of computer storage....
, with its D (data) input fed from its own inverted output. This circuit can store one bit, and hence can count from zero to one before it overflows (starts over from 0). This counter will increment once for every clock cycle and takes two clock cycles to overflow, so every cycle it will alternate between a transition from 0 to 1 and a transition from 1 to 0. Notice that this creates a new clock with a 50% duty cycle
Duty cycle

In telecommunications and electronics, the duty cycle is the fraction of time that a system is in an "active" state. In particular, it is used in the following contexts:...
 at exactly half the frequency of the input clock. If this output is then used as the clock signal for a similarly arranged D flip-flop (remembering to invert the output to the input), you will get another 1 bit counter that counts half as fast. Putting them together yields a two bit counter:

Cycle Q1 Q0 (Q1:Q0)dec
0 0 0 0
1 0 1 1
2 1 0 2
3 1 1 3
4 0 0 0


You can continue to add additional flip-flops, always inverting the output to its own input, and using the output from the previous flip-flop as the clock signal. The result is called a ripple counter, which can count to 2n-1 where n is the number of bits (flip-flop stages) in the counter. Ripple counters suffer from unstable outputs as the overflows "ripple" from stage to stage, but they do find frequent application as dividers for clock signals, where the instantaneous count is unimportant, but the division ratio
Ratio

A ratio is an expression which compares quantities relative to each other. The most common examples involve two quantities, but in theory any number of quantities can be compared....
 overall is. (To clarify this, a 1-bit counter is exactly equivalent to a divide by two circuit – the output frequency is exactly half that of the input when fed with a regular train of clock pulses).

The use of flip-flop outputs as clocks leads to timing skew between the count data bits, making this ripple technique incompatible with normal synchronous circuit
Synchronous circuit

A synchronous circuit is a digital circuit in which the parts are synchronized by a clock signal.In an ideal synchronous circuit, every change in the logical levels of its storage components is simultaneous....
 design styles.

Synchronous counter


Where a stable count value is important across several bits, which is the case in most counter systems, synchronous counters are used. These also use flip-flops, either the D-type or the more complex J-K type, but here, each stage is clocked simultaneously by a common clock signal. Logic gate
Logic gate

A logic gate performs a logical operation on one or more logic inputs and produces a single logic output. The logic normally performed is Boolean logic and is most commonly found in digital circuits....
s between each stage of the circuit control data flow from stage to stage so that the desired count behavior is realized. Synchronous counters can be designed to count up or down, or both according to a direction input, and may be presetable via a set of parallel "jam" inputs. Most types of hardware-based counter are of this type. A simple way of implementing the logic for each bit of an ascending counter (which is what is shown in the image to the right) is for each bit to toggle when all of the less significant bits are at a logic high state. For example, bit 1 toggles when bit 0 is logic high; bit 2 toggles when both bit 1 and bit 0 are logic high; bit 3 toggles when bit 2, bit 1 and bit 0 are all high; and so on.

Synchronous counters can also be implemented with hardware finite state machine
Finite state machine

A finite state machine or finite state automaton or simply a state machine, is a model of behavior composed of a finite number of state s, transitions between those states, and actions....
s, which are more complex but allow for smoother, more stable transitions.

Ring counter


A ring counter is a shift register
Shift register

In digital circuits, a shift register is a group of flip-flop s set up in a linear fashion which have their inputs and outputs connected together in such a way that the data is shifted down the line when the circuit is activated....
 (a cascade connection of flip-flop
Flip-flop

In footwear and fashion, flip-flops are a flat, backless, usually rubber sandal consisting of a flat sole held loosely on the foot by a Y-shaped strap, like a thin thong, that passes between the first and second toes and around either side of the foot....
s) with the output of the last one connected to the input of the first, that is, in a ring. Typically a pattern consisting of a single 1 bit is circulated, so the state repeats every N clock cycles if N flip-flops are used. It can be used as a cycle counter of N states.

Johnson counter


A Johnson counter (or switchtail ring counter, twisted-ring counter, walking-ring counter, or Moebius counter) is a modified ring counter, where the output from the last stage is inverted and fed back as input to the first stage. A pattern of bits equal in length to twice the length of the shift register thus circulates indefinitely. These counters find specialist applications, including those similar to the decade counter, digital to analogue conversion, etc.

Decade counter


A decade counter is one that counts in decimal digits, rather than binary. A decimal counter may have each digit binary encoded (that is, it may count in binary-coded decimal
Binary-coded decimal

In computing and electronics systems, binary-coded decimal is an encoding for decimal numbers in which each digit is represented by its own binary sequence....
, as the 7490
List of 7400 series integrated circuits

The following is a list of 7400 series digital logic integrated circuits. The 7400 series originated with Transistor-transistor logic integrated circuits made by Texas Instruments....
 integrated circuit did) or other binary encodings (such as the bi-quinary encoding of the 7490
List of 7400 series integrated circuits

The following is a list of 7400 series digital logic integrated circuits. The 7400 series originated with Transistor-transistor logic integrated circuits made by Texas Instruments....
 integrated circuit). Alternatively, it may have a "fully decoded" or one-hot output code in which each output goes high in turn; the 4017
4000 series

The 4000 series is a family of industry standard integrated circuits which implement a variety of logic gate functions using CMOS technology. They were introduced by RCA as CD4000 COS/MOS in 1968, as a lower power and more versatile alternative to the 7400 series of transistor-transistor logic logic chips....
 was such a circuit. The latter type of circuit finds applications in multiplexer
Multiplexer

In electronics, a multiplexer or mux is a device that performs multiplexing; it selects one of many analog or digital input signals and outputs that into a single line....
s and demultiplexers, or wherever a scanning type of behaviour is useful. Similar counters with different numbers of outputs are also common.

Up–down counter


A counter that can change state in either direction, under control an up–down selector input, is known as an up–down counter. When the selector is in the up state, the counter increments its value; when the selector is in the down state, the counter decrements the count.

In computer science


In computability theory, a counter is considered a type of memory. A counter stores a single natural number
Natural number

In mathematics, a natural number can mean either an element of the Set = *n = = ? = ? ...
 (initially zero
0 (number)

0 is both a number and the numerical digit used to represent that number in numeral system. It plays a central role in mathematics as the additive identity of the integers, real numbers, and many other algebraic structures....
) and can be arbitrarily many digits long. A counter is usually considered in conjunction with a finite state machine
Finite state machine

A finite state machine or finite state automaton or simply a state machine, is a model of behavior composed of a finite number of state s, transitions between those states, and actions....
 (FSM), which can perform the following operations on the counter:

  • Check whether the counter is zero
  • Increment the counter by one
  • Decrement the counter by one (if it's already zero, this leaves it unchanged).


The following machines are listed in order of power, with each one being strictly more powerful than the one below it:
  1. Deterministic or non-deterministic FSM plus two counters
  2. Non-deterministic FSM plus one stack
    Stack (data structure)

    In computer science, a stack is an abstract data type and data structure based on the principle of LIFO . Stacks are used extensively at every level of a modern computer system....
  3. Non-deterministic FSM plus one counter
  4. Deterministic FSM plus one counter
  5. Deterministic or non-deterministic FSM


For the first and last, it doesn't matter whether the FSM is deterministic or non-deterministic (see determinism
Deterministic finite state machine

In the theory of computation, a deterministic automaton finite state machine is a finite state machine where for each pair of state and input symbol there is one and only one transition to a next state....
). They have equivalent power. The first two and the last one are levels of the Chomsky hierarchy
Chomsky hierarchy

Within the field of computer science, specifically in the area of formal languages, the Chomsky hierarchy is a containment hierarchy of classes of formal grammars....
.

The first machine, an FSM plus two counters, is equivalent in power to a Turing machine
Turing machine

Turing machines are basic abstract symbol-manipulating devices which, despite their simplicity, can be adapted to simulate the logic of any computer algorithm....
. See the article on register machine
Register machine

In mathematical logic and theoretical computer science a register machine is a generic class of abstract machines used in a manner similar to a Turing machine....
s for a proof.

In the Internet


A web counter
Web counter

A web counter or hit counter is a computer software program that indicates the number of visitors, or hits, a particular webpage has received....
 counts how many time a website or certain page has been viewed. They are usually accurate but some controversies have started regarding if they are accurate or not. This is usually because most counters count the number of unique hits a page gets while others count how many times a page was viewed even if the same person viewed it twice.

See also


  • Time to digital converter
    Time to digital converter

    In Electronics instrumentation and signal processing, a time to digital converter is a device for converting a signal of sporadic pulses into a digital representation of their time indices....