diff --git a/litex_boards/platforms/arty.py b/litex_boards/platforms/arty.py index 4895439..c9e6383 100644 --- a/litex_boards/platforms/arty.py +++ b/litex_boards/platforms/arty.py @@ -145,57 +145,6 @@ _io = [ ), ] -_usb_uart_pmod_io = [ - # USB-UART PMOD on JA: - # - https://store.digilentinc.com/pmod-usbuart-usb-to-uart-interface/ - ("usb_uart", 0, - Subsignal("tx", Pins("pmoda:1")), - Subsignal("rx", Pins("pmoda:2")), - IOStandard("LVCMOS33") - ), -] - -_i2s_pmod_io = [ - # I2S PMOD on JD: - # - https://store.digilentinc.com/pmod-i2s2-stereo-audio-input-and-output/ - ("i2s_rx_mclk", 0, Pins("pmodd:4"), IOStandard("LVCMOS33")), - ("i2s_rx", 0, - Subsignal("clk", Pins("pmodd:6")), - Subsignal("sync", Pins("pmodd:5")), - Subsignal("rx", Pins("pmodd:7")), - IOStandard("LVCMOS33"), - ), - ("i2s_tx_mclk", 0, Pins("pmodd:0"), IOStandard("LVCMOS33")), - ("i2s_tx", 0, - Subsignal("clk",Pins("pmodd:2")), - Subsignal("sync", Pins("pmodd:1")), - Subsignal("tx", Pins("pmodd:3")), - IOStandard("LVCMOS33"), - ), -] - -_sdcard_pmod_io = [ - # SDCard PMOD on JD: - # - https://store.digilentinc.com/pmod-microsd-microsd-card-slot/ - # - https://github.com/antmicro/arty-expansion-board - ("spisdcard", 0, - Subsignal("clk", Pins("pmodd:3")), - Subsignal("mosi", Pins("pmodd:1"), Misc("PULLUP True")), - Subsignal("cs_n", Pins("pmodd:0"), Misc("PULLUP True")), - Subsignal("miso", Pins("pmodd:2"), Misc("PULLUP True")), - Misc("SLEW=FAST"), - IOStandard("LVCMOS33"), - ), - ("sdcard", 0, - Subsignal("data", Pins("pmodd:2 pmodd:4 pmodd:5 pmodd:0"), Misc("PULLUP True")), - Subsignal("cmd", Pins("pmodd:1"), Misc("PULLUP True")), - Subsignal("clk", Pins("pmodd:3")), - Subsignal("cd", Pins("pmodd:6")), - Misc("SLEW=FAST"), - IOStandard("LVCMOS33"), - ), -] - # Connectors --------------------------------------------------------------------------------------- _connectors = [ @@ -289,6 +238,64 @@ _connectors = [ } ), ] +# PMODS -------------------------------------------------------------------------------------------- + +def usb_pmod_io(pmod): + return [ + # USB-UART PMOD: https://store.digilentinc.com/pmod-usbuart-usb-to-uart-interface/ + ("usb_uart", 0, + Subsignal("tx", Pins(f"{pmod}:1")), + Subsignal("rx", Pins(f"{pmod}:2")), + IOStandard("LVCMOS33") + ), + ] +_usb_uart_pmod_io = usb_pmod_io("pmoda") # USB-UART PMOD on JA. + + +def i2s_pmod_io(pmod): + return [ + # I2S PMOD: https://store.digilentinc.com/pmod-i2s2-stereo-audio-input-and-output/ + ("i2s_rx_mclk", 0, Pins(f"{pmod}:4"), IOStandard("LVCMOS33")), + ("i2s_rx", 0, + Subsignal("clk", Pins(f"{pmod}:6")), + Subsignal("sync", Pins(f"{pmod}:5")), + Subsignal("rx", Pins(f"{pmod}:7")), + IOStandard("LVCMOS33"), + ), + ("i2s_tx_mclk", 0, Pins(f"{pmod}:0"), IOStandard("LVCMOS33")), + ("i2s_tx", 0, + Subsignal("clk",Pins(f"{pmod}:2")), + Subsignal("sync", Pins(f"{pmod}:1")), + Subsignal("tx", Pins(f"{pmod}:3")), + IOStandard("LVCMOS33"), + ), + ] +_i2s_pmod_io = i2s_pmod_io("pmodd") # I2S PMOD on JD. + +def sdcard_pmod_io(pmod): + return [ + # SDCard PMOD: + # - https://store.digilentinc.com/pmod-microsd-microsd-card-slot/ + # - https://github.com/antmicro/arty-expansion-board + ("spisdcard", 0, + Subsignal("clk", Pins(f"{pmod}:3")), + Subsignal("mosi", Pins(f"{pmod}:1"), Misc("PULLUP True")), + Subsignal("cs_n", Pins(f"{pmod}:0"), Misc("PULLUP True")), + Subsignal("miso", Pins(f"{pmod}:2"), Misc("PULLUP True")), + Misc("SLEW=FAST"), + IOStandard("LVCMOS33"), + ), + ("sdcard", 0, + Subsignal("data", Pins(f"{pmod}:2 {pmod}:4 {pmod}:5 {pmod}:0"), Misc("PULLUP True")), + Subsignal("cmd", Pins(f"{pmod}:1"), Misc("PULLUP True")), + Subsignal("clk", Pins(f"{pmod}:3")), + Subsignal("cd", Pins(f"{pmod}:6")), + Misc("SLEW=FAST"), + IOStandard("LVCMOS33"), + ), +] +_sdcard_pmod_io = sdcard_pmod_io("pmodd") # SDCARD PMOD on JD. + # Platform ----------------------------------------------------------------------------------------- class Platform(XilinxPlatform): diff --git a/litex_boards/targets/arty.py b/litex_boards/targets/arty.py index 007bdd9..958cd4b 100755 --- a/litex_boards/targets/arty.py +++ b/litex_boards/targets/arty.py @@ -105,13 +105,21 @@ def main(): builder_args(parser) soc_sdram_args(parser) vivado_build_args(parser) - parser.add_argument("--with-ethernet", action="store_true", help="Enable Ethernet support") - parser.add_argument("--with-etherbone", action="store_true", help="Enable Etherbone support") + parser.add_argument("--with-ethernet", action="store_true", help="Enable Ethernet support") + parser.add_argument("--with-etherbone", action="store_true", help="Enable Etherbone support") + parser.add_argument("--with-spi-sdcard", action="store_true", help="Enable SPI-mode SDCard support") + parser.add_argument("--with-sdcard", action="store_true", help="Enable SDCard support") args = parser.parse_args() assert not (args.with_ethernet and args.with_etherbone) soc = BaseSoC(with_ethernet=args.with_ethernet, with_etherbone=args.with_etherbone, **soc_sdram_argdict(args)) + assert not (args.with_spi_sdcard and args.with_sdcard) + soc.platform.add_extension(arty._sdcard_pmod_io) + if args.with_spi_sdcard: + soc.add_spi_sdcard() + if args.with_sdcard: + soc.add_sdcard() builder = Builder(soc, **builder_argdict(args)) builder.build(**vivado_build_argdict(args), run=args.build)