misc doc updates

This commit is contained in:
Jan Petykiewicz 2026-02-01 15:04:34 -08:00
parent 49e3917a6e
commit d8702af5b9
6 changed files with 57 additions and 8 deletions

View File

@ -37,6 +37,55 @@ A layout consists of a hierarchy of `Pattern`s stored in a single `Library`.
Each `Pattern` can contain `Ref`s pointing at other patterns, `Shape`s, `Label`s, and `Port`s. Each `Pattern` can contain `Ref`s pointing at other patterns, `Shape`s, `Label`s, and `Port`s.
Library / Pattern hierarchy:
```
+-----------------------------------------------------------------------+
| Library |
| |
| Name: "MyChip" ...> Name: "Transistor" |
| +---------------------------+ : +---------------------------+ |
| | [Pattern] | : | [Pattern] | |
| | | : | | |
| | shapes: {...} | : | shapes: { | |
| | ports: {...} | : | "Si": [<Polygon>, ...] | |
| | | : | "M1": [<Polygon>, ...]}| |
| | refs: | : | ports: {G, S, D} | |
| | "Transistor": [Ref, Ref]|..: +---------------------------+ |
| +---------------------------+ |
| |
| # (`refs` keys resolve to Patterns within the Library) |
+-----------------------------------------------------------------------+
```
Pattern internals:
```
+---------------------------------------------------------------+
| [Pattern] |
| |
| shapes: { |
| (1, 0): [Polygon, Circle, ...], # Geometry by layer |
| (2, 0): [Path, ...] |
| "M1" : [Path, ...] |
| "M2" : [Polygon, ...] |
| } |
| |
| refs: { # Key sets target name, Ref sets transform |
| "my_cell": [ |
| Ref(offset=(0,0), rotation=0), |
| Ref(offset=(10,0), rotation=R90, repetition=Grid(...)) |
| ] |
| } |
| |
| ports: { |
| "in": Port(offset=(0,0), rotation=0, ptype="M1"), |
| "out": Port(offset=(10,0), rotation=R180, ptype="wg") |
| } |
| |
+---------------------------------------------------------------+
```
`masque` departs from several "classic" GDSII paradigms: `masque` departs from several "classic" GDSII paradigms:
- A `Pattern` object does not store its own name. A name is only assigned when the pattern is placed - A `Pattern` object does not store its own name. A name is only assigned when the pattern is placed
into a `Library`, which is effectively a name->`Pattern` mapping. into a `Library`, which is effectively a name->`Pattern` mapping.
@ -236,3 +285,4 @@ my_pattern.ref(_make_my_subpattern(), offset=..., ...)
* Better interface for polygon operations (e.g. with `pyclipper`) * Better interface for polygon operations (e.g. with `pyclipper`)
- de-embedding - de-embedding
- boolean ops - boolean ops
* tuple / string layer auto-translation

View File

@ -24,6 +24,7 @@ class Abstract(PortList):
When snapping a sub-component to an existing pattern, only the name (not contained When snapping a sub-component to an existing pattern, only the name (not contained
in a `Pattern` object) and port info is needed, and not the geometry itself. in a `Pattern` object) and port info is needed, and not the geometry itself.
""" """
# Alternate design option: do we want to store a Ref instead of just a name? then we can translate/rotate/mirror...
__slots__ = ('name', '_ports') __slots__ = ('name', '_ports')
name: str name: str
@ -48,8 +49,6 @@ class Abstract(PortList):
self.name = name self.name = name
self.ports = copy.deepcopy(ports) self.ports = copy.deepcopy(ports)
# TODO do we want to store a Ref instead of just a name? then we can translate/rotate/mirror...
def __repr__(self) -> str: def __repr__(self) -> str:
s = f'<Abstract {self.name} [' s = f'<Abstract {self.name} ['
for name, port in self.ports.items(): for name, port in self.ports.items():
@ -88,7 +87,7 @@ class Abstract(PortList):
def rotate_around(self, pivot: ArrayLike, rotation: float) -> Self: def rotate_around(self, pivot: ArrayLike, rotation: float) -> Self:
""" """
Rotate the Abstract around the a location. Rotate the Abstract around a pivot point.
Args: Args:
pivot: (x, y) location to rotate around pivot: (x, y) location to rotate around

View File

@ -210,7 +210,8 @@ class Builder(PortList):
self.pattern.rect(*args, **kwargs) self.pattern.rect(*args, **kwargs)
return self return self
# Note: We're a superclass of `Pather`, where path() means something different... # Note: We're a superclass of `Pather`, where path() means something different,
# so we shouldn't wrap Pattern.path()
#@wraps(Pattern.path) #@wraps(Pattern.path)
#def path(self, *args, **kwargs) -> Self: #def path(self, *args, **kwargs) -> Self:
# self.pattern.path(*args, **kwargs) # self.pattern.path(*args, **kwargs)

View File

@ -487,7 +487,7 @@ class RenderPather(PatherMixin):
# Fall back to drawing two L-bends # Fall back to drawing two L-bends
ccw0 = jog > 0 ccw0 = jog > 0
kwargs_no_out = (kwargs | {'out_ptype': None}) kwargs_no_out = (kwargs | {'out_ptype': None})
t_port0, _ = tool.planL( ccw0, length / 2, in_ptype=in_ptype, **kwargs_no_out) t_port0, _ = tool.planL( ccw0, length / 2, in_ptype=in_ptype, **kwargs_no_out) # TODO length/2 may fail with asymmetric ptypes
jog0 = Port((0, 0), 0).measure_travel(t_port0)[0][1] jog0 = Port((0, 0), 0).measure_travel(t_port0)[0][1]
t_port1, _ = tool.planL(not ccw0, abs(jog - jog0), in_ptype=t_port0.ptype, **kwargs) t_port1, _ = tool.planL(not ccw0, abs(jog - jog0), in_ptype=t_port0.ptype, **kwargs)
jog1 = Port((0, 0), 0).measure_travel(t_port1)[0][1] jog1 = Port((0, 0), 0).measure_travel(t_port1)[0][1]

View File

@ -141,7 +141,6 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
Args: Args:
tops: Name(s) of the pattern(s) to check. tops: Name(s) of the pattern(s) to check.
Default is all patterns in the library. Default is all patterns in the library.
skip: Memo, set patterns which have already been traversed.
Returns: Returns:
Set of all referenced pattern names Set of all referenced pattern names
@ -274,7 +273,7 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
For an in-place variant, see `Pattern.flatten`. For an in-place variant, see `Pattern.flatten`.
Args: Args:
tops: The pattern(s) to flattern. tops: The pattern(s) to flatten.
flatten_ports: If `True`, keep ports from any referenced flatten_ports: If `True`, keep ports from any referenced
patterns; otherwise discard them. patterns; otherwise discard them.
dangling_ok: If `True`, no error will be thrown if any dangling_ok: If `True`, no error will be thrown if any

View File

@ -1241,7 +1241,7 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
ports specified by `map_out`. ports specified by `map_out`.
Examples: Examples:
======list, === =========
- `my_pat.plug(subdevice, {'A': 'C', 'B': 'B'}, map_out={'D': 'myport'})` - `my_pat.plug(subdevice, {'A': 'C', 'B': 'B'}, map_out={'D': 'myport'})`
instantiates `subdevice` into `my_pat`, plugging ports 'A' and 'B' instantiates `subdevice` into `my_pat`, plugging ports 'A' and 'B'
of `my_pat` into ports 'C' and 'B' of `subdevice`. The connected ports of `my_pat` into ports 'C' and 'B' of `subdevice`. The connected ports