def _genArchState(self, arch, state: State): statestr = "case " + arch + "_" + state.getstatename() + ":" + self.nl statestr += "switch " + self.cinmsg + "." + self.cmtype + self.nl transitions = state.getdataack() + state.getremote() + \ [trans for trans in state.getaccess() if trans.getinmsg()] guard_list = [] for transition in transitions: guard_list.append(transition.getguard()) guard_list = list(set(guard_list)) transitions.sort(key=lambda transition: (transition.getguard( ), transition.getcond(), transition.getfinalstate().getstatename())) op_string = "" for guard in guard_list: guard_trans = [ transition for transition in transitions if transition.getguard() == guard ] op_string += self.gen_operation_str(arch, guard_trans) statestr += self._addtabs(op_string, 1) statestr += self.tab + " else return false" + self.end statestr += "endswitch" + self.end return self._addtabs(statestr, 1)
def _genAccessState(self, arch, state: State, verify_ssp: bool = False): transitions = [trans for trans in state.getaccess() if trans.getaccess() and not trans.getinmsg()] \ + state.getevictmiss() trans_dict = MultiDict() for transition in transitions: trans_dict[transition.getguard()] = transition statestr = "" for guard in trans_dict: ruleid = arch + "_" + str(state) + "_" + guard ccle_dot_state = self.ccle + "." + self.iState statestr += "rule \"" + ruleid + "\"" + self.nl statestr += self.tab + ccle_dot_state + " = " + arch + "_" + str( state) + self.nl statestr += self.gen_network_ready_test(trans_dict[guard]) # Add network ready check here if verify_ssp: statestr += " & " + self._LockTest() + self.nl statestr += "==>" + self.nl if verify_ssp: statestr += self._LockAcquire() + self.end statestr += self.tab + self.tSEND + ruleid + "(" + self.cadr + ", m)" + self.end statestr += "endrule" + self.end + self.nl return statestr
def _genAccessSendFunc(self, arch: Architecture, state: State): transitions = [trans for trans in state.getaccess() if trans.getaccess() and not trans.getinmsg()] \ + state.getevictmiss() trans_dict = MultiDict() for transition in transitions: trans_dict[transition.getguard()] = transition sendfctstr = "" for guard in trans_dict: ruleid = arch.get_unique_id_str() + "_" + str(state) + "_" + guard sendfctstr += self._genSendFunctionHeader( arch, ruleid, trans_dict[guard]) + self.nl return sendfctstr