Example #1
0
 def reset(self):
     """Reset the fault injection component manager"""
     ComponentManager.reset(self)
     import ProbeLT32
     self.__probeClass = ProbeLT32.ProbeLT32
     self.__probeID = 0
     self.__locationDescriptors = self.__loadComponentFaultLocationDescriptors()
     self.__architectureFaultLocations = []        
     self.__probes = {} 
Example #2
0
 def __init__(self, components):
     """Constructor for the fault injection component manager"""
     ComponentManager.__init__(self, components) # init the standard component manager
     import ProbeLT32
     self.__probeClass = ProbeLT32.ProbeLT32
     self.__probeID = 0 #id used for probes
     self.__locationDescriptors = self.__loadComponentFaultLocationDescriptors() #load the decriptors of the fault location of each component.
     self.__architectureFaultLocations = [] #fault locations for the current architecture
     #probes connected to the current architecture
     # the key is a tuple containing the names of the involved source and target ports. The value is a ProbleConnectionNode object
     self.__probes = {}
     self.__fi = None
Example #3
0
 def connectPorts(self, source, sourcePort, target, targetPort, enableProbe = True):
     """Connects two specified components on the specified ports. The references of the components and the ports to be connected
        are required. Moreover, if specified, a probe is introduced on the connection, i.e., the source component is connected to the target
        port of the probe and the target component is connected to the initiator port of the probe"""
     #check if ports are already connected
     key = (sourcePort.name(),targetPort.name())
     if self.__probes.has_key(key):
         return
     if ComponentManager.areConnected(self, source, sourcePort, target, targetPort):
         return
     
     if enableProbe:
         #instantiate the probe
         probeInst = self.__probeClass('probe_'+str(self.__probeID))
         self.__probeID = self.__probeID + 1
         probeInPort = helper.getTLMInPort(probeInst)
         if len(probeInPort) != 1:
             raise exceptions.Exception('The probe must have exactly one target port')
         probeOutPort = helper.getTLMOutPort(probeInst)
         if len(probeOutPort) != 1:
             raise exceptions.Exception('The probe must have exactly one initiator port')
         #interconnect the components
         ComponentManager.connectPorts(self, source, sourcePort, probeInst, probeInPort[0])
         ComponentManager.connectPorts(self, probeInst, probeOutPort[0], target, targetPort)
         #keep track of the connected probe
         key = (sourcePort.name(), targetPort.name())
         self.__probes[key] = ProbeConnectionNode(probeInst, source.name(), sourcePort.name(), target.name(), targetPort.name()) 
         return probeInst
     else:
         ComponentManager.connectPorts(self, source, sourcePort, target, targetPort)
Example #4
0
 def registerComponent(self, component, attributes=None): 
     """Registers a component instantiated in the architecture in the fault location list. It is possible to specify the attribute
     to register; if no attribute is specified, all the possible attribute are registered"""
     #check if component is a valid object
     if not(helper.isSystemCComponent(component) and ComponentManager.getInstantiatedComponents(self).count(component.name()) == 1):
         raise exception.Exception(str(component) + ' is not a valid SystemC component instantiated in the architecture')
                 
     #it is necessary to create a descriptor for each instance of the component
     if self.__locationDescriptors.has_key(component.__class__):            
         #check if specified attributes exist in the component class
         compAttributes = []
         for currLocationsDescriptor in self.__locationDescriptors[component.__class__]:
             compAttributes.append(currLocationsDescriptor.getAttribute())
         if attributes == None:
             attributes = compAttributes 
         else:
             for currAttr in attributes:
                 if compAttributes.count(currAttr) == 0:
                     raise exceptions.Exception(str(currAttr) + ' is not a valid attribute for component ' + str(component))
         
         #generate location descriptors for the specified component
         for currLocationsDescriptor in self.__locationDescriptors[component.__class__]:
             if attributes.count(currLocationsDescriptor.getAttribute()):
                 attribute = currLocationsDescriptor.getAttribute()
                 lines = currLocationsDescriptor.getLines()
                 wordSize = currLocationsDescriptor.getWordSize()
                 wrapperClass = currLocationsDescriptor.getWrapperClass()
                 
                 #get the number of lines. 
                 #it may be a number or also the name of a function to be called in order to load the value dinamically  
                 try:
                     #the number of lines is specified into the file
                     lines = long(lines)
                 except:
                     #the number of lines is retrieved dinamically by reading an attribute or calling a method of the object
                     try:
                         pars = lines.split('.')
                         parRef = component
                         for nextParStr in pars:
                             parRef = getattr(parRef,nextParStr)
                         if callable(parRef):
                             lines = parRef()
                         else:
                             lines = parRef
                     except:
                         raise exceptions.Exception(str(lines) + ' attribute has not been found in component ' + str(component))
     
                 #get the word size. 
                 #it may be a number or also the name of a function to be called in order to load the value dinamically
                 try:
                     wordSize = long(wordSize)
                 except:
                     try:
                         pars = lines.split('.')
                         parRef = component
                         for nextParStr in pars:
                             parRef = getattr(parRef,nextParStr)
                         if callable(parRef):
                             wordSize = parRef()
                         else:
                             wordSize = parRef
                     except:
                         raise exceptions.Exception(str(lines) + ' attribute has not been found in component ' + str(component))
                         
                 #create the location descriptor
                 ld = locationDescriptor(component.name(), attribute, wrapperClass, lines, wordSize)
                 self.__architectureFaultLocations.append(ld)