Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

GPIO with both input and output pins

Hi,

I have a DE1 develeopment board with lots of GPIO pins. Currently I use one header for inputs and the other for outputs. But I would like to put them all on the same header.

When I try to set them up in the top level module (I am using verilog) I get the error Error (10134): Verilog HDL Module Declaration error at TopLevel: port "GPIO_1" is declared more than once

This is when the code looks something like:

module TopLevel (GPIO_1);

input [1:0] GPIO_1;

output [3:2] GPIO_1;

Stuff goes here;

endmodule

This seems like a really simple question to me but I don't know what the solution is. I don't want/need bi directional pins I just want some to be inputs and some to be outputs from the same header.

Please let me know if you know what to do to fix this.

Thanks

Deep

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Using the same array name for both inputs and outputs is not allowed.

    You must declare two different bit vectors.

    input [1:0] GPin;

    output [1:0] GPout;

    You then assign to the required pins as you'd have done with GPIO_1
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Otherwise, if you need to mantain the overall GPIO_1 name, you need to declare a bidirectional array:

    inout [3:0] GPIO_1

    and then write something like this:

    assign GPIO_1[3:0] = { GPout[1:0], 2'bzz };

    assign GPin[1:0] = GPIO_1[1:0];
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    Thanks for your reply. I went with using bidirectional pins in the end because the PCB has GPIO_1 written on the board and I would like my code to match up with that.

    Cheers,

    Sandeep