soc/integration: move mem_decoder to soc_core

This commit is contained in:
Florent Kermarrec 2020-02-11 17:19:22 +01:00
parent 0a737cb624
commit d5ad1d56f2
2 changed files with 9 additions and 7 deletions

View File

@ -12,13 +12,6 @@ from migen import *
# 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)))
def get_version(with_time=True):
fmt = "%Y-%m-%d %H:%M:%S" if with_time else "%Y-%m-%d"
return datetime.datetime.fromtimestamp(time.time()).strftime(fmt)

View File

@ -37,6 +37,15 @@ __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)))
# SoCController ------------------------------------------------------------------------------------
class SoCController(Module, AutoCSR):