nmigen-learning/fpga/__init__.py

35 lines
1.2 KiB
Python

__version__ = '0.1.0'
# YOWASP:
def populate_environ_with_yowasp():
import os, shutil
for nmigen_envvar, expected_path, alternative_path in [
("SBY", "sby", "yowasp-sby"),
("YOSYS", "yosys", "yowasp-yosys"), # nmigen-yosys is handled by nmigen
("NEXTPNR_ECP5", "nextpnr-ecp5", "yowasp-nextpnr-ecp5"),
("NEXTPNR_ICE40", "nextpnr-ice40", "yowasp-nextpnr-ice40"),
("NEXTPNR_ICE40", "nextpnr-ice40", "yowasp-nextpnr-ice40"),
("ICEBRAM", "icebram", "yowasp-icebram"),
("ICEMULTI", "icemulti", "yowasp-icemulti"),
("ICEPACK", "icepack", "yowasp-icepack"),
("ICEPLL", "icepll", "yowasp-icepll"),
("ICEUNPACK", "iceunpack", "yowasp-iceunpack"),
]:
if nmigen_envvar in os.environ: continue
if shutil.which(expected_path): continue
if not shutil.which(alternative_path): continue
os.environ[nmigen_envvar] = alternative_path
populate_environ_with_yowasp()
del populate_environ_with_yowasp
# dogelang: Slow. Stupid. Absolutely adorable.
import dg # setup the dg import hook
del dg