soc_core/common: move old mem_decoder to soc_core, simplify get_version
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Feb 2020 07:44:23 +0000 (08:44 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 11 Feb 2020 07:44:23 +0000 (08:44 +0100)
litex/soc/integration/common.py
litex/soc/integration/soc_core.py

index 7fa11a340f3d136fdeb82c8797dc0b07dd457dda..d07f05185e4b13fc76466babee8ac1003e238ba3 100644 (file)
@@ -12,21 +12,9 @@ from migen import *
 
 # Helpers ----------------------------------------------------------------------------------------
 
-def mem_decoder(address, size=0x10000000):
-    address &= ~0x80000000
-    size = 2**log2_int(size, False)
-    assert (address & (size - 1)) == 0
-    address >>= 2 # bytes to words aligned
-    size    >>= 2 # bytes to words aligned
-    return lambda a: (a[log2_int(size):-1] == (address >> log2_int(size)))
-
 def get_version(with_time=True):
-    if with_time:
-        return datetime.datetime.fromtimestamp(
-                time.time()).strftime("%Y-%m-%d %H:%M:%S")
-    else:
-        return datetime.datetime.fromtimestamp(
-                time.time()).strftime("%Y-%m-%d")
+    fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
+    return datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")
 
 def get_mem_data(filename_or_regions, endianness="big", mem_size=None):
     # create memory regions
index 25a10d25237ef415d4c507791b07c1b45f5b00dd..6106dedfc3381cbbd8aabcf4e9c9b2b34fe46485 100644 (file)
@@ -37,6 +37,16 @@ __all__ = [
     "soc_mini_argdict",
 ]
 
+# Helpers ------------------------------------------------------------------------------------------
+
+def mem_decoder(address, size=0x10000000):
+    size = 2**log2_int(size, False)
+    assert (address & (size - 1)) == 0
+    address >>= 2 # bytes to words aligned
+    size    >>= 2 # bytes to words aligned
+    return lambda a: (a[log2_int(size):] == (address >> log2_int(size)))
+
+
 # SoCCore ------------------------------------------------------------------------------------------
 
 class SoCCore(LiteXSoC):