From: Andrey Miroshnikov Date: Mon, 21 Aug 2023 16:38:37 +0000 (+0000) Subject: inorder.py: Use insn_trace more consistently. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=755b918d6dad6fc2d1a2a75beb1fdd39223679c7;p=openpower-isa.git inorder.py: Use insn_trace more consistently. --- diff --git a/src/openpower/cyclemodel/inorder.py b/src/openpower/cyclemodel/inorder.py index da5cbbe0..c0a42ccd 100644 --- a/src/openpower/cyclemodel/inorder.py +++ b/src/openpower/cyclemodel/inorder.py @@ -69,6 +69,10 @@ def read_file(fname): this function is a generator, it yields a list comprising each line: ["insn", Hazard(...), Hazard(....), ....] + The ["insn", Hazard(...), Hazard(....), ....] format has been given the + name 'insn_trace', because 'insn' already refers to the assembler + instruction string. + fname may be a *file* (an object) with a function named "read", in which case the Contract is that it is the *CALLER* that must take responsibility for the file: opening, closing, seeking. @@ -82,10 +86,10 @@ def read_file(fname): for line in fname.readlines(): (specs, insn) = map(str.strip, line.strip().split("#")) - line = [insn] + insn_trace = [insn] for spec in specs.split(" "): - line.append(Hazard._make(spec.split(":"))) - yield line + insn_trace.append(Hazard._make(spec.split(":"))) + yield insn_trace if not is_file: fname.close() @@ -360,11 +364,11 @@ class TestTrace(unittest.TestCase): "r:GPR:3:0:64 r:GPR:2:0:64 w:GPR:1:0:64 # add 1, 3, 2", ) f = io.StringIO("\n".join(lines)) - lines = read_file(f) + insn_traces = list(read_file(f)) basic_cpu.print_headings() - for trace in lines: - #print(trace) - basic_cpu.process_instructions(trace) + for insn_trace in insn_traces: + #print(insn_trace) + basic_cpu.process_instructions(insn_trace) def help(): print ("-t runs unit tests")