def test_via_multi_terminal_open():
    c = Canvas()
    c.addGen(Wire(nm='m1', layer='M1', direction='v', clg=None, spg=None))
    c.addGen(Wire(nm='m2', layer='M2', direction='h', clg=None, spg=None))
    c.addGen(Via(nm="v1", layer="via1", h_clg=None, v_clg=None))
    c.terminals = [{
        'layer': 'M2',
        'netName': None,
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'M1',
        'netName': 'M1:S',
        'rect': [100, -150, 200, 150]
    }, {
        'layer': 'M1',
        'netName': 'M1:D',
        'rect': [0, -150, 50, 150]
    }, {
        'layer': 'via1',
        'netName': None,
        'rect': [100, -50, 200, 50]
    }, {
        'layer': 'via1',
        'netName': None,
        'rect': [0, -50, 50, 50]
    }]
    c.removeDuplicates()
    assert len(c.rd.shorts) == 0
    assert len(c.rd.opens) == 2
    assert len(c.rd.subinsts) == 1
    assert len(c.rd.subinsts['M1']) == 2
def test_via_multi_terminal_short():
    c = Canvas()
    c.addGen(Wire(nm='m1', layer='M1', direction='v', clg=None, spg=None))
    c.addGen(Via(nm="v0", layer="via0", h_clg=None, v_clg=None))
    c.terminals = [{
        'layer': 'M1',
        'netName': 'x',
        'rect': [100, -150, 200, 150]
    }, {
        'layer': 'M1',
        'netName': 'y',
        'rect': [300, -150, 600, 150]
    }, {
        'layer': 'via0',
        'netName': 'M1:S',
        'rect': [100, -50, 200, 50]
    }, {
        'layer': 'via0',
        'netName': 'M1:S',
        'rect': [300, -50, 600, 50]
    }]
    c.layer_stack.append(('via0', ('M1', None)))
    c.removeDuplicates()
    assert len(c.rd.subinsts) == 1
    assert len(c.rd.subinsts['M1']) == 1
    assert len(c.rd.shorts) == 1
    assert len(c.rd.opens) == 0
def test_metal_multi_terminal_connection():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'M1:S',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'inp1',
        'rect': [200, -50, 600, 50]
    }, {
        'layer': 'metal2',
        'netName': 'M1:D',
        'rect': [400, -50, 800, 50]
    }, {
        'layer': 'metal2',
        'netName': None,
        'rect': [700, -50, 1000, 50]
    }, {
        'layer': 'metal2',
        'netName': 'M2:inp',
        'rect': [900, -50, 1200, 50]
    }]
    c.removeDuplicates()
    assert len(c.rd.shorts) == 0
    assert len(c.rd.subinsts) == 2
    assert len(c.rd.subinsts['M1']) == 2
    assert len(c.rd.subinsts['M2']) == 1
    assert len(c.rd.opens) == 0
Ejemplo n.º 4
0
def setup():
    p = Pdk().load('../PDK_Abstraction/FinFET14nm_Mock_PDK/FinFET_Mock_PDK_Abstraction.json')
    c = Canvas(p)
    c.addGen( Wire( nm='m1', layer='M1', direction='v', clg=None, spg=None))
    c.addGen( Wire( nm='m2', layer='M2', direction='h', clg=None, spg=None))
    c.addGen( Via( nm="v1", layer="V1", h_clg=None, v_clg=None))
    return c
def test_vertical():
    c = Canvas()
    c.addGen(Wire(nm='m1', layer='metal1', direction='v', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal1',
        'netName': 'x',
        'rect': [0, 0, 100, 300]
    }]
    c.removeDuplicates()
