Drop ports by default
This commit is contained in:
parent
e0939049dd
commit
069dde3648
@ -207,6 +207,7 @@ class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
def flatten(
|
def flatten(
|
||||||
self,
|
self,
|
||||||
tops: Union[str, Sequence[str]],
|
tops: Union[str, Sequence[str]],
|
||||||
|
flatten_ports: bool = False, # TODO document
|
||||||
) -> Dict[str, 'Pattern']:
|
) -> Dict[str, 'Pattern']:
|
||||||
"""
|
"""
|
||||||
Removes all refs and adds equivalent shapes.
|
Removes all refs and adds equivalent shapes.
|
||||||
@ -238,6 +239,8 @@ class Library(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
raise PatternError(f'Circular reference in {name} to {target}')
|
raise PatternError(f'Circular reference in {name} to {target}')
|
||||||
|
|
||||||
p = ref.as_pattern(pattern=flattened[target])
|
p = ref.as_pattern(pattern=flattened[target])
|
||||||
|
if not flatten_ports:
|
||||||
|
p.ports.clear()
|
||||||
pat.append(p)
|
pat.append(p)
|
||||||
|
|
||||||
pat.refs.clear()
|
pat.refs.clear()
|
||||||
|
@ -561,6 +561,7 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
|
|||||||
def flatten(
|
def flatten(
|
||||||
self: P,
|
self: P,
|
||||||
library: Mapping[str, P],
|
library: Mapping[str, P],
|
||||||
|
flatten_ports: bool = False, # TODO document
|
||||||
) -> 'Pattern':
|
) -> 'Pattern':
|
||||||
"""
|
"""
|
||||||
Removes all refs (recursively) and adds equivalent shapes.
|
Removes all refs (recursively) and adds equivalent shapes.
|
||||||
@ -592,6 +593,8 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
|
|||||||
raise PatternError(f'Circular reference in {name} to {target}')
|
raise PatternError(f'Circular reference in {name} to {target}')
|
||||||
|
|
||||||
p = ref.as_pattern(pattern=flattened[target])
|
p = ref.as_pattern(pattern=flattened[target])
|
||||||
|
if not flatten_ports:
|
||||||
|
p.ports.clear()
|
||||||
pat.append(p)
|
pat.append(p)
|
||||||
|
|
||||||
pat.refs.clear()
|
pat.refs.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user