5. Floorplan API

class siliconcompiler.floorplan.Floorplan(chip, tool='openroad')

Floorplan layout class.

This is the main object used to interact with the Floorplan API. In the context of a full SiliconCompiler flow, a Floorplan instance pre-populated with the current chip configuration is passed to the user, who will then call the member functions of this class to define objects and their location within the floorplan.

In order to define the floorplan geometry in a technology-agnostic way, this object exposes several attributes that allow the user to access technology-specific dimensions, such as standard cell width and height. These attributes can be used as scaling factors to determine the locations and sizes of objects on the floorplan.

Parameters
  • chip (Chip) – Object storing the chip config. The Floorplan API expects the chip’s configuration to be populated with information from a tech library.

  • tool (str) – String specifying which tool will consume the generated floorplan. This tool should have an associated tech LEF configured in the PDK setup file. Defaults to ‘openroad’.

available_cells

A dictionary mapping macro names to information about each macro. The values stored in this dictionary have two keys: width, the width of the macro in microns and height, the height of the macro in microns.

In order to make macro libraries usable by the Floorplan API, a user must specify them in the chip configuration.

To point SC to a certain macro library’s LEF file:

chip.add('asic', 'macrolib', libname)
chip.set('library', libname, 'lef', lef_path)
Type

dict

diearea

A tuple of two floats (width, height) storing the size of the die area in microns.

Type

tuple

layers

A dictionary mapping names to technology-specific info about the layers. This dictionary can be accessed using either SC-standardized layer names or PDK-specific layer names. Note that this means the dictionary should not be iterated over to extract all layers. Instead, the function get_layers() can be used for this. The values in this dictionary are dictionaries themselves, containing the keys name, width, xpitch, ypitch, xoffset, and yoffset.

Type

dict

stdcell_width

Width of standard cells in microns.

Type

float

stdcell_height

Height of standard cells in microns.

Type

float

add_net(net, pins, use)

Add special net.

Must be called before placing a wire for a net. Calls after the first will overwrite configuration values, but leave wires placed.

Parameters
  • net (str) – Name of net.

  • pins (list of str) – Name of pins in macro to associate with this net.

  • use (str) – Use of net. Must be valid LEF/DEF use.

add_via(name, bottom_layer, bottom_shapes, cut_layer, cut_shapes, top_layer, top_shapes)

Adds a fixed via definition that can be placed using place_vias.

Parameters
  • name (str) – Name of the via definition.

  • bottom_layer (str) – Name of bottom routing layer.

  • bottom_shapes (list of tuple) – Shapes to place on bottom layer. Each item in the list is a rectangle specified as a tuple of points representing the lower left and upper right corners of the rectangle, relative to the center of the via.

  • cut_layer (str) – Name of cut layer.

  • cut_shapes (list of tuple) – Shapes to place on cut layer, specified the same as bottom_shapes.

  • top_layer (str) – Name of top routing layer.

  • top_shapes (list of tuple) – Shapes to place on top layer, specified the same as bottom_shapes.

Examples

>>> shapes = [
    ((-10, -10), (-2.5, -2.5)),
    ((2.5, -10), (10, -2.5)),
    ((-10, 2.5), (-2.5, 10)),
    ((2.5, 2.5), (10, 10))
    ]
>>> fp.add_via('myvia', 'm1', shapes, 'via1', shapes, 'm2', shapes)
Defines via connecting layers 'm1' and 'm2' through 'via1', in the
form of a 2x2 array of squares.
create_diearea(diearea, corearea=None, generate_rows=True, generate_tracks=True)

Initializes die.

Initializes the area of the die and generates placement rows and routing tracks. The provided die and core dimensions will overwrite the die/core size already present in the chip config.

Parameters
  • diearea (list of (float, float)) – List of points that form the die area. Currently only allowed to provide two points, specifying the two bounding corners of a rectangular die. Dimensions are specified in microns.

  • corearea (list of (float, float)) – List of points that form the core area of the physical design. If None, corearea is set to be equivalent to the die area. Currently only allowed to provide two points, specifying the two bounding corners of a rectangular area. Dimensions are specified in microns.

  • generate_rows (bool) – Automatically generate rows to fill entire core area.

  • generate_tracks (bool) – Automatically generate tracks to fill entire core area.

