Interface Protocols
1-Bit GPIO Pin Driver (Combinational) — L1 Upgrade — L2 Upgrade
A 1-bit GPIO pin driver that detects edge transitions and generates a sticky interrupt flag.
About this block
Simulate it in the Verilog IDE
1-Bit GPIO Pin Driver (Combinational) — L1 Upgrade — L2 Upgrade 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 core implements a robust 1-bit GPIO pin driver with sticky interrupt detection. It monitors the gpio_in signal for both rising and falling edges, generating an irq_sticky flag that remains asserted until explicitly cleared by the irq_clear signal. This ensures that transient events are never missed, making it ideal for embedded systems requiring reliable event logging or interrupt handling.
The design utilizes synchronous logic for edge detection and interrupt latching, ensuring deterministic behavior and compatibility with standard synchronous design flows.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 1-Bit GPIO Pin Driver (Combinational) — L1 Upgrade — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: A 1-bit GPIO pin driver that detects edge transitions and generates a sticky interrupt flag.
- 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
- Edge Detection: Detects both rising and falling edges on the
gpio_insignal. - Sticky Interrupt: The
irq_stickyflag remains asserted until cleared, ensuring no interrupt is missed. - Asynchronous Clear: Supports an active-high
irq_clearsignal to reset the interrupt flag. - Synchronous Reset: Ensures deterministic initialization via an active-low
rst_nsignal. - Efficient Logic: Uses minimal resources with a single delay register for edge comparison.
Interface
The module uses the following ports:
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | System clock input |
rst_n | Input | 1 | Active-low asynchronous reset |
gpio_in | Input | 1 | GPIO pin input signal |
irq_clear | Input | 1 | Active-high signal to clear sticky interrupt |
irq_sticky | Output | 1 | Sticky interrupt flag (high when edge detected) |
Architecture
The design consists of two main components:
- Edge Detector: A flip-flop (
gpio_dly) delays thegpio_insignal by one clock cycle. A comparator checks for differences between the currentgpio_inand the delayed value. - Sticky Latch: A second flip-flop latches the
irq_stickyflag. It is set when a transition is detected and cleared whenirq_clearis asserted orrst_nis active.
Verification
The testbench verifies the following scenarios:
| Test Case | Description | Expected Result |
|---|---|---|
| TC1 | Reset behavior | irq_sticky is 0 |
| TC2 | No change, no IRQ | irq_sticky remains 0 |
| TC3 | Rising edge detection | irq_sticky becomes 1 |
| TC4 | Falling edge detection | irq_sticky remains 1 |
| TC5 | Clear IRQ | irq_sticky becomes 0 |
| TC6 | Re-trigger after clear | irq_sticky becomes 1 |
Run the simulation to verify all test cases pass. The simulation log should confirm INFO: PASS for all tests.
### Expected Results
After Run Simulation, the Log panel should show:
TC1 PASS Reset checkTC2 PASS No change checkTC3 PASS Rising edge checkTC4 PASS Falling edge sticky checkTC5 PASS Clear checkTC6 PASS Re-trigger checkSimulation ends with INFO: PASS.
More in Interface Protocols
- 32-Bit MMIO GPIO (DI Read, Byte-Strobed DO) — L2 Upgrade
- 8-Bit GPIO Output Register
- 8-Bit GPIO Set/Clear Register
- 8-Bit GPIO with Direction and Rising-Edge IRQ
- I2C Arbitration Lost Detector
- I2C Bus Idle Timeout
- I2C Clock Stretch Detector
- I2C NACK Sticky Flag Detector
- I2C Start/Stop Detector
- JTAG TAP Controller
- Lightweight I²C Master Controller (Standard Mode)
- Lightweight I²C Slave Controller (Standard Mode)
- SPI Master Lite
- SPI Mode-0 Host (8-Bit Frames)
- SPI Mode-3 Slave (CPOL=1, CPHA=1) 8-Bit
- SPI Slave Controller (Mode 0)