Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12608 Discussions

DEII GPIO Bidirectional setting

Altera_Forum
Honored Contributor II
1,077 Views

1. 

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; 

 

then: 

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

 

 

2. 

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? 

 

Thanks
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
288 Views

Anyone can help?

0 Kudos
Altera_Forum
Honored Contributor II
288 Views

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.
0 Kudos
Reply