Пример #1
0
def getTopNumber(dbData, archDefData, topModule, verbose):
  ''' Returns the value requested for top level module
    
    Arguments:
    dbData = Database data in dict format
    archDefData = List of all Modules
    topModule = Name of top level module to be evaluated
    verbose = Verbosity level
  '''

  allModulesName = list(archDefData.keys())

  assert topModule in allModulesName, topModule + ' not in the Arch files'

  # Create Root node
  rootNode = ppa_tree.Node(topModule,False)

  # Queue to hold nodes non-leaf to be yet expanded in the tree
  qNameToNode = [(topModule, rootNode)]

  while qNameToNode:
    verbose_print ('Current Q status: ' + str(qNameToNode), verbose, 3)
    moduleName, moduleNode = qNameToNode.pop(0)
    verbose_print ('Processing Node: ' + moduleName, verbose,3)
    verbose_print ('Current Q status: ' + str(qNameToNode), verbose,3)
    for childName,childVal in archDefData[moduleName].items():
      
      if childName in list(dbData.keys()):
        childArea = dbData[childName]['Area']  # TODO Make it generic for power
        verbose_print(childName + ' is basicblock. Adding as child to ' + moduleName, verbose, 2)
        
        # Create node for basic block
        childNode = ppa_tree.Node(moduleName + '.' + childName, True, childArea, childVal)
        moduleNode.addChild(childNode)

      elif childName in list(archDefData.keys()):
        verbose_print(childName + ' is a Module. Adding as child to ' + moduleName, verbose, 2)
        
        # Create node for basic block
        childNode = ppa_tree.Node(childName, False, None, childVal)
        moduleNode.addChild(childNode)
        qNameToNode.append((childName, childNode))

  #Update all values
  rootNode.updateTreeValue()

  # Dump tree 
  if verbose == 2:
    rootNode.dumpGraphPng(topModule, full = 0)
  if verbose == 3:
    rootNode.dumpGraphPng(topModule, full = 1)

  return rootNode.value    
Пример #2
0
    def dumpGraphPng(self, filename='graph', full=0):
        ''' Dumps a png image for  entire tree rooted at this node

        Args:
        G: Dot Graph
        full: 0 prints only node names
              1 prints full node info
    '''
        G = Graph('ppa', format='png')
        self._constructDotNodes(G, full)
        self._constructDotEdges(G, full)

        verbose_print('Dumping Graph to file:' + filename)
        G.render(filename, cleanup=True)
Пример #3
0
def parseArchFile(filePath, verbose=1):
  ''' Parses Yaml file and returns component list 
      
      Args:
      filePath: Full path of Arch File
      vebose: Verbosity level
      
      Return:
      dict of Components and its Basic block conf 
  '''    
  assert os.path.exists(filePath), filePath + 'does not exist'

  archMap = yaml.load(open(filePath))
  
  # TODO Sanity Checks for Components
  
  verbose_print ('Parsed Arch file: ' + filePath, verbose, 2)
  verbose_print (yaml.dump(archMap), verbose, 3)
      
  return archMap
Пример #4
0
def parseDB(filePath, verbose=1):
  ''' Parses Yaml file and returns dict 
      
      Args:
      filePath: Full path of DB File
      vebose: Verbosity level
      
      Return:
      dict of blocks and its parameters
  '''    
  assert os.path.exists(filePath), filePath + ' not found'
  
  ymlDict = yaml.load(open(filePath))
  
  # TODO Sanity Checks for Components
  
  verbose_print ('Parsed DB file: ' + filePath, verbose, 2)
  verbose_print ('Parse Dataset \n' + yaml.dump(ymlDict), verbose, 3)
      
  return ymlDict
Пример #5
0
    def printNodeName(self):
        ''' Prints the Node Name
    '''

        verbose_print(self.name)
Пример #6
0
    def printNode(self):
        ''' Prints the Node info with all attributes
    '''

        verbose_print(pformat(self.__dict__) + '\n')