RTL Studio Open IDE

Control & Timers

Period-Based Frequency Meter 8-Bit — L2 Upgrade

An 8-bit period-based frequency meter that captures clock cycles between rising edges of an input signal. It features a sticky interrupt flag and a synchronous clear mechanism. The counter saturates at 255 to handle long periods.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Period-Based Frequency Meter 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 core implements a period-based frequency meter using an 8-bit counter.

It measures the number of clock cycles between rising edges of an input signal (sig_in).

The design features a sticky interrupt flag (irq_sticky) to notify the processor of new period captures and a synchronous clear signal for system synchronization.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Period-Based Frequency Meter 8-Bit — L2 Upgrade.
  2. Read the Verilog module in the editor. The catalog line for this block: An 8-bit period-based frequency meter that captures clock cycles between rising edges of an input signal. It features a sticky interrupt flag and a synchronous clear mechanism. The counter saturates at 255 to handle long periods.
  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 Resolution: Measures periods from 1 to 255 clock cycles.
  • Rising-Edge Detection: Automatically detects transitions on the input signal.
  • Sticky Interrupt: Asserts irq_sticky on every period capture; requires software clear.
  • Synchronous Clear: Resets internal state and outputs without affecting the clock domain.
  • Overflow Protection: Counter saturates at 255 to handle long periods gracefully.

Ports

Port NameDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low asynchronous reset
clearInput1Synchronous clear signal
sig_inInput1Input signal to measure
period_countOutput8Captured period count (cycles)
irq_stickyOutput1Sticky interrupt flag (set on capture, cleared by clear)

Verification

The design has been verified using Icarus Verilog. The testbench covers the following scenarios:

Test CaseDescriptionExpected Result
TC1Reset TestAll outputs zero
TC2Basic Period Captureperiod_count equals cycle count
TC3IRQ Clearirq_sticky and period_count clear
TC4Second Period CaptureNew period captured correctly
TC5Saturation Testperiod_count saturates at 255
TC6Reset During OperationState resets immediately

### Running Simulations

To reproduce the results:

  1. Ensure Icarus Verilog is installed.
  2. Run the simulation script:
  3. Check the log output for:

- TC1 PASS through TC6 PASS - INFO: PASS

More in Control & Timers

All Control & Timers blocks