fill_io_region(region, fillcells, orientation, direction)

Fill empty space in region with I/O filler cells.

Parameters
  • region (list of tuple of float) – bottom-left and top-right corner of region to fill.

  • fillcells (list of str) – List of names of I/O filler cells to use.

  • orientation (str) – The orientation the filler cells are placed in (must be valid LEF/DEF orientation).

  • direction (str) – The direction to place fill cells along. Must be ‘h’ for horizontal or ‘v’ for vertical.

Raises

ValueError – Region contains macros such that it is unfillable.

generate_rows(site_name=None, flip_first_row=False, area=None)

Auto-generates placement rows based on floorplan parameters and tech library.

Parameters
  • site_name (str) – Name of placement site to specify in rows. If None, uses default standard cell site.

  • flip_first_row (bool) – Determines orientation of row placement sites. If False, alternates starting at “FS”, if True, alternates starting at “N”.

  • area (tuple of float) – Area to fill with rows as tuple of four floats. If None, fill entire core area. Specified as microns.

generate_tracks(area=None)

Auto-generates routing tracks based on floorplan parameters and tech library.

Parameters

area (tuple of float) – Area to fill with tracks as tuple of four floats. If None, fill entire die area. Specified in microns.

get_layers()

Returns list of SC-standardized layer names defined in schema.

insert_vias(nets=None, layers=None)

Automatically insert vias.

Automatically inserts vias between common specialnets that intersect on different metal layers. Via geometries are generated based on VIARULE GENERATE statements found in the tech LEF.

Parameters
  • nets (list of str) – List of nets to analyze for via insertion. If empty or None, look at all nets.

  • layers (list of tuples) – List of tuples representing pairs of layers to check for intersections between. If empty or None, look at all layer pairs. Each pair should be ordered with lower layer first and higher layer second.

place_blockage(x, y, width, height, layer=None, snap=False)

Places blockage at specified location.

Parameters
  • x (float) – x-coordinate of blockage in microns.

  • y (float) – y-coordinate of blockage in microns.

  • width (float) – Width of blockage in microns.

  • height (float) – Height of blockage in microns.

  • layers (str) – Metal layer to block routing on. If None, mark as placement blockage.

  • snap (bool) – Whether or not to snap blockage position to be aligned with the nearest placement site.

place_macros(macros, x, y, xpitch, ypitch, orientation, halo=None, fixed=True, snap=False)

Places macros on floorplan.

Parameters
  • macros (list of (str, str)) – List of macros to place as tuples of (instance name, macro name).

  • x (float) – x-coordinate of first instance in microns.

  • y (float) – y-coordinate of first instance in microns.

  • xpitch (float) – Increment along x-axis in microns.

  • ypitch (float) – Increment along y-axis in microns.

  • orientation (str) – Orientation of macros (must be valid LEF/DEF orientation).

  • halo (tuple of int) – Halo around macro as tuple (left bottom right top), in microns.

  • fixed (bool) – Whether or not macro placement is fixed or placed.

  • snap (bool) – Whether or not to snap macro position to be aligned with the nearest placement site.

place_obstruction(x, y, width, height, layers=None, snap=False)

Places obstruction at specified location.

The obstructions specified using this method only take effect when dumping the floorplan as a LEF macro.

Parameters
  • x (float) – x-coordinate of blockage in microns.

  • y (float) – y-coordinate of blockage in microns.

  • width (float) – Width of blockage in microns.

  • height (float) – Height of blockage in microns.

  • layers (list) – List of layers to place obstructions on. If None, block all metal layers.

  • snap (bool) – Whether or not to snap obstruction position to be aligned with the nearest placement site.

place_pins(pins, x, y, xpitch, ypitch, width, height, layer, direction='inout', netname=None, use='signal', fixed=True, snap=False, add_port=False)

Places pins along edge of floorplan.

