Interface Protocols
32-Bit MMIO GPIO (DI Read, Byte-Strobed DO) — L2 Upgrade
32-Bit MMIO GPIO with byte-strobed data output and sticky pin-change interrupt.
About this block
Simulate it in the Verilog IDE
32-Bit MMIO GPIO (DI Read, Byte-Strobed DO) — 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 implements a 32-bit General Purpose Input/Output (GPIO) interface with Memory-Mapped I/O (MMIO). It supports reading external pin states and writing to internal data registers with byte-level granularity.
A key feature is a sticky interrupt request (IRQ) flag that asserts whenever external input pins differ from the stored data register value. This flag must be explicitly cleared via a control register write, ensuring that pin state changes are not missed by the processor.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 32-Bit MMIO GPIO (DI Read, Byte-Strobed DO) — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: 32-Bit MMIO GPIO with byte-strobed data output and sticky pin-change interrupt.
- 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
- 32-bit Data Bus: Supports full 32-bit data input and output operations.
- Byte-Level Write Control: Uses a 4-bit
byte_strobemask to selectively update individual 8-bit segments of the internal data register. - Sticky Interrupt: Asserts
irqhigh whengpio_indiffers fromgpio_data. Remains high until cleared by writing to the control register. - Asynchronous Reset: Initializes all internal registers to zero on
rst_nassertion. - L2 Integration Ready: Designed for seamless integration into L2 system architectures.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock signal |
rst_n | Input | 1 | Active-low asynchronous reset |
addr | Input | 5 | Memory-mapped address bus |
wr_en | Input | 1 | Write enable signal |
data_in | Input | 32 | Data input from bus |
byte_strobe | Input | 4 | Byte write enable mask [3:0] |
gpio_in | Input | 32 | External GPIO pin inputs |
data_out | Output | 32 | Internal data register output |
irq | Output | 1 | Sticky interrupt request flag |
Architecture
The module consists of an internal 32-bit data register (gpio_data) and a 1-bit sticky flag (irq_sticky).
### Address Map
| Address | Register | Description |
|---|---|---|
5'h00 | Data Register | Read/Write. Updates gpio_data based on byte_strobe. |
5'h1F | Control Register | Write-Only. Clears irq_sticky to 0. |
### Logic Flow
- Data Update: On
wr_enandaddr == 5'h00,gpio_datais updated byte-by-byte based onbyte_strobe. - IRQ Clear: On
wr_enandaddr == 5'h1F,irq_stickyis cleared to 0. - IRQ Assert: Combinational logic compares
gpio_inwithgpio_data. If they differ,irq_stickyis set to 1.
Integration
- Import: Add the RTL file
rtl/gpio_mmio_32bit_byte_strobed_pin_change_sticky.vto your project. - Connect: Map the ports according to the table above.
- Constraints: Ensure
clkmeets timing requirements for your target frequency.rst_nis asynchronous.
### Instantiation Example
Verification
The provided testbench validates:
- Reset behavior (registers zeroed).
- Byte-strobed writes to the data register.
- IRQ triggering on pin state changes.
- IRQ clearing via control register.
### Running Simulation
### Expected Log Output
TC1 PASS reset checkTC1 PASS irq zero after resetTC2 PASS byte_strobe[0] write(and 1-3)TC3 PASS irq set on gpio_in changeTC3 PASS irq stickyTC3 PASS irq clearedTC4 PASS data read backSimulation ends with INFO: PASS.
More in Interface Protocols
- 1-Bit GPIO Pin Driver (Combinational) — L1 Upgrade — 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)