gdsfactory / kfactory

gdsfactory with a klayout backend
https://gdsfactory.github.io/kfactory/
MIT License
28 stars 10 forks source link

Add Schematic Cells #311

Open sebastian-goeldi opened 1 month ago

sebastian-goeldi commented 1 month ago

This will allow to use a more schematic approach compared to the current iterative procedure:

@pdk.schematic_cell
def my_schematic_cell(c: SchematicCell, *args: SchematicParams.args, **kwargs: SchematicParams.kwargs) -> None:
    anchor_inst = c << my_kcell(param1,param2=param2,...)
    c.anchor(anchor_inst, dest=kdb.Trans(500_000,0) # put the instance with origin at 500,0
    inst2 = c << my_kcell2()
    c.add_connection(inst2, "o1", anchor_inst, "o2") # equivalent to `c.add_connection(anchor_inst, "o2", inst2, "o1")`, which one is picked doesn't matter
    c.add_route(inst2, "o2", anchor_inst, "o1") # not equivalent to the swapped because the route function might route different if end and start are swapped
    # ...

Which should be equivalent to this:

@pdk.schematic_cell
def my_schematic_cell(c: SchematicCell, *args: SchematicParams.args, **kwargs: SchematicParams.kwargs) -> None:
    inst2 = c << my_kcell2()
    anchor_inst = c << my_kcell(param1,param2=param2,...)

    c.add_route(inst2, "o2", anchor_inst, "o1") # not equivalent to the swapped because the route function might route different if end and start are swapped
    c.anchor(anchor_inst, dest=kdb.Trans(500_000,0) # put the instance with origin at 500,0
    c.add_connection(inst2, "o1", anchor_inst, "o2") # equivalent to `c.add_connection(anchor_inst, "o2", inst2, "o1")`, which one is picked doesn't matter
    # ...