Ejemplo n.º 6
0
def test_m2_and_m3():
    c = Canvas()

    m1 = c.addGen( Wire( nm='m1', layer='M1', direction='v',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=2),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    m2 = c.addGen( Wire( nm='m2', layer='M2', direction='h',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=5),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    m3 = c.addGen( Wire( nm='m3', layer='M3', direction='v',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=2),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    v1 = c.addGen( Via( nm='v1', layer='via1', h_clg=m2.clg, v_clg=m1.clg))
    v2 = c.addGen( Via( nm='v2', layer='via2', h_clg=m2.clg, v_clg=m3.clg))

    for i in [0,2,4]:
        c.addWire( m1, 'a', None, i, (0,1), (4,-1)) 

    for i in [1,3,5]:
        c.addWire( m1, 'b', None, i, (0,1), (4,-1)) 

    c.addWireAndViaSet( 'b', None, m2, v1, 3, [(0,1), (1,1), (2,1)])
    c.addWireAndViaSet( 'a', None, m2, v1, 2, [(0,0), (1,0), (2,0)])
    c.addWireAndMultiViaSet( 'b', None, m2, 1, [(v1, [(0,1), (1,1)]), (v2, [(2,1)])])

    c.addWireAndViaSet( 'b', None, m3, v2, (2,1), [1,3])


    print( c.terminals)

    c.computeBbox()

    fn = "tests/__json_via_set_m2_m3"

    data = { 'bbox' : c.bbox.toList(),
             'globalRoutes' : [],
             'globalRouteGrid' : [],
#             'terminals' : c.terminals}
             'terminals' : c.removeDuplicates()}

    with open( fn + "_cand", "wt") as fp:
        fp.write( json.dumps( data, indent=2) + '\n')

    with open( fn + "_gold", "rt") as fp:
        data2 = json.load( fp)

        assert data == data2
def test_open():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'x',
        'rect': [400, -50, 600, 50]
    }]
    c.removeDuplicates()
    assert len(c.rd.opens) == 1
def test_metal_terminal_connection():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'M1:S',
        'rect': [200, -50, 600, 50]
    }]
    c.removeDuplicates()
    assert len(c.rd.shorts) == 0
    assert len(c.rd.subinsts) == 1
def test_overlapping():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'x',
        'rect': [200, -50, 600, 50]
    }]
    newTerminals = c.removeDuplicates()
    assert len(newTerminals) == 1
    assert newTerminals[0]['rect'] == [0, -50, 600, 50]
def test_different_widths():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -60, 300, 60]
    }]
    #    with pytest.raises(AssertionError) as excinfo:
    if True:
        c.removeDuplicates()
def test_different_widths():
    c = Canvas()
    c.addGen(Wire(nm='m2', layer='metal2', direction='h', clg=None, spg=None))
    c.terminals = [{
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'metal2',
        'netName': 'x',
        'rect': [0, -60, 300, 60]
    }]
    with pytest.raises(AssertionError) as excinfo:
        c.removeDuplicates()
    assert "Rectangles on layer metal2 with the same centerline 0 but" in str(
        excinfo.value)
