@@ -61,6 +61,10 @@ def __init__(self, platform, sys_clk_freq, with_video_terminal):
6161class BaseSoC (SoCCore ):
6262 def __init__ (self , sys_clk_freq = 24e6 , toolchain = "colognechip" ,
6363 with_video_terminal = False ,
64+ with_ethernet = False ,
65+ with_etherbone = False ,
66+ eth_ip = "192.168.1.50" ,
67+ remote_ip = None ,
6468 with_led_chaser = True ,
6569 ** kwargs ):
6670 platform = olimex_gatemate_a1_evb .Platform (toolchain )
@@ -84,6 +88,36 @@ def __init__(self, sys_clk_freq=24e6, toolchain="colognechip",
8488 pads = platform .request_all ("user_led_n" ),
8589 sys_clk_freq = sys_clk_freq )
8690
91+ # Ethernet / Etherbone ---------------------------------------------------------------------
92+ if with_ethernet or with_etherbone :
93+ from litex .build .generic_platform import Subsignal
94+ def eth_lan8720_rmii_pmod_io (pmod ):
95+ # Lan8720 RMII PHY "PMOD": To be used as a PMOD, MDIO should be disconnected and TX1 connected to PMOD8 IO.
96+ return [
97+ ("eth_rmii_clocks" , 0 ,
98+ Subsignal ("ref_clk" , Pins (f"{ pmod } :6" )),
99+ ),
100+ ("eth_rmii" , 0 ,
101+ Subsignal ("rx_data" , Pins (f"{ pmod } :5 { pmod } :1" )),
102+ Subsignal ("crs_dv" , Pins (f"{ pmod } :2" )),
103+ Subsignal ("tx_en" , Pins (f"{ pmod } :4" )),
104+ Subsignal ("tx_data" , Pins (f"{ pmod } :0 { pmod } :7" )),
105+ ),
106+ ]
107+ platform .add_extension (eth_lan8720_rmii_pmod_io ("PMOD" ))
108+
109+ from liteeth .phy .rmii import LiteEthPHYRMII
110+ self .ethphy = LiteEthPHYRMII (
111+ clock_pads = platform .request ("eth_rmii_clocks" ),
112+ pads = platform .request ("eth_rmii" ),
113+ refclk_cd = None
114+ )
115+
116+ if with_ethernet :
117+ self .add_ethernet (phy = self .ethphy , local_ip = eth_ip , remote_ip = remote_ip , software_debug = False )
118+ if with_etherbone :
119+ self .add_etherbone (phy = self .ethphy , ip_address = eth_ip )
120+
87121# Build --------------------------------------------------------------------------------------------
88122
89123def main ():
@@ -92,13 +126,32 @@ def main():
92126 parser .add_target_argument ("--sys-clk-freq" , default = 24e6 , type = float , help = "System clock frequency." )
93127 parser .add_target_argument ("--with-video-terminal" , action = "store_true" , help = "Enable Video Terminal (VGA)." )
94128 parser .add_target_argument ("--flash" , action = "store_true" , help = "Flash bitstream." )
129+ pmodopts = parser .target_group .add_mutually_exclusive_group ()
130+ pmodopts .add_argument ("--with-spi-sdcard" , action = "store_true" , help = "Enable SPI-mode SDCard support." )
131+ pmodopts .add_argument ("--with-sdcard" , action = "store_true" , help = "Enable SDCard support." )
132+ pmodopts .add_argument ("--with-ethernet" , action = "store_true" , help = "Enable Ethernet support." )
133+ pmodopts .add_argument ("--with-etherbone" , action = "store_true" , help = "Enable Etherbone support." )
134+ parser .add_target_argument ("--eth-ip" , default = "192.168.1.50" , help = "Ethernet/Etherbone IP address." )
135+ parser .add_target_argument ("--remote-ip" , default = "192.168.1.100" , help = "Remote IP address of TFTP server." )
136+
95137 args = parser .parse_args ()
96138
97139 soc = BaseSoC (
98140 sys_clk_freq = args .sys_clk_freq ,
99141 toolchain = args .toolchain ,
100142 with_video_terminal = args .with_video_terminal ,
143+ with_ethernet = args .with_ethernet ,
144+ with_etherbone = args .with_etherbone ,
145+ eth_ip = args .eth_ip ,
146+ remote_ip = args .remote_ip ,
101147 ** parser .soc_argdict )
148+
149+ soc .platform .add_extension (olimex_gatemate_a1_evb ._pmods_io )
150+ if args .with_spi_sdcard :
151+ soc .add_spi_sdcard ()
152+ if args .with_sdcard :
153+ soc .add_sdcard ()
154+
102155 builder = Builder (soc , ** parser .builder_argdict )
103156 if args .build :
104157 builder .build (** parser .toolchain_argdict )
0 commit comments