Nazca-Design manual

Contents:

class nazca.Cell(name='cell', celltype='element', instantiate=True, autobbox=False, hull=None, store_pins=None, hashme=False, cnt=False, params=False, show_hull=False, hull_based_bbox=None)

Cell object, corresponding to a GDS cell when exported to GDS.

A cell has default pins:

‘org’: cell origin (non-chain) ‘a0’ : input pin (chain) ‘b0’ : output pin (chain)

It is up to the user to place ‘a0’ and ‘b0’ at sensible positions in the cell. If not provided, they will be placed at the origin automatically.

When starting a new cell: cp = C.pin[‘org’]

A cell typically contains one or more of the following objects:
  1. pins: A position w.r.t. the cell origin that can be used to connect to.

    method: Pin().put()

  2. cell instances: A reference to another cell

    method: Cell().put()

  3. polygons: A polygon assigned to a specific GDS layer.

    method: Polygon().put()

  4. polylines: A polyline/path assigned to a specific GDS layer.

    method: Polyline().put()

  5. annotations:

    method: Annotation().put()

add_property(item)

Add item to the cell properties dictionary.

item (dict): new property

Returns

None

close()

Close the cell.

Solve the geometry of the nodes in the Cell. Set the cp back to the position before opening the cell. If default input and/or output pins have not been set yet they will be set on ‘org’, pointing in opposite directions.

Returns

self

Return type

Cell

default_pins(pinin=None, pinout=None)

Set default input and output pin.

Parameters
  • pinin (Node | str) – pin to set as default cell input pin

  • pinout (Node | str) – pin to set as default cell output pin

Returns

None

filter()

Create a new cell after applying a layer filter.

Parameters

layers (list of layer) – layers to keep

Returns

new cell with subset of original layers

Return type

Cell

To be implemented

get_pin(pinname=None, connect=None)

“Parse pinname and connect for put_polygon and put_gds methods.

Returns

pin position, new if needed

Return type

Node

ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields

str, Pin – iterator over pins in cell

parse_instance_connection(C1, C2, C3, C4, C5, instance=None)

Connect a (closed) cell as an Instance object into the active cell.

Parse up to five connection arguments to extract: pin1, pin2 and (x,y,a):

Parameters
  • C1 (float | Node | Instance) – connection information

  • C2 (float | Node | Instance) – connection information

  • C3 (float | Node | Instance) – connection information

  • C4 (float | Node | Instance) – connection information

  • C5 (float | Node | Instance) – connection information

  • instance (Instance) – instance object to connect to

Returns

instance pin, cell pin, connection

Return type

Node, Node, (x, y, a)

Notes

The connection has the following syntax:

[pin_inst [, translation]]

or

[pin_inst, ] translation [, pin_cell]

  • translation = x | x,y | x, y, a | (x) | (x, y) | (x, y, z), where translation is w.r.t. <pin_cell>

  • pin_inst: pinname of instance (default=’a0’)

  • pin_cell: pinname of cell (default=’org’)

Options:

  • ()

  • (node)

  • (instance)

  • (0,)

  • (0, 0)

  • (0, 0, 0)

  • ((0))

  • ((0, 0))

  • ((0, 0, 0))

  • (0, pin)

  • (0, 0, pin_cell)

  • (0, 0, 0, pin_cell)

  • ((0), pin_cell)

  • ((0, 0), pin_cell)

  • ((0, 0, 0), pin_cell)

  • (pin_inst)

  • (pin_inst, 0)

  • (pin_inst, 0, 0)

  • (pin_inst, 0, 0, 0)

  • (pin_inst, (0))

  • (pin_inst, (0, 0))

  • (pin_inst, (0, 0, 0))

  • (pin_inst, pin_cell)

  • (pin_inst, 0, pin)

  • (pin_inst, 0, 0, pin_cell)

  • (pin_inst, 0, 0, 0, pin_cell)

  • (pin_inst, (0), pin_cell)

  • (pin_inst, (0, 0), pin_cell)

  • (pin_inst, (0, 0, 0), pin_cell)

parse_pin_connection(C1, C2, C3, C4)

Parse pin connection for polygon, polyline, annotation and gds methods.

Parameters
  • C1 (float | Node | instance) – Parsing information

  • C2 (float | Node | instance) – Parsing information

  • C3 (float | Node | instance) – Parsing information

  • C4 (float | Node | instance) – Parsing information

Returns

pin, translation

Return type

Node, (x, y, a)

Example

Options:

  • ()

  • (node)

  • (0,)

  • (0, 0)

  • (0, 0 ,0)

  • ((0))

  • ((0, 0))

  • ((0, 0 ,0))

  • (0, ‘b0’)

  • (0, 0, ‘b0’)

  • (0, 0 ,0, ‘b0’)

  • ((0), ‘b0’)

  • ((0, 0), ‘b0’)

  • ((0, 0 ,0), ‘b0’)

put(*args, flip=False, flop=False, array=None, scale=1.0, drc=None, **kwargs)

Instantiate a Cell object and put it in the active cell.

