案例分享:在给定的Shape内填充dummy
所有代码如下:
from si_fab import all as pdk
from ipkiss3 import all as i3
from shapely.geometry import Polygon, MultiPolygon
import numpy as np
import matplotlib.pyplot as plt
class CellFilledWithContacts(i3.PCell):
contact_size = i3.PositiveNumberProperty(default=1.5, doc="width and height of the contact box")
contact_pitch = i3.PositiveNumberProperty(default=2, doc="contact pitch")
class Layout(i3.LayoutView):
def _generate_elements(self, elems):
elems += i3.Boundary(
layer=i3.TECH.PPLAYER.SI,
shape=[(0, 0), (7.7, -23.7),
(32.6, -23.7), (12.4, -38.4),
(20.1, -62.1), (0, -47.4),
(-20.1, -62.1), (-12.4, -38.4),
(-32.6, -23.7), (-7.7, -23.7)]
)
s = elems.size_info()
polygons = [Polygon(el.shape) for el in elems]
region = MultiPolygon(polygons).buffer(-2.0)
plt.show()
no_of_contacts_row = int((s.east - s.west - self.contact_pitch) / self.contact_pitch)
no_of_contacts_col = int((s.north - s.south - self.contact_pitch) / self.contact_pitch)
print('number of contacts in each row of along the whole cell =', no_of_contacts_row)
print('number of contacts in each column of along the whole cell =', no_of_contacts_col)
contact_regions = []
# set the x and y coordinates for each contact via a for-loop
for cnt, i in enumerate(np.linspace(s.west, s.east, no_of_contacts_row)):
for cn, j in enumerate(np.linspace(s.north, s.south, no_of_contacts_col)):
contact = i3.Rectangle(layer=i3.TECH.PPLAYER.SI,
center=(i, j),
box_size=(self.contact_size, self.contact_size)
)
contact_region = Polygon(contact.shape)
contact_regions.append(contact_region)
# only add the contacts when they are not in the cell
if contact_region.intersects(region):
elems += contact
return elems
if __name__ == '__main__':
lay = CellFilledWithContacts().Layout()
lay.write_gdsii("demo.gds")
dummy的大小可以调节:
contact_size = i3.PositiveNumberProperty(default=1.5, doc="width and height of the contact box")
contact_pitch = i3.PositiveNumberProperty(default=2, doc="contact pitch")
可以通过:
shape=[(0, 0), (7.7, -23.7),
(32.6, -23.7), (12.4, -38.4),
(20.1, -62.1), (0, -47.4),
(-20.1, -62.1), (-12.4, -38.4),
(-32.6, -23.7), (-7.7, -23.7)]
来调节shape