[otbn] Move Python library code into a shared/ directory
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/util/Makefile b/hw/ip/otbn/util/Makefile
index e5805d4..27ec52a 100644
--- a/hw/ip/otbn/util/Makefile
+++ b/hw/ip/otbn/util/Makefile
@@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
-pylibs := insn_yaml.py mem_layout.py
+pylibs := shared/insn_yaml.py shared/mem_layout.py
pyscripts := yaml_to_doc.py otbn-as otbn-ld otbn-objdump
.PHONY: all
diff --git a/hw/ip/otbn/util/otbn-as b/hw/ip/otbn/util/otbn-as
index 9b2be5a..23e8117 100755
--- a/hw/ip/otbn/util/otbn-as
+++ b/hw/ip/otbn/util/otbn-as
@@ -24,8 +24,8 @@
import tempfile
from typing import Dict, List, Optional, Set, TextIO, Tuple
-from insn_yaml import (BitRanges, Encoding, Insn, InsnsFile, Operand,
- RegOperandType, load_file)
+from shared.insn_yaml import (BitRanges, Encoding, Insn, InsnsFile, Operand,
+ RegOperandType, load_file)
class RVFmt:
diff --git a/hw/ip/otbn/util/otbn-ld b/hw/ip/otbn/util/otbn-ld
index 91e32ec..0d8c382 100755
--- a/hw/ip/otbn/util/otbn-ld
+++ b/hw/ip/otbn/util/otbn-ld
@@ -16,11 +16,11 @@
from mako.template import Template # type: ignore
from mako import exceptions # type: ignore
-import mem_layout
+from shared.mem_layout import get_memory_layout
def interpolate_linker_script(in_path: str, out_path: str) -> None:
- mems = mem_layout.get_memory_layout()
+ mems = get_memory_layout()
try:
template = Template(filename=in_path)
diff --git a/hw/ip/otbn/util/otbn-objdump b/hw/ip/otbn/util/otbn-objdump
index 49d326d..0cc2ac4 100755
--- a/hw/ip/otbn/util/otbn-objdump
+++ b/hw/ip/otbn/util/otbn-objdump
@@ -11,7 +11,7 @@
import sys
from typing import Dict, List, Optional, Tuple
-from insn_yaml import Encoding, Insn, InsnsFile, load_file
+from shared.insn_yaml import Encoding, Insn, InsnsFile, load_file
def snoop_disasm_flags(argv: List[str]) -> bool:
diff --git a/hw/ip/otbn/util/__init__.py b/hw/ip/otbn/util/shared/__init__.py
similarity index 100%
rename from hw/ip/otbn/util/__init__.py
rename to hw/ip/otbn/util/shared/__init__.py
diff --git a/hw/ip/otbn/util/insn_yaml.py b/hw/ip/otbn/util/shared/insn_yaml.py
similarity index 100%
rename from hw/ip/otbn/util/insn_yaml.py
rename to hw/ip/otbn/util/shared/insn_yaml.py
diff --git a/hw/ip/otbn/util/mem_layout.py b/hw/ip/otbn/util/shared/mem_layout.py
similarity index 97%
rename from hw/ip/otbn/util/mem_layout.py
rename to hw/ip/otbn/util/shared/mem_layout.py
index 2a023f7..577168b 100644
--- a/hw/ip/otbn/util/mem_layout.py
+++ b/hw/ip/otbn/util/shared/mem_layout.py
@@ -30,7 +30,7 @@
_OLD_SYS_PATH = sys.path
try:
_UTIL_PATH = os.path.join(os.path.dirname(__file__),
- '..', '..', '..', '..', 'util')
+ '..', '..', '..', '..', '..', 'util')
sys.path = [_UTIL_PATH] + _OLD_SYS_PATH
from reggen.validate import checking_dict, validate # type: ignore
finally:
@@ -118,7 +118,7 @@
'''
hjson_path = os.path.join(os.path.dirname(__file__),
- '..', 'data', 'otbn.hjson')
+ '..', '..', 'data', 'otbn.hjson')
reg_byte_width, registers = load_registers(hjson_path)
windows = extract_windows(reg_byte_width, registers)
diff --git a/hw/ip/otbn/util/yaml_to_doc.py b/hw/ip/otbn/util/yaml_to_doc.py
index 9f163e3..30d815a 100755
--- a/hw/ip/otbn/util/yaml_to_doc.py
+++ b/hw/ip/otbn/util/yaml_to_doc.py
@@ -9,8 +9,8 @@
import sys
from typing import List
-from insn_yaml import (BoolLiteral, Encoding, Insn, InsnsFile, Operand,
- load_file)
+from shared.insn_yaml import (BoolLiteral, Encoding, Insn, InsnsFile, Operand,
+ load_file)
def render_operand_row(operand: Operand) -> str: