diff --git a/emu/pe.py b/emu/pe.py --- a/emu/pe.py +++ b/emu/pe.py @@ -260,15 +260,27 @@ yield self.env.timeout(1) # EMIT cycle self._do_emit_new(inst, result, False, token.act_id, frame_id) elif inst.opcode == RoutingOp.ALLOC_REMOTE: - # PE-level: read target PE and act_id from frame constants + # PE-level: read target PE, act_id, and optional parent act_id from frame constants + # fref+0: target PE + # fref+1: target act_id + # fref+2: parent act_id (0 = fresh ALLOC, non-zero = ALLOC_SHARED) # Total: 4 cycles (dequeue + IFETCH + EXECUTE + EMIT) target_pe = self.frames[frame_id][inst.fref] if inst.fref < len(self.frames[frame_id]) else 0 target_act = self.frames[frame_id][inst.fref + 1] if inst.fref + 1 < len(self.frames[frame_id]) else 0 + parent_act = self.frames[frame_id][inst.fref + 2] if inst.fref + 2 < len(self.frames[frame_id]) else 0 + + if parent_act: + alloc_op = FrameOp.ALLOC_SHARED + payload = parent_act + else: + alloc_op = FrameOp.ALLOC + payload = 0 + fct = FrameControlToken( target=target_pe, act_id=target_act, - op=FrameOp.ALLOC, - payload=0, + op=alloc_op, + payload=payload, ) self._on_event(Executed( time=self.env.now, component=self._component,