cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sf
Visitor
Visitor
183 Views
Registered: ‎06-17-2020

fpga pins and design of bidirectional I/O

Jump to solution

Hi,

I am making a design and doing implementation of a sd card interface. The command signal and data signal of the sd card interface are bidirectional and I am having some port declaration and connection issues with these.

I have two modules related to the issues, one is the top module, and another is a submodule(just call it A here) for handling the data of sd card.

let's say the top module is like:

module top(

output sd_clock,

inout sd_command,

inout sd_dat);

 

 A     A_inst(

 .sd_clock(sd_clock),

.sd_command(sd_command),

.sd_dat(sd_dat));

... some code for other functionality ...

 

and the submodule A used for handling sd card data is like:

module A(

output sd_clock,

inout sd_command,

inout sd_dat);

... some code for handling data ...

 

You know, bidirectional signals need enable signals to control whether it is actually sending or receiving data. I declare the signal as tri type and handle the signal in submodule A like this:

tri sd_command;

assign sd_command = command_en ? command_in : 1'hz;

 

command_in is a local signal.

 

I was able to program the design on a fpga board but I haven't seen any value yet.

 

BTW I tried ILA debugger but it seems ILA does not accept inout signals.

 

Any ideas how to resolve the issue? Even hints for getting ILA working for the inout signals can be very helpful.

0 Kudos
1 Solution

Accepted Solutions
drjohnsmith
Teacher
Teacher
68 Views
Registered: ‎07-09-2009

The confusion is the lack of distinction between pin, as in the copper bits on the output of the package, and the signals inside the FPGA

Pins , can be and are bi directional, they have tri state driver capabilities depending what type of pin you select,

Signals, as in the ports on your code that do not connect to IO pins, can not be actual bi directional signals,

So for say a SD card IP block,

 the top level module in you code will have inout pins , which are tri state controlled,

     But the first thing these signals do inside your code, is split into in / out ports / signals.

 

 

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

View solution in original post

5 Replies
drjohnsmith
Teacher
Teacher
163 Views
Registered: ‎07-09-2009

Inside the FPGA you can not have inout pins, as in there is no internal bi directional interconnects,

  what language you programming in ?

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
sf
Visitor
Visitor
145 Views
Registered: ‎06-17-2020

systemverilog.

hmm it's a bit confusing. The sd card does need bidirectional ports. My fpga board has a sd slot so I think the pins for it should be bidirectional.

0 Kudos
sf
Visitor
Visitor
145 Views
Registered: ‎06-17-2020

------------------- seems the message was not sent to you, so I am trying again.

systemverilog.

hmm it's a bit confusing. The sd card does need bidirectional ports. My fpga board has a sd slot so I think the pins for it should be bidirectional.

0 Kudos
drjohnsmith
Teacher
Teacher
69 Views
Registered: ‎07-09-2009

The confusion is the lack of distinction between pin, as in the copper bits on the output of the package, and the signals inside the FPGA

Pins , can be and are bi directional, they have tri state driver capabilities depending what type of pin you select,

Signals, as in the ports on your code that do not connect to IO pins, can not be actual bi directional signals,

So for say a SD card IP block,

 the top level module in you code will have inout pins , which are tri state controlled,

     But the first thing these signals do inside your code, is split into in / out ports / signals.

 

 

 

 

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>

View solution in original post

Firewall
Visitor
Visitor
63 Views
Registered: ‎02-22-2021

On top level, inout ports are fine., and you need to split it into in and out signals like this:

assign I_sd_dat = sd_dat;

assign sd_dat = (en == 1'b1)? O_sd_dat: 'bz;

On submodule level, you should only use I_sd_dat and O_sd_dat signals