Internals: Add more python strict typing. No functional change intended
This commit is contained in:
parent
5847b105a5
commit
782fe1daf2
13
Makefile.in
13
Makefile.in
|
|
@ -551,6 +551,9 @@ format-make:
|
||||||
|
|
||||||
format-yaml: yamlfix
|
format-yaml: yamlfix
|
||||||
|
|
||||||
|
MYPY = mypy
|
||||||
|
MYPY_FLAGS = --strict --no-error-summary
|
||||||
|
|
||||||
PYLINT = pylint
|
PYLINT = pylint
|
||||||
PYLINT_FLAGS = --recursive=n --score=n --disable=R0801
|
PYLINT_FLAGS = --recursive=n --score=n --disable=R0801
|
||||||
PYLINT_TEST_FLAGS = $(PYLINT_FLAGS) --disable=C0103,C0114,C0116,C0209,C0411,C0413,C0301,R0801,R0912,R0915,R0916,R1702,W0511,W0621
|
PYLINT_TEST_FLAGS = $(PYLINT_FLAGS) --disable=C0103,C0114,C0116,C0209,C0411,C0413,C0301,R0801,R0912,R0915,R0916,R1702,W0511,W0621
|
||||||
|
|
@ -562,6 +565,16 @@ RUFF_FLAGS = check --ignore=E402,E501,E701
|
||||||
lint-py:
|
lint-py:
|
||||||
$(MAKE) -k lint-py-pylint lint-py-pylint-tests lint-py-ruff
|
$(MAKE) -k lint-py-pylint lint-py-pylint-tests lint-py-ruff
|
||||||
|
|
||||||
|
lint-py-mypy:
|
||||||
|
for filename in `fgrep -l '# mypy' $(PY_PROGRAMS)`; do \
|
||||||
|
echo "$(MYPY) $(MYPY_FLAGS) $$filename" ; \
|
||||||
|
$(MYPY) $(MYPY_FLAGS) $$filename ; \
|
||||||
|
done
|
||||||
|
@echo "Not mypy checked: " `fgrep -L '# mypy' $(PY_PROGRAMS)`
|
||||||
|
|
||||||
|
lint-py-mypy-none:
|
||||||
|
@echo "mypy not checking: " `fgrep -L '# mypy' $(PY_PROGRAMS)`
|
||||||
|
|
||||||
lint-py-pylint:
|
lint-py-pylint:
|
||||||
$(PYLINT) $(PYLINT_FLAGS) $(PY_PROGRAMS)
|
$(PYLINT) $(PYLINT_FLAGS) $(PY_PROGRAMS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0115,C0116,C0123,C0209,C0301,R0902,R0913,R0914,R0912,R0915,W0621
|
# pylint: disable=C0103,C0114,C0115,C0116,C0123,C0209,C0301,R0902,R0913,R0914,R0912,R0915,W0621
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -36,7 +37,7 @@ results = {}
|
||||||
elapsed = {}
|
elapsed = {}
|
||||||
|
|
||||||
|
|
||||||
def toDateTime(s):
|
def toDateTime(s: str) -> datetime:
|
||||||
return datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.%f")
|
return datetime.strptime(s, "%Y-%m-%dT%H:%M:%S.%f")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,6 +54,7 @@ for logfile in args.logdir.iterdir():
|
||||||
match = re.match(r'\[(\S+)\s.*Result: (.*)$', line)
|
match = re.match(r'\[(\S+)\s.*Result: (.*)$', line)
|
||||||
if match:
|
if match:
|
||||||
assert obj is not None
|
assert obj is not None
|
||||||
|
assert start is not None
|
||||||
elapsed[obj] = toDateTime(match.group(1)) - start
|
elapsed[obj] = toDateTime(match.group(1)) - start
|
||||||
results[obj] = match.group(2)
|
results[obj] = match.group(2)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0116,C0209,W0603
|
# pylint: disable=C0103,C0114,C0116,C0209,W0603
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ import sys
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
|
|
||||||
|
|
||||||
def diff(a, b):
|
def diff(a: str, b: str) -> None:
|
||||||
if not os.path.exists(a):
|
if not os.path.exists(a):
|
||||||
sys.stderr.write("%Error: No old diff filename found: " + a + "\n")
|
sys.stderr.write("%Error: No old diff filename found: " + a + "\n")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
@ -29,9 +30,9 @@ def diff(a, b):
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
def diff_dir(a, b):
|
def diff_dir(a: str, b: str) -> None:
|
||||||
# Diff all files under two directories
|
# Diff all files under two directories
|
||||||
files = collections.defaultdict(lambda: {})
|
files: dict[str, dict[str, str]] = collections.defaultdict(lambda: {})
|
||||||
|
|
||||||
for fn in glob.glob(a + "/*.tree"):
|
for fn in glob.glob(a + "/*.tree"):
|
||||||
base = re.sub(r'.*/', '', fn)
|
base = re.sub(r'.*/', '', fn)
|
||||||
|
|
@ -54,7 +55,7 @@ def diff_dir(a, b):
|
||||||
sys.stderr.write("%Warning: No .tree files found that have similar base names\n")
|
sys.stderr.write("%Warning: No .tree files found that have similar base names\n")
|
||||||
|
|
||||||
|
|
||||||
def diff_file(a, b):
|
def diff_file(a: str, b: str) -> None:
|
||||||
global exit_code
|
global exit_code
|
||||||
|
|
||||||
# Compare the two tree files
|
# Compare the two tree files
|
||||||
|
|
@ -82,20 +83,7 @@ def diff_file(a, b):
|
||||||
exit_code = 2
|
exit_code = 2
|
||||||
|
|
||||||
|
|
||||||
def version_from(filename):
|
def filterf(fn1: str, fn2: str) -> None:
|
||||||
# Return dump format
|
|
||||||
with open(filename, "r", encoding="utf8") as fh:
|
|
||||||
lineno = 0
|
|
||||||
for line in fh:
|
|
||||||
if lineno > 10:
|
|
||||||
break
|
|
||||||
match = re.search(r'format (0x[0-9.]+)', line)
|
|
||||||
if match:
|
|
||||||
return hex(match.group(1))
|
|
||||||
return 1.0
|
|
||||||
|
|
||||||
|
|
||||||
def filterf(fn1, fn2):
|
|
||||||
# Remove hex numbers before diffing
|
# Remove hex numbers before diffing
|
||||||
with open(fn1, "r", encoding="utf8") as fh1:
|
with open(fn1, "r", encoding="utf8") as fh1:
|
||||||
with open(fn2, "w", encoding="utf8") as fh2:
|
with open(fn2, "w", encoding="utf8") as fh2:
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ ThreadScheduleWaitIntervals = [] # list of (start, tick, ecpu) pairs
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def read_data(filename):
|
def read_data(filename: str) -> None:
|
||||||
with open(filename, "r", encoding="utf8") as fh:
|
with open(filename, "r", encoding="utf8") as fh:
|
||||||
re_thread = re.compile(r'^VLPROFTHREAD (\d+)$')
|
re_thread = re.compile(r'^VLPROFTHREAD (\d+)$')
|
||||||
re_record = re.compile(r'^VLPROFEXEC (\S+) (\d+)(.*)$')
|
re_record = re.compile(r'^VLPROFEXEC (\S+) (\d+)(.*)$')
|
||||||
|
|
@ -171,7 +171,7 @@ def re_match_result(regexp, line, result_to):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def report():
|
def report() -> None:
|
||||||
print("Verilator Gantt report")
|
print("Verilator Gantt report")
|
||||||
|
|
||||||
print("\nArgument settings:")
|
print("\nArgument settings:")
|
||||||
|
|
@ -220,12 +220,12 @@ def report():
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
def report_numa():
|
def report_numa() -> None:
|
||||||
print("\nNUMA assignment:")
|
print("\nNUMA assignment:")
|
||||||
print(" NUMA status = %s" % Global['info']['numa'])
|
print(" NUMA status = %s" % Global['info']['numa'])
|
||||||
|
|
||||||
|
|
||||||
def report_mtasks():
|
def report_mtasks() -> None:
|
||||||
if not Mtasks:
|
if not Mtasks:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -342,7 +342,7 @@ def report_mtasks():
|
||||||
print(" e ^ stddev = %0.3f" % math.exp(stddev))
|
print(" e ^ stddev = %0.3f" % math.exp(stddev))
|
||||||
|
|
||||||
|
|
||||||
def report_cpus():
|
def report_cpus() -> None:
|
||||||
print("\nCPU info:")
|
print("\nCPU info:")
|
||||||
|
|
||||||
Global['cpu_sockets'] = collections.defaultdict(lambda: 0)
|
Global['cpu_sockets'] = collections.defaultdict(lambda: 0)
|
||||||
|
|
@ -377,14 +377,14 @@ def report_cpus():
|
||||||
Global['cpu_socket_cores_warning'] = True
|
Global['cpu_socket_cores_warning'] = True
|
||||||
|
|
||||||
|
|
||||||
def report_sections():
|
def report_sections() -> None:
|
||||||
for thread, section in Sections.items():
|
for thread, section in Sections.items():
|
||||||
if section:
|
if section:
|
||||||
print(f"\nSection profile for thread {thread}:")
|
print(f"\nSection profile for thread {thread}:")
|
||||||
report_section(section)
|
report_section(section)
|
||||||
|
|
||||||
|
|
||||||
def report_section(section):
|
def report_section(section) -> None:
|
||||||
totalTime = collections.defaultdict(lambda: 0)
|
totalTime = collections.defaultdict(lambda: 0)
|
||||||
selfTime = collections.defaultdict(lambda: 0)
|
selfTime = collections.defaultdict(lambda: 0)
|
||||||
|
|
||||||
|
|
@ -436,7 +436,7 @@ def report_section(section):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def write_vcd(filename):
|
def write_vcd(filename: str) -> None:
|
||||||
print("Writing %s" % filename)
|
print("Writing %s" % filename)
|
||||||
with open(filename, "w", encoding="utf8") as fh:
|
with open(filename, "w", encoding="utf8") as fh:
|
||||||
# dict of dicts of hierarchy elements/signal name -> (code, width)
|
# dict of dicts of hierarchy elements/signal name -> (code, width)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0114,C0209
|
# pylint: disable=C0114,C0209
|
||||||
#
|
#
|
||||||
# Copyright 2003-2025 by Wilson Snyder. This program is free software; you
|
# Copyright 2003-2025 by Wilson Snyder. This program is free software; you
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import re
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def profcfunc(filename):
|
def profcfunc(filename: str) -> None:
|
||||||
funcs = {}
|
funcs = {}
|
||||||
|
|
||||||
with open(filename, "r", encoding="utf8") as fh:
|
with open(filename, "r", encoding="utf8") as fh:
|
||||||
|
|
@ -26,7 +26,7 @@ def profcfunc(filename):
|
||||||
calls = float(match.group(3))
|
calls = float(match.group(3))
|
||||||
func = match.group(4)
|
func = match.group(4)
|
||||||
if func not in funcs:
|
if func not in funcs:
|
||||||
funcs[func] = {'pct': 0, 'sec': 0, 'calls': 0}
|
funcs[func] = {'pct': 0.0, 'sec': 0.0, 'calls': 0}
|
||||||
funcs[func]['pct'] += pct
|
funcs[func]['pct'] += pct
|
||||||
funcs[func]['sec'] += sec
|
funcs[func]['sec'] += sec
|
||||||
funcs[func]['calls'] += calls
|
funcs[func]['calls'] += calls
|
||||||
|
|
@ -150,7 +150,7 @@ def profcfunc(filename):
|
||||||
print((" time seconds seconds calls %-" + str(design_width) +
|
print((" time seconds seconds calls %-" + str(design_width) +
|
||||||
"s type filename and line number") % "design")
|
"s type filename and line number") % "design")
|
||||||
|
|
||||||
cume = 0
|
cume = 0.0
|
||||||
for func in sorted(vfuncs.keys(), key=lambda f: vfuncs[f]['sec'], reverse=True):
|
for func in sorted(vfuncs.keys(), key=lambda f: vfuncs[f]['sec'], reverse=True):
|
||||||
cume += vfuncs[func]['sec']
|
cume += vfuncs[func]['sec']
|
||||||
print(("%6.2f %9.2f %8.2f %10d %-" + str(design_width) + "s %s") %
|
print(("%6.2f %9.2f %8.2f %10d %-" + str(design_width) + "s %s") %
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0112,C0114,C0115,C0116,C0209,C0301,R0903
|
# pylint: disable=C0112,C0114,C0115,C0116,C0209,C0301,R0903
|
||||||
# -*- Python -*- See copyright, etc below
|
# -*- Python -*- See copyright, etc below
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -11,9 +12,8 @@ import re
|
||||||
|
|
||||||
class VlSphinxExtract:
|
class VlSphinxExtract:
|
||||||
debug = 0
|
debug = 0
|
||||||
SkipBasenames = {}
|
|
||||||
|
|
||||||
def process(self, filename):
|
def process(self, filename: str) -> None:
|
||||||
with open(filename, "r", encoding="utf8") as fhr:
|
with open(filename, "r", encoding="utf8") as fhr:
|
||||||
fhw = None
|
fhw = None
|
||||||
for line in fhr:
|
for line in fhr:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0112,C0114,C0115,C0116,C0209,C0301,R0903
|
# pylint: disable=C0112,C0114,C0115,C0116,C0209,C0301,R0903
|
||||||
# -*- Python -*- See copyright, etc below
|
# -*- Python -*- See copyright, etc below
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
@ -12,19 +13,17 @@ import re
|
||||||
|
|
||||||
class VlSphinxFix:
|
class VlSphinxFix:
|
||||||
debug = 0
|
debug = 0
|
||||||
SkipBasenames = {}
|
|
||||||
|
|
||||||
def process(self, path):
|
def process(self, path: str) -> None:
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
for basefile in os.listdir(path):
|
for basefile in os.listdir(path):
|
||||||
file = os.path.join(path, basefile)
|
file = os.path.join(path, basefile)
|
||||||
if ((basefile != ".") and (basefile != "..") and basefile not in self.SkipBasenames
|
if ((basefile != ".") and (basefile != "..") and not os.path.islink(file)):
|
||||||
and not os.path.islink(file)):
|
|
||||||
self.process(file)
|
self.process(file)
|
||||||
elif re.search(r'\.(html|tex)$', path):
|
elif re.search(r'\.(html|tex)$', path):
|
||||||
self._edit(path)
|
self._edit(path)
|
||||||
|
|
||||||
def _edit(self, filename):
|
def _edit(self, filename: str) -> None:
|
||||||
is_html = re.search(r'\.(html)$', filename)
|
is_html = re.search(r'\.(html)$', filename)
|
||||||
with open(filename, "r", encoding="utf8") as fhr:
|
with open(filename, "r", encoding="utf8") as fhr:
|
||||||
origfile = fhr.read()
|
origfile = fhr.read()
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ Those developing Verilator itself also need these (see internals.rst):
|
||||||
sudo apt-get install python3-clang python3-distro pipx yapf3 bear jq
|
sudo apt-get install python3-clang python3-distro pipx yapf3 bear jq
|
||||||
python3 -m venv --system-site-packages ~/.verilator_pyenv
|
python3 -m venv --system-site-packages ~/.verilator_pyenv
|
||||||
source ~/.verilator_pyenv/bin/activate
|
source ~/.verilator_pyenv/bin/activate
|
||||||
pip3 install sphinx sphinx_rtd_theme sphinxcontrib-spelling breathe gersemi mbake ruff
|
pip3 install sphinx sphinx_rtd_theme sphinxcontrib-spelling breathe gersemi mbake mypy ruff
|
||||||
pip3 install git+https://github.com/antmicro/astsee.git
|
pip3 install git+https://github.com/antmicro/astsee.git
|
||||||
pipx install sarif-tools
|
pipx install sarif-tools
|
||||||
cpan install Pod::Perldoc
|
cpan install Pod::Perldoc
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0115,C0116,C0209,C0301
|
# pylint: disable=C0103,C0114,C0115,C0116,C0209,C0301
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ Edges = []
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
|
||||||
def dotread(filename):
|
def dotread(filename: str) -> None:
|
||||||
with open(filename, "r", encoding="utf8") as fh:
|
with open(filename, "r", encoding="utf8") as fh:
|
||||||
header = True
|
header = True
|
||||||
vnum = 0
|
vnum = 0
|
||||||
|
|
@ -55,7 +56,7 @@ def dotread(filename):
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
|
||||||
def cwrite(filename):
|
def cwrite(filename: str) -> None:
|
||||||
with open(filename, "w", encoding="utf8") as fh:
|
with open(filename, "w", encoding="utf8") as fh:
|
||||||
fh.write("void V3GraphTestImport::dotImport() {\n")
|
fh.write("void V3GraphTestImport::dotImport() {\n")
|
||||||
fh.write(" auto* gp = &m_graph;\n")
|
fh.write(" auto* gp = &m_graph;\n")
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0115,C0116,C0321,R0911
|
# pylint: disable=C0103,C0114,C0115,C0116,C0321,R0911
|
||||||
######################################################################
|
######################################################################
|
||||||
# DESCRIPTION: Fuzzer result checker
|
# DESCRIPTION: Fuzzer result checker
|
||||||
|
|
@ -18,25 +19,25 @@ from subprocess import getstatusoutput
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
|
||||||
def interesting(s):
|
def interesting(s: str) -> bool:
|
||||||
if 'assert' in s:
|
if 'assert' in s:
|
||||||
return 1
|
return True
|
||||||
if 'Assert' in s:
|
if 'Assert' in s:
|
||||||
return 1
|
return True
|
||||||
if 'Aborted' in s:
|
if 'Aborted' in s:
|
||||||
return 1
|
return True
|
||||||
if 'terminate' in s:
|
if 'terminate' in s:
|
||||||
if 'unterminated' in s:
|
if 'unterminated' in s:
|
||||||
return 0
|
return False
|
||||||
return 1
|
return True
|
||||||
if 'Segmentation' in s:
|
if 'Segmentation' in s:
|
||||||
return 1
|
return True
|
||||||
if 'internal error' in s:
|
if 'internal error' in s:
|
||||||
return 1
|
return True
|
||||||
return 0
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main() -> None:
|
||||||
p = ArgumentParser()
|
p = ArgumentParser()
|
||||||
p.add_argument('--dir', default='out1/queue')
|
p.add_argument('--dir', default='out1/queue')
|
||||||
args = p.parse_args()
|
args = p.parse_args()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0115,C0116,C0209,R0801,R0915
|
# pylint: disable=C0103,C0114,C0115,C0116,C0209,R0801,R0915
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ import sys
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test() -> None:
|
||||||
if not os.path.exists("nodist/install_test"):
|
if not os.path.exists("nodist/install_test"):
|
||||||
sys.exit("%Error: Run from the top of the verilator kit")
|
sys.exit("%Error: Run from the top of the verilator kit")
|
||||||
|
|
||||||
|
|
@ -80,30 +81,30 @@ def test():
|
||||||
print("*-* All Finished *-*")
|
print("*-* All Finished *-*")
|
||||||
|
|
||||||
|
|
||||||
def write_verilog(odir):
|
def write_verilog(odir: str) -> None:
|
||||||
shutil.copy2("examples/make_hello_c/top.v", odir + "/top.v")
|
shutil.copy2("examples/make_hello_c/top.v", odir + "/top.v")
|
||||||
shutil.copy2("examples/make_hello_c/sim_main.cpp", odir + "/sim_main.cpp")
|
shutil.copy2("examples/make_hello_c/sim_main.cpp", odir + "/sim_main.cpp")
|
||||||
|
|
||||||
|
|
||||||
def cleanenv():
|
def cleanenv() -> None:
|
||||||
for var in os.environ:
|
for var in os.environ:
|
||||||
if var in ('VERILATOR_ROOT', 'VERILATOR_INCLUDE', 'VERILATOR_NO_OPT_BUILD'):
|
if var in ('VERILATOR_ROOT', 'VERILATOR_INCLUDE', 'VERILATOR_NO_OPT_BUILD'):
|
||||||
print("unset %s # Was '%s'" % (var, os.environ[var]))
|
print("unset %s # Was '%s'" % (var, os.environ[var]))
|
||||||
del os.environ[var]
|
del os.environ[var]
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_count():
|
def get_cpu_count() -> int:
|
||||||
try:
|
try:
|
||||||
return len(os.sched_getaffinity(0))
|
return len(os.sched_getaffinity(0))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return multiprocessing.cpu_count()
|
return multiprocessing.cpu_count()
|
||||||
|
|
||||||
|
|
||||||
def calc_jobs():
|
def calc_jobs() -> int:
|
||||||
return get_cpu_count() + 1
|
return get_cpu_count() + 1
|
||||||
|
|
||||||
|
|
||||||
def run(command):
|
def run(command: str) -> None:
|
||||||
# run a system command, check errors
|
# run a system command, check errors
|
||||||
print("\t%s" % command)
|
print("\t%s" % command)
|
||||||
os.system(command)
|
os.system(command)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=
|
# pylint: disable=
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -17,7 +18,7 @@ SUPPRESSES = [
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def process():
|
def process() -> None:
|
||||||
anymsg = False
|
anymsg = False
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
line = line.rstrip();
|
line = line.rstrip();
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0114,C0116,C0209,R0911,R0912,R0915
|
# pylint: disable=C0114,C0116,C0209,R0911,R0912,R0915
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -10,7 +11,7 @@ import re
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
|
|
||||||
def message_section(msg):
|
def message_section(msg: str) -> int:
|
||||||
"""Return sorting-section number for given commit message"""
|
"""Return sorting-section number for given commit message"""
|
||||||
if re.match(r'^Support', msg):
|
if re.match(r'^Support', msg):
|
||||||
return 10
|
return 10
|
||||||
|
|
@ -27,7 +28,7 @@ def message_section(msg):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def process():
|
def process() -> None:
|
||||||
cmd = "git log"
|
cmd = "git log"
|
||||||
|
|
||||||
msgs = {}
|
msgs = {}
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ SIGNAL_TYPE = "SIGNAL"
|
||||||
EOF_ERROR = "Unexpected EOF"
|
EOF_ERROR = "Unexpected EOF"
|
||||||
|
|
||||||
|
|
||||||
def saif_assert(expression, message):
|
def saif_assert(expression : bool, message : str) -> None:
|
||||||
if not expression:
|
if not expression:
|
||||||
raise Exception(message)
|
raise Exception(message)
|
||||||
|
|
||||||
|
|
||||||
def saif_error(message):
|
def saif_error(message : str) -> None:
|
||||||
raise Exception(message)
|
raise Exception(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ class SAIFSignalBit:
|
||||||
low_time: int
|
low_time: int
|
||||||
transitions: int
|
transitions: int
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name : str):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.high_time = 0
|
self.high_time = 0
|
||||||
self.low_time = 0
|
self.low_time = 0
|
||||||
|
|
@ -43,7 +43,7 @@ class SAIFSignalBit:
|
||||||
|
|
||||||
class SAIFInstance:
|
class SAIFInstance:
|
||||||
|
|
||||||
def __init__(self, scope_name):
|
def __init__(self, scope_name : str):
|
||||||
self.scope_name = scope_name
|
self.scope_name = scope_name
|
||||||
self.parent_instance = None
|
self.parent_instance = None
|
||||||
self.nets = {}
|
self.nets = {}
|
||||||
|
|
@ -52,7 +52,7 @@ class SAIFInstance:
|
||||||
|
|
||||||
class SAIFToken:
|
class SAIFToken:
|
||||||
|
|
||||||
def __init__(self, token):
|
def __init__(self, token : str):
|
||||||
self.token = token
|
self.token = token
|
||||||
self.type = ''
|
self.type = ''
|
||||||
self.value = ''
|
self.value = ''
|
||||||
|
|
@ -69,11 +69,11 @@ class SAIFParser:
|
||||||
self.direction = ''
|
self.direction = ''
|
||||||
self.saif_version = ''
|
self.saif_version = ''
|
||||||
self.top_instances = {}
|
self.top_instances = {}
|
||||||
self.duration = 0
|
self.duration = ''
|
||||||
self.divider = ''
|
self.divider = ''
|
||||||
self.timescale = ''
|
self.timescale = ''
|
||||||
|
|
||||||
def parse(self, saif_filename):
|
def parse(self, saif_filename : str) -> None:
|
||||||
file_contents = ''
|
file_contents = ''
|
||||||
with open(saif_filename, 'r', encoding="utf8") as saif_file:
|
with open(saif_filename, 'r', encoding="utf8") as saif_file:
|
||||||
content = saif_file.readlines()
|
content = saif_file.readlines()
|
||||||
|
|
@ -180,7 +180,7 @@ class SAIFParser:
|
||||||
saif_assert(len(self.token_stack) == 1, "Incorrect nesting of scopes")
|
saif_assert(len(self.token_stack) == 1, "Incorrect nesting of scopes")
|
||||||
|
|
||||||
|
|
||||||
def compare_saif_instances(first: SAIFInstance, second: SAIFInstance):
|
def compare_saif_instances(first: SAIFInstance, second: SAIFInstance) -> None:
|
||||||
if len(first.nets) != len(second.nets):
|
if len(first.nets) != len(second.nets):
|
||||||
saif_error(f"Number of nets doesn't match in {first.scope_name}: "
|
saif_error(f"Number of nets doesn't match in {first.scope_name}: "
|
||||||
f"{len(first.nets)} != {len(second.nets)}")
|
f"{len(first.nets)} != {len(second.nets)}")
|
||||||
|
|
@ -202,7 +202,7 @@ def compare_saif_instances(first: SAIFInstance, second: SAIFInstance):
|
||||||
compare_saif_instances(instance, second.child_instances[instance_name])
|
compare_saif_instances(instance, second.child_instances[instance_name])
|
||||||
|
|
||||||
|
|
||||||
def compare_saif_contents(first_file: str, second_file: str):
|
def compare_saif_contents(first_file: str, second_file: str) -> int:
|
||||||
"""Test if second SAIF file has the same values as the first"""
|
"""Test if second SAIF file has the same values as the first"""
|
||||||
first_saif = SAIFParser()
|
first_saif = SAIFParser()
|
||||||
first_saif.parse(first_file)
|
first_saif.parse(first_file)
|
||||||
|
|
|
||||||
53
src/bisonpre
53
src/bisonpre
|
|
@ -11,10 +11,10 @@ import sys
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
Bison_Version = None
|
Bison_Version = 0.0
|
||||||
|
|
||||||
|
|
||||||
def process():
|
def process() -> None:
|
||||||
unlink_outputs()
|
unlink_outputs()
|
||||||
|
|
||||||
supports_report = Bison_Version >= 2.3
|
supports_report = Bison_Version >= 2.3
|
||||||
|
|
@ -56,43 +56,43 @@ def process():
|
||||||
unlink_tmp()
|
unlink_tmp()
|
||||||
|
|
||||||
|
|
||||||
def tmp_prefix():
|
def tmp_prefix() -> str:
|
||||||
return output_prefix() + "_pretmp"
|
return output_prefix() + "_pretmp"
|
||||||
|
|
||||||
|
|
||||||
def output_prefix():
|
def output_prefix() -> str:
|
||||||
if Args.output:
|
if Args.output:
|
||||||
o = re.sub(r'\.[^.]*$', '', Args.output)
|
o = re.sub(r'\.[^.]*$', '', Args.output)
|
||||||
return o
|
return o
|
||||||
return Args.file_prefix + ".tab"
|
return str(Args.file_prefix) + ".tab"
|
||||||
|
|
||||||
|
|
||||||
def unlink_ok(filename):
|
def unlink_ok(filename: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.unlink(filename)
|
os.unlink(filename)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def unlink_tmp():
|
def unlink_tmp() -> None:
|
||||||
unlink_ok(tmp_prefix() + ".c")
|
unlink_ok(tmp_prefix() + ".c")
|
||||||
unlink_ok(tmp_prefix() + ".h")
|
unlink_ok(tmp_prefix() + ".h")
|
||||||
unlink_ok(tmp_prefix() + ".output")
|
unlink_ok(tmp_prefix() + ".output")
|
||||||
|
|
||||||
|
|
||||||
def unlink_outputs():
|
def unlink_outputs() -> None:
|
||||||
unlink_tmp()
|
unlink_tmp()
|
||||||
unlink_ok(output_prefix() + ".c")
|
unlink_ok(output_prefix() + ".c")
|
||||||
unlink_ok(output_prefix() + ".h")
|
unlink_ok(output_prefix() + ".h")
|
||||||
# We don't remove .output file, as it's useful for debugging errors
|
# We don't remove .output file, as it's useful for debugging errors
|
||||||
|
|
||||||
|
|
||||||
def bison_version_check():
|
def bison_version_check() -> float:
|
||||||
with subprocess.Popen([Args.yacc, "--version"], stdout=subprocess.PIPE) as sp:
|
with subprocess.Popen([Args.yacc, "--version"], stdout=subprocess.PIPE) as sp:
|
||||||
out = str(sp.stdout.read())
|
out = str(sp.stdout.read())
|
||||||
match = re.search(r'([0-9]+\.[0-9]+)', out)
|
m = re.search(r'([0-9]+\.[0-9]+)', out)
|
||||||
if match:
|
if m:
|
||||||
v = float(match.group(1))
|
v = float(m.group(1))
|
||||||
if v < 1.875:
|
if v < 1.875:
|
||||||
sys.exit("bisonpre: %Error: '" + Args.yacc + "' is version " + v +
|
sys.exit("bisonpre: %Error: '" + Args.yacc + "' is version " + v +
|
||||||
"; version 1.875 or newer is required\n")
|
"; version 1.875 or newer is required\n")
|
||||||
|
|
@ -101,14 +101,14 @@ def bison_version_check():
|
||||||
sys.exit("bisonpre: %Error: '" + Args.yacc + "' is not installed, or not working\n")
|
sys.exit("bisonpre: %Error: '" + Args.yacc + "' is not installed, or not working\n")
|
||||||
|
|
||||||
|
|
||||||
def clean_output(filename, outname, is_output, is_c):
|
def clean_output(filename: str, outname: str, is_output: bool, is_c: bool) -> None:
|
||||||
print(" edit " + filename + " " + outname)
|
print(" edit " + filename + " " + outname)
|
||||||
|
|
||||||
with open(filename, "r", encoding="utf-8") as fh:
|
with open(filename, "r", encoding="utf-8") as fh:
|
||||||
lines = fh.readlines()
|
lines = fh.readlines()
|
||||||
|
|
||||||
if is_output:
|
if is_output:
|
||||||
state_line = {}
|
state_line: dict[str, int] = {}
|
||||||
lineno = 0
|
lineno = 0
|
||||||
for line in lines:
|
for line in lines:
|
||||||
lineno += 1
|
lineno += 1
|
||||||
|
|
@ -122,14 +122,14 @@ def clean_output(filename, outname, is_output, is_c):
|
||||||
if match:
|
if match:
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
if match.group(1) in state_line:
|
if match.group(1) in state_line:
|
||||||
line += " // line " + state_line[match.group(1)]
|
line += " // line " + str(state_line[match.group(1)])
|
||||||
line += "\n"
|
line += "\n"
|
||||||
out.append(line)
|
out.append(line)
|
||||||
lines = out
|
lines = out
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
if is_c:
|
if is_c:
|
||||||
token_values = {}
|
token_values: dict[str, str] = {}
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if re.search(r'enum\s+yytokentype', line) and not re.search(r';', line):
|
if re.search(r'enum\s+yytokentype', line) and not re.search(r';', line):
|
||||||
match = re.search(r'\b(\S+) = (\d+)', line)
|
match = re.search(r'\b(\S+) = (\d+)', line)
|
||||||
|
|
@ -165,7 +165,7 @@ def clean_output(filename, outname, is_output, is_c):
|
||||||
fh.write(line)
|
fh.write(line)
|
||||||
|
|
||||||
|
|
||||||
def warning_check(filename):
|
def warning_check(filename: str) -> None:
|
||||||
with open(filename, "r", encoding="utf-8") as fh:
|
with open(filename, "r", encoding="utf-8") as fh:
|
||||||
linenum = 0
|
linenum = 0
|
||||||
for line in fh:
|
for line in fh:
|
||||||
|
|
@ -177,12 +177,9 @@ def warning_check(filename):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def clean_input(filename, outname):
|
def clean_input(filename: str, outname: str) -> None:
|
||||||
print(" edit " + filename + " " + outname)
|
print(" edit " + filename + " " + outname)
|
||||||
|
|
||||||
global Filename # pylint: disable=global-variable-undefined
|
|
||||||
Filename = filename
|
|
||||||
|
|
||||||
with open(filename, "r", encoding="utf-8") as fh:
|
with open(filename, "r", encoding="utf-8") as fh:
|
||||||
lines = fh.readlines()
|
lines = fh.readlines()
|
||||||
|
|
||||||
|
|
@ -191,7 +188,7 @@ def clean_input(filename, outname):
|
||||||
global Rules # pylint: disable=global-variable-undefined
|
global Rules # pylint: disable=global-variable-undefined
|
||||||
Rules = {}
|
Rules = {}
|
||||||
|
|
||||||
types = {}
|
types: dict[str, dict[str, int]] = {}
|
||||||
tokens = {}
|
tokens = {}
|
||||||
last_rule = None
|
last_rule = None
|
||||||
section = 1
|
section = 1
|
||||||
|
|
@ -344,7 +341,7 @@ def clean_input(filename, outname):
|
||||||
for line in linesin:
|
for line in linesin:
|
||||||
lineno += 1
|
lineno += 1
|
||||||
if _enaline(line) and re.search(r'BISONPRE_COPY', line):
|
if _enaline(line) and re.search(r'BISONPRE_COPY', line):
|
||||||
line = _bisonpre_copy(line, lineno, 0)
|
line = _bisonpre_copy(line, filename, lineno, 0)
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
|
|
||||||
# Replace ~[x]~ - must be after BISONPRE_COPY expansion
|
# Replace ~[x]~ - must be after BISONPRE_COPY expansion
|
||||||
|
|
@ -391,7 +388,7 @@ def clean_input(filename, outname):
|
||||||
fh.write(line)
|
fh.write(line)
|
||||||
|
|
||||||
|
|
||||||
def _bisonpre_copy(text, lineno, depth):
|
def _bisonpre_copy(text: str, filename: str, lineno: int, depth: int) -> str:
|
||||||
while re.search(r'BISONPRE_COPY', text):
|
while re.search(r'BISONPRE_COPY', text):
|
||||||
match = re.match(
|
match = re.match(
|
||||||
# 1 2 3 4 5
|
# 1 2 3 4 5
|
||||||
|
|
@ -399,14 +396,14 @@ def _bisonpre_copy(text, lineno, depth):
|
||||||
text,
|
text,
|
||||||
flags=re.DOTALL)
|
flags=re.DOTALL)
|
||||||
if not match:
|
if not match:
|
||||||
sys.exit("%Error: " + Filename + ":" + str(lineno) + ": Bad form of BISONPRE_NOT: " +
|
sys.exit("%Error: " + filename + ":" + str(lineno) + ": Bad form of BISONPRE_NOT: " +
|
||||||
text)
|
text)
|
||||||
text = match.group(1) + '{HERE}' + match.group(5)
|
text = match.group(1) + '{HERE}' + match.group(5)
|
||||||
once = match.group(2)
|
once = match.group(2)
|
||||||
rule = match.group(3)
|
rule = match.group(3)
|
||||||
code = match.group(4)
|
code = match.group(4)
|
||||||
if rule not in Rules:
|
if rule not in Rules:
|
||||||
sys.exit("%Error: " + Filename + ":" + str(lineno) +
|
sys.exit("%Error: " + filename + ":" + str(lineno) +
|
||||||
": Can't find definition for rule: " + rule)
|
": Can't find definition for rule: " + rule)
|
||||||
if depth > 0 and once:
|
if depth > 0 and once:
|
||||||
# _ONCE means don't inherit
|
# _ONCE means don't inherit
|
||||||
|
|
@ -422,7 +419,7 @@ def _bisonpre_copy(text, lineno, depth):
|
||||||
continue
|
continue
|
||||||
match = re.match(r'^\s*s/(.*?)/(.*?)/g\s*$', op)
|
match = re.match(r'^\s*s/(.*?)/(.*?)/g\s*$', op)
|
||||||
if not match:
|
if not match:
|
||||||
sys.exit("%Error: " + Filename + ":" + str(lineno) +
|
sys.exit("%Error: " + filename + ":" + str(lineno) +
|
||||||
": Didn't understand replacement: " + op)
|
": Didn't understand replacement: " + op)
|
||||||
left = match.group(1)
|
left = match.group(1)
|
||||||
right = match.group(2)
|
right = match.group(2)
|
||||||
|
|
@ -435,7 +432,7 @@ def _bisonpre_copy(text, lineno, depth):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def _enaline(line):
|
def _enaline(line: str) -> bool:
|
||||||
return not re.search(r'//UN', line)
|
return not re.search(r'//UN', line)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114
|
# pylint: disable=C0103,C0114
|
||||||
######################################################################
|
######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0114,C0301
|
# pylint: disable=C0114,C0301
|
||||||
######################################################################
|
######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114,C0116,C0209,eval-used
|
# pylint: disable=C0103,C0114,C0116,C0209,eval-used
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -12,7 +13,7 @@ Items = []
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def read_keys(filename):
|
def read_keys(filename: str) -> None:
|
||||||
with open(filename, "r", encoding="utf8") as fh:
|
with open(filename, "r", encoding="utf8") as fh:
|
||||||
for line in fh:
|
for line in fh:
|
||||||
line = re.sub(r'\/\/.*$', '', line)
|
line = re.sub(r'\/\/.*$', '', line)
|
||||||
|
|
@ -31,7 +32,7 @@ def read_keys(filename):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def lint():
|
def lint() -> None:
|
||||||
shorts = {}
|
shorts = {}
|
||||||
for item in Items:
|
for item in Items:
|
||||||
if item['short'] in shorts:
|
if item['short'] in shorts:
|
||||||
|
|
@ -39,7 +40,7 @@ def lint():
|
||||||
shorts[item['short']] = True
|
shorts[item['short']] = True
|
||||||
|
|
||||||
|
|
||||||
def write_keys(filename):
|
def write_keys(filename: str) -> None:
|
||||||
orig = []
|
orig = []
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import time
|
||||||
|
|
||||||
from functools import lru_cache # Eventually use python 3.9's cache
|
from functools import lru_cache # Eventually use python 3.9's cache
|
||||||
from pprint import pformat, pprint
|
from pprint import pformat, pprint
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import distro
|
import distro
|
||||||
|
|
||||||
|
|
@ -50,7 +51,7 @@ All_Scenarios = {
|
||||||
|
|
||||||
# Globals
|
# Globals
|
||||||
test = None
|
test = None
|
||||||
Arg_Tests = []
|
Arg_Tests: list[str] = []
|
||||||
Quitting = False
|
Quitting = False
|
||||||
Vltmt_Threads = 3
|
Vltmt_Threads = 3
|
||||||
forker = None
|
forker = None
|
||||||
|
|
@ -155,7 +156,7 @@ class Capabilities:
|
||||||
if match:
|
if match:
|
||||||
Capabilities._cached_cmake_version = match.group(1) + "." + match.group(2)
|
Capabilities._cached_cmake_version = match.group(1) + "." + match.group(2)
|
||||||
else:
|
else:
|
||||||
Capabilities._cached_cmake_version = 0
|
Capabilities._cached_cmake_version = "none"
|
||||||
return Capabilities._cached_cmake_version
|
return Capabilities._cached_cmake_version
|
||||||
|
|
||||||
@staticproperty
|
@staticproperty
|
||||||
|
|
@ -227,7 +228,7 @@ class Capabilities:
|
||||||
if match:
|
if match:
|
||||||
Capabilities._cached_make_version = match.group(1)
|
Capabilities._cached_make_version = match.group(1)
|
||||||
else:
|
else:
|
||||||
Capabilities._cached_make_version = -1
|
Capabilities._cached_make_version = "none"
|
||||||
return Capabilities._cached_make_version
|
return Capabilities._cached_make_version
|
||||||
|
|
||||||
# Fetch
|
# Fetch
|
||||||
|
|
@ -243,7 +244,7 @@ class Capabilities:
|
||||||
# Internals
|
# Internals
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _verilator_get_supported(feature) -> str:
|
def _verilator_get_supported(feature) -> bool:
|
||||||
# Returns if given feature is supported
|
# Returns if given feature is supported
|
||||||
cmd = "perl " + os.environ['VERILATOR_ROOT'] + "/bin/verilator -get-supported " + feature
|
cmd = "perl " + os.environ['VERILATOR_ROOT'] + "/bin/verilator -get-supported " + feature
|
||||||
out = VtOs.run_capture(cmd, check=False).strip()
|
out = VtOs.run_capture(cmd, check=False).strip()
|
||||||
|
|
@ -561,7 +562,7 @@ class Runner:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _py_filename_adjust(py_filename: str,
|
def _py_filename_adjust(py_filename: str,
|
||||||
tdir_def: str) -> list: # Return (py_filename, t_dir)
|
tdir_def: str) -> tuple[str, str]: # Return (py_filename, t_dir)
|
||||||
for tdir in Args.test_dirs: # pylint: disable=redefined-outer-name
|
for tdir in Args.test_dirs: # pylint: disable=redefined-outer-name
|
||||||
# t_dir used both absolutely and under obj_dir
|
# t_dir used both absolutely and under obj_dir
|
||||||
try_py_filename = tdir + "/" + os.path.basename(py_filename)
|
try_py_filename = tdir + "/" + os.path.basename(py_filename)
|
||||||
|
|
@ -596,7 +597,7 @@ class Runner:
|
||||||
out += " Time %d:%02d" % (int(delta / 60), delta % 60)
|
out += " Time %d:%02d" % (int(delta / 60), delta % 60)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def _manual_args(self) -> str:
|
def _manual_args(self) -> list[str]:
|
||||||
# Return command line with scenarios stripped
|
# Return command line with scenarios stripped
|
||||||
out = []
|
out = []
|
||||||
for oarg in Args.orig_argv_sw:
|
for oarg in Args.orig_argv_sw:
|
||||||
|
|
@ -1752,7 +1753,7 @@ class VlTest:
|
||||||
fails=False, # True: normal 1 exit code, 'any': any exit code
|
fails=False, # True: normal 1 exit code, 'any': any exit code
|
||||||
logfile=None, # Filename to write putput to
|
logfile=None, # Filename to write putput to
|
||||||
tee=True,
|
tee=True,
|
||||||
verilator_run=False) -> str: # Move gcov data to parallel area
|
verilator_run=False) -> bool: # Move gcov data to parallel area
|
||||||
|
|
||||||
try:
|
try:
|
||||||
command = ' '.join(cmd)
|
command = ' '.join(cmd)
|
||||||
|
|
@ -2343,7 +2344,7 @@ class VlTest:
|
||||||
return again
|
return again
|
||||||
|
|
||||||
def _files_identical_reader(self, f1, f2, fn1: str, fn2: str, is_logfile: bool,
|
def _files_identical_reader(self, f1, f2, fn1: str, fn2: str, is_logfile: bool,
|
||||||
strip_hex: bool, moretry: bool) -> None:
|
strip_hex: bool, moretry: bool) -> bool:
|
||||||
# If moretry, then return true to try again
|
# If moretry, then return true to try again
|
||||||
l1s = f1.readlines()
|
l1s = f1.readlines()
|
||||||
l2s = f2.readlines() if f2 else []
|
l2s = f2.readlines() if f2 else []
|
||||||
|
|
@ -2496,7 +2497,7 @@ class VlTest:
|
||||||
self.copy_if_golden(fn1, fn2)
|
self.copy_if_golden(fn1, fn2)
|
||||||
self.error("SAIF files don't match!")
|
self.error("SAIF files don't match!")
|
||||||
|
|
||||||
def _vcd_read(self, filename: str) -> str:
|
def _vcd_read(self, filename: str) -> dict:
|
||||||
data = {}
|
data = {}
|
||||||
with open(filename, 'r', encoding='latin-1') as fh:
|
with open(filename, 'r', encoding='latin-1') as fh:
|
||||||
hier_stack = ["TOP"]
|
hier_stack = ["TOP"]
|
||||||
|
|
@ -2608,7 +2609,7 @@ class VlTest:
|
||||||
if re.search(regexp, contents, re.MULTILINE):
|
if re.search(regexp, contents, re.MULTILINE):
|
||||||
self.error("File_grep_not: " + filename + ": Regexp found: '" + regexp + "'")
|
self.error("File_grep_not: " + filename + ": Regexp found: '" + regexp + "'")
|
||||||
|
|
||||||
def file_grep(self, filename: str, regexp, expvalue=None) -> list:
|
def file_grep(self, filename: str, regexp, expvalue=None) -> Optional[list]:
|
||||||
contents = self.file_contents(filename)
|
contents = self.file_contents(filename)
|
||||||
if contents == "_Already_Errored_":
|
if contents == "_Already_Errored_":
|
||||||
return None
|
return None
|
||||||
|
|
@ -2762,7 +2763,7 @@ def calc_threads(default_threads) -> int:
|
||||||
return ok_threads if (ok_threads < default_threads) else default_threads
|
return ok_threads if (ok_threads < default_threads) else default_threads
|
||||||
|
|
||||||
|
|
||||||
def _calc_hashset() -> list:
|
def _calc_hashset() -> None:
|
||||||
match = re.match(r'^(\d+)/(\d+)$', Args.hashset)
|
match = re.match(r'^(\d+)/(\d+)$', Args.hashset)
|
||||||
if not match:
|
if not match:
|
||||||
sys.exit("%Error: Need number/number format for --hashset: " + Args.hashset)
|
sys.exit("%Error: Need number/number format for --hashset: " + Args.hashset)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0114
|
# pylint: disable=C0114
|
||||||
#
|
#
|
||||||
# DESCRIPTION: Verilator: Verilog Test example --pipe-filter script
|
# DESCRIPTION: Verilator: Verilog Test example --pipe-filter script
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0103,C0114
|
# pylint: disable=C0103,C0114
|
||||||
#
|
#
|
||||||
# DESCRIPTION: Verilator: Verilog Test example --pipe-filter script
|
# DESCRIPTION: Verilator: Verilog Test example --pipe-filter script
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue