Data Structures - Getting started..

rh0dium steven.klass at gmail.com
Tue Jun 3 19:18:39 CEST 2008


Hi all,

I have a primitive data structure which looks like this.

cells = [{'name': 'AND2X1',
              'pins': [{'direction': 'input', 'name': 'A', 'type':
'signal'},
                       {'direction': 'input', 'name': 'B', 'type':
'signal'},
                       {'direction': 'output', 'name': 'Y', 'type':
'signal'},
                       {'direction': 'inout', 'name': 'VDD', 'type':
'power'},
                       {'direction': 'inout', 'name': 'VSS', 'type':
'ground'}],
              'type': None},
             {'name': 'AND2X2',
              'pins': [{'direction': 'input', 'name': 'A', 'type':
'signal'},
                       {'direction': 'input', 'name': 'B', 'type':
'signal'},
                       {'direction': 'output', 'name': 'Y', 'type':
'signal'},
                       {'direction': 'inout', 'name': 'VDD', 'type':
'power'},
                       {'direction': 'inout', 'name': 'VSS', 'type':
'ground'}],
              'type': None},]

I want to make me a 'more better'  data structure where I could do the
following:

    lef = IP()                      # My new fangled data structure
    lef.add("AND2X1")
    lef.AND2X.type("stdcell")
    lef.AND2X.pin.add("A")
    lef.AND2X.pin.A.direction=("Input")
    lef.AND2X.pin.add("B")
    lef.AND2X.pin.A.direction=("Input")
    lef.AND2X.pin.add("Y")
    lef.AND2X.pin.A.direction=("Output")
    lef.AND2X.pin.A.type=("signal")

    lef.add("AND3X1")
    lef.AND2X.type("stdcell")
    lef.AND2X.pin.add("A")
    lef.AND2X.pin.A.direction=("Input")
    lef.AND2X.pin.add("B")
    lef.AND2X.pin.A.direction=("Input")
    lef.AND2X.pin.add("Y")
    lef.AND2X.pin.A.direction=("Output")
    lef.AND2X.pin.A.type=("signal")

    print lef.asList()              # Would return ["AND2X1",
"AND3X1"]
    print lef.AND2X1.pins.asList()  # Would return ["A", "B", "Y"]

    for x in lef:
        print x.name                # Would return AND2X1
        print x.type                # Would return stdcell (if used)
        print x.pins                # Would return pins (if used)

Can anyone get me started?



More information about the Python-list mailing list