From: Luke Kenneth Casson Leighton Date: Wed, 18 Oct 2023 14:52:30 +0000 (+0100) Subject: add "is_idle" capability to inorder.py so that after adding X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6f11fa2409ccf081fad13289753d609547006f63;p=openpower-isa.git add "is_idle" capability to inorder.py so that after adding instructions the pipeline continues to propagate --- diff --git a/src/openpower/cyclemodel/inorder.py b/src/openpower/cyclemodel/inorder.py index 485b488e..8d16515d 100644 --- a/src/openpower/cyclemodel/inorder.py +++ b/src/openpower/cyclemodel/inorder.py @@ -170,6 +170,9 @@ class Execute: instruction['writes'].difference_update(writes_possible) return stall + def is_idle(self): + return len(self.stages) == 0 + class Fetch: """ @@ -198,6 +201,9 @@ class Fetch: self.stages[0] = insn_trace return stall + def is_idle(self): + return self.stages[0] is None + class Decode: """ @@ -239,6 +245,10 @@ class Decode: self.cpu.issue.add_instruction(insn, writeregs) return stall + def is_idle(self): + return True + + class Issue: """ Issue phase: if not stalled will place the instruction into execute. @@ -266,6 +276,9 @@ class Issue: self.cpu.exe.add_instruction(insn, writeregs) return stall + def is_idle(self): + return True + class CPU: """ @@ -319,6 +332,12 @@ class CPU: self.curr_clk += 1 #print("---------------") + def is_idle(self): + return (self.fetch.is_idle() and + self.decode.is_idle() and + self.issue.is_idle() and + self.exe.is_idle()) + # TODO: Make formatting prettier, and conform to markdown table format # TODO: Adjust based on actual number of pipeline stages. def print_headings(self): @@ -374,6 +393,9 @@ class TestTrace(unittest.TestCase): for trace in lines: #print(trace) basic_cpu.process_instructions(trace) + # wait for all instructions to finish + while not basic_cpu.is_idle(): + basic_cpu.process_instructions(None) def test_trace1(self): # TODO, assert this is valid basic_cpu = CPU() @@ -388,6 +410,10 @@ class TestTrace(unittest.TestCase): for trace in lines: #print(trace) basic_cpu.process_instructions(trace) + # wait for all instructions to finish + while not basic_cpu.is_idle(): + basic_cpu.process_instructions(None) + def help(): print ("-t runs unit tests")