Parameters
  • pins (list of str) – List of pin names to place.

  • x (float) – x-coordinate of first instance in microns.

  • y (float) – y-coordinate of first instance in microns.

  • xpitch (float) – Increment along x-axis in microns.

  • ypitch (float) – Increment along y-axis in microns.

  • width (float) – Width of pin.

  • height (float) – Height of pin.

  • layer (str) – Which metal layer pin is placed on.

  • direction (str) – I/O direction of pins (must be valid LEF/DEF direction).

  • netname (str) – Name of net that each pin is connected to. If None, the net name of each pin will correspond to the pin name.

  • use (str) – Usage of pin (must be valid LEF/DEF use).

  • fixed (bool) – Whether pin status is ‘FIXED’ or ‘PLACED’.

  • snap (bool) – Whether to snap pin position to align it with the nearest routing track. Track direction is determined by preferred routing direction as specified in the tech LEF.

  • add_port (bool) – If True, then calls specifying a pin name that has already been placed on the floorplan will add a new port to the pin definition. This will disregard the netname, direction, and use arguments. If False, then calls specifying a pin name that has already been placed will add a new geometry to the most recently added port. This will disregard the netname, direction, use, and fixed arguments.

place_ring(net, x, y, width, height, hwidth, vwidth, hlayer, vlayer, pins=False)

Place wire ring.

Parameters
  • net (str) – Name of net.

  • x (float) – x-coordinate of bottom left corner of ring.

  • y (float) – y-coordinate of bottom left corner of ring.

  • width (float) – Width of ring from edge-to-edge.

  • height (float) – Height of ring from edge-to-edge.

  • hwidth (float) – Width of horizontal wires used in ring.

  • vwidth (float) – Width of vertical wires used in ring.

  • hlayer (str) – Metal layer to place horizontal wires on.

  • vlayer (str) – Metal layer to place vertical wires on.

  • pins (bool) – Whether to overlay pin definitions on rings.

place_vias(nets, x, y, xpitch, ypitch, name, snap=False)

Place vias on floorplan.

Parameters
  • nets (list of str) – List of net names to associate with each via. This function will place one via per entry in this list. To place multiple vias associated with the same net, repeat that name in the list.

  • x (float) – x-coordinate of first instance in microns.

  • y (float) – y-coordinate of first instance in microns.

  • xpitch (float) – Increment along x-axis in microns.

  • ypitch (float) – Increment along y-axis in microns.

  • name (str) – Name of via definition to place.

  • snap (bool) – Whether to snap via position to align it with routing tracks. If the preferred routing direction of the bottom layer is horizontal, the via’s x position is snapped to the nearest top layer x track and the y position is snapped to the nearest bottom layer y track. If the preferred routing direction of the bottom layer is vertical, the x position is snapped to the nearest bottom layer x track, and the y position is snaped to the nearest top layer y track.

place_wires(nets, x, y, xpitch, ypitch, width, height, layer, shape=None, snap=False)

Place wires on floorplan.

Parameters
  • nets (list of str) – List of net names of wires to place.

  • x (float) – x-coordinate of first instance in microns.

  • y (float) – y-coordinate of first instance in microns.

  • xpitch (float) – Increment along x-axis in microns.

  • ypitch (float) – Increment along y-axis in microns.

  • width (float) – Width of wire in microns.

  • height (float) – Height of wire in microns.

  • layer (str) – Which metal layer wire is placed on.

  • shape (str) – Specify wire with special connection requirements because of its shape. Must be a valid DEF shape value, such as “stripe” or “followpin”, or None for no special shape. See the DEF 5.8 language reference for more information.

  • snap (bool) – Whether to snap wire position to align it with the nearest routing track. Track direction is determined by preferred routing direction as specified in the tech LEF.

snap(val, grid)

Helper function for snapping val to nearest multiple of grid.

snap_to_x_track(x, layer)

Helper function to snap a value x to the x coordinate of the nearest vertical routing track on layer.

snap_to_y_track(y, layer)

Helper function to snap a value y to the y coordinate of the nearest horizontal routing track on layer.

write_def(filename)

Writes chip layout to DEF file.

Parameters

filename (str) – Name of output file.

write_lef(filename)

Writes chip layout to LEF file.

Parameters
  • filename (str) – Name of output file.

  • macro_name (str) – Macro name to use in LEF.

siliconcompiler.floorplan.render_tuple(vals)

