Forum Discussion

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

The question about bidirectional port

In my design, I have a inout port. Then I search it, found most examples, they only put the high impedance for output direction as (case 1):

inout [7:0 ]data_io;

reg [7:0] out_a;

wire [7:0] in_b;

reg rnw;

assign data_io = (rnw==1'b0) out_a : 8'bZ; /// when read, assign io as high impedance

assign in_b = data_io;

But I think we may also put high impedance in both direction like (case 2):

inout [7:0 ]data_io;

reg [7:0] out_a;

wire [7:0] in_b;

reg rnw;

assign data_io = (rnw==1'b0) out_a : 8'bZ; /// when read, assign io as high impedance

assign in_b = (rnw==1'b1) data_io : 8'bZ; /// when write, read high impedance

So my question is, will put high impedance in both directions (like case 2) cause problems?

My understanding is it won't cause problem. The difference between case 1 and case 2 is, in case 1, the "in_b" will equal the output date during write operation.

Thanks.

1 Reply

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

    --- Quote Start ---

    In my design, I have a inout port. Then I search it, found most examples, they only put the high impedance for output direction as (case 1):

    inout [7:0 ]data_io;

    reg [7:0] out_a;

    wire [7:0] in_b;

    reg rnw;

    assign data_io = (rnw==1'b0) out_a : 8'bZ; /// when read, assign io as high impedance

    assign in_b = data_io;

    But I think we may also put high impedance in both direction like (case 2):

    inout [7:0 ]data_io;

    reg [7:0] out_a;

    wire [7:0] in_b;

    reg rnw;

    assign data_io = (rnw==1'b0) out_a : 8'bZ; /// when read, assign io as high impedance

    assign in_b = (rnw==1'b1) data_io : 8'bZ; /// when write, read high impedance

    So my question is, will put high impedance in both directions (like case 2) cause problems?

    My understanding is it won't cause problem. The difference between case 1 and case 2 is, in case 1, the "in_b" will equal the output date during write operation.

    Thanks.

    --- Quote End ---

    the idea of two directions is:

    (1) pin as output, so you drive it, external device is meant to apply z

    (2) pin as input, external device drives it and you just read it so use z in order not to read your own drive(in contention with external drive)

    so in short either you drive it or external device but never both. But either can read it anytime.

    you can if it helps your design apply z to input buffer if available at io block.