# SPDX-License-Identifier: GPL-2.0-or-later
# PDKMaster & co. don't put a license requirement on the generated files.
# The generated gds files in this project are released under the LGPL 2.0 or later license.
from pathlib import Path
from typing import Dict, Any, cast

import pya as _pya
# Disable type checking
pya = cast(Any, _pya)

from pdkmaster.technology import geometry as _geo, primitive as _prm
from pdkmaster.design import layout as _lay, library as _lib
from pdkmaster.io.klayout import export as _klexp

from c4m.pdk import sky130

from . import frame as _frm


__all__ = ["gen_gds"]


# Match nets in IOConnected to pins
_netlookup = {
    "vss": "io_analog[0]",
    "vdd": "io_analog[1]",
    "ioout_pad": "io_analog[2]",
    "ioinout_pad": "io_analog[3]",
    "d_core": "io_analog[4]",
    "de_core": "io_analog[5]",
    "ioinout_core": "io_analog[6]",
    "ioin_core": "io_analog[7]",
    "ioin_pad": "io_analog[8]",
    "iovdd": "io_analog[9]",
    "iovss": "io_analog[10]",
    "ro_de": "gpio_analog[4]",
    "ro_en": "gpio_analog[5]",
    "ro_out": "gpio_noesd[7]",
}

# Dimensions for top level interconnects
_conn_width = 25.0
_conn_space = 2.0
_conn_pitch = _conn_width + _conn_space


def _gen_ioblock(*, lib: _lib.Library):
    tech = lib.tech
    prims = tech.primitives

    m1 = cast(_prm.MetalWire, prims.m1)
    assert m1.pin is not None
    m1pin = m1.pin[0]
    via = cast(_prm.Via, prims.via)
    m2 = cast(_prm.MetalWire, prims.m2)
    assert m2.pin is not None
    m2pin = m2.pin[0]
    m5 = cast(_prm.MetalWire, prims.m5)
    assert m5.pin is not None
    m5pin = m5.pin[0]

    # Create the IOBlock
    ioblock = lib.new_cell(name="IOBlock")
    ckt = ioblock.new_circuit()
    nets = ckt.nets
    layouter = ioblock.new_circuitlayouter()

    for net_name in _netlookup.keys():
        if net_name.startswith("ro_"):
            continue
        ckt.new_net(name=net_name, external=True)

    x = 0.0
    lay = None
    d_m1pin_bounds1 = d_m1pin_bounds2 = None
    de_m1pin_bounds1 = de_m1pin_bounds2 = None
    for (cell_name, top_pad_netname, cell_pad_netname) in (
        ("IOPadIOVss", "iovss", "iovss"),
        ("IOPadIOVdd", "iovdd", "iovdd"),
        ("IOPadIn", "ioin_pad", "pad"),
        ("IOPadInOut", "ioinout_pad", "pad"),
        ("IOPadOut", "ioout_pad", "pad"),
        ("IOPadVdd", "vdd", "vdd"),
        ("IOPadVss", "vss", "vss"),
    ):
        cell = sky130.iolib.cells[cell_name]
        inst = ckt.new_instance(name=cell_name, object_=cell)
        lay = layouter.place(inst, x=x, y=0.0)

        nets[top_pad_netname].childports += inst.ports[cell_pad_netname]
        if cell_name == "IOPadIn":
            nets.ioin_core.childports += inst.ports.s
        elif cell_name == "IOPadInOut":
            nets.ioinout_core.childports += inst.ports.s
        if cell_name in ("IOPadInOut", "IOPadOut"):
            nets.d_core.childports += inst.ports.d
            nets.de_core.childports += inst.ports.de
        m5pin_bounds = lay.bounds(mask=m5pin.mask)
        layouter.add_wire(net=nets[top_pad_netname], wire=m5, pin=m5pin, shape=m5pin_bounds)

        if cell_name == "IOPadIn":
            net = nets.ioin_core
            m1pin_bounds = lay.bounds(mask=m1pin.mask, net=net, depth=1)
            layouter.add_wire(net=net, wire=m1, pin=m1pin, shape=m1pin_bounds)
        elif cell_name == "IOPadInOut":
            net = nets.ioinout_core
            m1pin_bounds = lay.bounds(mask=m1pin.mask, net=net, depth=1)
            layouter.add_wire(net=net, wire=m1, pin=m1pin, shape=m1pin_bounds)

            d_m1pin_bounds1 = lay.bounds(mask=m1pin.mask, net=nets.d_core, depth=1)
            de_m1pin_bounds1 = lay.bounds(mask=m1pin.mask, net=nets.de_core, depth=1)
        elif cell_name == "IOPadOut":
            d_m1pin_bounds2 = lay.bounds(mask=m1pin.mask, net=nets.d_core, depth=1)
            de_m1pin_bounds2 = lay.bounds(mask=m1pin.mask, net=nets.de_core, depth=1)

        assert lay.boundary is not None
        x = lay.boundary.right
    assert lay is not None
    assert d_m1pin_bounds1 is not None
    assert d_m1pin_bounds2 is not None
    assert de_m1pin_bounds1 is not None
    assert de_m1pin_bounds2 is not None

    # Connect d and de
    m2_width = tech.computed.min_width(m2, down=True, up=True, min_enclosure=True)

    net = nets.d_core
    bottom = max(d_m1pin_bounds1.top, d_m1pin_bounds2.top) + m1.min_space
    width = d_m1pin_bounds2.right - d_m1pin_bounds1.left
    _l_via = layouter.wire_layout(
        net=net, wire=via,
        bottom_width=width, bottom_enclosure="wide",
        top_width=width, top_height=m2_width, top_enclosure="wide",
    )
    _m1_bounds = _l_via.bounds(mask=m1.mask)
    x = 0.5*(d_m1pin_bounds2.right + d_m1pin_bounds1.left)
    y = bottom - _m1_bounds.bottom
    l_via = layouter.place(_l_via, x=x, y=y)
    m1_bounds = l_via.bounds(mask=m1.mask)
    m2_bounds = l_via.bounds(mask=m2.mask)
    layouter.add_wire(
        net=net, wire=m1, shape=_geo.Rect.from_rect(rect=d_m1pin_bounds1, top=m1_bounds.top),
    )
    layouter.add_wire(
        net=net, wire=m1, shape=_geo.Rect.from_rect(rect=d_m1pin_bounds2, top=m1_bounds.top),
    )
    _l_m2 = layouter.wire_layout(
        net=net, wire=m2, pin=m2pin, width=m2_bounds.width, height=m2_width,
    )
    _m2_bounds = _l_m2.bounds()
    x = m2_bounds.left - _m2_bounds.left
    y = m2_bounds.bottom - _m2_bounds.bottom
    l_m2 = layouter.place(_l_m2, x=x, y=y)
    dm2_bounds = l_m2.bounds()

    net = nets.de_core
    bottom = dm2_bounds.top + m2.min_space
    width = de_m1pin_bounds2.right - de_m1pin_bounds1.left
    _l_via = layouter.wire_layout(
        net=net, wire=via,
        bottom_width=width, bottom_enclosure="wide",
        top_width=width, top_height=m2_width, top_enclosure="wide",
    )
    _m1_bounds = _l_via.bounds(mask=m1.mask)
    x = 0.5*(de_m1pin_bounds2.right + de_m1pin_bounds1.left)
    y = bottom - _m1_bounds.bottom
    l_via = layouter.place(_l_via, x=x, y=y)
    m1_bounds = l_via.bounds(mask=m1.mask)
    m2_bounds = l_via.bounds(mask=m2.mask)
    layouter.add_wire(
        net=net, wire=m1, shape=_geo.Rect.from_rect(rect=de_m1pin_bounds1, top=m1_bounds.top),
    )
    layouter.add_wire(
        net=net, wire=m1, shape=_geo.Rect.from_rect(rect=de_m1pin_bounds2, top=m1_bounds.top),
    )
    _l_m2 = layouter.wire_layout(
        net=net, wire=m2, pin=m2pin, width=m2_bounds.width, height=m2_width,
    )
    _m2_bounds = _l_m2.bounds()
    x = m2_bounds.left - _m2_bounds.left
    y = m2_bounds.bottom - _m2_bounds.bottom
    layouter.place(_l_m2, x=x, y=y)

    assert isinstance(lay.boundary, _geo.Rect)
    layouter.layout.boundary = _geo.Rect.from_rect(rect=lay.boundary, left=0.0)

    return ioblock


