Forum Discussion

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

Creating a bidirectional bus

I want to connect a USB chip (FT245R) to a CPLD. To do that I need a bidirectional 8-bit bus. I thought I could declare the pins to be bidirectional and with a mux, read to or write from the pins as necessary. My Verilog code for the mux is:

[code]

always @(negedge clk) begin: TESTUSB_MUX

if ((TXE == 0)) begin

USBBUS <= OUTBUS;

end

else if ((RXF == 0)) begin

INBUS <= USBBUS;

end

end

[\code]

But the Fitter generates errors, e.g., Error: Can't reserve pin "USBBUS[0]" because its name already exists with a different direction

How can a bidirectional bus be created?

13 Replies

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

    inout port bidir can be either a wire set by an assign statement or a reg set in the sequential code, but not both at a time.

    I'm under the impression that you are overcomplicating a basically simple thing.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    No doubt, but how about suggesting how I could simplify things and come up with something that works?

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

    Your code from post# 2 can basically work, if USBBUS is declared as inout and all variables assigned in the always block as reg.

    Functional detail related to your application are a different thing, but you get legal Verilog syntax as a starting point.