Schematic#
A schematic is a graph representation of your circuit.
For complex circuits, a schematic allows you to create symbols and hierarchy levels to represent your circuit.
Having a schematic allows you to also ensure that your layout matches you schematic (design intent).
There are many schematic capture tools out there:
Qucs-s: for RF.
Xschem: for analog circuits.
Lumerical interconnect: for photonic circuits.
These tools allow you to both create schematics with your mouse or by code.
gdsfactory also allows you to create complex Schematics directly from python with a very simple interface.
import gdsfactory as gf
import gdsfactory.schematic as gt
Lets create a MZI lattice of 3 elements.
s = gt.Schematic()
s.add_instance("mzi1", gt.Instance(component=gf.c.mzi(delta_length=10)))
s.add_instance("mzi2", gt.Instance(component=gf.c.mzi(delta_length=100)))
s.add_instance("mzi3", gt.Instance(component=gf.c.mzi(delta_length=200)))
s.add_placement("mzi1", gt.Placement(x=000))
s.add_placement("mzi2", gt.Placement(x=100, y=100))
s.add_placement("mzi3", gt.Placement(x=200))
s.add_net(gt.Net(ip1="mzi1,o2", ip2="mzi2,o2"))
s.add_net(gt.Net(ip1="mzi2,o2", ip2="mzi3,o1"))
g = s.plot_netlist()
You can also create a splitter tree.
s = gt.Schematic()
s.add_instance("s11", gt.Instance(component=gf.c.mmi1x2()))
s.add_instance("s21", gt.Instance(component=gf.c.mmi1x2()))
s.add_instance("s22", gt.Instance(component=gf.c.mmi1x2()))
s.add_placement("s11", gt.Placement(x=000))
s.add_placement("s21", gt.Placement(x=100, y=+50))
s.add_placement("s22", gt.Placement(x=100, y=-50))
s.add_net(gt.Net(ip1="s11,o2", ip2="s21,o1"))
s.add_net(gt.Net(ip1="s11,o3", ip2="s22,o1"))
g = s.plot_netlist()
The nice thing is that you can abstract it to have as many levels as you need.
splitter = gf.components.mmi1x2()
n = 3
dx = 100
dy = 100
s = gt.Schematic()
for col in range(n):
rows = 2**col
for row in range(rows):
s.add_instance(f"s{col}{row}", gt.Instance(component=splitter))
s.add_placement(
f"s{col}{row}", gt.Placement(x=col * dx, y=(row - rows / 2) * dy)
)
if col < n - 1:
s.add_net(gt.Net(ip1=f"s{col}{row},o2", ip2=f"s{col+1}{2*row},o1"))
s.add_net(gt.Net(ip1=f"s{col}{row},o3", ip2=f"s{col+1}{2*row+1},o1"))
g = s.plot_netlist()
splitter = gf.components.mmi1x2()
n = 5
dx = 100
dy = 100
s = gt.Schematic()
for col in range(n):
rows = 2**col
for row in range(rows):
s.add_instance(f"s{col}{row}", gt.Instance(component=splitter))
s.add_placement(
f"s{col}{row}", gt.Placement(x=col * dx, y=(row - rows / 2) * dy)
)
if col < n - 1:
s.add_net(gt.Net(ip1=f"s{col}{row},o2", ip2=f"s{col+1}{2*row},o1"))
s.add_net(gt.Net(ip1=f"s{col}{row},o3", ip2=f"s{col+1}{2*row+1},o1"))
g = s.plot_netlist()
dict(s.netlist)
{'instances': {'s00': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's10': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's11': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's20': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's21': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's22': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's23': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's30': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's31': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's32': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's33': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's34': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's35': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's36': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's37': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's40': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's41': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's42': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's43': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's44': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's45': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's46': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's47': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's48': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's49': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's410': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's411': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's412': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's413': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's414': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={}),
's415': Instance(component='mmi1x2', settings={'width_taper': 1.0, 'length_taper': 10.0, 'length_mmi': 5.5, 'width_mmi': 2.5, 'gap_mmi': 0.25, 'taper': {'function': 'taper'}, 'cross_section': 'xs_sc'}, info={})},
'placements': {'s00': Placement(x=0.0, y=-50.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's10': Placement(x=100.0, y=-100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's11': Placement(x=100.0, y=0.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's20': Placement(x=200.0, y=-200.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's21': Placement(x=200.0, y=-100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's22': Placement(x=200.0, y=0.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's23': Placement(x=200.0, y=100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's30': Placement(x=300.0, y=-400.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's31': Placement(x=300.0, y=-300.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's32': Placement(x=300.0, y=-200.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's33': Placement(x=300.0, y=-100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's34': Placement(x=300.0, y=0.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's35': Placement(x=300.0, y=100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's36': Placement(x=300.0, y=200.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's37': Placement(x=300.0, y=300.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's40': Placement(x=400.0, y=-800.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's41': Placement(x=400.0, y=-700.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's42': Placement(x=400.0, y=-600.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's43': Placement(x=400.0, y=-500.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's44': Placement(x=400.0, y=-400.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's45': Placement(x=400.0, y=-300.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's46': Placement(x=400.0, y=-200.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's47': Placement(x=400.0, y=-100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's48': Placement(x=400.0, y=0.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's49': Placement(x=400.0, y=100.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's410': Placement(x=400.0, y=200.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's411': Placement(x=400.0, y=300.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's412': Placement(x=400.0, y=400.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's413': Placement(x=400.0, y=500.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's414': Placement(x=400.0, y=600.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False),
's415': Placement(x=400.0, y=700.0, xmin=None, ymin=None, xmax=None, ymax=None, dx=0, dy=0, port=None, rotation=0, mirror=False)},
'connections': {},
'routes': {'route_10': Bundle(links={'s00,o2': 's10,o1'}, settings={}, routing_strategy='get_bundle'),
'route_11': Bundle(links={'s00,o3': 's11,o1'}, settings={}, routing_strategy='get_bundle'),
'route_12': Bundle(links={'s10,o2': 's20,o1'}, settings={}, routing_strategy='get_bundle'),
'route_13': Bundle(links={'s10,o3': 's21,o1'}, settings={}, routing_strategy='get_bundle'),
'route_14': Bundle(links={'s11,o2': 's22,o1'}, settings={}, routing_strategy='get_bundle'),
'route_15': Bundle(links={'s11,o3': 's23,o1'}, settings={}, routing_strategy='get_bundle'),
'route_16': Bundle(links={'s20,o2': 's30,o1'}, settings={}, routing_strategy='get_bundle'),
'route_17': Bundle(links={'s20,o3': 's31,o1'}, settings={}, routing_strategy='get_bundle'),
'route_18': Bundle(links={'s21,o2': 's32,o1'}, settings={}, routing_strategy='get_bundle'),
'route_19': Bundle(links={'s21,o3': 's33,o1'}, settings={}, routing_strategy='get_bundle'),
'route_20': Bundle(links={'s22,o2': 's34,o1'}, settings={}, routing_strategy='get_bundle'),
'route_21': Bundle(links={'s22,o3': 's35,o1'}, settings={}, routing_strategy='get_bundle'),
'route_22': Bundle(links={'s23,o2': 's36,o1'}, settings={}, routing_strategy='get_bundle'),
'route_23': Bundle(links={'s23,o3': 's37,o1'}, settings={}, routing_strategy='get_bundle'),
'route_24': Bundle(links={'s30,o2': 's40,o1'}, settings={}, routing_strategy='get_bundle'),
'route_25': Bundle(links={'s30,o3': 's41,o1'}, settings={}, routing_strategy='get_bundle'),
'route_26': Bundle(links={'s31,o2': 's42,o1'}, settings={}, routing_strategy='get_bundle'),
'route_27': Bundle(links={'s31,o3': 's43,o1'}, settings={}, routing_strategy='get_bundle'),
'route_28': Bundle(links={'s32,o2': 's44,o1'}, settings={}, routing_strategy='get_bundle'),
'route_29': Bundle(links={'s32,o3': 's45,o1'}, settings={}, routing_strategy='get_bundle'),
'route_30': Bundle(links={'s33,o2': 's46,o1'}, settings={}, routing_strategy='get_bundle'),
'route_31': Bundle(links={'s33,o3': 's47,o1'}, settings={}, routing_strategy='get_bundle'),
'route_32': Bundle(links={'s34,o2': 's48,o1'}, settings={}, routing_strategy='get_bundle'),
'route_33': Bundle(links={'s34,o3': 's49,o1'}, settings={}, routing_strategy='get_bundle'),
'route_34': Bundle(links={'s35,o2': 's410,o1'}, settings={}, routing_strategy='get_bundle'),
'route_35': Bundle(links={'s35,o3': 's411,o1'}, settings={}, routing_strategy='get_bundle'),
'route_36': Bundle(links={'s36,o2': 's412,o1'}, settings={}, routing_strategy='get_bundle'),
'route_37': Bundle(links={'s36,o3': 's413,o1'}, settings={}, routing_strategy='get_bundle'),
'route_38': Bundle(links={'s37,o2': 's414,o1'}, settings={}, routing_strategy='get_bundle'),
'route_39': Bundle(links={'s37,o3': 's415,o1'}, settings={}, routing_strategy='get_bundle')},
'name': None,
'info': {},
'ports': {},
'settings': {}}
import yaml
yaml_component = yaml.dump(s.netlist.model_dump(exclude_none=True))
print(yaml_component)
connections: {}
info: {}
instances:
s00:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s10:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s11:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s20:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s21:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s22:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s23:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s30:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s31:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s32:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s33:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s34:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s35:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s36:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s37:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s40:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s41:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s410:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s411:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s412:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s413:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s414:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s415:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s42:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s43:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s44:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s45:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s46:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s47:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s48:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
s49:
component: mmi1x2
settings:
cross_section: xs_sc
gap_mmi: 0.25
length_mmi: 5.5
length_taper: 10.0
taper:
function: taper
width_mmi: 2.5
width_taper: 1.0
placements:
s00:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 0.0
y: -50.0
s10:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 100.0
y: -100.0
s11:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 100.0
y: 0.0
s20:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 200.0
y: -200.0
s21:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 200.0
y: -100.0
s22:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 200.0
y: 0.0
s23:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 200.0
y: 100.0
s30:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: -400.0
s31:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: -300.0
s32:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: -200.0
s33:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: -100.0
s34:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: 0.0
s35:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: 100.0
s36:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: 200.0
s37:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: 300.0
s40:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -800.0
s41:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -700.0
s410:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 200.0
s411:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 300.0
s412:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 400.0
s413:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 500.0
s414:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 600.0
s415:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 700.0
s42:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -600.0
s43:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -500.0
s44:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -400.0
s45:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -300.0
s46:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -200.0
s47:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: -100.0
s48:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 0.0
s49:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 400.0
y: 100.0
ports: {}
routes:
route_10:
links:
s00,o2: s10,o1
routing_strategy: get_bundle
settings: {}
route_11:
links:
s00,o3: s11,o1
routing_strategy: get_bundle
settings: {}
route_12:
links:
s10,o2: s20,o1
routing_strategy: get_bundle
settings: {}
route_13:
links:
s10,o3: s21,o1
routing_strategy: get_bundle
settings: {}
route_14:
links:
s11,o2: s22,o1
routing_strategy: get_bundle
settings: {}
route_15:
links:
s11,o3: s23,o1
routing_strategy: get_bundle
settings: {}
route_16:
links:
s20,o2: s30,o1
routing_strategy: get_bundle
settings: {}
route_17:
links:
s20,o3: s31,o1
routing_strategy: get_bundle
settings: {}
route_18:
links:
s21,o2: s32,o1
routing_strategy: get_bundle
settings: {}
route_19:
links:
s21,o3: s33,o1
routing_strategy: get_bundle
settings: {}
route_20:
links:
s22,o2: s34,o1
routing_strategy: get_bundle
settings: {}
route_21:
links:
s22,o3: s35,o1
routing_strategy: get_bundle
settings: {}
route_22:
links:
s23,o2: s36,o1
routing_strategy: get_bundle
settings: {}
route_23:
links:
s23,o3: s37,o1
routing_strategy: get_bundle
settings: {}
route_24:
links:
s30,o2: s40,o1
routing_strategy: get_bundle
settings: {}
route_25:
links:
s30,o3: s41,o1
routing_strategy: get_bundle
settings: {}
route_26:
links:
s31,o2: s42,o1
routing_strategy: get_bundle
settings: {}
route_27:
links:
s31,o3: s43,o1
routing_strategy: get_bundle
settings: {}
route_28:
links:
s32,o2: s44,o1
routing_strategy: get_bundle
settings: {}
route_29:
links:
s32,o3: s45,o1
routing_strategy: get_bundle
settings: {}
route_30:
links:
s33,o2: s46,o1
routing_strategy: get_bundle
settings: {}
route_31:
links:
s33,o3: s47,o1
routing_strategy: get_bundle
settings: {}
route_32:
links:
s34,o2: s48,o1
routing_strategy: get_bundle
settings: {}
route_33:
links:
s34,o3: s49,o1
routing_strategy: get_bundle
settings: {}
route_34:
links:
s35,o2: s410,o1
routing_strategy: get_bundle
settings: {}
route_35:
links:
s35,o3: s411,o1
routing_strategy: get_bundle
settings: {}
route_36:
links:
s36,o2: s412,o1
routing_strategy: get_bundle
settings: {}
route_37:
links:
s36,o3: s413,o1
routing_strategy: get_bundle
settings: {}
route_38:
links:
s37,o2: s414,o1
routing_strategy: get_bundle
settings: {}
route_39:
links:
s37,o3: s415,o1
routing_strategy: get_bundle
settings: {}
yaml.dump(s.netlist.model_dump(exclude_none=True), open("schematic.yaml", "w"))
Python routing#
n = 2**3
splitter = gf.components.splitter_tree(noutputs=n, spacing=(50, 50))
dbr_array = gf.components.array(
component=gf.c.dbr, rows=n, columns=1, spacing=(0, 3), centered=True
)
s = gt.Schematic()
s.add_instance("s", gt.Instance(component=splitter))
s.add_placement("s", gt.Placement(x=0))
s.add_instance("dbr", gt.Instance(component=dbr_array))
s.add_placement("dbr", gt.Placement(x=300))
for i in range(n):
s.add_net(
gt.Net(
ip1=f"s,o2_2_{i+1}",
ip2=f"dbr,o1_{i+1}_1",
name="splitter_to_dbr",
settings=dict(radius=5, enforce_port_ordering=False),
)
)
g = s.plot_netlist()
dbr_array.pprint_ports()
┏━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ ┃ name ┃ width ┃ center ┃ orientation ┃ layer ┃ port_type ┃ ┡━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ o1_1_1 │ 0.5 │ [-1.749, -10.5] │ 180.0 │ [1, 0] │ optical │ │ o1_2_1 │ 0.5 │ [-1.749, -7.5] │ 180.0 │ [1, 0] │ optical │ │ o1_3_1 │ 0.5 │ [-1.749, -4.5] │ 180.0 │ [1, 0] │ optical │ │ o1_4_1 │ 0.5 │ [-1.749, -1.5] │ 180.0 │ [1, 0] │ optical │ │ o1_5_1 │ 0.5 │ [-1.749, 1.5] │ 180.0 │ [1, 0] │ optical │ │ o1_6_1 │ 0.5 │ [-1.749, 4.5] │ 180.0 │ [1, 0] │ optical │ │ o1_7_1 │ 0.5 │ [-1.749, 7.5] │ 180.0 │ [1, 0] │ optical │ │ o1_8_1 │ 0.5 │ [-1.749, 10.5] │ 180.0 │ [1, 0] │ optical │ │ o2_1_1 │ 0.5 │ [1.749, -10.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_1 │ 0.5 │ [1.749, -7.5] │ 0.0 │ [1, 0] │ optical │ │ o2_3_1 │ 0.5 │ [1.749, -4.5] │ 0.0 │ [1, 0] │ optical │ │ o2_4_1 │ 0.5 │ [1.749, -1.5] │ 0.0 │ [1, 0] │ optical │ │ o2_5_1 │ 0.5 │ [1.749, 1.5] │ 0.0 │ [1, 0] │ optical │ │ o2_6_1 │ 0.5 │ [1.749, 4.5] │ 0.0 │ [1, 0] │ optical │ │ o2_7_1 │ 0.5 │ [1.749, 7.5] │ 0.0 │ [1, 0] │ optical │ │ o2_8_1 │ 0.5 │ [1.749, 10.5] │ 0.0 │ [1, 0] │ optical │ └────────┴───────┴─────────────────┴─────────────┴────────┴───────────┘
splitter.pprint_ports()
┏━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┓ ┃ name ┃ width ┃ center ┃ orientation ┃ layer ┃ port_type ┃ ┡━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━┩ │ o1_0_0 │ 0.5 │ [-10.0, 0.0] │ 180.0 │ [1, 0] │ optical │ │ o2_2_1 │ 0.5 │ [165.5, -62.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_2 │ 0.5 │ [165.5, -87.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_3 │ 0.5 │ [165.5, -12.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_4 │ 0.5 │ [165.5, -37.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_5 │ 0.5 │ [165.5, 37.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_6 │ 0.5 │ [165.5, 12.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_7 │ 0.5 │ [165.5, 87.5] │ 0.0 │ [1, 0] │ optical │ │ o2_2_8 │ 0.5 │ [165.5, 62.5] │ 0.0 │ [1, 0] │ optical │ └────────┴───────┴────────────────┴─────────────┴────────┴───────────┘
yaml.dump(s.netlist.model_dump(exclude_none=True), open("schematic.yaml", "w"))
yaml_component = yaml.dump(s.netlist.model_dump(exclude_none=True))
print(yaml_component)
connections: {}
info: {}
instances:
dbr:
component: array
settings:
add_ports: true
centered: true
columns: 1
component:
function: dbr
rows: 8
spacing:
- 0
- 3
s:
component: splitter_tree
settings:
bend_s:
function: bend_s
coupler:
function: mmi1x2
cross_section: xs_sc
noutputs: 8
spacing:
- 50
- 50
placements:
dbr:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 300.0
y: 0
s:
dx: 0
dy: 0
mirror: false
rotation: 0
x: 0.0
y: 0
ports: {}
routes:
splitter_to_dbr:
links:
s,o2_2_1: dbr,o1_1_1
s,o2_2_2: dbr,o1_2_1
s,o2_2_3: dbr,o1_3_1
s,o2_2_4: dbr,o1_4_1
s,o2_2_5: dbr,o1_5_1
s,o2_2_6: dbr,o1_6_1
s,o2_2_7: dbr,o1_7_1
s,o2_2_8: dbr,o1_8_1
routing_strategy: get_bundle
settings:
enforce_port_ordering: false
radius: 5
c = gf.read.from_yaml(yaml_component)
c
2024-10-31 18:40:04.982 | WARNING | gdsfactory.read.from_yaml:from_yaml:692 - UserWarning: prefix is deprecated and will be removed soon. _from_yaml
2024-10-31 18:40:05.061 | WARNING | gdsfactory.show:show:47 - UserWarning: Unnamed cells, 1 in 'Unnamed_0f91b9ae'
2024-10-31 18:40:05.063 | WARNING | gdsfactory.klive:show:49 - UserWarning: Could not connect to klive server. Is klayout open and klive plugin installed?
2024-10-31 18:40:05.156 | WARNING | gdsfactory.component:plot_klayout:1646 - UserWarning: Unnamed cells, 1 in 'Unnamed_0f91b9ae'
Unnamed_0f91b9ae: uid a7300852, ports [], references ['dbr', 's', 'bend_euler_1', 'bend_euler_2', 'straight_1', 'straight_2', 'straight_3', 'bend_euler_3', 'bend_euler_4', 'straight_4', 'straight_5', 'straight_6', 'bend_euler_5', 'bend_euler_6', 'straight_7', 'straight_8', 'straight_9', 'bend_euler_7', 'bend_euler_8', 'straight_10', 'straight_11', 'straight_12', 'bend_euler_9', 'bend_euler_10', 'straight_13', 'straight_14', 'straight_15', 'bend_euler_11', 'bend_euler_12', 'straight_16', 'straight_17', 'straight_18', 'bend_euler_13', 'bend_euler_14', 'straight_19', 'straight_20', 'straight_21', 'bend_euler_15', 'bend_euler_16', 'straight_22', 'straight_23', 'straight_24'], 0 polygons