Пример #1
0
    def process_operation(self, operation: CommonTree, arch: str,
                          transition: Transition):
        inmsgtype = transition.getrefguard() if transition.getrefguard(
        ) else transition.getguard()

        if operation.getText() == self.tASSIGN:
            return self._genArchAssignment(operation, arch, inmsgtype,
                                           transition)

        if operation.getText() == self.tMODSTATEFUNC:
            return self._gen_mod_state_func(operation, arch) + self.end

        if operation.getChildren()[0].getText() == self.iState:
            return self._genArchAccess(transition)

        if operation.getText() == self.tSEND:
            return self._genSendFunction(operation) + self.end

        if operation.getText() == self.tMCAST:
            return self._genMCastFunction(operation) + self.end

        if operation.getText() == self.tBCAST:
            return self._genBCastFunction(operation) + self.end

        # For every if cond=true, there exists an else (if cond=false)
        if operation.getText() == self.tCOND:
            return self._genIfCondFunction(operation, 0, arch,
                                           inmsgtype) + self.nl

        if operation.getText() == self.tNCOND:
            return self._genIfCondFunction(operation, 1, arch,
                                           inmsgtype) + self.nl

        if operation.getText() == self.tSETFUNC:
            return self._genSetFunction(operation, arch, inmsgtype) + self.end

        # DEFER FUNCTION FUNCTIONALITY
        if operation.getText() == self.tPUSH_HL_DEFER:
            msg_name = str(operation.children[1])
            if msg_name in self.messageslist:
                msg_name = self.cinmsg
            return self._genmsgDeferpush(arch, msg_name,
                                         MurphiTokens.iHL_Defer)

        if operation.getText() == self.tPUSH_LL_DEFER:
            msg_name = str(operation.children[1])
            if msg_name in self.messageslist:
                msg_name = self.cinmsg
            return self._genmsgDeferpush(arch, msg_name,
                                         MurphiTokens.iLL_Defer)

        if operation.getText() == self.tPUSH_STALL_DEFER:
            msg_name = str(operation.children[1])
            if msg_name in self.messageslist:
                msg_name = self.cinmsg
            return self._genmsgDeferpush(arch, msg_name,
                                         MurphiTokens.iStall_Defer)
Пример #2
0
 def test_serialization_msg(self, transition: Transition) -> bool:
     # Rule if a remote transition exists in the stable startstate and stable finalstate having the same guard,
     # the message is considered NOT to be a serialization message and therefore to be unrelated to the current state
     # and will be therefore ignored until a stable state is reached if the ProtoGen works in the stalling mode or
     # handled if no data dependencies exist in the non-stalling mode
     guard = str(transition.getguard())
     if (self.state_guard_search(guard, transition.startState)
             and self.state_guard_search(guard, transition.finalState)):
         return False
     return True
Пример #3
0
    def copy_modify_state(self,
                          startstate: State,
                          transition: Transition,
                          old_state_to_new_state_map: Dict[str, State],
                          forbidden_guards: List[str],
                          final_state: [State, None] = None):
        # If a known final state exists, then
        if final_state:
            newstate = final_state
            if str(final_state) in old_state_to_new_state_map:
                newstate = old_state_to_new_state_map[str(final_state)]
        else:
            new_state_str = startstate.getstatename(
            ) + "_" + transition.getguard()
            if new_state_str in old_state_to_new_state_map:
                newstate = old_state_to_new_state_map[new_state_str]
            else:
                newstate = State(new_state_str, self.access, self.evict)
                old_state_to_new_state_map[new_state_str] = newstate

                # The new_state replaces the final state so it must possess all local access permissions
                for trans in transition.startState.setTrans:
                    if str(trans.inMsg) in forbidden_guards:
                        continue

                    if trans.startState == trans.finalState:
                        new_trans = self._CopyModifyTransition(
                            trans, newstate, newstate)
                        newstate.addtransitions(new_trans)

                for trans in transition.finalState.setTrans:
                    if str(trans.inMsg) in forbidden_guards:
                        continue

                    if trans.startState == trans.finalState:
                        new_trans = self._CopyModifyTransition(
                            trans, newstate, newstate)
                        newstate.addtransitions(new_trans)

                # The new_state replaces the final state so it must possess all local access permissions
                for trans in startstate.setTrans:
                    if str(trans.inMsg) in forbidden_guards:
                        continue

                    if trans.startState == trans.finalState:
                        new_trans = self._CopyModifyTransition(
                            trans, newstate, newstate)
                        newstate.addtransitions(new_trans)

                for startset in transition.getfinalstate().getstatesets():
                    startset.addstartstate(newstate)

                for endset in startstate.getendstatesets():
                    endset.addendstate(newstate)

        # Create vertice
        new_trans = self._CopyModifyTransition(transition, startstate,
                                               newstate)
        startstate.addtransitions(new_trans)

        return newstate, new_trans