def write_gdsii_mask(self, **kwargs): elems = ElementList() for pg in self.process_elements: for e in pg.elements: elems += e D = Cell(name=self.name + '_VMODEL', elements=elems) D.gdsii_output()
def view_derived_overlap_elements(self, **kwargs): elems = ElementList() for pg in self.derived_overlap_elements: for e in pg.elements: elems += e name = '{}_{}'.format(self.name, 'DERIVED_OVERLAP_ELEMENTS') D = Cell(name=name, elements=elems) D.gdsii_view()
def gdsii_output_electrical_connection(self): elems = ElementList() overlap_elems, edges = self.edges for e in overlap_elems: elems += e for edge in edges: elems += edge.outside for e in self.cell.elements: elems += e D = Cell(name='_ELECTRICAL_CONNECT', elements=elems) D.gdsii_output()
def __filter___Cell____(self, item): from spira.yevon.utils import clipping from spira.yevon.gdsii.cell import Cell ports = PortList() elems = ElementList() for e in item.elements.polygons: e.shape = clipping.simplify_points(e.points) elems += e # points = clipping.simplify_points(e.points) # elems += e.copy(shape=points) # p = e.__class__(shape=points, layer=e.layer, transformation=e.transformation) # elems += e.__class__(shape=points, layer=e.layer, transformation=e.transformation) for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e for p in item.ports: ports += p cell = Cell(elements=elems, ports=ports) # cell = item.__class__(elements=elems, ports=ports) return cell
def filter_Cell(self, item): from copy import deepcopy from spira.yevon.gdsii.cell import Cell elems = ElementList() if self.width is None: for p1 in deepcopy(item.elements.polygons): if p1.layer.purpose in self.purposes: for edge in p1.edges: shape = ShapeEdge(original_shape=edge.line_shape, edge_width=edge.width, edge_type=self.edge_type) elems += edge.copy(shape=shape) elems += p1 else: for p1 in deepcopy(item.elements.polygons): if p1.layer.purpose in self.purposes: for edge in p1.edges: shape = ShapeEdge(original_shape=edge.line_shape, edge_width=self.width, edge_type=self.edge_type) elems += edge.copy(shape=shape) elems += p1 cell = Cell(elements=elems) return cell
def bbox_info_cell(elem): from spira.yevon.gdsii.cell import Cell from spira.yevon.gdsii.polygon import Polygon bbox_shape = elem.bbox_info.bounding_box() bbox_ply = Polygon(shape=bbox_shape) D = Cell(name='BBoxCell') D += bbox_ply return D
def load_aspect(): """ Mix the aspects into their corresponding classes. """ Cell.mixin(CellAspects) Cell.mixin(CellPortProperty) Cell.mixin(NetlistAspects) Cell.mixin(Transformable) Cell.mixin(Outputs) SRef.mixin(SRefPortProperty) SRef.mixin(NetlistAspects) Shape.mixin(ShapeClipperAspects) __Polygon__.mixin(PolygonAspects) __Polygon__.mixin(NetlistAspects) __Polygon__.mixin(PolygonPortProperty) __Polygon__.mixin(PolygonClipperAspects)
def filter_Port(self, item): elems = ElementList() elems += self._create_label(item) if item.purpose.symbol == 'C': elems += self._contact_template(item) else: elems += self._edge_template(item) elems += self._create_arrow(item) cell = Cell(elements=elems) return cell
def filter_Polygon(self, item): elems = ElementList() for p in item.ports: el = self.filter_Port(p).elements # FIXME: We have to use this for PCells. elems += el.transform(item.transformation) # FIXME: Have to use this for GDS files. # elems += el cell = Cell(elements=elems) return cell
def __create_elements__(self, elems): elems = self.create_elements(elems) elems += self.structures elems += self.routes if self.pcell is True: D = Cell(elements=elems.flat_copy()) elems = RDD.FILTERS.PCELL.DEVICE(D).elements return elems
def __filter___Cell____(self, item): from copy import deepcopy from spira.yevon.gdsii.cell import Cell elems = ElementList() for p1 in deepcopy(item.elements): if p1.layer.purpose == RDD.PURPOSE.METAL: for edge in p1.edges: e = EdgeAdapter(original_edge=edge, edge_type=self.edge_type) # print(e) elems += e # elems += edge.outside.transform(edge.transformation) elems += p1 cell = Cell(elements=elems) return cell
def filter_Cell(self, item): from spira.yevon.utils import clipping from spira.yevon.gdsii.cell import Cell ports = PortList() elems = ElementList() for e in item.elements.polygons: e.shape = clipping.simplify_points(e.points) elems += e for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e for p in item.ports: ports += p cell = Cell(elements=elems, ports=ports) return cell
def filter_Cell(self, item): from spira.yevon.gdsii.cell import Cell ports = PortList() elems = ElementList() for e in item.derived_merged_elements: elems += e for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e for p in item.ports: if p.purpose.symbol == 'P': ports += p if p.purpose.symbol == 'T': ports += p cell = Cell(elements=elems, ports=ports) return cell
def __filter___Cell____(self, item): from spira.yevon.gdsii.cell import Cell ports = PortList() elems = ElementList() # for pg in item.process_elements: # for e in pg.elements: # elems += e for e in item.process_elements: elems += e for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e for p in item.ports: ports += p cell = Cell(elements=elems, ports=ports) return cell
def __create_elements__(self, elems): F = RDD.PCELLS.FILTERS F['boolean'] = False F['simplify'] = False F['via_contact'] = False F['metal_connect'] = False elems = self.create_elements(elems) elems += self.structures elems += self.routes if self.pcell is True: # elems = elems.expand_transform() # D = Cell(elements=elems).expand_flat_copy(exclude_devices=True) D = Cell(elements=elems).expand_transform() # D = Cell(elements=elems) elems = F(D).elements return elems
def __filter___Cell____(self, item): from spira.yevon.gdsii.cell import Cell from spira.yevon.utils import clipping from spira.yevon.vmodel.virtual import virtual_connect from shapely.geometry import Polygon as ShapelyPolygon ports = PortList() elems = ElementList() v_model = virtual_connect(device=item) for e in v_model.connected_elements: elems += e for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e for p in item.ports: ports += p cell = Cell(elements=elems, ports=ports) return cell
def filter_Cell(self, item): from spira.yevon.utils import clipping from spira.yevon.gdsii.cell import Cell from spira.yevon.geometry.ports import Port from spira.yevon.vmodel.virtual import virtual_connect from shapely.geometry import Polygon as ShapelyPolygon # ports = PortList() elems = ElementList() v_model = virtual_connect(device=item) for e1 in v_model.derived_contacts: ps = e1.layer.process.symbol for e2 in item.elements: for m in ['BOT_LAYER', 'TOP_LAYER']: if ps in RDD.VIAS.keys: if e2.layer == RDD.VIAS[ps].LAYER_STACK[m]: if e2.encloses(e1.center): port = Port( name='{}:Cv'.format(ps), midpoint=e1.center, process=e1.layer.process) e2.ports += port elems += item.elements for e in item.elements.sref: elems += e for e in item.elements.labels: elems += e # for p in item.ports: # ports += p # cell = Cell(elements=elems, ports=ports) cell = Cell(elements=elems) return cell
def write_gdsii_blocks(self, **kwargs): D = Cell(name=self.name + '_BLOCKS', elements=self.block_elements) D.gdsii_output()
if S.reference.is_layer_in_cell(layer): bbox_shape = S.bbox_info.bounding_box() layer.purpose = RDD.PURPOSE.BOUNDARY_BOX elems += Polygon(shape=bbox_shape, layer=layer) return elems class ReferenceBlocks(__Aspects__): """ Create a boundary block around the cell references in the current cell structure. """ block_elements = ElementListParameter() def create_block_elements(self, elems): for e in self.elements.sref: for layer in RDD.get_physical_layers_by_purpose(purposes=['METAL', 'GND']): if e.reference.is_layer_in_cell(layer): bbox_shape = e.bbox_info.bounding_box() elems += Polygon(shape=bbox_shape, layer=layer) return elems def write_gdsii_blocks(self, **kwargs): D = Cell(name=self.name + '_BLOCKS', elements=self.block_elements) D.gdsii_output() Cell.mixin(ReferenceBlocks)
def __create_elements__(self, elems): from spira.yevon.gdsii.sref import SRef elems = self.create_elements(elems) elems += self.structures elems += self.routes def wrap_references(cell, c2dmap, devices): for e in cell.elements.sref: if isinstance(e.reference, Device): D = deepcopy(e.reference) D.elements.transform(e.transformation) D.ports.transform(e.transformation) devices[D] = D.elements D.elements = ElementList() S = deepcopy(e) S.reference = D c2dmap[cell] += S else: S = deepcopy(e) S.reference = c2dmap[e.reference] c2dmap[cell] += S if self.pcell is True: ex_elems = elems.expand_transform() C = Cell(elements=ex_elems) c2dmap, devices = {}, {} for cell in C.dependencies(): D = Cell(name=cell.name, elements=deepcopy(cell.elements.polygons), ports=deepcopy(cell.ports)) c2dmap.update({cell: D}) for cell in C.dependencies(): wrap_references(cell, c2dmap, devices) D = c2dmap[C] # for e in D.elements.polygons: # if e.layer.purpose.symbol == 'METAL': # e.layer.purpose = RDD.PURPOSE.CIRCUIT_METAL F = RDD.FILTERS.PCELL.CIRCUIT # from spira.yevon import filters # F = filters.ToggledCompositeFilter(filters=[]) # F += filters.ProcessBooleanFilter(name='boolean') Df = F(D) # NOTE: Add devices back into the circuit. for d in Df.dependencies(): if d in devices.keys(): d.elements = devices[d] # for e in d.elements.polygons: # if e.layer.purpose.symbol == 'METAL': # e.layer.purpose = RDD.PURPOSE.DEVICE_METAL elems = Df.elements return elems
class ElementsForModelling(__Aspects__): """ Convert the cell elements into a new set of elements for every active process. """ process_elements = ElementListParameter() overlap_elements = ElementListParameter() def create_process_elements(self, elems): elems += get_process_polygons(self.elements, 'or') return elems def create_overlap_elements(self, elems): elems += get_process_polygons(self.elements, 'and') return elems def write_gdsii_mask(self, **kwargs): elems = ElementList() for pg in self.process_elements: for e in pg.elements: elems += e D = Cell(name=self.name + '_VMODEL', elements=elems) D.gdsii_output() Cell.mixin(ElementsForModelling)
return elems def create_derived_overlap_elements(self, elems): elems += get_process_polygons(self.elements, 'and') return elems def create_derived_diff_elements(self, elems): elems += get_process_polygons(self.elements, 'not') return elems def view_derived_merged_elements(self, **kwargs): elems = ElementList() for pg in self.derived_merged_elements: for e in pg.elements: elems += e name = '{}_{}'.format(self.name, 'DERIVED_MERGED_ELEMENTS') D = Cell(name=name, elements=elems) D.gdsii_view() def view_derived_overlap_elements(self, **kwargs): elems = ElementList() for pg in self.derived_overlap_elements: for e in pg.elements: elems += e name = '{}_{}'.format(self.name, 'DERIVED_OVERLAP_ELEMENTS') D = Cell(name=name, elements=elems) D.gdsii_view() Cell.mixin(DerivedElements)
def load_aspect(): """ Mix the aspects into their corresponding classes. """ Shape.mixin(ShapeClipperAspects) Polygon.mixin(PolygonAspects) Polygon.mixin(NetlistAspects) Polygon.mixin(PolygonPortAspects) Polygon.mixin(PolygonClipperAspects) Polygon.mixin(OutputPlotlyNetlist) SRef.mixin(SRefPortAspects) SRef.mixin(NetlistAspects) Cell.mixin(CellAspects) Cell.mixin(CellPortAspects) Cell.mixin(NetlistAspects) Cell.mixin(Transformable) Cell.mixin(OutputGdsiiAspect) Cell.mixin(OutputPlotlyNetlist)
def filter_Polygon(self, item): elems = ElementList() for p in item.edge_ports: elems += self.filter_Port(p).elements cell = Cell(elements=elems) return cell
# --------------------- 90 Degree Turns ------------------------- # # Q1 # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=0) # port2 = spira.Port(name='P2', midpoint=(20,10), orientation=180) # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=90) # port2 = spira.Port(name='P2', midpoint=(20,10), orientation=270) # # Q2 # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=180) # port2 = spira.Port(name='P2', midpoint=(-20,10), orientation=0) # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=90) # port2 = spira.Port(name='P2', midpoint=(-20,10), orientation=270) # # Q3 # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=180) # port2 = spira.Port(name='P2', midpoint=(-20,-10), orientation=0) # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=90) # port2 = spira.Port(name='P2', midpoint=(-20,10), orientation=270) # # Q4 # port1 = spira.Port(name='P1', midpoint=(0,0), orientation=0) # port2 = spira.Port(name='P2', midpoint=(20,-10), orientation=180) port1 = Port(name='P1', midpoint=(0, 0), orientation=270) port2 = Port(name='P2', midpoint=(20, -10), orientation=90) D = Cell(name='Route') D += Route180(port1, port2, width=1, layer=Layer(1)) D.gdsii_output()