def _gen_ioro(*, lib: _lib.Library):
    tech = lib.tech
    prims = tech.primitives

    li = cast(_prm.MetalWire, prims.li)
    assert (li.pin is not None) and (len(li.pin) == 1)
    lipin = li.pin[0]
    mcon = cast(_prm.Via, prims.mcon)
    m1 = cast(_prm.MetalWire, prims.m1)
    assert (m1.pin is not None) and (len(m1.pin) == 1)
    m1pin = m1.pin[0]
    via = cast(_prm.Via, prims.via)
    m2 = cast(_prm.MetalWire, prims.m2)
    assert (m2.pin is not None) and (len(m2.pin) == 1)
    m2pin = m2.pin[0]
    via2 = cast(_prm.Via, prims.via2)
    via3 = cast(_prm.Via, prims.via3)
    m4 = cast(_prm.MetalWire, prims.m4)
    assert (m4.pin is not None) and (len(m4.pin) == 1)
    m4pin = m4.pin[0]
    via4 = cast(_prm.Via, prims.via4)
    m5 = cast(_prm.MetalWire, prims.m5)
    assert (m5.pin is not None) and (len(m5.pin) == 1)
    m5pin = m5.pin[0]

    # Create the IORO
    ioro = lib.new_cell(name="IORO")
    ckt = ioro.new_circuit()
    nets = ckt.nets
    layouter = ioro.new_circuitlayouter()

    stages = 5

    # External nets
    for net_name in ("iovdd", "iovss", "vdd", "vss", "ro_de", "ro_en", "ro_out"):
        ckt.new_net(name=net_name, external=True)
    # Internal nets
    for i in range(stages):
        ckt.new_net(f"stage{i}_3v3", external=False)
        ckt.new_net(f"stage{i}_1v8", external=False)
    # Extra net for last d that will come from a NAND gate
    ckt.new_net(f"stage{stages}_1v8", external=False)

    # Instantiate all cells and compute cell width
    x = 0.0
    lay = None
    layouts: Dict[str, _lay._Layout] = {}
    # First DC cells
    for cell_name, pad_net_name in (
        ("IOPadVdd", "vdd"),
        ("IOPadVss", "vss"),
        ("IOPadIOVdd", "iovdd"),
        ("IOPadIOVss", "iovss"),
    ):
        inst_name = f"{cell_name}0"
        cell = sky130.iolib.cells[cell_name]
        inst = ckt.new_instance(name=inst_name, object_=cell)
        nets[pad_net_name].childports += inst.ports[pad_net_name]
        layouts[inst_name] = lay = layouter.place(object_=inst, x=x, y=0.0)
        assert lay.boundary is not None
        x = lay.boundary.right
    # 5 In/Out pairs
    cell_in = sky130.iolib.cells["IOPadIn"]
    cell_out = sky130.iolib.cells["IOPadOut"]
    for i in range(stages):
        conn_net_3v3 = nets[f"stage{i}_3v3"]
        conn_net_1v8_in = nets[f"stage{i}_1v8"]
        conn_net_1v8_out = nets[f"stage{i + 1}_1v8"]

        inst_name = f"in{i}"
        inst = ckt.new_instance(name=inst_name, object_=cell_in)
        nets.vss.childports += inst.ports.vss
        nets.vdd.childports += inst.ports.vdd
        nets.iovss.childports += inst.ports.iovss
        nets.iovdd.childports += inst.ports.iovdd
        conn_net_3v3.childports += inst.ports.pad
        conn_net_1v8_in.childports += inst.ports.s
        layouts[inst_name] = lay = layouter.place(object_=inst, x=x, y=0.0)
        assert lay.boundary is not None

        if i == 0:
            # Insert standard cells
            bottom = lay.boundary.top + 2*m4.min_space

            buf = sky130.stdcelllib.cells["buf_x4"]
            assert buf.layout.boundary is not None
            x2 = lay.boundary.center.x - buf.layout.boundary.right
            inst_name = "roout_buf"
            inst2 = ckt.new_instance(name=inst_name, object_=buf)
            nets.vss.childports += inst2.ports.vss
            nets.vdd.childports += inst2.ports.vdd
            conn_net_1v8_in.childports += inst2.ports.i
            nets.ro_out.childports += inst2.ports.q
            layouts[inst_name] = lay2 = layouter.place(inst2, x=x2, y=bottom)
            assert lay2.boundary is not None
            x2 = lay2.boundary.right

            nand = sky130.stdcelllib.cells["nand2_x0"]
            inst_name = "en_nand"
            inst2 = ckt.new_instance(name=inst_name, object_=nand)
            nets.vss.childports += inst2.ports.vss
            nets.vdd.childports += inst2.ports.vdd
            conn_net_1v8_in.childports += inst2.ports.i0
            nets.ro_en.childports += inst2.ports.i1
            nets[f"stage{stages}_1v8"].childports += inst2.ports.nq
            layouts[inst_name] = lay2 = layouter.place(inst2, x=x2, y=bottom)
            assert lay2.boundary is not None
            x2 = lay2.boundary.right

            tie = sky130.stdcelllib.cells["tie"]
            inst_name = "tie0"
            inst2 = ckt.new_instance(name=inst_name, object_=tie)
            nets.vss.childports += inst2.ports.vss
            nets.vdd.childports += inst2.ports.vdd
            layouts[inst_name] = lay2 = layouter.place(inst2, x=x2, y=bottom)
            assert lay2.boundary is not None
            x2 = lay2.boundary.right
            inst_name = "tie1"
            inst2 = ckt.new_instance(name=inst_name, object_=tie)
            nets.vss.childports += inst2.ports.vss
            nets.vdd.childports += inst2.ports.vdd
            layouts[inst_name] = lay2 = layouter.place(inst2, x=x2, y=bottom)

        x = lay.boundary.right

        inst_name = f"out{i}"
        inst = ckt.new_instance(name=inst_name, object_=cell_out)
        nets.vss.childports += inst.ports.vss
        nets.vdd.childports += inst.ports.vdd
        nets.iovss.childports += inst.ports.iovss
        nets.iovdd.childports += inst.ports.iovdd
        conn_net_3v3.childports += inst.ports.pad
        conn_net_1v8_out.childports += inst.ports.d
        nets.ro_de.childports += inst.ports.de
        layouts[inst_name] = lay = layouter.place(object_=inst, x=x, y=0.0)
        assert lay.boundary is not None
        x = lay.boundary.right
    # Last DC cells
    for cell_name, pad_net_name in (
        ("IOPadVdd", "vdd"),
        ("IOPadVss", "vss"),
        ("IOPadIOVdd", "iovdd"),
        ("IOPadIOVss", "iovss"),
    ):
        inst_name = f"{cell_name}1"
        cell = sky130.iolib.cells[cell_name]
        inst = ckt.new_instance(name=inst_name, object_=cell)
        nets[pad_net_name].childports += inst.ports[pad_net_name]
        layouts[inst_name] = lay = layouter.place(object_=inst, x=x, y=0.0)
        assert lay.boundary is not None
        x = lay.boundary.right
    assert (lay is not None) and (lay.boundary is not None)
    block_top = lay.boundary.top
    cell_width = x

    # Add DC pins and connect to pads
    for i, (cell_name, pad_net) in enumerate((
        ("IOPadVdd", nets.vdd),
        ("IOPadVss", nets.vss),
        ("IOPadIOVdd", nets.iovdd),
        ("IOPadIOVss", nets.iovss),
    )):
        m4_top = -_conn_space - i*_conn_pitch
        m4_bottom = m4_top - _conn_width
        rect = _geo.Rect(left=0.0, bottom=m4_bottom, right=cell_width, top=m4_top)
        layouter.add_wire(net=pad_net, wire=m4, pin=m4pin, shape=rect)

        for j in range(2):
            inst_name = f"{cell_name}{j}"
            lay = layouts[inst_name]
            m5pin_bounds = lay.bounds(net=pad_net, mask=m5pin.mask)

            _l_via4 = layouter.wire_layout(
                net=pad_net, wire=via4,
                bottom_width=_conn_width, bottom_height=_conn_width,
                top_width=_conn_width, top_height=_conn_width,
            )
            _m4_bounds = _l_via4.bounds(mask=m4.mask)
            x = m5pin_bounds.center.x
            y = m4_top - _m4_bounds.top
            l_via4 = layouter.place(_l_via4, x=x, y=y)
            via4m5_bounds = l_via4.bounds(mask=m5.mask)
            layouter.add_wire(net=pad_net, wire=m5, shape=_geo.Rect.from_rect(
                rect=via4m5_bounds, top=m5pin_bounds.top,
            ))
    cell_bottom = -_conn_space - (4 - 1)*_conn_pitch

    tie0_bndry = layouts["tie0"].boundary
    assert tie0_bndry is not None

    # Draw output pins
    dem2_bottom = tie0_bndry.top + _conn_space
    dem2_top = dem2_bottom + _conn_width
    dem2_rect = _geo.Rect(left=0.0, bottom=dem2_bottom, right=cell_width, top=dem2_top)
    layouter.add_wire(net=nets.ro_de, wire=m2, pin=m2pin, shape=dem2_rect)

    roen_bottom = dem2_top + _conn_space
    roen_top = roen_bottom + _conn_width
    roen_rect = _geo.Rect(left=0.0, bottom=roen_bottom, right=cell_width, top=roen_top)
    layouter.add_wire(net=nets.ro_en, wire=m2, pin=m2pin, shape=roen_rect)

    roout_bottom = roen_top + _conn_space
    cell_top = roout_top = roout_bottom + _conn_width
    roout_rect = _geo.Rect(left=0.0, bottom=roout_bottom, right=cell_width, top=roout_top)
    layouter.add_wire(net=nets.ro_out, wire=m2, pin=m2pin, shape=roout_rect)

    # Connect de to pin
    _l_de_via = layouter.wire_layout(
        net=nets.ro_de, wire=via, bottom_height=_conn_width, top_height=_conn_width,
    )
    _m1_bounds = _l_de_via.bounds(mask=m1.mask)
    s = dem2_bottom - block_top
    rect = _geo.Rect.from_rect(rect=_m1_bounds, bottom=(_m1_bounds.bottom - s))
    _l_de_via.add_shape(prim=m1, net=nets.ro_de, shape=rect)
    y_de_via = block_top - rect.bottom
    for i in range(stages):
        conn_net_3v3 = nets[f"stage{i}_3v3"]
        conn_net_1v8_in = nets[f"stage{i}_1v8"]
        conn_net_1v8_out = nets[f"stage{i + 1}_1v8"]

        inst_name = f"in{i}"
        lay = layouts[inst_name]
        inm5pin_bounds = lay.bounds(mask=m5pin.mask, net=conn_net_3v3)

        inst_name = f"out{i}"
        lay = layouts[inst_name]
        outm5pin_bounds = lay.bounds(mask=m5pin.mask, net=conn_net_3v3)
        dem1pin_bounds = lay.bounds(mask=m1pin.mask, net=nets.ro_de)
        assert abs(dem1pin_bounds.top - block_top) < tech.grid
        x = dem1pin_bounds.center.x
        y = y_de_via
        layouter.place(_l_de_via, x=x, y=y)

        rect = _geo.Rect(
            left=inm5pin_bounds.right, bottom=inm5pin_bounds.bottom,
            right=outm5pin_bounds.left, top=inm5pin_bounds.bottom + _conn_width,
        )
        layouter.add_wire(net=conn_net_3v3, wire=m5, shape=rect)
        rect = _geo.Rect(
            left=inm5pin_bounds.right, bottom=inm5pin_bounds.top - _conn_width,
            right=outm5pin_bounds.left, top=inm5pin_bounds.top,
        )
        layouter.add_wire(net=conn_net_3v3, wire=m5, shape=rect)

    # Connect ro_out
    net = nets.ro_out
    rooutlipin_bounds = layouts["roout_buf"].bounds(mask=lipin.mask, net=net, depth=1)
    _l_mcon = layouter.wire_layout(net=net, wire=mcon, rows=3)
    _li_bounds = _l_mcon.bounds(mask=li.mask)
    x = rooutlipin_bounds.center.x
    y = rooutlipin_bounds.top - _li_bounds.top
    l_mcon = layouter.place(_l_mcon, x=x, y=y)
    rooutmconm1_bounds = l_mcon.bounds(mask=m1.mask)
    _l_via = layouter.wire_layout(net=net, wire=via, top_height=_conn_width)
    _m2_bounds = _l_via.bounds(mask=m2.mask)
    x = rooutlipin_bounds.center.x
    y = roout_bottom - _m2_bounds.bottom
    l_via = layouter.place(_l_via, x=x, y=y)
    rooutviam1_bounds = l_via.bounds(mask=m1.mask)
    rect = _geo.Rect.from_rect(rect=rooutviam1_bounds, bottom=rooutmconm1_bounds.bottom)
    layouter.add_wire(net=net, wire=m1, shape=rect)

    # Connect ro_en
    net = nets.ro_en
    roenlipin_bounds = layouts["en_nand"].bounds(mask=lipin.mask, net=net, depth=1)
    _l_mcon = layouter.wire_layout(net=net, wire=mcon, rows=3)
    _li_bounds = _l_mcon.bounds(mask=li.mask)
    x = roenlipin_bounds.center.x
    y = roenlipin_bounds.top - _li_bounds.top
    l_mcon = layouter.place(_l_mcon, x=x, y=y)
    roenmconm1_bounds = l_mcon.bounds(mask=m1.mask)
    _l_via = layouter.wire_layout(net=net, wire=via, top_height=_conn_width)
    _m2_bounds = _l_via.bounds(mask=m2.mask)
    x = roenmconm1_bounds.left - _m2_bounds.right
    y = roen_bottom - _m2_bounds.bottom
    l_via = layouter.place(_l_via, x=x, y=y)
    roenviam1_bounds = l_via.bounds(mask=m1.mask)
    rect = _geo.Rect.from_rect(rect=roenviam1_bounds, bottom=roenmconm1_bounds.bottom)
    layouter.add_wire(net=net, wire=m1, shape=rect)

    # Connect stage0_1v8
    net = nets.stage0_1v8

    padm1pin_bounds = layouts["in0"].bounds(net=net, mask=m1pin.mask, depth=1)
    buflipin_bounds = layouts["roout_buf"].bounds(net=net, mask=lipin.mask, depth=1)
    nandlipin_bounds = layouts["en_nand"].bounds(net=net, mask=lipin.mask, depth=1)
    # Check assumption of placement of cells with regard to pad pin
    assert buflipin_bounds.center.x < padm1pin_bounds.center.x < nandlipin_bounds.center.x

    _l_mcon = layouter.wire_layout(net=net, wire=mcon, rows=2)
    _li_bounds = _l_mcon.bounds(mask=li.mask)
    bottom = max(buflipin_bounds.bottom, nandlipin_bounds.bottom)
    y = bottom - _li_bounds.bottom
    l_mcon1 = layouter.place(_l_mcon, x=buflipin_bounds.center.x, y=y)
    bufm1_bounds = l_mcon1.bounds(mask=m1.mask)
    l_mcon2 = layouter.place(_l_mcon, x=nandlipin_bounds.center.x, y=y)
    nandm1_bounds = l_mcon2.bounds(mask=m1.mask)
    shape = _geo.Polygon.from_floats(points=(
        (padm1pin_bounds.left, padm1pin_bounds.top),
        (padm1pin_bounds.left, bottom),
        (bufm1_bounds.left, bottom),
        (bufm1_bounds.left, bufm1_bounds.top),
        (nandm1_bounds.right, bufm1_bounds.top),
        (nandm1_bounds.right, bottom),
        (padm1pin_bounds.right, bottom),
        (padm1pin_bounds.right, padm1pin_bounds.top),
        (padm1pin_bounds.left, padm1pin_bounds.top),
    ))
    layouter.add_wire(net=net, wire=m1, shape=shape)

    # Connect stage{stages}_1v8
    net = nets[f"stage{stages}_1v8"]

    padm1pin_bounds = layouts[f"out{stages - 1}"].bounds(net=net, mask=m1pin.mask, depth=1)
    nandlipin_bounds = layouts["en_nand"].bounds(net=net, mask=lipin.mask)
    # Check assumptions of placement of pin
    assert nandlipin_bounds.right < padm1pin_bounds.left

    _l_mcon = layouter.wire_layout(net=net, wire=mcon, rows=2)
    _li_bounds = _l_mcon.bounds(mask=li.mask)
    x = nandlipin_bounds.center.x
    y = nandlipin_bounds.top - _li_bounds.top
    l_mcon = layouter.place(_l_mcon, x=x, y=y)
    nandm1_bounds = l_mcon.bounds(mask=m1.mask)
    x = nandm1_bounds.center.x
    y = nandm1_bounds.center.y
    l1_via = layouter.add_wire(net=net, wire=via, rows=2, x=x, y=y)
    m2_bounds1 = l1_via.bounds(mask=m2.mask)
    x = padm1pin_bounds.center.x
    l2_via = layouter.add_wire(net=net, wire=via, rows=2, x=x, y=y)
    m1_bounds2 = l2_via.bounds(mask=m1.mask)
    m2_bounds2 = l2_via.bounds(mask=m2.mask)
    rect = _geo.Rect.from_rect(rect=m2_bounds1, right=m2_bounds2.right)
    layouter.add_wire(net=net, wire=m2, shape=rect)
    rect = _geo.Rect.from_rect(rect=padm1pin_bounds, top=m1_bounds2.top)
    layouter.add_wire(net=net, wire=m1, shape=rect)

    layouter.add_wire(net=net, wire=m1, shape=shape)

    # Connect stage{n}_1v8 n=1..(stages - 1)
    for i in range(1, stages):
        net = nets[f"stage{i}_1v8"]

        outpadm1pin_bounds = layouts[f"out{i - 1}"].bounds(net=net, mask=m1pin.mask, depth=1)
        inpadm1pin_bounds = layouts[f"in{i}"].bounds(net=net, mask=m1pin.mask, depth=1)
        # Check assumptions
        assert outpadm1pin_bounds.right < inpadm1pin_bounds.left

        _l_via = layouter.wire_layout(net=net, wire=via, rows=2)
        _m2_bounds = _l_via.bounds(mask=m2.mask)
        y = block_top + 2*m2.min_space - _m2_bounds.bottom
        l1_via = layouter.place(_l_via, x=outpadm1pin_bounds.center.x, y=y)
        m1_bounds1 = l1_via.bounds(mask=m1.mask)
        m2_bounds1 = l1_via.bounds(mask=m2.mask)
        l2_via = layouter.place(_l_via, x=inpadm1pin_bounds.center.x, y=y)
        m1_bounds2 = l2_via.bounds(mask=m1.mask)
        m2_bounds2 = l2_via.bounds(mask=m2.mask)

        rect = _geo.Rect.from_rect(rect=outpadm1pin_bounds, top=m1_bounds1.top)
        layouter.add_wire(net=net, wire=m1, shape=rect)
        rect = _geo.Rect.from_rect(rect=inpadm1pin_bounds, top=m1_bounds2.top)
        layouter.add_wire(net=net, wire=m1, shape=rect)
        rect = _geo.Rect.from_rect(rect=m2_bounds1, right=m2_bounds2.right)
        layouter.add_wire(net=net, wire=m2, shape=rect)

    # Connect vss/vdd of standard cells
    net = nets.vss
    vsstielipin_bounds = layouts["tie0"].bounds(net=net, mask=lipin.mask)
    vsspadm4pin_bounds = layouts["in0"].bounds(net=net, mask=m4pin.mask)
    x = vsstielipin_bounds.center.x
    y = vsstielipin_bounds.center.y
    h = vsstielipin_bounds.height
    for via_layer in (mcon, via, via2, via3):
        l_via = layouter.add_wire(
            net=net, wire=via_layer, bottom_height=h, top_height=h, x=x, y=y,
        )
    m4_bounds = l_via.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=m4_bounds, bottom=vsspadm4pin_bounds.bottom)
    layouter.add_wire(net=net, wire=m4, shape=rect)

    net = nets.vdd
    vddtielipin_bounds = layouts["tie1"].bounds(net=net, mask=lipin.mask)
    vddpadm4pin_bounds = layouts["in0"].bounds(net=net, mask=m4pin.mask)
    x = vddtielipin_bounds.center.x
    y = vddtielipin_bounds.center.y
    h = vddtielipin_bounds.height
    for via_layer in (mcon, via, via2, via3):
        l_via = layouter.add_wire(
            net=net, wire=via_layer, bottom_height=h, top_height=h, x=x, y=y,
        )
    # via4 needs bigger line
    l_via4 = layouter.add_wire(net=net, wire=via4, rows=2, x=x, y=y)
    m5_bounds1 = l_via4.bounds(mask=m5.mask)
    _l_via4 = layouter.wire_layout(net=net, wire=via4, rows=2)
    _m4_bounds = _l_via4.bounds(mask=m4.mask)
    y = vddpadm4pin_bounds.top - _m4_bounds.top
    l_via4 = layouter.place(_l_via4, x=x, y=y)
    m5_bounds2 = l_via4.bounds(mask=m5.mask)
    rect = _geo.Rect.from_rect(rect=m5_bounds1, bottom=m5_bounds2.bottom)
    layouter.add_wire(net=net, wire=m5, shape=rect)

    # Set set boundary
    bndry = _geo.Rect(left=0.0, bottom=cell_bottom, right=cell_width, top=cell_top)
    layouter.layout.boundary = bndry

    return ioro


