Beispiel #1
0
def test_basic_usage():
    pc = ParamContainer()

    pc.add_param(PCellParameter(name="orange", default=1))
    assert pc.orange == 1

    pc.orange = 2
    assert pc.orange == 2
    pc["orange"] == 2  # it is also accessible as a dictionary

    with pytest.raises(TypeError, match="Cannot set 'orange' to 'blah'"):
        pc.orange = "blah"

    with pytest.raises(
        RuntimeError, match="Unkown parameter type, cannot determine from default."
    ):
        pc.add_param(PCellParameter(name="apple"))
    pc.add_param(PCellParameter(name="apple", type=int))

    with pytest.raises(TypeError, match="Cannot set 'apple' to 'one'"):
        pc.apple = "one"

    pc.add_param(PCellParameter(name="strawberry", default=DPoint(0, 0)))
    assert type(pc.strawberry) == DPoint

    with pytest.raises(TypeError, match="Cannot set 'strawberry' to 'test'"):
        pc.strawberry = "test"
Beispiel #2
0
class DCPadArray(DCPadArray):
    params = ParamContainer(
        PCellParameter(
            name="layer_metal",
            type=TypeLayer,
            description="Metal Layer",
            default=EBeam.layers["M1"],
        ),
        PCellParameter(
            name="layer_opening",
            type=TypeLayer,
            description="Open Layer",
            default=EBeam.layers["13_MLopen"],
        ),
    )
Beispiel #3
0
class PositionMixin(PCell):
    """ handles the angle_ex parameter """

    params = ParamContainer(
        PCellParameter(
            name="angle_ex",
            type=TypeDouble,
            description="Placement Angle (0, 90, ..)",
            default=0,
        ))

    def origin_ex_ey(self, multiple_of_90=False):  # pylint: disable=unused-argument
        EX = kdb.DVector(1, 0)
        cp = self.get_cell_params()
        origin = kdb.DPoint(0, 0)
        # if 'angle_ex' not in cp.__dict__:
        #     cp.angle_ex = 0
        if multiple_of_90:
            if cp.angle_ex % 90 != 0:
                raise RuntimeError("Specify an angle multiple of 90 degrees")

        from math import pi

        ex = rotate(EX, cp.angle_ex * pi / 180)
        ey = rotate90(ex)
        return origin, ex, ey
Beispiel #4
0
def define_param(name, type, description, default=None, **kwargs):
    from zeropdk.pcell import PCellParameter

    return PCellParameter(name=name,
                          type=type,
                          description=description,
                          default=default,
                          **kwargs)
Beispiel #5
0
def test_quirky_cases():
    pc = ParamContainer()

    pc.add_param(PCellParameter(name="orange", default=1))

    # Don't try to set any value here
    with pytest.raises(
        TypeError, match="'ParamContainer' object does not support item assignment"
    ):
        pc["orange"] = 2
Beispiel #6
0
def define_param(name,
                 type,
                 description,
                 default=None,
                 layertype=None,
                 zmin=None,
                 zmax=None,
                 dopinglevel=None,
                 **kwargs):
    from zeropdk.pcell import PCellParameter

    return PCellParameter(name=name,
                          type=type,
                          description=description,
                          default=default,
                          **kwargs)
Beispiel #7
0
import pytest
import os
from ..context import zeropdk  # noqa
from zeropdk.pcell import PCell, PCellParameter, ParamContainer, TypeDouble, TypeInt
from zeropdk.pcell import GDSCell

import klayout.db as kdb

pad_size = PCellParameter(
    name="pad_size",
    type=TypeDouble,
    description="Size of electrical pad.",
    default=100,
    unit="um",
)

pad_array_count = PCellParameter(name="pad_array_count",
                                 type=TypeInt,
                                 description="Number of pads")


class Pad(PCell):
    params = ParamContainer(pad_size)


class PadArray(Pad):
    params = ParamContainer(pad_array_count)


def test_pcell_initializer():
    pad = Pad(name="testname", params={"pad_size": 10})
Beispiel #8
0
    TypeDouble,
    TypeInt,
    TypeLayer,
    TypePoint,
    Port,
    ParamContainer,
)
from zeropdk.layout import insert_shape
from zeropdk.layout.polygons import rectangle

from klayout.db import DPoint, DVector

pad_width = PCellParameter(
    name="pad_width",
    type=TypeDouble,
    description="Width of electrical pad.",
    default=120,
    unit="um",
)

pad_height = PCellParameter(
    name="pad_height",
    type=TypeDouble,
    description="Height of electrical pad.",
    default=120,
    unit="um",
)

port_width = PCellParameter(
    name="port_width",
    type=TypeDouble,