[tutorial] update pather and renderpather tutorials to new syntax
This commit is contained in:
parent
9d6fb985d8
commit
8a45c6d8d6
2 changed files with 33 additions and 34 deletions
|
|
@ -106,7 +106,9 @@ def map_layer(layer: layer_t) -> layer_t:
|
||||||
'M2': (20, 0),
|
'M2': (20, 0),
|
||||||
'V1': (30, 0),
|
'V1': (30, 0),
|
||||||
}
|
}
|
||||||
return layer_mapping.get(layer, layer)
|
if isinstance(layer, str):
|
||||||
|
return layer_mapping.get(layer, layer)
|
||||||
|
return layer
|
||||||
|
|
||||||
|
|
||||||
def prepare_tools() -> tuple[Library, Tool, Tool]:
|
def prepare_tools() -> tuple[Library, Tool, Tool]:
|
||||||
|
|
@ -224,19 +226,17 @@ def main() -> None:
|
||||||
|
|
||||||
# Path VCC forward (in this case south) and turn clockwise 90 degrees (ccw=False)
|
# Path VCC forward (in this case south) and turn clockwise 90 degrees (ccw=False)
|
||||||
# The total distance forward (including the bend's forward component) must be 6um
|
# The total distance forward (including the bend's forward component) must be 6um
|
||||||
pather.path('VCC', ccw=False, length=6_000)
|
pather.cw('VCC', 6_000)
|
||||||
|
|
||||||
# Now path VCC to x=0. This time, don't include any bend (ccw=None).
|
# Now path VCC to x=0. This time, don't include any bend.
|
||||||
# Note that if we tried y=0 here, we would get an error since the VCC port is facing in the x-direction.
|
# Note that if we tried y=0 here, we would get an error since the VCC port is facing in the x-direction.
|
||||||
pather.path_to('VCC', ccw=None, x=0)
|
pather.straight('VCC', x=0)
|
||||||
|
|
||||||
# Path GND forward by 5um, turning clockwise 90 degrees.
|
# Path GND forward by 5um, turning clockwise 90 degrees.
|
||||||
# This time we use shorthand (bool(0) == False) and omit the parameter labels
|
pather.cw('GND', 5_000)
|
||||||
# Note that although ccw=0 is equivalent to ccw=False, ccw=None is not!
|
|
||||||
pather.path('GND', 0, 5_000)
|
|
||||||
|
|
||||||
# This time, path GND until it matches the current x-coordinate of VCC. Don't place a bend.
|
# This time, path GND until it matches the current x-coordinate of VCC. Don't place a bend.
|
||||||
pather.path_to('GND', None, x=pather['VCC'].offset[0])
|
pather.straight('GND', x=pather['VCC'].offset[0])
|
||||||
|
|
||||||
# Now, start using M1_tool for GND.
|
# Now, start using M1_tool for GND.
|
||||||
# Since we have defined an M2-to-M1 transition for Pather, we don't need to place one ourselves.
|
# Since we have defined an M2-to-M1 transition for Pather, we don't need to place one ourselves.
|
||||||
|
|
@ -244,7 +244,7 @@ def main() -> None:
|
||||||
# and achieve the same result without having to define any transitions in M1_tool.
|
# and achieve the same result without having to define any transitions in M1_tool.
|
||||||
# Note that even though we have changed the tool used for GND, the via doesn't get placed until
|
# Note that even though we have changed the tool used for GND, the via doesn't get placed until
|
||||||
# the next time we draw a path on GND (the pather.mpath() statement below).
|
# the next time we draw a path on GND (the pather.mpath() statement below).
|
||||||
pather.retool(M1_tool, keys=['GND'])
|
pather.retool(M1_tool, keys='GND')
|
||||||
|
|
||||||
# Bundle together GND and VCC, and path the bundle forward and counterclockwise.
|
# Bundle together GND and VCC, and path the bundle forward and counterclockwise.
|
||||||
# Pick the distance so that the leading/outermost wire (in this case GND) ends up at x=-10_000.
|
# Pick the distance so that the leading/outermost wire (in this case GND) ends up at x=-10_000.
|
||||||
|
|
@ -252,7 +252,7 @@ def main() -> None:
|
||||||
#
|
#
|
||||||
# Since we recently retooled GND, its path starts with a via down to M1 (included in the distance
|
# Since we recently retooled GND, its path starts with a via down to M1 (included in the distance
|
||||||
# calculation), and its straight segment and bend will be drawn using M1 while VCC's are drawn with M2.
|
# calculation), and its straight segment and bend will be drawn using M1 while VCC's are drawn with M2.
|
||||||
pather.mpath(['GND', 'VCC'], ccw=True, xmax=-10_000, spacing=5_000)
|
pather.ccw(['GND', 'VCC'], xmax=-10_000, spacing=5_000)
|
||||||
|
|
||||||
# Now use M1_tool as the default tool for all ports/signals.
|
# Now use M1_tool as the default tool for all ports/signals.
|
||||||
# Since VCC does not have an explicitly assigned tool, it will now transition down to M1.
|
# Since VCC does not have an explicitly assigned tool, it will now transition down to M1.
|
||||||
|
|
@ -262,35 +262,34 @@ def main() -> None:
|
||||||
# The total extension (travel distance along the forward direction) for the longest segment (in
|
# The total extension (travel distance along the forward direction) for the longest segment (in
|
||||||
# this case the segment being added to GND) should be exactly 50um.
|
# this case the segment being added to GND) should be exactly 50um.
|
||||||
# After turning, the wire pitch should be reduced only 1.2um.
|
# After turning, the wire pitch should be reduced only 1.2um.
|
||||||
pather.mpath(['GND', 'VCC'], ccw=True, emax=50_000, spacing=1_200)
|
pather.ccw(['GND', 'VCC'], emax=50_000, spacing=1_200)
|
||||||
|
|
||||||
# Make a U-turn with the bundle and expand back out to 4.5um wire pitch.
|
# Make a U-turn with the bundle and expand back out to 4.5um wire pitch.
|
||||||
# Here, emin specifies the travel distance for the shortest segment. For the first mpath() call
|
# Here, emin specifies the travel distance for the shortest segment. For the first call
|
||||||
# that applies to VCC, and for teh second call, that applies to GND; the relative lengths of the
|
# that applies to VCC, and for the second call, that applies to GND; the relative lengths of the
|
||||||
# segments depend on their starting positions and their ordering within the bundle.
|
# segments depend on their starting positions and their ordering within the bundle.
|
||||||
pather.mpath(['GND', 'VCC'], ccw=False, emin=1_000, spacing=1_200)
|
pather.cw(['GND', 'VCC'], emin=1_000, spacing=1_200)
|
||||||
pather.mpath(['GND', 'VCC'], ccw=False, emin=2_000, spacing=4_500)
|
pather.cw(['GND', 'VCC'], emin=2_000, spacing=4_500)
|
||||||
|
|
||||||
# Now, set the default tool back to M2_tool. Note that GND remains on M1 since it has been
|
# Now, set the default tool back to M2_tool. Note that GND remains on M1 since it has been
|
||||||
# explicitly assigned a tool. We could `del pather.tools['GND']` to force it to use the default.
|
# explicitly assigned a tool.
|
||||||
pather.retool(M2_tool)
|
pather.retool(M2_tool)
|
||||||
|
|
||||||
# Now path both ports to x=-28_000.
|
# Now path both ports to x=-28_000.
|
||||||
# When ccw is not None, xmin constrains the trailing/innermost port to stop at the target x coordinate,
|
# With ccw=None, all ports stop at the same coordinate, and so specifying xmin= or xmax= is
|
||||||
# However, with ccw=None, all ports stop at the same coordinate, and so specifying xmin= or xmax= is
|
|
||||||
# equivalent.
|
# equivalent.
|
||||||
pather.mpath(['GND', 'VCC'], None, xmin=-28_000)
|
pather.straight(['GND', 'VCC'], xmin=-28_000)
|
||||||
|
|
||||||
# Further extend VCC out to x=-50_000, and specify that we would like to get an output on M1.
|
# Further extend VCC out to x=-50_000, and specify that we would like to get an output on M1.
|
||||||
# This results in a via at the end of the wire (instead of having one at the start like we got
|
# This results in a via at the end of the wire (instead of having one at the start like we got
|
||||||
# when using pather.retool().
|
# when using pather.retool().
|
||||||
pather.path_to('VCC', None, -50_000, out_ptype='m1wire')
|
pather.straight('VCC', x=-50_000, out_ptype='m1wire')
|
||||||
|
|
||||||
# Now extend GND out to x=-50_000, using M2 for a portion of the path.
|
# Now extend GND out to x=-50_000, using M2 for a portion of the path.
|
||||||
# We can use `pather.toolctx()` to temporarily retool, instead of calling `retool()` twice.
|
# We can use `pather.toolctx()` to temporarily retool, instead of calling `retool()` twice.
|
||||||
with pather.toolctx(M2_tool, keys=['GND']):
|
with pather.toolctx(M2_tool, keys='GND'):
|
||||||
pather.path_to('GND', None, -40_000)
|
pather.straight('GND', x=-40_000)
|
||||||
pather.path_to('GND', None, -50_000)
|
pather.straight('GND', x=-50_000)
|
||||||
|
|
||||||
# Save the pather's pattern into our library
|
# Save the pather's pattern into our library
|
||||||
library['Pather_and_AutoTool'] = pather.pattern
|
library['Pather_and_AutoTool'] = pather.pattern
|
||||||
|
|
|
||||||
|
|
@ -48,28 +48,28 @@ def main() -> None:
|
||||||
rpather.pattern.label(layer='M2', string='GND', offset=(18e3, 60e3))
|
rpather.pattern.label(layer='M2', string='GND', offset=(18e3, 60e3))
|
||||||
|
|
||||||
# ...and start routing the signals.
|
# ...and start routing the signals.
|
||||||
rpather.path('VCC', ccw=False, length=6_000)
|
rpather.cw('VCC', 6_000)
|
||||||
rpather.path_to('VCC', ccw=None, x=0)
|
rpather.straight('VCC', x=0)
|
||||||
rpather.path('GND', 0, 5_000)
|
rpather.cw('GND', 5_000)
|
||||||
rpather.path_to('GND', None, x=rpather['VCC'].x)
|
rpather.straight('GND', x=rpather.pattern['VCC'].x)
|
||||||
|
|
||||||
# `PathTool` doesn't know how to transition betwen metal layers, so we have to
|
# `PathTool` doesn't know how to transition betwen metal layers, so we have to
|
||||||
# `plug` the via into the GND wire ourselves.
|
# `plug` the via into the GND wire ourselves.
|
||||||
rpather.plug('v1_via', {'GND': 'top'})
|
rpather.plug('v1_via', {'GND': 'top'})
|
||||||
rpather.retool(M1_ptool, keys=['GND'])
|
rpather.retool(M1_ptool, keys='GND')
|
||||||
rpather.mpath(['GND', 'VCC'], ccw=True, xmax=-10_000, spacing=5_000)
|
rpather.ccw(['GND', 'VCC'], xmax=-10_000, spacing=5_000)
|
||||||
|
|
||||||
# Same thing on the VCC wire when it goes down to M1.
|
# Same thing on the VCC wire when it goes down to M1.
|
||||||
rpather.plug('v1_via', {'VCC': 'top'})
|
rpather.plug('v1_via', {'VCC': 'top'})
|
||||||
rpather.retool(M1_ptool)
|
rpather.retool(M1_ptool)
|
||||||
rpather.mpath(['GND', 'VCC'], ccw=True, emax=50_000, spacing=1_200)
|
rpather.ccw(['GND', 'VCC'], emax=50_000, spacing=1_200)
|
||||||
rpather.mpath(['GND', 'VCC'], ccw=False, emin=1_000, spacing=1_200)
|
rpather.cw(['GND', 'VCC'], emin=1_000, spacing=1_200)
|
||||||
rpather.mpath(['GND', 'VCC'], ccw=False, emin=2_000, spacing=4_500)
|
rpather.cw(['GND', 'VCC'], emin=2_000, spacing=4_500)
|
||||||
|
|
||||||
# And again when VCC goes back up to M2.
|
# And again when VCC goes back up to M2.
|
||||||
rpather.plug('v1_via', {'VCC': 'bottom'})
|
rpather.plug('v1_via', {'VCC': 'bottom'})
|
||||||
rpather.retool(M2_ptool)
|
rpather.retool(M2_ptool)
|
||||||
rpather.mpath(['GND', 'VCC'], None, xmin=-28_000)
|
rpather.straight(['GND', 'VCC'], xmin=-28_000)
|
||||||
|
|
||||||
# Finally, since PathTool has no conception of transitions, we can't
|
# Finally, since PathTool has no conception of transitions, we can't
|
||||||
# just ask it to transition to an 'm1wire' port at the end of the final VCC segment.
|
# just ask it to transition to an 'm1wire' port at the end of the final VCC segment.
|
||||||
|
|
@ -80,7 +80,7 @@ def main() -> None:
|
||||||
|
|
||||||
# alternatively, via_size = v1pat.ports['top'].measure_travel(v1pat.ports['bottom'])[0][0]
|
# alternatively, via_size = v1pat.ports['top'].measure_travel(v1pat.ports['bottom'])[0][0]
|
||||||
# would take into account the port orientations if we didn't already know they're along x
|
# would take into account the port orientations if we didn't already know they're along x
|
||||||
rpather.path_to('VCC', None, -50_000 + via_size)
|
rpather.straight('VCC', x=-50_000 + via_size)
|
||||||
rpather.plug('v1_via', {'VCC': 'top'})
|
rpather.plug('v1_via', {'VCC': 'top'})
|
||||||
|
|
||||||
# Render the path we defined
|
# Render the path we defined
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue