def test_m3():
    p = Pdk().load(
        '../PDK_Abstraction/FinFET14nm_Mock_PDK/FinFET_Mock_PDK_Abstraction.json'
    )
    c = DefaultCanvas(p)

    m = c.generators['m3']
    mt = MetalTemplate(m)

    print("m3 clg grid", m.clg.grid, "m3 clg legal indices",
          m.clg.legalIndices)
    print("m3 spg grid", m.spg.grid, "m3 spg legal indices",
          m.spg.legalIndices)

    assert 1 in m.spg.legalIndices
    assert 3 in m.spg.legalIndices
    ### The following assertions are modified based on the updtaed PDK
    assert m.spg.grid[1][0] == 36
    assert m.spg.grid[3][0] == 48

    assert mt.widths == [40, 40, 40]
    assert mt.colors == ["c1", "c2", "c1"]
    assert mt.spaces == [40, 40]
    assert mt.offset == 0

    assert mt.stop_offset == 36
    assert mt.stops == [12, 72]
def test_one_half_with_offset():
    m = Wire('m1', 'M1', 'v', clg=None, spg=None)
    m.clg = UncoloredCenterLineGrid(width=400, pitch=720)
    m.spg = CenteredGrid(pitch=720, offset=280)
    mt = MetalTemplate(m)

    assert mt.widths == [400, 400]
    assert mt.spaces == [320]
    assert mt.offset == 0
    assert mt.stop_offset == 360 + 280
    assert mt.stops == [720]
def test_one_third():
    m = Wire('m1', 'M1', 'v', clg=None, spg=None)
    m.clg = UncoloredCenterLineGrid(width=400, pitch=720)
    m.spg = EnclosureGrid(pitch=720, stoppoint=240)
    mt = MetalTemplate(m)

    assert mt.widths == [400, 400]
    assert mt.spaces == [320]
    assert mt.offset == 0
    assert mt.stop_offset == 240
    assert mt.stops == [240, 480]
def test_endpoints():
    m = Wire('m1', 'M1', 'v', clg=None, spg=None)
    m.clg = UncoloredCenterLineGrid(width=400, pitch=720)
    m.spg = Grid()
    m.spg.addGridLine(0, True)
    m.spg.addGridLine(720, True)
    m.spg.semantic()
    mt = MetalTemplate(m)

    assert mt.widths == [400, 400]
    assert mt.spaces == [320]
    assert mt.offset == 0
    assert mt.stop_offset == 0
    assert mt.stops == [720]
def test_colors():
    m = Wire('m1', 'M1', 'v', clg=None, spg=None)
    m.clg = CenterLineGrid()
    m.clg.addCenterLine(0 * 720, 400, True, color="red")
    m.clg.addCenterLine(1 * 720, 400, True, color="black")
    m.clg.addCenterLine(2 * 720, 400, True, color="red")

    m.spg = EnclosureGrid(pitch=720, stoppoint=240)
    mt = MetalTemplate(m)

    assert mt.widths == [400, 400, 400]
    assert mt.spaces == [320, 320]
    assert mt.offset == 0
    assert mt.colors == ["red", "black", "red"]
    assert mt.stop_offset == 240
    assert mt.stops == [240, 480]