compat: Fix (only triggers notice when used) and enable SoCSDRAM compat.
This commit is contained in:
parent
50ed5e262d
commit
ee36138f75
|
@ -1,6 +1,8 @@
|
|||
import sys
|
||||
import time
|
||||
|
||||
# Helpers ------------------------------------------------------------------------------------------
|
||||
|
||||
def colorer(s, color="bright"): # FIXME: Move colorer to litex.common?
|
||||
header = {
|
||||
"bright": "\x1b[1m",
|
||||
|
@ -12,6 +14,8 @@ def colorer(s, color="bright"): # FIXME: Move colorer to litex.common?
|
|||
trailer = "\x1b[0m"
|
||||
return header + str(s) + trailer
|
||||
|
||||
# Compat -------------------------------------------------------------------------------------------
|
||||
|
||||
def compat_notice(name, date, info=""):
|
||||
print("Compat: {name} is {deprecated} since {date} and will soon no longer work, please {update}. {info}".format(
|
||||
name = colorer(name),
|
||||
|
@ -26,14 +30,28 @@ def compat_notice(name, date, info=""):
|
|||
print(".", end="")
|
||||
sys.stdout.flush()
|
||||
print("thanks :)")
|
||||
time.sleep(1)
|
||||
|
||||
def add_compat(location):
|
||||
# Integration.
|
||||
if location == "litex.soc.integration":
|
||||
#compat_notice("SoCSDRAM", date="2020-03-24", info="Switch to SoCCore/add_sdram/soc_core_args instead.")
|
||||
from litex.compat import soc_sdram
|
||||
sys.modules["litex.soc.integration.soc_sdram"] = soc_sdram
|
||||
class compat_soc_sdram:
|
||||
noticed = False
|
||||
def __getattr__(self, name):
|
||||
if not self.noticed:
|
||||
compat_notice("SoCSDRAM", date="2020-03-24", info="Switch to SoCCore/add_sdram/soc_core_args instead.")
|
||||
self.noticed = True
|
||||
from litex.compat import soc_sdram
|
||||
return getattr(soc_sdram, name)
|
||||
sys.modules["litex.soc.integration.soc_sdram"] = compat_soc_sdram()
|
||||
# Cores.
|
||||
elif location == "litex.soc.cores":
|
||||
compat_notice("litex.soc.cores.up5kspram", date="2020-03-24", info="Switch to litex.soc.cores.ram.")
|
||||
class compat_up5kspram:
|
||||
noticed = False
|
||||
def __getattr__(self, name):
|
||||
if not self.noticed:
|
||||
compat_notice("litex.soc.cores.up5kspram", date="2020-03-24", info="Switch to litex.soc.cores.ram.")
|
||||
self.noticed = True
|
||||
from litex.soc.cores import ram
|
||||
return getattr(ram, name)
|
||||
from litex.soc.cores import ram
|
||||
sys.modules["litex.soc.cores.up5kspram"] = ram
|
||||
sys.modules["litex.soc.cores.up5kspram"] = compat_up5kspram()
|
||||
|
|
Loading…
Reference in New Issue