Jinja filter for rendering tuples in DEF style, e.g. (0, 0) becomes “( 0 0 )”.

6. Leflib API

siliconcompiler.leflib.parse(path)

Parses LEF file.

Given a path to a LEF file, this function parses the file and returns a dictionary representing the contents of the LEF file. If there’s an error while reading or parsing the file, this function returns None instead.

Note that this function does not return all information contained in the LEF. The subset of information returned includes:

  • LEF version

  • Bus bit characters

  • Divider characters

  • Units

  • Manufacturing grid

  • Use min spacing

  • Clearance measure

  • Fixed mask

  • Layer information

    • Type

    • Width

    • Direction

    • Offset

    • Pitch

  • Max stack via

  • Viarules

  • Sites

  • Macro information

    • Size

    • Pins

    • Obstructions

The dictionary returned by this function is designed to mimic the structure of the LEF file as closely as possible, and this function does minimal legality checking. The order all top-level objects appear in the dictionary is guaranteed to match the LEF file. It looks like follows:

{
    'version': 5.8,
    'busbitchars': '<>',
    'dividerchar': ':',
    'units': {
        'capacitance': 10.0,
        'current': 10000.0,
        'database': 20000.0,
        'frequency': 10.0,
        'power': 10000.0,
        'resistance': 10000.0,
        'time': 100.0,
        'voltage': 1000.0
    },
    'manufacturinggrid': 0.05,
    'useminspacing': {'OBS': 'OFF'},
    'clearancemeasure': 'MAXXY',
    'fixedmask': True,
    'layers': {
        'M1': {
            'type': 'ROUTING',
            'direction': 'HORIZONTAL',
            'offset': (0.1, 0.2),
            'pitch': 1.8,
            'width': 1.0
        },
        'V1': {
            'type': 'CUT',
        },
        ...
    },
    'maxviastack': {'range': {'bottom': 'm1', 'top': 'm7'}, 'value': 4},
    'viarules': {
        '<name>': {
            'generate': True,
            'layers': [
                {'enclosure': {'overhang1': 1.4,
                               'overhang2': 1.5},
                 'name': 'M1',
                 'width': {'max': 19.0, 'min': 0.1}},
                {'enclosure': {'overhang1': 1.4,
                               'overhang2': 1.5},
                 'name': 'M2',
                 'width': {'max': 1.9, 'min': 0.2}},
                {'name': 'M3',
                 'rect': (-0.3, -0.3, -0.3, 0.3),
                 'resistance': 0.5,
                 'spacing': {'x': 5.6, 'y': 7.0}}
            ]
        },
        '<name>': {
            {'layers': [
                {'direction': 'VERTICAL',
                 'name': 'M1',
                 'width': {'max': 9.6, 'min': 9.0}},
                 {'direction': 'HORZIONTAL',
                 'name': 'M1',
                 'width': {'max': 3.0, 'min': 3.0}}
            ]}
        },
        ...
    }
    'macros': {
        '<name>': {
            'size': {
                'width': 5,
                'height': 8
            },
            'pins': {
                '<name>': {
                    'ports': [{
                        'class': 'CORE',
                        'layer_geometries': [{
                            'layer': 'M1',
                            'exceptpgnet': True,
                            'spacing': 0.01,
                            'designrulewidth': 0.05,
                            'width': 1.5,
                            'shapes': [
                                {
                                    'rect': (0, 0, 5, 5),
                                    'mask': 1,
                                    'iterate': {
                                        'num_x': 2,
                                        'num_y': 3,
                                        'space_x': 1,
                                        'space_y': 4
                                    }
                                },
                                {
                                    'path': [(0, 0), (5, 0), (0, 5)],
                                    'iterate': ...
                                },
                                {
                                    'polygon': [(0, 0), (5, 0), (0, 5)],
                                    'iterate': ...
                                }
                            ],
                            'via': {
                                'pt': (2, 3),
                                'name': 'via1',
                                'iterate': ...
                            }
                        }]
                    }]
                },
                ...
            }
        },
        ...
    }
}

If some entry is not specified in the LEF, the corresponding key will not be present in the dictionary.

Parameters

path (str) – Path to LEF file to parse.