Parameters
  • *args (float | Node | Instance) – a set of maximum 5 unnamed parameters interpreted as a connection between two pins, where put() connects to the current pin cp For more details see method ‘parse_instance_connection’.

  • flip (bool) – mirror the instance in the vector line (default=False) flip is preformed after any translation and/or rotation. Hint: for connecting waveguides you only need flip (not flop).

  • flop (bool) – mirror the instance in the line perpendicular to the vector (default=False) flop is performed after any translation and/or rotation. A flop is the same as rot(180) + a flip Hint: for mask assembly or connecting bbox pins you may find both flip and flop useful.

  • cp (str) – Set current pin cp to a specific pin after putting (default=’b0’). Example: cp=’b1’

  • array (list) – creates an array instance upon GDS output if not None. Format the array as [col#, [dx1, dy1], row#, [dx2, dy2]] dx1, dy1 is the column vector measured between adjacent elements. dx2, dy2 is the row vector measured between adjacent elements. (default=None)

  • scale (float) – set scaling factor of the instance (default=1.0). In gds the scaling will be set as instance attribute. In case of flattening the instance, the scaling factor will be applied to the instance content.

Returns

reference to the instance of the cell being put

Return type

Instance

Examples

Below are different syntax examples for put.

In the examples we use the following objects:
  • nd.example: a pre-defined cell in Nazca

  • ‘a0’: default input pin name of “example”

  • ‘b0’: default output pin name of “example”

  1. connect the default pin of cell “example” to current pin (cp):

    import nazca as nd
    nd.example_cell().put() # -> put('a0', cp)
    nd.export_plt()
    
  2. connect pin ‘b0’ of cell “example_cell()” to current pin (cp):

    import nazca as nd
    nd.example_cell().put('b0') # -> put('b0', cp)
    nd.export_plt()
    
  3. connect default pin of cell “example_cell()” to its parent cell at org + (10, 20, 30):

    import nazca as nd
    nd.example_cell().put(10, 20, 30) # -> put('a0').move(10, 20, 30)
    nd.export_plt()
    
  4. connect default pin of cell “example_cell()” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example.put(C.pin['b0']) # -> put('a0', C.pin['b0'])
    nd.export_plt()
    
  5. connect pin ‘b0’ of cell “example_cell()” to instance C at pin ‘b0’:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example_cell().put('b0', C.pin['b0']) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
  6. connect pin ‘b0’ of cell “example_cell()” to instance C at its default out pin, i.e. refering to instance C only without pin attribute is interpreted as connecting to the default output pin of C.:

    import nazca as nd
    C = nd.example_cell().put(0)
    nd.example.put('b0', C) # -> put('b0', C.pin['b0'])
    nd.export_plt()
    
rebuild(instantiate=True, flat=False, layermap=None, layermapmode=None, cellmap=None, infolevel=0, clear=False)

Flatten, rename, relayer, reshape and/or filter a Nazca Cell object.

The original cell(tree) remains unchanged. This method operates at mask-element level. It contructs the output cell(tree) as geometrical info from the ground up, i.e. any circuit-type netlist information will not be copied. Rebuild can be used, for example, to place each layer of a cell at a different position in the mask layout.

Parameters
  • instantiate (bool) – instantiate setting of returned (top)cell. (default=True)

  • flat (bool) – flatten cell(tree) (default=False)

  • layermap (dict) – {oldlayer, newlayer} mapping

  • cellmap (dict) – to be implemented

  • layermapmode ('all' | 'none') – start mapping with all layers included in the map: ‘all’, or an empty map ‘none’. (default=’all’)

Returns

rebuilt input cell

Return type

Cell

class nazca.Instance(name=None)

Class to store pin information and properties of cell instantiations.

ic_pins()

Generator over interconnect pins, filter out org and bounding box.

Yields

str, Pin – iterator over pins in cell

raise_pins(namesin=None, namesout=None, show=True)

Copy pins of a cell instance to its parent cell.

If a cell A is “put” in cell P, then an instance of cell A is created inside “parent” cell P. Each instance of cell A, say A1, A2, …, contains a copy of all pins of cell A to represent cell A in P at a particular location, rotation, flip state and/or scaling. raise_pins automatically copies all pin attributes.

The instance pins are themselves not pins of cell P. Pins have to be explicitly set in P with nd.Pin.put(). Alternatively, all or part of the pins in an instance can be set at once in P by “raise_pins”, avoiding many nd.Pin().put() statements. This can very useful when an instance has a large number of pins that have to be “raised”.

Note

raise_pins is a method of Class Instance, not of Cell. Hence, it operates on a cell that has been put.

Parameters
  • namesin (list of str) – list of pin names to raise (default=all pins of the instance)

  • namesout (list of str) – list of new names of the raised pins (default=<namesin>)

  • show (bool) – show the pins in the layout with an arrow (default=True)

Returns

None

Example

Raise (copy) all pins of an instance to its parent cell. In the example a 90 degree bend is connected to port ‘a0’ of the new_cell.

Create pins without the raise_pins method looks like this:

# create and put Pins explicitly one by one:
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(100, 200)
    nd.Pin('a0').put(instance1.pin['a0'])
    nd.Pin('b0').put(instance1.pin['b0'])

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['a0'])
nd.export_plt()

Now raise pins with raise_pins on <instance1> in the new_cell. This also copies all pin attributes:

# raise pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(100, 200)
    instance1.raise_pins()

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['a0'])
nd.export_plt()

Now raise and rename pins ‘a0’ and ‘b0’ of <instance1> with method raise_pins. Note that the cell default pins, ‘a0’ and ‘b0’, are automatically added to <new_cell>:

# raise and rename pins
import nazca as nd

with nd.Cell('new_cell') as new_cell:
    instance1 = nd.example_cell().put(0)
    instance1.raise_pins(['a0', 'b0'], ['new_a0', 'new_b0'])

instance2 = new_cell.put(0)
nd.bend(angle=90).put(instance2.pin['new_a0'])
nd.bend(angle=-90).put(instance2.pin['a0'])
nd.export_plt()