Template: 4-Bit Binary Counter
Template: Template: 4-Bit Binary Counter - Interactive 4-bit binary counter with visual output lights. Learn binary counting sequences and clock-driven operation. Count from 0 to 15 in binary.
Lo que aprenderás
- Build a 4-bit counter that increments by 1 each clock edge.
- Cycle through 16 states from 0000 to 1111 then wrap.
- Distinguish synchronous (all bits clock together) from asynchronous (ripple) counters.
- Recognize that bit i toggles when all lower bits are 1.
- Apply 4-bit counters to timers, address generators, and frequency dividers.
Cómo funciona
A 4-bit binary counter counts clock pulses through values 0 to 15, incrementing by 1 each clock edge, then wrapping back to 0. The four flip-flops together hold the count; each new clock edge drives an adder (or toggle logic) that produces count+1.
In the synchronous form, all four flip-flops share the same clock — every bit updates simultaneously. The next-state logic for each bit i is: bit i toggles when all lower bits are 1 (i.e., AND of bits 0..i-1). This is the binary increment pattern.
In the asynchronous (ripple) form, each bit's toggle is clocked by the bit below it — simpler wiring but staggered timing.
The counter sequence: 0000 → 0001 → 0010 → ... → 1110 → 1111 → 0000 (wrap). One full cycle of bit 3 takes 16 clock pulses.
Counters are foundational to digital design — every timer, every program counter, every memory address generator is essentially a counter. Modern CPUs include dedicated counter cells in their standard libraries, often with parallel-load and reset for flexible initialization.
Pruébalo paso a paso
Configura las entradas en la simulación de arriba, lee qué debería suceder y verifícalo.
- 1Clock = runningEsperado:
Output cycles 0, 1, 2, ..., 15, 0, 1, ...Lo que verás: Watch the binary lights and digit display. Each clock edge increments by 1; after 1111 (15) it wraps to 0000. - 2Clock = stopped at 0101Esperado:
Counter holds at 5Lo que verás: Stop the clock — counter freezes at whatever value it had. Sequential logic needs a clock to evolve. - 3Clock = after 8 edgesEsperado:
Bit 3 first lights up at the 8th edgeLo que verás: Bit 3 (the MSB) only goes high when the count reaches 8 — the upper-half threshold. - 4Clock = after 16 edgesEsperado:
Counter wraps to 0000Lo que verás: 16 edges complete one full cycle. The counter rolls over from 1111 to 0000 with no special intervention.
Componentes utilizados
Aplicaciones en el mundo real
CPU program counter. The PC is essentially a counter that increments by the instruction width on each fetch.
Timer/counter peripherals. Microcontrollers have multiple hardware counters for precise timing of events, PWM generation, and pulse measurement.
Address generation in memory tests. ATE (test equipment) walks through memory addresses using a counter to write/read each cell during march tests.
Frequency divider chains. Cascading counters divide a master oscillator down to lower-frequency clocks for various subsystems.
Sequential state encoding. State machines with linearly progressing states often use a counter-based state register for simplicity.