Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12435 Discussions

DEII GPIO Bidirectional setting

Honored Contributor II


Hi, I am working on a project involving nand flash, and the nand flash has 8 bit bidirectional data bus. I am testing it on a DE2 board, so my question is how to make the GPIO_0 work as a bidirectional bus.  

my current idea is to declare pins as inout in the top level, and make it tri-state. is that correct? or there are other ways to do it. 


inout wire [32:21]GPIO_0; 



.nand_data_inout({GPIO_0[21:25],GPIO_0[30:32]}), btw, is this the correct way to combine pins together?  




In addition, I have some GPIO pins work as output only, so when i implement as the following, 


output wire [35:30]GPIO_0; 

inout wire [32:21]GPIO_0; 


i will get the error message"Error : port "GPIO_0" is declared more than once" how should i solve this problem? 


0 Kudos
2 Replies
Honored Contributor II

Anyone can help?

Honored Contributor II

Question 1: 

This is correct; you can connect pins that way. 

Anyway I don't know your design, so I can't say this will perform what you need. 


Question 2: 

In your code there are 2 errors: 

- GPIO_0[32:30] are declared twice, for different ports, as the error message states. 

- Moreover a GPIO port can't mix both output and inout pins. AFAIK PIO with Bidir configuration must be connected directly to fpga pins, since the physical tristate hardware is available only in i/o pads. Other internal tristate behavior is actually emulated through logic synthesis. 


If you need a few PIO pins to behave always as output and other as i/o you have these choices: 

- generate separate PIOs: one for outputs an one for bidirectional signals 

- declare inout all PIO pins, even if they have a fixed direction. 

- declare the PIO direction setting as "Both input and output ports" instead of "Bidirectional" and add the tristate logic external to the Nios sopc system, this is useful only when you need to globally change the direction of the whole PIO or a group of PIO pins; you need additional signals to control tristate gates, so this solution is not convenient if you need to change individual PIO pin directions.