Example #1
0
 def layout_mzi_curve(P0, P1):
     curve = bezier_optimal(P0, P1, cp.angle_ex, cp.angle_ex)
     return layout_waveguide(cell,
                             lay.Si,
                             curve,
                             cp.wg_width,
                             smooth=True)
Example #2
0
def layout_connect_ports(cell, layer, port_from, port_to, smooth=True):
    """ Places an "optimal" bezier curve from port_from to port_to.
    """

    if port_from.name.startswith("el"):
        assert port_to.name.startswith("el")
        P0 = port_from.position + port_from.direction * port_from.width / 2
        P3 = port_to.position + port_to.direction * port_to.width / 2
        smooth = smooth and True
    else:
        dbu = cell.layout().dbu
        P0 = port_from.position - dbu * port_from.direction
        P3 = port_to.position - dbu * port_to.direction
        smooth = smooth or True
    angle_from = np.arctan2(port_from.direction.y,
                            port_from.direction.x) * 180 / pi
    angle_to = np.arctan2(-port_to.direction.y,
                          -port_to.direction.x) * 180 / pi

    curve = bezier_optimal(P0, P3, angle_from, angle_to)
    if debug:
        for point in curve:
            print(point)
        print(f"bezier_optimal({P0}, {P3}, {angle_from}, {angle_to})")
    return layout_waveguide(cell,
                            layer,
                            curve, [port_from.width, port_to.width],
                            smooth=smooth)
Example #3
0
def layout_connect_ports_angle(cell, layer, port_from, port_to, angle):
    """Places an "optimal" bezier curve from port_from to port_to, with a fixed orientation angle.

    Args:
        angle: degrees
    Use when connecting ports that are like horizontal-in and horizontal-out.
    """

    if port_from.name.startswith("el"):
        assert port_to.name.startswith("el")
        P0 = port_from.position + port_from.direction * port_from.width / 2
        P3 = port_to.position + port_to.direction * port_to.width / 2

        # straight lines for electrical connectors
        curve = [P0, P3]
    else:
        P0 = port_from.position
        P3 = port_to.position
        curve = bezier_optimal(P0, P3, angle, angle)

    return layout_waveguide_angle(cell, layer, curve,
                                  [port_from.width, port_to.width], angle)
Example #4
0
def bezier_curve(origin, angle0, angle3, ex, ey):
    P0 = origin
    P3 = origin + 100 * ex

    curve = bezier_optimal(P0, P3, angle0, angle3)
    return curve