def _gen_ioconn(*,
    lib: _lib.Library, ioblock: _lib._Cell[_lib.Library], ioro: _lib._Cell[_lib.Library],
):
    tech = lib.tech
    prims = tech.primitives

    m1 = cast(_prm.MetalWire, prims.m1)
    assert (m1.pin is not None) and (len(m1.pin) == 1)
    m1pin = m1.pin[0]
    via = cast(_prm.Via, prims.via)
    m2 = cast(_prm.MetalWire, prims.m2)
    assert (m2.pin is not None) and (len(m2.pin) == 1)
    m2pin = m2.pin[0]
    via2 = cast(_prm.Via, prims.via2)
    m3 = cast(_prm.MetalWire, prims.m3)
    assert (m3.pin is not None) and (len(m3.pin) == 1)
    m3pin = m3.pin[0]
    via3 = cast(_prm.Via, prims.via3)
    m4 = cast(_prm.MetalWire, prims.m4)
    assert (m4.pin is not None) and (len(m4.pin) == 1)
    m4pin = m4.pin[0]
    via4 = cast(_prm.Via, prims.via4)
    m5 = cast(_prm.MetalWire, prims.m5)
    assert (m5.pin is not None) and (len(m5.pin) == 1)
    m5pin = m5.pin[0]

    conn_top = 3500.0

    # Create connected out cell
    ioconn = lib.new_cell(name="IOConnected")
    ckt = ioconn.new_circuit()
    nets = ckt.nets
    layouter = ioconn.new_circuitlayouter()

    # Create the top nets
    for net_name in _netlookup.keys():
        ckt.new_net(name=net_name, external=True)

    # assign nets to different horizontal m4 lanes, some at same height
    n_conn = {
        "iovdd": 0,
        "vdd": 0,
        "ioin_pad": 1,
        "ioout_pad": 1,
        "ioin_core": 2,
        "ioinout_pad": 2,
        "ioinout_core": 3,
        "d_core": 4,
        "de_core": 4,
    }
    conns = max(n_conn.values()) + 1
    blk_top = conn_top - conns*_conn_pitch

    inst = ckt.new_instance(name="block", object_=ioblock)
    for net_name in _netlookup.keys():
        if net_name.startswith("ro_"):
            continue
        nets[net_name].childports += inst.ports[net_name]
    bound = ioblock.layout.boundary
    assert isinstance(bound, _geo.Rect)
    x = _frm.boundary.center.x - bound.center.x
    y = blk_top - bound.top
    l_block = layouter.place(inst, x=x, y=y)

    # Connect other bond pads
    for net_name in ("iovdd", "ioin_pad", "ioinout_pad", "ioout_pad", "vdd"):
        net = nets[net_name]
        pinrect = _frm.toppins[_netlookup[net_name]]
        blkpinm5_bounds = l_block.bounds(net=net, mask=m5pin.mask)
        lane = n_conn[net_name]
        m4_top = conn_top - lane*_conn_pitch
        conn_right = pinrect.right < blkpinm5_bounds.left
        if not conn_right:
            assert pinrect.left > blkpinm5_bounds.right

        layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)
        _l_via3 = layouter.wire_layout(
            net=net, wire=via3,
            bottom_width=_conn_width, bottom_height=_conn_width,
            top_width=_conn_width, top_height=_conn_width,
        )
        _m4_bounds = _l_via3.bounds(mask=m4.mask)
        x = pinrect.center.x
        y = m4_top - _m4_bounds.top
        l_via3 = layouter.place(_l_via3, x=x, y=y)
        via3m3_bounds = l_via3.bounds(mask=m3.mask)
        via3m4_bounds = l_via3.bounds(mask=m4.mask)
        layouter.add_wire(net=net, wire=m3, shape=_geo.Rect.from_rect(
            rect=via3m3_bounds, top=pinrect.bottom,
        ))
        _l_via4 = layouter.wire_layout(
            net=net, wire=via4,
            bottom_width=_conn_width, bottom_height=_conn_width,
            top_width=_conn_width, top_height=_conn_width,
        )
        _m4_bounds = _l_via4.bounds(mask=m4.mask)
        _m5_bounds = _l_via4.bounds(mask=m5.mask)
        x = blkpinm5_bounds.center.x
        y = m4_top - _m4_bounds.top
        l_via4 = layouter.place(_l_via4, x=x, y=y)
        via4m4_bounds = l_via4.bounds(mask=m4.mask)
        via4m5_bounds = l_via4.bounds(mask=m5.mask)
        if conn_right:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, right=via4m4_bounds.right,
            ))
        else:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, left=via4m4_bounds.left,
            ))
        layouter.add_wire(net=net, wire=m5, shape=_geo.Rect.from_rect(
            rect=via4m5_bounds, bottom=blkpinm5_bounds.bottom,
        ))

    # Connect core pins
    for net_name in ("ioin_core", "ioinout_core"):
        net = nets[net_name]
        pinrect = _frm.toppins[_netlookup[net_name]]
        blkpinm1_bounds = l_block.bounds(net=net, mask=m1pin.mask)
        blkm2_bounds = l_block.bounds(mask=m2.mask)
        lane = n_conn[net_name]
        m4_top = conn_top - lane*_conn_pitch
        conn_right = pinrect.right < blkpinm1_bounds.left
        if not conn_right:
            assert pinrect.left > blkpinm1_bounds.right

        layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)
        _l_via3 = layouter.wire_layout(
            net=net, wire=via3,
            bottom_width=_conn_width, bottom_height=_conn_width,
            top_width=_conn_width, top_height=_conn_width,
        )
        _m4_bounds = _l_via3.bounds(mask=m4.mask)
        x = pinrect.center.x
        y = m4_top - _m4_bounds.top
        l_via3 = layouter.place(_l_via3, x=x, y=y)
        via3m3_bounds = l_via3.bounds(mask=m3.mask)
        via3m4_bounds = l_via3.bounds(mask=m4.mask)
        layouter.add_wire(net=net, wire=m3, shape=_geo.Rect.from_rect(
            rect=via3m3_bounds, top=pinrect.bottom,
        ))
        _l_blkvia = layouter.wire_layout(
            net=net, wire=via, columns=10, rows=10,
        )
        _m2_bounds = _l_blkvia.bounds(mask=m2.mask)
        x = blkpinm1_bounds.center.x
        y = blkm2_bounds.top + 2*m2.min_space - _m2_bounds.bottom
        l_blkvia = layouter.place(_l_blkvia, x=x, y=y)
        blkviam1_bounds = l_blkvia.bounds(mask=m2.mask)
        blkviam2_bounds = l_blkvia.bounds(mask=m2.mask)
        layouter.add_wire(net=net, wire=m1, shape=_geo.Rect.from_rect(
            rect=blkpinm1_bounds, top=blkviam1_bounds.top,
        ))
        _l_blkvia2 = layouter.wire_layout(
            net=net, wire=via2, columns=20, rows=20,
        )
        _m2_bounds = _l_blkvia2.bounds(mask=m2.mask)
        x = blkpinm1_bounds.center.x
        y = blkviam2_bounds.top - _m2_bounds.bottom
        l_blkvia2 = layouter.place(_l_blkvia2, x=x, y=y)
        blkvia2m3_bounds = l_blkvia2.bounds(mask=m3.mask)
        layouter.add_wire(net=net, wire=m3, shape=_geo.Rect.from_rect(
            rect=blkvia2m3_bounds, top=m4_top,
        ))
        _l_blkvia3 = layouter.wire_layout(
            net=net, wire=via3,
            bottom_width=blkvia2m3_bounds.width, bottom_height=_conn_width,
            top_width=blkvia2m3_bounds.width, top_height=_conn_width,
        )
        _m4_bounds = _l_blkvia3.bounds(mask=m4.mask)
        x = blkpinm1_bounds.center.x
        y = m4_top - _m4_bounds.top
        l_blkvia3 = layouter.place(_l_blkvia3, x=x, y=y)
        blkvia3m4_bounds = l_blkvia3.bounds(mask=m4.mask)
        if conn_right:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, right=blkvia3m4_bounds.right,
            ))
        else:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, left=blkvia3m4_bounds.left,
            ))

    # Connect block m2 pins
    for net_name in ("d_core", "de_core"):
        net = nets[net_name]
        pinrect = _frm.toppins[_netlookup[net_name]]
        blkpinm2_bounds = l_block.bounds(net=net, mask=m2pin.mask)
        lane = n_conn[net_name]
        m4_top = conn_top - lane*_conn_pitch
        conn_right = pinrect.right < blkpinm2_bounds.left
        if not conn_right:
            assert pinrect.left > blkpinm2_bounds.right

        layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)
        _l_via3 = layouter.wire_layout(
            net=net, wire=via3,
            bottom_width=_conn_width, bottom_height=_conn_width,
            top_width=_conn_width, top_height=_conn_width,
        )
        _m4_bounds = _l_via3.bounds(mask=m4.mask)
        x = pinrect.center.x
        y = m4_top - _m4_bounds.top
        l_via3 = layouter.place(_l_via3, x=x, y=y)
        via3m3_bounds = l_via3.bounds(mask=m3.mask)
        via3m4_bounds = l_via3.bounds(mask=m4.mask)
        layouter.add_wire(net=net, wire=m3, shape=_geo.Rect.from_rect(
            rect=via3m3_bounds, top=pinrect.bottom,
        ))
        _l_blkvia2 = layouter.wire_layout(net=net, wire=via2, columns=20, bottom_enclosure="wide")
        _m2_bounds = _l_blkvia2.bounds(mask=m2.mask)
        if conn_right:
            x = blkpinm2_bounds.left - _m2_bounds.left
        else:
            x = blkpinm2_bounds.right - _m2_bounds.right
        y = blkpinm2_bounds.center.y
        l_blkvia2 = layouter.place(_l_blkvia2, x=x, y=y)
        blkvia2m3_bounds = l_blkvia2.bounds(mask=m3.mask)
        layouter.add_wire(net=net, wire=m3, shape=_geo.Rect.from_rect(
            rect=blkvia2m3_bounds, top=m4_top,
        ))
        _l_blkvia3 = layouter.wire_layout(
            net=net, wire=via3,
            bottom_width=blkvia2m3_bounds.width, bottom_height=_conn_width,
            top_width=blkvia2m3_bounds.width, top_height=_conn_width,
        )
        _m4_bounds = _l_blkvia3.bounds(mask=m4.mask)
        x = blkvia2m3_bounds.center.x
        y = m4_top - _m4_bounds.top
        l_blkvia3 = layouter.place(_l_blkvia3, x=x, y=y)
        blkvia3m4_bounds = l_blkvia3.bounds(mask=m4.mask)
        if conn_right:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, right=blkvia3m4_bounds.right,
            ))
        else:
            layouter.add_wire(net=net, wire=m4, shape=_geo.Rect.from_rect(
                rect=via3m4_bounds, left=blkvia3m4_bounds.left,
            ))

    inst = ckt.new_instance(name="ro", object_=ioro)
    for net_name in _netlookup.keys():
        if not (
            net_name.startswith("ro_")
            or net_name.endswith("vss")
            or net_name.endswith("vdd")
        ):
            continue
        nets[net_name].childports += inst.ports[net_name]
    bound = ioro.layout.boundary
    assert isinstance(bound, _geo.Rect)
    x = _frm.boundary.center.x - bound.center.x
    assert l_block.boundary is not None
    y = l_block.boundary.bottom - _conn_space - bound.top
    l_ro = layouter.place(object_=inst, x=x, y=y)

    # Connect iovss
    net_name = "iovss"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    blkpinm5_bounds = l_block.bounds(net=net, mask=m5pin.mask, depth=1)
    ropinm4_bounds = l_ro.bounds(net=net, mask=m4pin.mask, depth=1)

    layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)

    _l_via3 = layouter.wire_layout(
        net=net, wire=via3,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    _m3_bounds = _l_via3.bounds(mask=m3.mask)
    _m4_bounds = _l_via3.bounds(mask=m4.mask)
    x = pinrect.right + _conn_width - _m3_bounds.left
    y = blkpinm5_bounds.top - _m4_bounds.top
    l_via3 = layouter.place(_l_via3, x=x, y=y)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=via3m4_bounds, right=blkpinm5_bounds.left)
    layouter.add_wire(net=net, wire=m4, shape=rect)
    y = ropinm4_bounds.center.y
    l_via3 = layouter.place(_l_via3, x=x, y=y)
    via3m3_bounds = l_via3.bounds(mask=m3.mask)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=ropinm4_bounds, left=via3m4_bounds.left)
    layouter.add_wire(net=net, wire=m4, shape=rect)

    shape = _geo.Polygon.from_floats(points=(
        (via3m3_bounds.left, via3m3_bounds.bottom),
        (via3m3_bounds.left, pinrect.bottom),
        (pinrect.left, pinrect.bottom),
        (pinrect.left, pinrect.top),
        (via3m3_bounds.right, pinrect.top),
        (via3m3_bounds.right, via3m3_bounds.bottom),
        (via3m3_bounds.left, via3m3_bounds.bottom),
    ))
    layouter.add_wire(net=net, wire=m3, shape=shape)

    # Connect vss
    net_name = "vss"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    blkpinm5_bounds = l_block.bounds(net=net, mask=m5pin.mask, depth=1)
    ropinm4_bounds = l_ro.bounds(net=net, mask=m4pin.mask, depth=1)

    layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)

    _l_via3 = layouter.wire_layout(
        net=net, wire=via3,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    _m3_bounds = _l_via3.bounds(mask=m3.mask)
    _m4_bounds = _l_via3.bounds(mask=m4.mask)
    x = pinrect.left - _conn_width - _m3_bounds.right
    y = blkpinm5_bounds.top - _m4_bounds.top
    l_via3 = layouter.place(_l_via3, x=x, y=y)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=via3m4_bounds, left=blkpinm5_bounds.right)
    layouter.add_wire(net=net, wire=m4, shape=rect)
    y = ropinm4_bounds.center.y
    l_via3 = layouter.place(_l_via3, x=x, y=y)
    via3m3_bounds = l_via3.bounds(mask=m3.mask)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=ropinm4_bounds, right=via3m4_bounds.right)
    layouter.add_wire(net=net, wire=m4, shape=rect)

    shape = _geo.Polygon.from_floats(points=(
        (via3m3_bounds.left, via3m3_bounds.bottom),
        (via3m3_bounds.left, pinrect.top),
        (pinrect.left, pinrect.top),
        (pinrect.left, pinrect.bottom),
        (via3m3_bounds.right, pinrect.bottom),
        (via3m3_bounds.right, via3m3_bounds.bottom),
        (via3m3_bounds.left, via3m3_bounds.bottom),
    ))
    layouter.add_wire(net=net, wire=m3, shape=shape)

    # Connect second iovdd
    net_name = "iovdd"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    ropinm4_bounds = l_ro.bounds(net=net, mask=m4pin.mask, depth=1)

    l_via3 = layouter.add_wire(
        net=net, wire=via3, x=pinrect.center.x, y=ropinm4_bounds.center.y,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    via3m3_bounds = l_via3.bounds(mask=m3.mask)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=pinrect, bottom=via3m3_bounds.bottom)
    layouter.add_wire(net=net, wire=m3, shape=rect)
    rect = _geo.Rect.from_rect(rect=ropinm4_bounds, left=via3m4_bounds.left)
    layouter.add_wire(net=net, wire=m4, shape=rect)

    # Connect second vdd
    net_name = "vdd"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    ropinm4_bounds = l_ro.bounds(net=net, mask=m4pin.mask, depth=1)

    l_via3 = layouter.add_wire(
        net=net, wire=via3, x=pinrect.center.x, y=ropinm4_bounds.center.y,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    via3m3_bounds = l_via3.bounds(mask=m3.mask)
    via3m4_bounds = l_via3.bounds(mask=m4.mask)
    rect = _geo.Rect.from_rect(rect=pinrect, bottom=via3m3_bounds.bottom)
    layouter.add_wire(net=net, wire=m3, shape=rect)
    rect = _geo.Rect.from_rect(rect=ropinm4_bounds, right=via3m4_bounds.right)
    layouter.add_wire(net=net, wire=m4, shape=rect)

    # Connect ro_en
    net_name = "ro_en"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    ropinm2_bounds = l_ro.bounds(net=net, mask=m2pin.mask, depth=1)
    # Assumptions
    assert pinrect.top < ropinm2_bounds.bottom
    assert pinrect.left > ropinm2_bounds.right

    layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)

    x = pinrect.left - _conn_width
    l_via2 = layouter.add_wire(
        net=net, wire=via2, x=x, y=pinrect.center.y,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    m2_bounds = l_via2.bounds(mask=m2.mask)
    m3_bounds = l_via2.bounds(mask=m3.mask)
    rect = _geo.Rect.from_rect(rect=pinrect, left=m3_bounds.left)
    layouter.add_wire(net=net, wire=m3, shape=rect)
    shape = _geo.Polygon.from_floats(points=(
        (m2_bounds.left, m2_bounds.bottom),
        (m2_bounds.left, ropinm2_bounds.bottom),
        (ropinm2_bounds.left, ropinm2_bounds.bottom),
        (ropinm2_bounds.left, ropinm2_bounds.top),
        (m2_bounds.right, ropinm2_bounds.top),
        (m2_bounds.right, m2_bounds.bottom),
        (m2_bounds.left, m2_bounds.bottom),
    ))
    layouter.add_wire(net=net, wire=m2, shape=shape)

    # Connect ro_de
    net_name = "ro_de"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    ropinm2_bounds = l_ro.bounds(net=net, mask=m2pin.mask, depth=1)
    # Assumptions
    assert pinrect.top < ropinm2_bounds.bottom
    assert pinrect.left > ropinm2_bounds.right

    layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)

    x = pinrect.left - _conn_pitch - _conn_width
    l_via2 = layouter.add_wire(
        net=net, wire=via2, x=x, y=pinrect.center.y,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    m2_bounds = l_via2.bounds(mask=m2.mask)
    m3_bounds = l_via2.bounds(mask=m3.mask)
    rect = _geo.Rect.from_rect(rect=pinrect, left=m3_bounds.left)
    layouter.add_wire(net=net, wire=m3, shape=rect)
    shape = _geo.Polygon.from_floats(points=(
        (m2_bounds.left, m2_bounds.bottom),
        (m2_bounds.left, ropinm2_bounds.bottom),
        (ropinm2_bounds.left, ropinm2_bounds.bottom),
        (ropinm2_bounds.left, ropinm2_bounds.top),
        (m2_bounds.right, ropinm2_bounds.top),
        (m2_bounds.right, m2_bounds.bottom),
        (m2_bounds.left, m2_bounds.bottom),
    ))
    layouter.add_wire(net=net, wire=m2, shape=shape)

    # Connect ro_out
    net_name = "ro_out"
    net = nets[net_name]
    pinrect = _frm.toppins[_netlookup[net_name]]
    ropinm2_bounds = l_ro.bounds(net=net, mask=m2pin.mask, depth=1)
    # Assumptions
    assert pinrect.top < ropinm2_bounds.bottom
    assert pinrect.right < ropinm2_bounds.left

    layouter.add_wire(net=net, wire=m3, pin=m3pin, shape=pinrect)

    x = pinrect.right + _conn_width
    l_via2 = layouter.add_wire(
        net=net, wire=via2, x=x, y=pinrect.center.y,
        bottom_width=_conn_width, bottom_height=_conn_width,
        top_width=_conn_width, top_height=_conn_width,
    )
    m2_bounds = l_via2.bounds(mask=m2.mask)
    m3_bounds = l_via2.bounds(mask=m3.mask)
    rect = _geo.Rect.from_rect(rect=pinrect, right=m3_bounds.right)
    layouter.add_wire(net=net, wire=m3, shape=rect)
    shape = _geo.Polygon.from_floats(points=(
        (m2_bounds.left, m2_bounds.bottom),
        (m2_bounds.left, ropinm2_bounds.top),
        (ropinm2_bounds.left, ropinm2_bounds.top),
        (ropinm2_bounds.left, ropinm2_bounds.bottom),
        (m2_bounds.right, ropinm2_bounds.bottom),
        (m2_bounds.right, m2_bounds.bottom),
        (m2_bounds.left, m2_bounds.bottom),
    ))
    layouter.add_wire(net=net, wire=m2, shape=shape)

    # Set boundary
    layouter.layout.boundary = _frm.boundary

    return ioconn


def _postprocess(*, klay: pya.Layout):
    # Post process
    # - split tapdiff into tap and diff layers
    # - remove pad drawing layer to avoid interacting with RDL
    nwell_idx = klay.layer(64, 20)
    diff_idx = klay.layer(65, 20)
    tap_idx = klay.layer(65, 44)
    nsdm_idx = klay.layer(93, 44)
    psdm_idx = klay.layer(94, 20)
    pad_idx = klay.layer(76, 20)

    for cell in klay.each_cell():
        nwell = pya.Region(cell.shapes(nwell_idx))
        nsdm = pya.Region(cell.shapes(nsdm_idx))
        psdm = pya.Region(cell.shapes(psdm_idx))

        tap_cover = (nsdm & nwell) + (psdm - nwell)

        diff_shapes = cell.shapes(diff_idx)
        tap_shapes = cell.shapes(tap_idx)

        difftap = pya.Region(cell.shapes(diff_idx)) # Original difftap layer to be split

        tap = difftap & tap_cover
        diff = difftap - tap

        diff_shapes.clear()
        diff_shapes.insert(diff)
        tap_shapes.insert(tap)

        cell.shapes(pad_idx).clear()


def gen_gds(*, gds_out: Path, gds_empty: Path):
    top_name = "user_analog_project_wrapper"
    prims = sky130.tech.primitives

    lib = _lib.Library(
        name="MPW4IOTest", tech=sky130.tech, cktfab=sky130.cktfab, layoutfab=sky130.layoutfab,
    )

    ioblock = _gen_ioblock(lib=lib)
    ioro = _gen_ioro(lib=lib)
    ioconn = _gen_ioconn(lib=lib, ioblock=ioblock, ioro=ioro)

    # Create user_analog_project_wrapper top cell
    top = lib.new_cell(name=top_name)
    ckt = top.new_circuit()
    layouter = top.new_circuitlayouter()

    inst = ckt.new_instance(name="ioconn", object_=ioconn)
    layouter.place(inst, x=0.0, y=0.0)

    layouter.layout.boundary = _frm.boundary

    # Convert to klayout
    klay = _klexp.export2db(
        obj=lib, add_pin_label=True, gds_layers=sky130.gds_layers, cell_name=None, merge=True,
    )

    _postprocess(klay=klay)

    # Instantiate the empty cell in top cell
    emptylib = pya.Library()
    emptylib.register("empty")
    emptylayout = emptylib.layout()
    emptylayout.read(str(gds_empty))
    emptylibcell_idx = emptylayout.cell("user_analog_project_wrapper_empty").cell_index()
    emptycell_idx = klay.add_lib_cell(emptylib, emptylibcell_idx)

    ktop = klay.cell(top_name)
    ktop.insert(pya.CellInstArray(emptycell_idx, pya.Trans.R0))

    ktech = pya.Technology.technology_by_name("Skywater_S8")
    ksaveopts = ktech.save_layout_options.dup()
    ksaveopts.write_context_info = False
    klay.write(str(gds_out), ksaveopts)
