Gpio Spec
Gpio Spec
Gpio Spec
OpenCores
GPIO IP Core
12/25/01
http://www.opencores.org/
Rev 1.0
2 of 22
OpenCores
GPIO IP Core
12/25/01
Revision History
Rev. 0.1 0.2 0.3 1.0 Date Author 4/2/01 Damjan Lampret 20/2/01 Damjan Lampret 29/10/01 Damjan Lampret 25/12/01 Damjan Lampret Description First Draft Compliance with WISHBONE Rev.B1 Updated names of ports and RGPIO_CTRL. Added additional parameters to Appendix A. Added RGPIO_INTS and renamed RGPIO_CTRL[INT] into RGPIO_CTRL[INTS]. Updated Appendix Core Configuration.
http://www.opencores.org/
Rev 1.0
3 of 22
OpenCores
GPIO IP Core
12/25/01
Table Of Contents
Introduction ....................................................................................................................... 7 Features ......................................................................................................................... 7 Architecture....................................................................................................................... 8 Clocks............................................................................................................................ 8 WISHBONE Interface................................................................................................... 9 GPIO Registers.............................................................................................................. 9 Auxiliary Inputs............................................................................................................. 9 Interface to External I/O Cells and Pads ....................................................................... 9 Operation......................................................................................................................... 11 Hardware Reset ........................................................................................................... 12 General-Purpose I/O as Polled Input........................................................................... 12 General-Purpose I/O as Input in Interrupt Mode......................................................... 12 General-Purpose I/O as Output ................................................................................... 13 General-Purpose I/O as Bi-Directional I/O ................................................................. 13 General-Purpose I/O driven by Auxiliary Input .......................................................... 13 Registers .......................................................................................................................... 14 Registers list ................................................................................................................ 14 Register RGPIO_IN description.................................................................................. 14 Register RGPIO_OUT description.............................................................................. 14 Register RGPIO_OE description................................................................................. 15 Register RGPIO_INTE description............................................................................. 15 Register RGPIO_PTRIG description .......................................................................... 15 Register RGPIO_AUX description ............................................................................. 16 Register RGPIO_CTRL description............................................................................ 16 Register RGPIO_INTS description ............................................................................. 16 IO ports............................................................................................................................ 18 WISHBONE host interface ......................................................................................... 18 Auxiliary inputs........................................................................................................... 19 Interface to external I/O cells and pads ....................................................................... 19 Core HW Configuration .................................................................................................. 20
http://www.opencores.org/
Rev 1.0
4 of 22
OpenCores
GPIO IP Core
12/25/01
Table Of Figures
Figure 1. Core Architecture............................................................................................... 8 Figure 2. Block Diagram of GPIO Logic ........................................................................ 11 Figure 3. Core Interfaces ................................................................................................. 18
http://www.opencores.org/
Rev 1.0
5 of 22
OpenCores
GPIO IP Core
12/25/01
Table Of Tables
Table 1. List of All Software Accessible Registers......................................................... 14 Table 2. Input Register .................................................................................................... 14 Table 3. Output Register ................................................................................................. 15 Table 4. Output Enable Register ..................................................................................... 15 Table 5. Interrupt Enable Register................................................................................... 15 Table 6. Trigger Register................................................................................................. 15 Table 7. Auxiliary Inputs Register .................................................................................. 16 Table 8. Control Register ................................................................................................ 16 Table 9. Interrupt Status Register.................................................................................... 17 Table 10. WISHBONE Interface Signals....................................................................... 19 Table 11. Auxiliary input signals .................................................................................... 19 Table 12. External interface ............................................................................................ 19
http://www.opencores.org/
Rev 1.0
6 of 22
OpenCores
GPIO IP Core
12/25/01
1
Introduction
The GPIO IP core is user-programmable general-purpose I/O controller. Its use is to implement functions that are not implemented with the dedicated controllers in a system and require simple input and/or output software controlled signals.
Features
The following lists the main features of GPIO IP core: Number of general-purpose I/O signals is user selectable and can be in range from 1 to 32. For more I/Os several GPIO cores can be used in parallel. All general-purpose I/O signals can be bi-directional (external bi-directional I/O cells are required in this case). All general-purpose I/O signals can be three-stated or open-drain enabled (external three-state or open-drain I/O cells are required in this case). General-purpose I/O signals programmed as inputs can cause an interrupt request to the CPU. General-purpose I/O signals programmed as inputs can be registered at raising edge of system clock or at user programmed edge of external clock. All general-purpose I/O signals are programmed as inputs at hardware reset. Auxiliary inputs to GPIO core to bypass outputs from RGPIO_OUT register. Alternative input reference clock signal from external interface. Extremely configurable (implementation of registers, external clock inverted versus negedge flip-flops etc.) WISHBONE SoC Interconnection Rev. B compliant interface
http://www.opencores.org/
Rev 1.0
7 of 22
OpenCores
GPIO IP Core
12/25/01
2
Architecture
Figure 1 below shows general architecture of GPIO IP core. It consists of four main building blocks: WISHBONE host interface GPIO registers Auxiliary inputs Interface to external I/O cells and pads
GPIO Registers
Clocks
http://www.opencores.org/
Rev 1.0
8 of 22
OpenCores
GPIO IP Core
12/25/01
The GPIO core has two clock domains. All registers except RGPIO_IN are in system clock domain. RGPIO_IN register can be clocked by system clock or by external clock reference.
WISHBONE Interface
WISHBONE interface connects GPIO core to the host system. It is WISHBONE SoC Interconnection specification Rev. B compliant. The implementation implements a 32-bit bus width and does not support other bus widths.
GPIO Registers
The GPIO IP Core has several software accessible registers. Most registers have the same width as number of general-purpose I/O signals and they can be from 1 32 bits. The host through these registers programs type and operation of each general-purpose I/O signal.
Auxiliary Inputs
The auxiliary inputs can bypass RGPIO_OUT outputs based on programming of RPGIO_AUX register. Auxiliary inputs are used to multiplex other on-chip peripherals on GPIO pins.
http://www.opencores.org/
Rev 1.0
9 of 22
OpenCores
GPIO IP Core
12/25/01
http://www.opencores.org/
Rev 1.0
10 of 22
OpenCores
GPIO IP Core
12/25/01
3
Operation
This section describes the operation of the GPIO core. The GPIO core provides toggling of general-purpose outputs and sampling of general-purpose inputs under software control.
RGPIO_AUX [0] RGPIO_OUT [0] out_pad_o[0] Bidir I/O Cell and Pad
oen_padoen_o[0] INT GEN RGPIO_INTS [0] RGPIO_IN [0] RGPIO_OE [0] I/O 0
http://www.opencores.org/
in_pad_i[0]
OTHER EDGES
AUX [0]
SYS CLK
GPIO IP Core
RGPIO_CTRL [NEC]
Rev 1.0
11 of 22
OpenCores
GPIO IP Core
12/25/01
General-purpose inputs can generate interrupts so that software does not have to be in poll mode all the time when sampling inputs. Switching output drivers into open-drain or three-state mode will disable general-purpose outputs. To lower number of pins of the chip, other on-chip peripherals can be multiplexed together with the GPIO pins. For this purpose, auxiliary inputs can be multiplexed on general-purpose outputs.
Hardware Reset
Following hardware reset all general-purpose I/O signals are set into input mode. Meaning, all output drivers are disabled. All interrupts are masked, so that inputs would not generate any spurious interrupts. Gpio_eclk signal is not used to latch inputs into RGPIO_IN register; instead system clock is used.
http://www.opencores.org/
Rev 1.0
12 of 22
OpenCores
GPIO IP Core
12/25/01
http://www.opencores.org/
Rev 1.0
13 of 22
OpenCores
GPIO IP Core
12/25/01
4
Registers
This section describes all control and status register inside the GPIO core. The Address field indicates address in hexadecimal. Width specifies the number of bits in the register, and Access specifies the valid access types for that register. R/W stands for read and write access and R stands for read only access. Width of most registers is user selectable and is set by the user of the GPIO core at synthesis time.
Registers list
Name RGPIO_IN RGPIO_OUT RGPIO_OE RGPIO_INTE RGPIO_PTRIG RGPIO_AUX Address Base + 0x0 Base + 0x4 Base + 0x8 Base + 0xC Base + 0x10 Base + 0x14 Width 1 - 32 1 - 32 1 - 32 1 - 32 1 - 32 1 - 32 Access R R/W R/W R/W R/W R/W Description GPIO input data GPIO output data GPIO output driver enable Interrupt enable Type of event that triggers an interrupt Multiplex auxiliary inputs to GPIO outputs Control register Interrupt status
http://www.opencores.org/
Rev 1.0
14 of 22
OpenCores
GPIO IP Core
12/25/01
RGPIO_OUT register drives general-purpose outputs. Additionally, external I/O cells can be operated open-drain or three-state with RGPIO_OE register. Bit # 1 - 32 Access R/W Reset 0x0 Description General-purpose driven outputs
Table 3. Output Register
http://www.opencores.org/
Rev 1.0
15 of 22
OpenCores
GPIO IP Core
12/25/01
R/W
2 3
R/W R/W
0 0
http://www.opencores.org/
Rev 1.0
16 of 22
GPIO IP Core
12/25/01
Description When set, input caused an interrupt. When cleared, no interrupt is pending for corresponding input.
Table 9. Interrupt Status Register
http://www.opencores.org/
Rev 1.0
17 of 22
OpenCores
GPIO IP Core
12/25/01
5
IO ports
GPIO IP core has three interfaces. Figure 3 below shows all three interfaces: WISHBONE host interface Auxiliary inputs interface Interface to external I/O cells and pads
WISHBONE BUS
I/O 0
I/O 1 I/O n
GPIO IP Core
RGPIO_OUT Bypass
ECLK
http://www.opencores.org/
Rev 1.0
18 of 22
OpenCores wb_cyc_i wb_adr_i wb_dat_i wb_dat_o wb_sel_i wb_ack_o wb_err_o wb_rty_o wb_we_i wb_stb_i wb_inta_o 1 Inputs 15 Inputs 32 Inputs 32 Outputs 4 Inputs 1 Output 1 Output 1 Output 1 Input 1 Input 1 Output
GPIO IP Core
12/25/01
Indicates valid bus cycle (core select) Address inputs Data inputs Data outputs Indicates valid bytes on data bus (during valid cycle it must be 0xf) Acknowledgment output (indicates normal transaction termination) Error acknowledgment output (indicates an abnormal transaction termination) Not used Write transaction when asserted high Indicates valid data transfer cycle Interrupt output
Auxiliary inputs
The auxiliary inputs can bypass RGPIO_OUT outputs based on programming of RPGIO_AUX register. Auxiliary inputs are used to multiplex other on-chip peripherals on GPIO pins. Port aux_i Width 1 - 32 Direction Inputs Description GPIO auxiliary inputs
http://www.opencores.org/
Rev 1.0
19 of 22
OpenCores
GPIO IP Core
12/25/01
A
Core HW Configuration
This section describes parameters that are set by the user of the core and define configuration of the core. Parameters must be set by the user before actual use of the core in simulation or synthesis.
// // Number of GPIO I/O signals // // This is the most important parameter of the GPIO IP core. It defines how many // I/O signals core has. Range is from 1 to 32. If more than 32 I/O signals are // required, use several instances of GPIO IP core. // // Default is 16. // `define GPIO_IOS 16 // // Undefine this one if you don't want to remove GPIO block from your design // but you also don't need it. When it is undefined, all GPIO ports still // remain valid and the core can be synthesized however internally there is // no GPIO funationality. // // Defined by default (duhh !). // `define GPIO_IMPLEMENTED // // Define to register all WISHBONE outputs. // // Register outputs if you are using GPIO core as a block and synthesizing // and place&routing it separately from the rest of the system. // // If you do not need registered outputs, you can save some area by not defining // this macro. By default it is defined. // `define GPIO_REGISTERED_WB_OUTPUTS // // Define to register all GPIO pad outputs. // // Register outputs if you are using GPIO core as a block and synthesizing // and place&routing it separately from the rest of the system. // // If you do not need registered outputs, you can save some area by not defining // this macro. By default it is defined. // `define GPIO_REGISTERED_IO_OUTPUTS // // Define to avoid using negative edge clock flip-flops for external clock // (caused by RGPIO_CTRL[NEC] bit. Instead an inverted external clock with // positive edge clock flip-flops will be used. // // By default it is defined. // `define GPIO_NO_NEGEDGE_FLOPS // // Undefine if you don't need to read GPIO registers except for RGPIO_IN register.
http://www.opencores.org/
Rev 1.0
20 of 22
OpenCores
GPIO IP Core
12/25/01
// When it is undefined all reads of GPIO registers return RGPIO_IN register. This // is usually useful if you want really small area (for example when implemented in // FPGA). // // To follow GPIO IP core specification document this one must be defined. Also to // successfully run the test bench it must be defined. By default it is defined. // `define GPIO_READREGS // // Full WISHBONE address decoding // // It is is undefined, partial WISHBONE address decoding is performed. // Undefine it if you need to save some area. // // By default it is defined. // `define GPIO_FULL_DECODE // // Strict 32-bit WISHBONE access // // If this one is defined, all WISHBONE accesses must be 32-bit. If it is // not defined, err_o is asserted whenever 8- or 16-bit access is made. // Undefine it if you need to save some area. // // By default it is defined. // `define GPIO_STRICT_32BIT_ACCESS // // WISHBONE address // `define GPIO_ADDRHH `define GPIO_ADDRHL `define GPIO_ADDRLH `define GPIO_ADDRLL bits used for full decoding of GPIO registers. 6 5 1 0
// // Bits of WISHBONE address used for partial decoding of GPIO registers. // // Default 4:2. // `define GPIO_OFS_BITS `GPIO_ADDRHL-1:`GPIO_ADDRLH+1 // // Addresses of GPIO registers // // To comply with GPIO IP core specification document they must go from // address 0 to address 0x18 in the following order: RGPIO_IN, RGPIO_OUT, // RGPIO_OE, RGPIO_INTE, RGPIO_PTRIG, RGPIO_AUX and RGPIO_CTRL // // If particular register is not needed, it's address definition can be omitted // and the register will not be implemented. Instead a fixed default value will // be used. // `define GPIO_RGPIO_IN 3'h0 // Address 0x00 `define GPIO_RGPIO_OUT 3'h1 // Address 0x04 `define GPIO_RGPIO_OE 3'h2 // Address 0x08 `define GPIO_RGPIO_INTE 3'h3 // Address 0x0c `define GPIO_RGPIO_PTRIG 3'h4 // Address 0x10 `define GPIO_RGPIO_AUX 3'h5 // Address 0x14 `define GPIO_RGPIO_CTRL 3'h6 // Address 0x18 `define GPIO_RGPIO_INTS 3'h7 // Address 0x1c // // Default values for unimplemented GPIO registers // `define GPIO_DEF_RGPIO_IN `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_OUT `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_OE `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_INTE `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_PTRIG `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_AUX `GPIO_IOS'h0 `define GPIO_DEF_RGPIO_CTRL `GPIO_IOS'h0
http://www.opencores.org/
Rev 1.0
21 of 22
OpenCores
GPIO IP Core
12/25/01
// // RGPIO_CTRL bits // // To comply with the GPIO IP core specification document they must go from // bit 0 to bit 3 in the following order: ECLK, NEC, INTE, INT // `define GPIO_RGPIO_CTRL_ECLK 0 `define GPIO_RGPIO_CTRL_NEC 1 `define GPIO_RGPIO_CTRL_INTE 2 `define GPIO_RGPIO_CTRL_INTS 3
There are additional parameters in the core but are considered only for development and should not be changed by the user.
http://www.opencores.org/
Rev 1.0
22 of 22