Counters
Decade BCD Counter 1-Digit — L1 Upgrade
A 1-digit Decade BCD counter with synchronous load, enable, and asynchronous reset.
About this block
Simulate it in the Verilog IDE
Decade BCD Counter 1-Digit — L1 Upgrade 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 1-digit Decade BCD (Binary-Coded Decimal) counter.
It counts from 0 to 9 and wraps around to 0 on the next clock cycle.
The design supports asynchronous active-low reset, synchronous load of a 4-bit input value, and synchronous enable to hold the current count.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Decade BCD Counter 1-Digit — L1 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: A 1-digit Decade BCD counter with synchronous load, enable, and asynchronous reset.
- 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
- Counts 0-9 in BCD format.
- Synchronous load input for presetting the counter.
- Synchronous enable input to pause counting.
- Asynchronous active-low reset to clear the output.
- Simple 4-bit data path.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Asynchronous reset, active low |
load | Input | 1 | Synchronous load enable |
enable | Input | 1 | Synchronous count enable |
d_in | Input | 4 | Data input for load operation |
q_out | Output | 4 | Counter output |
Verification
The testbench verifies the following scenarios:
| Test Case | Description | Expected Result |
|---|---|---|
| TC1 | Reset | q_out becomes 0 |
| TC2 | Load | q_out takes d_in value |
| TC3 | Count Up | q_out increments to 9 |
| TC4 | Wrap | q_out wraps from 9 to 0 |
| TC5 | Disable | q_out holds value when enable is low |
| TC6 | Load Different | q_out updates with new d_in |
All test cases passed successfully. After Run Simulation, the Log panel should show:
TC1 PASS ResetTC2 PASS LoadTC3 PASS Count to 9TC4 PASS WrapTC5 PASS DisableTC6 PASS Load differentSimulation ends with INFO: PASS.
More in Counters
- 16-Bit Cycle Counter with Prescaler — L1 Upgrade — L2 Upgrade
- 4-Bit Counter Match Pulse
- 4-Bit Counter with Wrap Strobe
- 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
- 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