Skip to content

Utils

utils

Utility functions for virtual cells.

extrude_backbone

extrude_backbone(
    c: VKCell,
    backbone: Sequence[DPoint],
    width: float,
    layer: LayerInfo,
    start_angle: float,
    end_angle: float,
    dbu: float,
    enclosure: LayerEnclosure | None = None,
) -> None

Extrude a backbone into a virtual cell.

Parameters:

Name Type Description Default
c VKCell

target cell

required
backbone Sequence[DPoint]

backbone to extrude

required
width float

width to extrude (main layer)

required
layer LayerInfo

main layer & reference for enclosure

required
enclosure LayerEnclosure | None

enclosure to apply

None
start_angle float

force a certain start angle

required
end_angle float

force a acertain end angle

required
dbu float

database unit to use as a reference

required
Source code in kfactory/factories/utils.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def extrude_backbone(
    c: VKCell,
    backbone: Sequence[kdb.DPoint],
    width: float,
    layer: kdb.LayerInfo,
    start_angle: float,
    end_angle: float,
    dbu: float,
    enclosure: LayerEnclosure | None = None,
) -> None:
    """Extrude a backbone into a virtual cell.

    Args:
        c: target cell
        backbone: backbone to extrude
        width: width to extrude (main layer)
        layer: main layer & reference for enclosure
        enclosure: enclosure to apply
        start_angle: force a certain start angle
        end_angle: force a acertain end angle
        dbu: database unit to use as a reference
    """
    center_path_l, center_path_r = extrude_path_points(
        backbone, width=width, start_angle=start_angle, end_angle=end_angle
    )
    center_path_r.reverse()
    c.shapes(c.kcl.layer(layer)).insert(kdb.DPolygon(center_path_l + center_path_r))

    if enclosure:
        for _layer, sections in enclosure.layer_sections.items():
            _li = c.kcl.layer(_layer)
            for section in sections.sections:
                if section.d_min is not None:
                    inner_l, inner_r = extrude_path_points(
                        backbone,
                        width=width + 2 * section.d_min * dbu,
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    outer_l, outer_r = extrude_path_points(
                        backbone,
                        width=width + 2 * section.d_max * dbu,
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    inner_l.reverse()
                    outer_r.reverse()
                    c.shapes(_li).insert(kdb.DPolygon(outer_l + inner_l))
                    c.shapes(_li).insert(kdb.DPolygon(inner_r + outer_r))
                else:
                    outer_l, outer_r = extrude_path_points(
                        backbone,
                        width=width + 2 * section.d_max * dbu,
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    outer_r.reverse()
                    c.shapes(_li).insert(kdb.DPolygon(outer_l + outer_r))

extrude_backbone_dynamic

extrude_backbone_dynamic(
    c: VKCell,
    backbone: list[DPoint],
    width1: float,
    width2: float,
    layer: LayerInfo,
    start_angle: float,
    end_angle: float,
    dbu: float,
    enclosure: LayerEnclosure | None = None,
) -> None

Extrude a backbone into a virtual cell.

Parameters:

Name Type Description Default
c VKCell

target cell

required
backbone list[DPoint]

backbone to extrude

required
width1 float

start width to extrude (main layer)

required
width2 float

end width to extrude (main layer)

required
layer LayerInfo

main layer & reference for enclosure

required
enclosure LayerEnclosure | None

enclosure to apply

None
start_angle float

force a certain start angle

required
end_angle float

force a acertain end angle

required
dbu float

database unit to use as a reference

required
Source code in kfactory/factories/utils.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def extrude_backbone_dynamic(
    c: VKCell,
    backbone: list[kdb.DPoint],
    width1: float,
    width2: float,
    layer: kdb.LayerInfo,
    start_angle: float,
    end_angle: float,
    dbu: float,
    enclosure: LayerEnclosure | None = None,
) -> None:
    """Extrude a backbone into a virtual cell.

    Args:
        c: target cell
        backbone: backbone to extrude
        width1: start width to extrude (main layer)
        width2: end width to extrude (main layer)
        layer: main layer & reference for enclosure
        enclosure: enclosure to apply
        start_angle: force a certain start angle
        end_angle: force a acertain end angle
        dbu: database unit to use as a reference
    """

    def width_f(x: float, a: float) -> float:
        return (width1 - width2) * (1 - x) + width2 + a

    center_path_l, center_path_r = extrude_path_dynamic_points(
        backbone,
        widths=partial(width_f, a=0),
        start_angle=start_angle,
        end_angle=end_angle,
    )
    center_path_r.reverse()
    c.shapes(c.kcl.layer(layer)).insert(kdb.DPolygon(center_path_l + center_path_r))

    if enclosure:
        for _layer, sections in enclosure.layer_sections.items():
            _li = c.kcl.layer(_layer)
            for section in sections.sections:
                if section.d_min is not None:
                    inner_l, inner_r = extrude_path_dynamic_points(
                        backbone,
                        widths=partial(width_f, a=2 * section.d_min * dbu),
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    outer_l, outer_r = extrude_path_dynamic_points(
                        backbone,
                        widths=partial(width_f, a=2 * section.d_max * dbu),
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    inner_l.reverse()
                    outer_r.reverse()
                    c.shapes(_li).insert(kdb.DPolygon(outer_l + inner_l))
                    c.shapes(_li).insert(kdb.DPolygon(inner_r + outer_r))
                else:
                    outer_l, outer_r = extrude_path_dynamic_points(
                        backbone,
                        widths=partial(width_f, a=2 * section.d_max * dbu),
                        start_angle=start_angle,
                        end_angle=end_angle,
                    )
                    outer_r.reverse()
                    c.shapes(_li).insert(kdb.DPolygon(outer_l + outer_r))