Digital LogicUnit 414 min read
Counters & Registers: Types, Design, Applications & Timing
Unit 4 of Digital Logic explores counters (synchronous/asynchronous, up/down, ripple vs. carry-lookahead) and registers (shift, parallel, serial-in/out), their internal logic, timing diagrams, and real-world applications in memory, CPUs, and communication systems. Learn to design, analyze, and troubleshoot these sequen
Key Concepts and Definitions
Registers: Temporary Data Storage
A register is a group of flip-flops used to store binary data temporarily. Registers are fundamental building blocks in CPUs, ALUs, and memory units.
Types of Registers
- Parallel Registers: Data is loaded and read simultaneously.
- Shift Registers: Data is shifted serially (left/right) between stages.
- Serial-In/Serial-Out (SISO): Data enters and exits serially.
- Serial-In/Parallel-Out (SIPO): Data enters serially but exits in parallel.
- Parallel-In/Serial-Out (PISO): Data enters in parallel but exits serially.
- Parallel-In/Parallel-Out (PIPO): Data enters and exits in parallel.
How Registers Work
- Clocked Operation: Registers update on clock edges (positive/negative).
- Enable Signal: Controls when data is loaded (e.g.,
LDsignal). - Reset/Clear: Forces all bits to
0.
Counters: Sequential Data Counting
A counter is a sequential circuit that counts pulses (clock cycles) and stores the count in binary. Counters are used in timers, frequency dividers, and address generators.
Types of Counters
- Asynchronous (Ripple) Counters: Each flip-flop triggers the next (propagation delay accumulates).
- Synchronous Counters: All flip-flops are clocked simultaneously (faster, no delay).
- Up Counters: Counts upward (0 → 1 → 2 → ...).
- Down Counters: Counts downward (N → N-1 → ...).
- Up-Down Counters: Can count up or down based on a control signal.
Key Parameters
- Modulus (N): Number of unique states (e.g., modulo-8 counter has 8 states).
- Counting Speed: Synchronous counters are faster due to parallel operation.
- Reset/Load: Additional control signals to preset the count.
Visualizing Registers and Counters
1. Parallel-In/Parallel-Out (PIPO) Register
flowchart LR
A["Clock"] --> B["D Flip-Flop 1"]
A --> C["D Flip-Flop 2"]
A --> D["D Flip-Flop 3"]
A --> E["D Flip-Flop 4"]
B --> F["Data Out 1"]
C --> G["Data Out 2"]
D --> H["Data Out 3"]
E --> I["Data Out 4"]
J["Data In 1"] --> B
K["Data In 2"] --> C
L["Data In 3"] --> D
M["Data In 4"] --> E
N["Load Enable"] -->|"LD"| B
N -->|"LD"| C
N -->|"LD"| D
N -->|"LD"| E2. 4-Bit Ripple Counter (Asynchronous)
flowchart LR
A["Clock"] --> B["T Flip-Flop 1 (LSB)"]
B --> C["T Flip-Flop 2"]
C --> D["T Flip-Flop 3"]
D --> E["T Flip-Flop 4 (MSB)"]
F["Reset"] --> B
F --> C
F --> D
F --> EHow it works:
- Each flip-flop toggles on the falling edge of the previous flip-flop’s output.
- Disadvantage: Slow due to propagation delay (e.g., 4-bit ripple counter takes ~4τ, where τ is flip-flop delay).
3. 4-Bit Synchronous Counter
Advantage: All flip-flops toggle simultaneously (faster, ~τ delay for 4-bit).
Worked Examples
Example 1: Design a 3-Bit Up Counter Using JK Flip-Flops
Objective: Create a counter that cycles from 000 to 111 and resets.
Step 1: Truth Table
| Q2 Q1 Q0 | Next State (Q2+ Q1+ Q0+) |
|---|---|
| 0 0 0 | 0 0 1 |
| 0 0 1 | 0 1 0 |
| 0 1 0 | 0 1 1 |
| 0 1 1 | 1 0 0 |
| 1 0 0 | 1 0 1 |
| 1 0 1 | 1 1 0 |
| 1 1 0 | 1 1 1 |
| 1 1 1 | 0 0 0 (reset) |
Step 2: Excitation Table for JK Flip-Flops
JK flip-flops toggle when J=K=1. Use the truth table to derive J and K inputs.
| Q2 Q1 Q0 | J2 K2 | J1 K1 | J0 K0 |
|---|---|---|---|
| 0 0 0 | 0 0 | 0 0 | 1 1 |
| 0 0 1 | 0 0 | 1 1 | 1 1 |
| 0 1 0 | 0 0 | 1 1 | 0 0 |
| 0 1 1 | 1 1 | 0 0 | 1 1 |
| 1 0 0 | 1 1 | 0 0 | 1 1 |
| 1 0 1 | 1 1 | 1 1 | 1 1 |
| 1 1 0 | 0 0 | 1 1 | 1 1 |
| 1 1 1 | 0 0 | 0 0 | 0 0 |
Step 3: K-Map Simplification for J2, K2, J1, K1, J0, K0
Simplify each input using K-Maps (example for J2):
J2: Q2Q1Q0 | 00 | 01 | 11 | 10
------------------------
0 0 | 0 | 1 | 1
1 1 | 1 | 0 | 0
Grouping: J2 = Q1Q0 (from the 1s in the K-Map).
Final Equations:
J2 = Q1Q0K2 = Q1Q0J1 = Q0K1 = Q0J0 = 1K0 = 1
Step 4: Circuit Diagram
Example 2: 4-Bit Shift Register (SIPO)
Objective: Design a shift register that loads data in parallel and shifts it out serially.
Circuit Diagram
Timing Diagram
_______ _______ _______
Clock | |__| |__| |__
|______| |______| |______|
| | | | | |
| | | | | |
Data In| D1 | D2 | D3 | D4 | |
----------------------------
| | | | |
| | | | |
Serial Out| | D1 | D2 | D3 | D4 |
Real-World Tie-In:
- Ncell Billing System: Uses counters to track call duration in seconds/minutes. A 10-bit counter can count up to 1024 seconds (~17 minutes), which is sufficient for prepaid call metering.
- Daraz Order Queue: Orders are processed in sequence (like a shift register). Each order’s status (e.g., "processing," "shipped") is stored in a register and shifted out as it moves through the fulfillment pipeline.
In the Real World
Nepali Banks (e.g., Nabil, Global IME): Use counters in ATMs to track transaction counts (e.g., daily withdrawal limits). A 16-bit counter can track up to 65,536 transactions, which is more than enough for a single ATM’s daily limit.
- How it works: Each transaction increments a counter. If the counter reaches the limit, the ATM blocks further transactions until the next day’s reset.
Pathao Ride Allocation: Uses shift registers to manage driver-rider matching. Riders’ requests are loaded into a shift register, and drivers’ availability is shifted out to match the next available rider. This ensures fair and sequential allocation.
- Example: If 5 riders request a ride in quick succession, their data is loaded into a 5-bit shift register. The system then shifts out driver IDs to match riders in order.
NTC Electricity Metering: Uses up-down counters to measure energy consumption. The counter increments with usage (up) and decrements during power outages or load shedding (down) to adjust billing accurately.
- Real Chip: The DS2423 (1-Wire digital thermometer/counter) is used in smart meters to count pulses from energy sensors.
YouTube Video Buffering: Uses ring counters (a type of counter) to manage video buffer states (e.g., "buffering," "playing," "paused"). Each state is a bit in the counter, and the counter cycles through states as the video plays.
- Example: A 3-bit ring counter cycles through
001(buffering),010(playing), and100(paused).
- Example: A 3-bit ring counter cycles through
Khalti Transaction IDs: Generates unique transaction IDs using binary counters. Each transaction increments a counter, and the binary output is converted to a hexadecimal or alphanumeric ID (e.g.,
TXN123456789).- Example: A 32-bit counter can generate ~4 billion unique IDs, sufficient for Khalti’s daily transactions.
Comparing Counters and Registers
| Feature | Registers | Counters |
|---|---|---|
| Purpose | Store data temporarily | Count pulses/sequences |
| Operation | Parallel or serial data transfer | Sequential state changes |
| Flip-Flop Type | D, JK, or T flip-flops | Often T or JK flip-flops |
| Clocking | Synchronous (all bits clocked together) | Synchronous or asynchronous |
| Applications | CPU registers, memory, ALUs | Timers, frequency dividers, address generators |
| Speed | Fast (parallel access) | Slower in ripple counters |
| Control Signals | Load, reset, clock | Clock, reset, load (optional) |
Advantages and Disadvantages
Registers
Advantages:
- Fast data access (parallel registers).
- Used in high-speed applications like CPUs.
- Can store multi-bit data simultaneously.
Disadvantages:
- Requires more hardware for larger bit sizes.
- Shift registers are slower for serial operations.
Counters
Advantages:
- Simple design for basic counting.
- Synchronous counters are fast and predictable.
- Can be cascaded for higher moduli (e.g., 8-bit counter from two 4-bit counters).
Disadvantages:
- Ripple counters have propagation delay.
- Complex control logic for up-down counters.
- Limited to counting sequences (not arbitrary data storage).
Practical Applications
Memory Addressing:
- Counters generate addresses for RAM/ROM access. For example, a 10-bit counter can address 1024 memory locations (2^10).
Traffic Light Control (Kathmandu Example):
- A modulo-6 counter controls the sequence of traffic lights (e.g., 3 states per direction × 2 directions). The counter cycles every 6 clock pulses to repeat the sequence.
- Real Implementation: The CD4026 decade counter (modulo-10) is used in traffic light systems worldwide.
Digital Clocks:
- A 60-second counter (modulo-60) and a 60-minute counter (modulo-60) work together to display time. The seconds counter rolls over every 60 counts, incrementing the minutes counter.
- Example: The 74LS90 (BCD counter) is used in digital clock circuits.
Data Communication (NTC/NTT Data):
- Serial data transmission uses shift registers to convert parallel data (from CPU) to serial form for transmission over a single wire (e.g., UART communication).
- Example: A PISO shift register sends 8-bit data bits one by one over an RS-232 line.
Game Consoles (e.g., Nintendo Switch):
- Sprite animation uses counters to cycle through frame data stored in registers. For example, a 4-bit counter cycles through 16 animation frames for a character.
Exam Tip
What to Expect in TU/PU Exams
Design Questions:
- You will be asked to design a counter or register from a given truth table or state diagram. Always start with the truth table and derive the excitation table.
- Example: "Design a 4-bit up-down counter using JK flip-flops."
Analysis Questions:
- Given a counter/register circuit, draw the timing diagram or list the sequence of states.
- Example: "For the given 3-bit ripple counter, draw the timing diagram for 10 clock pulses."
K-Map Simplification:
- Simplify the excitation equations for counters using K-Maps. Always show grouping in your answer.
- Example: "Simplify the J and K inputs for a 4-bit synchronous counter."
Real-World Applications:
- Explain how counters/registers are used in Nepali tech (e.g., Ncell billing, Daraz order processing). Be ready to tie theory to practice.
- Example: "How would you use a counter in an ATM to limit daily withdrawals?"
Short Answer:
- Define terms like ripple counter, synchronous counter, PISO register, and explain their differences.
- Example: "Differentiate between a ripple counter and a synchronous counter."
How to Score Full Marks
- Show all steps: Even if the question asks for a final answer, write intermediate steps (e.g., truth table, excitation table, K-Map grouping).
- Draw diagrams: Always include circuit diagrams and timing diagrams where required. Label all signals clearly.
- Use real examples: Relate your answers to Nepali tech (e.g., NTC meters, Khalti transactions) to stand out.
- Verify your design: For counters, ensure the sequence loops correctly (e.g., modulo-N counter should reset after N states).
- Label axes: In timing diagrams, clearly label clock, data inputs, and outputs.
Common Mistakes to Avoid
- Ignoring the reset condition: Always include a reset signal in your counter/register design unless specified otherwise.
- Incorrect flip-flop selection: Use JK or T flip-flops for counters (they toggle easily) and D flip-flops for registers.
- Forgetting propagation delay: In ripple counters, mention the delay accumulation in your explanation.
- K-Map errors: Double-check your grouping. Overlapping groups or missing terms will lose marks.
- Unlabeled diagrams: Diagrams without labels (e.g., clock, data, Q outputs) will not be graded.
Based on the TU BIM syllabus for Digital Logic (IT233), unit 4.
Discussion
Loading…