Contents

Genesis2.CMLCrawler Python Library

As you may remember, Genesis2 outputs all its hierarchy structure and for each module all its parameters (final binding) into an XML structure
(more information here, XML schema page here). The idea is that this information is useful for creating drivers, backend flows and more. To make your life easier in traversing the XML, we provide a small Python module called Genesis2.XMLCrawler that provides navigation and search methods. This page describes how to use it.

System Requirements and Setup

Genesis2.XMLCrawler requires Python 2.5 or above.

If you have not done so thus far, you may need to add $GENESIS_HOME/PythonLibs to your path. See here for setting up Genesis2 environment.
Or, if all you need is this python module, add the following line to your setup file:

setenv PYTHONPATH "$GENESIS_HOME/PythonLibs:$PYTHONPATH"

How to Use The Module

Say we want to create a script that extract info from the XML, I'll call it HelloXML.py. Start it with:

#!/usr/bin/python
from Genesis2.XMLCrawler import XMLCrawler

Now we create an object and init it with the XML file:

c = XMLCrawler()
c.read_xml('FPGen.xml')

'c' in this notation stands for crawler and is always pointing to the hierarchical equivalent of a design instance. It starts at the top. From here on, we can use the following API which is almost identical to the Genesis2 compiler API (as described here).

Traversal related methods

def get_parent(self)

returns the instance's parent or None if this is top

def get_top(self)

returns the top of the hierarchy

def iname(self)

instance name

def mname(self)

module name (after uniquification)

def bname(self)

base module name (i.e., template name, before uniquification)

def sname(self)

Source module name (i.e., before synonyms were applied; also the name of the source file)

def exists_subinst(self, name)

check if a subinst named name exists

def get_subinst(self, name)

returns a crawler object pointing to subinst by name name

def get_subinst_array(self,pattern='.*')

returns an array of crawler objects pointing to subinsts that matched pattern