2015-05-02 12:42:33 -04:00
|
|
|
import subprocess
|
|
|
|
|
2015-09-22 12:36:47 -04:00
|
|
|
from migen import *
|
2012-05-16 19:41:41 -04:00
|
|
|
from migen.bank.description import *
|
|
|
|
|
2015-05-02 12:42:33 -04:00
|
|
|
def get_id():
|
|
|
|
output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
|
|
|
|
return int(output[:8], 16)
|
2012-05-16 19:41:41 -04:00
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2013-03-30 12:28:15 -04:00
|
|
|
class Identifier(Module, AutoCSR):
|
2015-04-13 10:19:55 -04:00
|
|
|
def __init__(self, sysid, frequency, revision=None):
|
|
|
|
self._sysid = CSRStatus(16)
|
|
|
|
self._revision = CSRStatus(32)
|
|
|
|
self._frequency = CSRStatus(32)
|
2014-10-17 05:14:35 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
###
|
2013-03-10 14:32:38 -04:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
if revision is None:
|
2015-05-02 12:42:33 -04:00
|
|
|
revision = get_id()
|
2013-11-09 10:38:44 -05:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
self.comb += [
|
|
|
|
self._sysid.status.eq(sysid),
|
|
|
|
self._revision.status.eq(revision),
|
|
|
|
self._frequency.status.eq(frequency)
|
|
|
|
]
|