RTL Studio Open IDE

Control & Timers

Gated Frequency Counter 8-Bit — L2 Upgrade

An 8-bit gated frequency counter supporting binary and Gray code parallel loading with IRQ generation on overflow.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Gated Frequency Counter 8-Bit — L2 Upgrade is a Verilog reference block in the Control & Timers catalog. FSMs, timers, watchdogs, and control/state sequencing blocks. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements an 8-bit gated frequency counter with binary or Gray code loading capabilities.

It supports asynchronous reset and generates an interrupt request (IRQ) upon reaching the maximum count value (0xFF).

The module is suitable for L2 difficulty level design projects and includes comprehensive verification via a testbench.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Gated Frequency Counter 8-Bit — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: An 8-bit gated frequency counter supporting binary and Gray code parallel loading with IRQ generation on overflow.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. 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 Counting: Counts from 0x00 to 0xFF.
  • Gated Operation: Counts only when the gate signal is active.
  • Parallel Load: Supports loading a specific value via load_en.
  • Gray Code Support: Can interpret load_data as Gray code or binary via gray_load.
  • Interrupt Request: Asserts irq high when the counter reaches 0xFF.
  • Asynchronous Reset: Resets counter to 0x00 asynchronously.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
gateInput1Count enable signal
load_enInput1Parallel load enable signal
load_dataInput8Data to load into the counter
gray_loadInput1Selects Gray code interpretation for load_data
count_outOutput8Current counter value
irqOutput1Interrupt request when count reaches 0xFF

Verification

The testbench validates reset behavior, counting, stopping, binary loading, Gray code loading, and IRQ generation. All six test cases passed successfully during simulation.

Test CaseDescriptionResult
TC1Reset initialization to 0x00PASS
TC2Increment count with gate activePASS
TC3Stop counting when gate is inactivePASS
TC4Load binary data 0x55PASS
TC5Load Gray code 0x0A (interpreted as 0x0C)PASS
TC6IRQ assertion at count 0xFFPASS

To verify the design:

  1. Run the simulation script provided in the sim/ directory.
  2. Check the Log panel for INFO: PASS.
  3. Use the RtlStudio Waveform tab to inspect simulation results via sim/dump.vcd.

More in Control & Timers

All Control & Timers blocks