Counters
8-Bit Ring Counter
An 8-bit ring counter with synchronous load and circular right shift functionality.
About this block
Simulate it in the Verilog IDE
8-Bit Ring Counter is a Verilog reference block in the Counters catalog. Up/down, modulo, and loadable binary counters with enable logic. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This IP implements an 8-bit ring counter with synchronous load and reset capabilities. It shifts data right in a circular fashion when the load enable is disabled, feeding the least significant bit (LSB) back into the most significant bit (MSB). A synchronous active-low reset initializes the counter to a predefined seed value (8'b00000001). This IP is suitable for sequence detection, pattern generation, and control applications requiring deterministic state progression.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Ring Counter.
- Read the Verilog module in the editor. The catalog line for this block: An 8-bit ring counter with synchronous load and circular right shift functionality.
- 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
- 8-bit Width: Supports 8-bit data paths.
- Synchronous Load: Allows external data injection via
data_inwhenload_enis asserted. - Circular Shift: Automatically shifts right, wrapping the LSB to the MSB.
- Synchronous Reset: Resets to a predefined seed (
00000001) on the rising clock edge. - Deterministic State: Ensures predictable behavior for control logic applications.
Architecture
The core component is an 8-bit register. The feedback path connects the LSB (state[0]) to the MSB (state[7]) during shift operations. The control logic prioritizes reset, then load, then shift.
### Data Flow
- Reset: If
rst_nis low,statebecomes8'b00000001. - Load: If
rst_nis high andload_enis high,statebecomesdata_in. - Shift: If neither reset nor load is active,
stateshifts right:{state[0], state[7:1]}.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input signal |
rst_n | Input | 1 | Active-low synchronous reset |
load_en | Input | 1 | Load enable signal |
data_in | Input | 8 | Data input for loading |
q | Output | 8 | Counter output state |
Verification
The provided testbench (tb_ring_counter_8b) validates the following scenarios:
- TC1: Reset value check (verifies initial state is
00000001). - TC2: Load functionality check (verifies
data_inis correctly loaded). - TC3: Circulation sequence check (verifies bit rotation).
- TC4: Reset during operation check (verifies reset overrides shift/load).
- TC5: Load different pattern check (verifies arbitrary pattern loading).
### Running the Testbench
- Ensure you have a Verilog simulator installed (e.g., Icarus Verilog, ModelSim).
- Navigate to the simulation directory.
- Run the simulation:
- Check the console output for PASS/FAIL results and generate VCD for waveform analysis.
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 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