How to connect the inout data ports to multiple IOs

Viewed 44

I am working on an SPI Master using ArtyA7 development board, and I'm wondering if it's possible to connect the inout data ports to multiple IOs which will be connected to multiple spi slaves ? I tried doing this :

set_property -dict {PACKAGE_PIN L16 IOSTANDARD LVCMOS33} [get_ports spi_clk]
set_property -dict {PACKAGE_PIN L13 IOSTANDARD LVCMOS33} [get_ports {spi_cs[0]}]

set_property -dict {PACKAGE_PIN k17 IOSTANDARD LVCMOS33} [get_ports {spi[0]}]
set_property -dict {PACKAGE_PIN k18 IOSTANDARD LVCMOS33} [get_ports {spi[1]}]
#JA
set_property -dict {PACKAGE_PIN G13 IOSTANDARD LVCMOS33} [get_ports {spi_cs[1]}]
set_property -dict {PACKAGE_PIN B11 IOSTANDARD LVCMOS33} [get_ports {spi[0]}]
set_property -dict {PACKAGE_PIN A11 IOSTANDARD LVCMOS33} [get_ports {spi[1]}]
set_property -dict {PACKAGE_PIN D12 IOSTANDARD LVCMOS33} [get_ports spi_clk]

Where spi[i] is an inout port. But when I open the implemented design, I see that vivado implemented only the last constraints. What's wrong in my flow ?

1 Answers

From what I know, set_property will override existing values, so the second time you call it you're changing the PACKAGE_PIN and IOSTANDARD properties of the pins to the new values.

Generally for the SPI bus you're meant to share the common pins (clk, miso, mosi) with all the devices, so I don't see a reason to provide those on multiple pins from your fpga when you can connect them directly together on the board while keeping the chip select pins separate:

SPI

(source: https://en.wikipedia.org/wiki/Serial_Peripheral_Interface)

On a separate note, I would define the two data pins as input and output directly rather than both as inout, since both are used only in a single direction.

If for some reason (board design comes to mind, but you're using a dev board that souldn't have this requirement) you need to repeat the signals on multiple pins, I would add a small RTL module that does so:

module duplicate_pin(input pin_value, output output_1, output output_2);
    assign output_1 = pin_value;
    assign output_2 = pin_value;
endmodule

Then you can assign the two outputs of this module to different pins as you need.

This only works for the mosi pin, as you would need to read from only one of the miso inputs at a time, choosing based on the currently active slave device.

Related