1. Home
  2. Projects
  3. Blog
  4. Music
  5. Photos
  6. Contact
  1. Internal

wb_gpio - A Wishbone GPIO Engine for FPGAs

This is the project homepage for wb_gpio, a GPIO engine for the Wishbone bus, written in VHDL.

Last updated: $Date: 2013/01/05 20:45:48 $.


The wb_gpio module is a general-purpose I/O driver which can be controlled from the Wishbone bus interface. It allows the user to configure and control the I/O pins individually. Pins can be configured as inputs or outputs. The module does not support generating interrupts, e.g. when an input changes.


Using the wb_switch component in your VHDL design is as easy as declaring and instantiating any other component. Below is the VHDL entity declaration of the component.

Your browser apparently cannot display embedded frames. Try viewing the example directly here.

Because pins configured as inputs cause the output drivers to assume a "hi-Z" state, the module's gp_io signals should be routed to actual I/O pins on the FPGA. If you fail to do that, the synthesis tool will route the signals to IOBs which is likely to pessimize your design.

The design is customizable through generics, which are described in the following table.

Generic Description
dat_sz Width of Wishbone data bus. Also number of general purpose I/O pins.

The module supports Wishbone classic read and write cycles. It will generate a ack response within one clock cycle. The ack output is asserted as long as the module's stb input is active. There are no errors or retry conditions generated. Because the module generates a response within one cycle, it does never drive the stall output. Nevertheless, it should support Wishbone classic pipelined read and write cycles, too, but that hasn't been tested so far.


The module exposes four registers which are described in the table below.

Offset Name Description
0x00 Output Writing to this register causes enabled output pins to assume the written value. In other words, writing to this register adjusts all output pins. Reading from this register will return the current value of the general purpose I/O pins, independent of whether they are configured as outputs or inputs.
0x01 Enable Setting a bit in this register turns the general purpose I/O pin into an output. Clearing a bit in this register turns the general purpose I/O pin into an input. This will cause the output driver to assume a "hi-Z" state. Reading the register will return the current settings.
0x02 Mask Setting a bit in this register allows the corresponding output to be changed by writing to the "update" register. Reading this register will return the current settings.
0x03 Update Writing to this register updates those output pins whose corresponding bits in the "mask" register are set. In other words, by writing to the "mask" and then to the "update" register, "update" (or sometimes also "write under mask") semantics can be implemented, where only a single output pin is changed, while others are left untouched.


Below are the links to the VHDL file(s).


Here are a few links related to this project.


Contact the author Philip Schulz by Email.