From e74dfbf1ecfb75affa90b7ce091e15764e1b9ac8 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 2 May 2023 18:44:12 +0100 Subject: [PATCH] start on cycle-accurate model of inorder core --- src/openpower/cyclemodel/inorder.py | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/openpower/cyclemodel/inorder.py diff --git a/src/openpower/cyclemodel/inorder.py b/src/openpower/cyclemodel/inorder.py new file mode 100644 index 00000000..42176990 --- /dev/null +++ b/src/openpower/cyclemodel/inorder.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# An In-order cycle-accurate model of a Power ISA 3.0 hardware implementation + +class RegisterWrite(set): + def expect_write(self, regs): self.update(regs) + def write_expected(self, regs): len(self.intersection(regs)) != 0 + def retire_write(self, regs): self.difference_update(regs) + +class Execute: + def __init__(self, cpu): + self.stages = [] + self.cpu = cpu + + def add_stage(self, cycles_away, stage): + while cycles_away > len(self.stages): + self.stages.append([]) + self.stages[cycles_away].append(stage) + + def add_instruction(self, insn, writeregs): + self.add_stage(2, {'insn': insn, 'writes': writeregs}) + + def tick(self): + self.stages.pop(0) + + def process_instructions(self): + stall = False # stalls if not all writes possible + instructions = self.stages[0] # get list of instructions + to_write = set() # need to know total writes + for instruction in instructions: + to_write.update(instruction['writes']) + # see if all writes can be done, otherwise stall + writes_possible = self.cpu.all_writes_possible(to_write): + if writes_possible != to_write: + stall = True + # retire the writes that are possible in this cycle (regfile writes) + self.cpu.regs.retire_write(to_write) + return stall -- 2.30.2