RTL Studio Open IDE

Interface Protocols

Sticky Button Set/Clear Flag

A registered sticky flag module with set and clear inputs where clear takes priority.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Sticky Button Set/Clear Flag is a Verilog reference block in the Interface Protocols catalog. UART, SPI, I2C, and other serial or peripheral protocol interfaces. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP implements a registered sticky flag with set and clear inputs.

The flag is set when the set signal is asserted.

The flag is cleared when the clr signal is asserted.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Sticky Button Set/Clear Flag.
  2. Read the Verilog module in the editor. The catalog line for this block: A registered sticky flag module with set and clear inputs where clear takes priority.
  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

  • Registered Output: Synchronous state update on clock edge.
  • Priority Logic: clr overrides set if both are active.
  • Active-Low Reset: Synchronous reset to 0 on rst_n assertion.
  • Simple Interface: Minimal port count for easy integration.

Interface

The module exposes the following ports:

PortDirectionWidthDescription
clkInput1Clock input
rst_nInput1Active-low reset
setInput1Set flag command
clrInput1Clear flag command
flagOutput1Sticky flag status

Architecture

The design uses a single D-type flip-flop to store the flag state. The logic prioritizes the clear signal over the set signal.

Verification

The testbench verifies the following scenarios:

Test CaseDescriptionExpected Result
TC1Reset clears flagflag is 0
TC2Set sets flagflag is 1
TC3Sticky holdflag remains 1
TC4Clear clears flagflag is 0
TC5Set and Clear activeclr wins, flag is 0

All tests passed successfully.

More in Interface Protocols

All Interface Protocols blocks