Пример #1
0
    def _TransientStateInheritance(self, arch: Architecture,
                                   transition: Transition, state, stateset,
                                   stablestates, deferfunc) -> List[State]:
        new_states = []

        # Test if the message is a serialization message or any other control message
        # In the non-stalling configuration control messages are deferred if control dependencies exist,
        # else they are served immediately
        if not self.nonstalling:
            if not self.test_serialization_msg(transition):
                return new_states

        finalsets = transition.getfinalstate().getstatesets()

        # Rule if a remote transition exists in the startstate and finalstate having the same guard, the message
        # is considered to be unrelated to the current state and will be therefore ignored until a stable state is
        # reached

        # Test if final stable state or remote transition is startstate of current stateset
        if state in stateset.getstartstates():
            # Serialized before own transaction
            # Find path startstate to state
            guards = self._FindAccessTrace(state, stateset, stablestates)

            # Find new final state
            finalstate = self._SetGuardSearch(guards, finalsets)
            if finalstate:
                state.addtransitions(
                    self._CopyModifyTransition(transition, state, finalstate))
            else:
                new_states.append(self._CopyModifyState(state, transition))

        else:
            # Serialized after own transaction
            if self.nonstalling:
                # Cache and directory dependent. Only if they have data
                # Transition start and final state do not change, however,
                # responses might be deferred due to data dependencies
                if transition.getstartstate() == transition.getfinalstate(
                ) and state in stateset.getendstates():
                    pass
                    # ANALYZE DEPENDENCY OF CURRENT TRANSITION AND VARIABLES THAT ARE DEPENDENT.
                    # IF THERE EXISTS A DEPENDENCY NO LOOPING IS ALLOWED
                    '''
                    newtrans = self._CopyModifyTransition(transition, state, state)
                    # Defer message
                    defermsg = deferfunc(transition, newtrans)
                    if defermsg:
                        new_state = self._GenerateState(state, transition, stablestates, deferfunc)
                        if new_state:
                            new_states.append(new_state)
                    else:
                        state.addtransitions(newtrans)
                    '''
                else:
                    # A new state needs to be created
                    new_state = self._GenerateState(state, transition,
                                                    stablestates, deferfunc)
                    if new_state:
                        new_states.append(new_state)

        return new_states
Пример #2
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
Пример #3
0
 def _genFinalState(self, arch: str, transition: Transition):
     return self.ccle + "." + self.iState + " := " + arch + "_" + \
            transition.getfinalstate().getstatename() + self.end