mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-21 22:23:05 +00:00
tools/gen_reg_class.py: Script to generate Register classes
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
d9561b7507
commit
a3558c86d7
1 changed files with 33 additions and 0 deletions
33
tools/gen_reg_class.py
Normal file
33
tools/gen_reg_class.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import json, sys
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("regfile")
|
||||
args = parser.parse_args()
|
||||
|
||||
data = json.load(open(args.regfile))
|
||||
for reg in data:
|
||||
name = reg['name']
|
||||
|
||||
if name[-4:-1] == "_EL":
|
||||
name = name[:-4]
|
||||
|
||||
if not reg.get("fieldsets", []):
|
||||
continue
|
||||
|
||||
print(f"# {reg['name']}")
|
||||
print(f"class {name}(Register64):")
|
||||
|
||||
for fieldset in reg.get("fieldsets", []):
|
||||
if "instance" in fieldset:
|
||||
print(f"# {fieldset['instance']}")
|
||||
for f in fieldset["fields"]:
|
||||
fname = f["name"]
|
||||
msb, lsb = f["msb"], f["lsb"]
|
||||
|
||||
if msb == lsb:
|
||||
print(f" {fname} = {lsb}")
|
||||
else:
|
||||
print(f" {fname} {msb}, {lsb}")
|
||||
|
||||
print()
|
Loading…
Reference in a new issue