Ejemplo n.º 12
0
def setup():
    c = Canvas()

    m1 = c.addGen( Wire( nm='m1', layer='M1', direction='v',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=2),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    m2 = c.addGen( Wire( nm='m2', layer='M2', direction='h',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=5),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    m3 = c.addGen( Wire( nm='m3', layer='M3', direction='v',
                         clg=UncoloredCenterLineGrid( width=400, pitch=720, repeat=2),
                         spg=EnclosureGrid( pitch=720, stoppoint=360)))

    v1 = c.addGen( Via( nm='v1', layer='via1', h_clg=m2.clg, v_clg=m1.clg))
    v2 = c.addGen( Via( nm='v2', layer='via2', h_clg=m2.clg, v_clg=m3.clg))

    return (c, m1, v1, m2, v2, m3)
def test_via_short1():
    c = Canvas()
    c.addGen(Wire(nm='m1', layer='M1', direction='v', clg=None, spg=None))
    c.addGen(Wire(nm='m2', layer='M2', direction='h', clg=None, spg=None))
    c.addGen(Via(nm="v1", layer="via1", h_clg=None, v_clg=None))
    c.terminals = [{
        'layer': 'M2',
        'netName': 'a',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'M1',
        'netName': 'b',
        'rect': [100, -150, 200, 150]
    }, {
        'layer': 'via1',
        'netName': None,
        'rect': [100, -50, 200, 50]
    }]
    print(c.removeDuplicates())
    assert len(c.rd.shorts) == 1
def test_via_connectf():
    c = Canvas()
    c.addGen(Wire(nm='m1', layer='M1', direction='v', clg=None, spg=None))
    c.addGen(Wire(nm='m2', layer='M2', direction='h', clg=None, spg=None))
    c.addGen(Via(nm="v1", layer="via1", h_clg=None, v_clg=None))
    c.terminals = [{
        'layer': 'M2',
        'netName': 'b',
        'rect': [0, -50, 300, 50]
    }, {
        'layer': 'M1',
        'netName': None,
        'rect': [100, -150, 200, 150]
    }, {
        'layer': 'via1',
        'netName': None,
        'rect': [100, -50, 200, 50]
    }]
    terms = c.removeDuplicates()
    print(terms)
    assert len(c.rd.shorts) == 0
    assert {d['netName'] for d in terms} == {'b'}
Ejemplo n.º 15
0
def test_one():
    c = Canvas()

    m1 = c.addGen(
        Wire(nm='m1',
             layer='M1',
             direction='v',
             clg=UncoloredCenterLineGrid(width=320,
                                         pitch=720,
                                         offset=2 * 720,
                                         repeat=20),
             spg=EnclosureGrid(pitch=720, stoppoint=360)))

    m2 = c.addGen(
        Wire(nm='m2',
             layer='M2',
             direction='h',
             clg=UncoloredCenterLineGrid(width=400,
                                         pitch=720,
                                         offset=720,
                                         repeat=10),
             spg=EnclosureGrid(pitch=720, stoppoint=360)))

    v1 = c.addGen(Via(nm='v1', layer='via1', h_clg=m2.clg, v_clg=m1.clg))

    m3 = c.addGen(
        Wire(nm='m3',
             layer='M3',
             direction='v',
             clg=UncoloredCenterLineGrid(width=400,
                                         pitch=720,
                                         offset=2 * 720,
                                         repeat=20),
             spg=EnclosureGrid(pitch=720, stoppoint=360)))

    v2 = c.addGen(Via(nm='v2', layer='via2', h_clg=m2.clg, v_clg=m3.clg))

    ch = 5
    for base in [0, ch]:
        c.addWire(m1, 'S', None, 0, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'S', None, 6, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'S', None, 12, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'S', None, 18, (base + 1, 1), (base + ch + 1, -1))

        c.addWire(m1, 'DA', None, 2, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'DA', None, 20, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'DB', None, 8, (base + 1, 1), (base + ch + 1, -1))
        c.addWire(m1, 'DB', None, 14, (base + 1, 1), (base + ch + 1, -1))

        c.addWire(m2, 'GND', None, 0 + base, (0, 1), (24, -1))
        c.addWireAndViaSet('S', None, m2, v1, 1 + base, [0, 6, 12, 18])
        c.addWireAndViaSet('DA', None, m2, v1, 2 + base, [2, 20])
        c.addWireAndViaSet('DB', None, m2, v1, 3 + base, [8, 14])

    c.addWireAndViaSet('S', 'S', m3, v2, 5, [1, ch + 1])
    c.addWireAndViaSet('DA', 'DA', m3, v2, 4, [2, ch + 2])
    c.addWireAndViaSet('DB', 'DB', m3, v2, 9, [3, ch + 3])

    fn = "tests/__json_diff_pair"

    print(c.terminals)

    with open(fn + "_cand", "wt") as fp:
        data = c.writeJSON(fp)

    with open(fn + "_gold", "rt") as fp:
        data2 = json.load(fp)

        assert data == data2