From: Luke Kenneth Casson Leighton Date: Sun, 4 Oct 2020 16:44:18 +0000 (+0100) Subject: submodule update X-Git-Tag: 24jan2021_ls180~246 X-Git-Url: https://git.libre-soc.org/?p=soc.git;a=commitdiff_plain;h=0e1aa577769dec5b64a655b5cbc9587176dac274 submodule update --- diff --git a/libreriscv b/libreriscv index cdd0f8a5..29c78ebd 160000 --- a/libreriscv +++ b/libreriscv @@ -1 +1 @@ -Subproject commit cdd0f8a50f3c15703d8b507333b5df526b86210c +Subproject commit 29c78ebd8ac03fd811a41ea772fe20813bdb1927 diff --git a/pinmux b/pinmux index f1e4b3a8..6e6f3a7e 160000 --- a/pinmux +++ b/pinmux @@ -1 +1 @@ -Subproject commit f1e4b3a8bc48bcdfca867a0322096556e8317984 +Subproject commit 6e6f3a7e47ee08773d9ec0d8f129906ab28d140c diff --git a/src/soc/config/pinouts.py b/src/soc/config/pinouts.py new file mode 100644 index 00000000..95713e05 --- /dev/null +++ b/src/soc/config/pinouts.py @@ -0,0 +1,59 @@ +import os +import sys +import json +from pprint import pprint + +def _byteify(data, ignore_dicts = False): + # if this is a unicode string, return its string representation + try: + if isinstance(data, unicode): + return data.encode('utf-8') + except NameError: + return data + # if this is a list of values, return list of byteified values + if isinstance(data, list): + return [ _byteify(item, ignore_dicts=True) for item in data ] + # if this is a dictionary, return dictionary of byteified keys and values + # but only if we haven't already byteified it + if isinstance(data, dict) and not ignore_dicts: + return dict((_byteify(key, ignore_dicts=True), + _byteify(value, ignore_dicts=True)) + for key, value in data.iteritems()) + # if it's anything else, return it in its original form + return data + +def load_pinouts(chipname=None): + """load_pinouts - loads the JSON-formatted dictionary of a chip spec + + note: this works only when pinmux is a correctly-initialised git submodule + and when the spec has been actually generated. see Makefile "make mkpinmux" + """ + + # default pinouts for now: ls180 + if chipname is None: + chipname = 'ls180' + + # load JSON-formatted pad info from pinmux + pth = os.path.abspath(__file__) + pth = os.path.split(pth)[0] + + # path is relative to this filename, in the pinmux submodule + fname = "%s/../../../pinmux/%s/litex_pinpads.json" % (pth, chipname) + with open(fname) as f: + txt = f.read() + + # decode the json, strip unicode formatting (has to be recursive) + chip = json.loads(txt, object_hook=_byteify) + chip = _byteify(chip, ignore_dicts=True) + + return chip + +if __name__ == '__main__': + if sys.argv == 2: + chipname = sys.argv[1] + else: + chipname = None + chip = load_pinouts(chipname) + for k, v in chip.items(): + print ("\n****", k, "****") + pprint(v)