A simple parameterized GPIO pad configuration wrapper for ChipFoundry Openframe projects.
Set the mode once, forget about pad details.
// GPIO as OUTPUT
CF_gpio_config #(.MODE(3'd4)) gpio_out_inst (
.io_out(my_data_out),
.io_in(),
.io_oeb(),
.gpio_zero(gpio_loopback_zero[5]),
.gpio_one(gpio_loopback_one[5]),
.gpio_in(gpio_in[5]),
.gpio_dm({gpio_dm2[5], gpio_dm1[5], gpio_dm0[5]}),
.gpio_inp_dis(gpio_inp_dis[5]),
.gpio_oeb_out(gpio_oeb[5]),
.gpio_out_val(gpio_out[5]),
.gpio_analog_en(gpio_analog_en[5]),
.gpio_analog_sel(gpio_analog_sel[5]),
.gpio_analog_pol(gpio_analog_pol[5]),
.gpio_ib_mode_sel(gpio_ib_mode_sel[5]),
.gpio_vtrip_sel(gpio_vtrip_sel[5]),
.gpio_slow_sel(gpio_slow_sel[5]),
.gpio_holdover(gpio_holdover[5])
);
// GPIO as INPUT with pull-up
CF_gpio_config #(.MODE(3'd3)) gpio_in_inst (
.io_out(),
.io_in(my_data_in),
.io_oeb(),
.gpio_zero(gpio_loopback_zero[6]),
.gpio_one(gpio_loopback_one[6]),
.gpio_in(gpio_in[6]),
// ... connect config outputs (including gpio_out_val for pull-up)
);| MODE | Name | gpio_dm | gpio_oeb_out | gpio_out_val | Description |
|---|---|---|---|---|---|
| 0 | ANALOG | 000 | 1 | 0 | Analog mode - disables input and output buffers |
| 1 | INPUT | 001 | 1 | 0 | Digital input, no pull resistor (floating) |
| 2 | INPUT_PD | 111 | 0 | 0 | Digital input with pull-down (~5kΩ) |
| 3 | INPUT_PU | 111 | 0 | 1 | Digital input with pull-up (~5kΩ) |
| 4 | OUTPUT | 110 | 0 | io_out | Digital output, push-pull driver |
| 5 | BIDIR | 110 | io_oeb | io_out | Bidirectional - direction controlled by io_oeb |
Note: The gpio_out_val output handles both user data and pull-mode values automatically:
- For OUTPUT/BIDIR modes: passes through your
io_outsignal - For INPUT_PD: drives 0 to activate weak pull-down
- For INPUT_PU: drives 1 to activate weak pull-up
Analog Note:
- For ANALOG:
CF_gpio_configdoes not connect to the actual analog signal - it just configures the gpio. The direct pad connection isanalog_io[N]oranalog_noesd_io[N]of theopenframe_project_wrapper.
3.3V Note:
- Any modes that drive
io_inat 1.8V also have a 3.3V version of the signal available inopenframe_project_wrapperasgpio_in_h[N].
| Signal | Direction | Description |
|---|---|---|
io_out |
input | Data to drive the pad (OUTPUT/BIDIR modes) |
io_in |
output | Data from the pad |
io_oeb |
input | Output enable bar (BIDIR: 0=drive, 1=hi-z) |
Connect these to your openframe_project_wrapper signals:
| Signal | Connect to |
|---|---|
gpio_zero |
gpio_loopback_zero[n] |
gpio_one |
gpio_loopback_one[n] |
gpio_in |
gpio_in[n] |
gpio_dm[2:0] |
{gpio_dm2[n], gpio_dm1[n], gpio_dm0[n]} |
gpio_inp_dis |
gpio_inp_dis[n] |
gpio_oeb_out |
gpio_oeb[n] |
gpio_out_val |
gpio_out[n] |
gpio_analog_en |
gpio_analog_en[n] |
gpio_analog_sel |
gpio_analog_sel[n] |
gpio_analog_pol |
gpio_analog_pol[n] |
gpio_ib_mode_sel |
gpio_ib_mode_sel[n] |
gpio_vtrip_sel |
gpio_vtrip_sel[n] |
gpio_slow_sel |
gpio_slow_sel[n] |
gpio_holdover |
gpio_holdover[n] |
CF_gpio_config/
rtl/
CF_gpio_config.v # Main wrapper module
docs/
USAGE.md # Detailed usage guide
SIGNAL_MAPPING.md # Mode-to-signal reference
README.md # This file
LICENSE # Apache 2.0
Apache 2.0 - See LICENSE