04-08-2021 09:56 AM
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.
04-09-2021 01:17 AM
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.
04-08-2021 11:23 AM
Inside the FPGA you can not have inout pins, as in there is no internal bi directional interconnects,
what language you programming in ?
04-08-2021 01:00 PM
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.
04-08-2021 01:01 PM
------------------- 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.
04-09-2021 01:17 AM
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.
04-09-2021 01:33 AM
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