Counters
4-Bit Counter with Wrap Strobe
A 4-bit free-running counter with synchronous enable, load, and a wrap strobe output that pulses when the count rolls over from 15 to 0.
About this block
Simulate it in the Verilog IDE
4-Bit Counter with Wrap Strobe is a Verilog reference block in the Counters catalog. Up/down, modulo, and loadable binary counters with enable logic. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
This IP implements a 4-bit free-running counter with enable and synchronous load capabilities.
It generates a single-cycle pulse (wrap_stb) when the counter wraps from 15 to 0.
The module is suitable for basic timing, event counting, or sequence generation tasks.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 4-Bit Counter with Wrap Strobe.
- Read the Verilog module in the editor. The catalog line for this block: A 4-bit free-running counter with synchronous enable, load, and a wrap strobe output that pulses when the count rolls over from 15 to 0.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.
RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.
Features
- 4-bit counting range: Counts from 0 to 15.
- Synchronous Enable: Counting occurs only when
enis high. - Synchronous Load: Arbitrary initial values can be loaded via
load_valwhenload_enis high. - Wrap Strobe: Active-high pulse generated when the counter reaches 15 (gated by
en). - Asynchronous Reset: Active-low
rst_nresets the counter to 0 immediately.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Asynchronous active-low reset |
en | Input | 1 | Synchronous enable |
load_val | Input | 4 | Load data input |
load_en | Input | 1 | Synchronous load enable |
dout | Output | 4 | Counter output |
wrap_stb | Output | 1 | Wrap strobe pulse |
Verification
The design includes a comprehensive testbench (tb_wrap_strobe_4bit.v) that verifies all functional modes. Simulation was performed using Icarus Verilog. All five test cases passed successfully.
| Test Case | Description | Result |
|---|---|---|
| TC1 | Reset to 0 | PASS |
| TC2 | Count 0->15->0 with enable | PASS |
| TC3 | Wrap strobe high at 15 | PASS |
| TC4 | Value unchanged while en=0 | PASS |
| TC5 | Synchronous load works | PASS |
Integration
To integrate this IP into your project:
- Copy
rtl/wrap_strobe_4bit.vto your RTL directory. - Instantiate the module in your top-level design.
- Ensure
clkis driven by your system clock. - Handle
rst_naccording to your system reset strategy.
More in Counters
- 16-Bit Cycle Counter with Prescaler — L1 Upgrade — L2 Upgrade
- 4-Bit Counter Match Pulse
- 4-Bit Down Counter
- 4-Digit BCD Up/Down Counter with Carry/Borrow
- 8-Bit Binary Up Counter — L1 Upgrade — L2 Upgrade
- 8-Bit Johnson Counter (Twisted Ring) — L1 Upgrade — L2 Upgrade
- 8-Bit Leading Zero Counter — L1 Upgrade — L2 Upgrade
- 8-Bit Ring Counter
- 8-Bit Up/Down Counter
- Bidirectional Counter 4-Bit — L1 Upgrade — L2 Upgrade
- Decade BCD Counter 1-Digit — L1 Upgrade
- Dual Compare-Match Counter 8 — L1 Upgrade — L2 Upgrade
- Event Counter with Capture
- Gray-Code Counter 8-Bit — L2 Upgrade
- Loadable 4-Bit Up Counter
- Loadable Down Counter 8-Bit — L1 Upgrade — L2 Upgrade