1. Gyanastra
  2. Digital Logic
  3. Registers and Counters
  4. Need for Counters and Modular Counting
Free lesson, no account needed 5 min read 14 practice questions after it
Asked in past papers9 times
  • GATE CSE20162015201120071994
  • UGC NET2019201520132007

Digital Logic · Registers and Counters

Need for Counters and Modular Counting

Overview

A counter is a sequential device that counts clock cycles, where the clock is a periodic square wave alternating 1, 0, 1, 0 .... Counters are needed to know how many clock cycles have occurred so far, to count in a repeating (modular) manner, and to generate control signals in Computer Organization.

Key concepts

  • Counter: a sequential device that counts clock cycles; the clock is the input signal provided to the circuit.
  • Clock: a periodic signal alternating between 1 and 0 (1, 0, 0, 1 ...).
  • Modular counting: counting in a repeating manner — after reaching a fixed value, the count restarts from the beginning.
  • Round-robin CPU allocation: one CPU is shared among several devices, each given the CPU for one cycle in turn; after the last device, the first device is served again.
  • mod N counter: with N devices served in round-robin, the counter wraps around after every N counts, so a mod N counter is required (e.g. 4 devices → mod 4).

How it works

  1. A clock is a periodic signal alternating between 1 and 0 (1, 0, 1, 0 ...). A counter counts how many clock pulses have occurred up to the present time.
  2. Sometimes counting must be modular: after reaching a fixed value, the count restarts from the beginning.
  3. In round-robin CPU allocation, one CPU is shared among several devices, each given the CPU for one cycle in turn:
    • 1st clock → device 1
    • 2nd clock → device 2
    • 3rd clock → device 3
    • 4th clock → device 4
    • 5th clock → device 1 again (restart)
  4. With four devices, the count sequence is 1, 2, 3, 4, 1, 2, 3, 4, ... — the 5th clock behaves like the 1st, the 6th like the 2nd, the 7th like the 3rd, the 8th like the 4th.
    This is mod 4 counting: the counter wraps around after every 4 counts.
  5. Counters are also used in Computer Organization to generate control signals.
  6. Counters come in various types; the theoretical points come first, and the practical points (with examples and problems) follow afterwards.

Formulas

  • Count sequence for N devices in round-robin: 1,2,3,…,N,1,2,3,…,N,…1, 2, 3, \dots, N, 1, 2, 3, \dots, N, \dots — the count repeats every N clocks, so the required counter is a mod N counter.
  • For 4 devices: 1,2,3,4,1,2,3,4,…1, 2, 3, 4, 1, 2, 3, 4, \dots (mod 4 counting).

Worked examples

Round-robin scheduling with 4 devices (mod 4 counter):

Clock pulseDevice given CPUCounter value (mod 4)
1Device 11
2Device 22
3Device 33
4Device 44 (0)
5Device 11
6Device 22
7Device 33
8Device 44 (0)

The count repeats every 4 clocks, so the required counter is a mod-4 counter.

Revision summary

  • A counter counts clock cycles; the clock is the input to the counter.
  • Counters are needed for (i) counting clock cycles, (ii) modular counting, and (iii) generating control signals (seen later in CO).
  • Modular counting means the count restarts after a fixed number of clocks.
  • With N devices served in round-robin, the counter is a mod N counter (e.g. 4 devices → mod 4).
  • In round-robin allocation, each successive clock goes to the next device, and after the last device the first device is served again.
  • The 5th clock behaves like the 1st, the 6th like the 2nd, the 7th like the 3rd, the 8th like the 4th.

Previous-year exam insights

  • The number of flip-flops needed for a modulo-N (mod-N) counter is ceil(log⁡2N\log_{2} N); a mod-N counter has N states and requires at least that many flip-flops.
    Asked inGATE 2011GATE 1994UGC NET 2015UGC NET 2007
  • A counter that counts up to a maximum value M (i.e., M+1 distinct states 0..M) needs ceil(log⁡2(M+1)\log_{2}(M+1)) flip-flops; for a ripple counter counting up to a value, the number of flip-flops is the number of bits needed to represent that value.
    Asked inUGC NET 2013
  • When counters are cascaded, the overall modulus is the product of the individual moduli (a mod-M counter followed by a mod-N counter gives mod M×N).
    Asked inUGC NET 2019
  • For a counter with a non-standard or repeated sequence, the minimum number of flip-flops is ceil(log⁡2(number of distinct states in the sequence)\log_{2}(\text{number of distinct states in the sequence})), not the length of the sequence.
    Asked inGATE 2016GATE 2015
  • A mod-N counter using n flip-flops has 2n−N2^{n} - N unused states; these must be handled (self-starting design) so the counter cannot lock into an invalid state.
    Asked inGATE 2016GATE 2007
  • In a synchronous counter with clear/load/count control inputs, the next state is determined by priority of the control signals (typically Clear > Load > Count > No change), and the sequence depends on the feedback/decoding logic connected to the counter.
    Asked inGATE 2007
Pages 1–2 of 2