# LEF 5.8 C/C++ Programming Interface -- 6
Describes the C/C++ programming interface used to read and write Library Exchange Format (LEF) files.
Author: Technical Publications

###
LEF 5.8 C/C++ Programming Interface (Open Licensing Program)

# 6

# LEF Writer Routines

You can use the Cadence® Library Exchange Format (LEF) writer routines to create a program that outputs a LEF file. The LEF writer routines correspond to the sections in the LEF file. This chapter describes the routines listed below that you need to write a particular LEF section.

Routines | LEF File Sections
LEF Writer Setup and Control | Initialization and global variables
Bus Bit Characters | BUSBITCHARS statement
Clearance Measure | CLEARANCEMEASURE statement
Divider Character | DIVIDERCHAR statement
Extensions | Extensions statement
Layer (Cut, Masterslice, Overlap, Implant) | LAYER sections about cut, masterslice, overlap, and implant layers
Layer (Routing) | LAYER section about routing layers
Macro | MACRO section

> Macro Obstruction

OBS section within a MACRO section

> Macro Pin

PIN section within a MACRO section

> Macro Pin Port

PORT section within a PIN section

Manufacturing Grid | MANUFACTURINGGRID statement
Maximum Via Stack | MAXVIASTACK statement
Nondefault Rule | NONDEFAULTRULE section
Property | PROPERTY statement in a VIA, VIARULE, LAYER, MACRO or NONDEFAULTRULE section
Property Definitions | PROPERTYDEFINTIONS statement
Same-Net Spacing | SPACING statement
Site | SITE statement
Units | UNITS statement
Use Min Spacing | USEMINSPACING statement
Version | VERSION statement
Via | VIA section
Via Rule | VIARULE statement
Via Rule Generate | VIARULEGENERATE statement

## LEF Writer Setup and Control

The LEF writer setup and control routines initialize the reader and set global variables that are used by the reader. You must begin and end a LEF file with the lefwInit and lefwEnd routines. All other routines must be used between these two routines. The remaining routines described in this section are provided as utilities. For examples of the routines described, see "Setup Examples".

All routines return 0 if successful.

### lefwInit

Initializes the LEF writer. This routine must be used first.

#### Syntax

int lefwInit(
  FILE*
file)

#### Arguments

file

> Specifies the name of the LEF file to create.

### lefwEnd

Ends the LEF file. This routine must be used last. This routine does not require any arguments.

#### Syntax

int lefwEnd()

### lefwCurrentLineNumber

Returns the line number of the last line written to the LEF file. This routine does not require any arguments.

#### Syntax

int lefwCurrentLineNumber()

### lefwNewLine

Writes a blank line. This routine does not require any arguments.

#### Syntax

int lefwNewLine()

### lefwPrintError

Prints the return status of the lefw* routines.

#### Syntax

void lefwPrintError(
  int
status)

#### Arguments

status

> Specifies the non-zero integer returned by the LEF writer routines.

### Setup Examples

The following examples show how to set up the writer. There are two ways to use the LEF writer:

| You call the write routines in your own sequence. The writer makes sure that some routines are called before others, but you must make sure the entire sequence is correct, and that all required sections are there.

| You write callback routines for each section, and the writer calls your callback routines in the sequence based on the LEF/DEF Language Reference. If a section is required, but you do not provide a callback routine, the writer issues a warning. If there is a default routine, the writer invokes the default routine with a message attached.

This manual includes examples with and without callback routines.

The following example uses the writer without callbacks.

int setupRoutine() {
  FILE* f;
  int res;
  ...
  // Open the lef file for the writer to write.
  if ((f = fopen("lefOutputFileName","w")) == 0) {
  printf("Couldn't open output file '%s'\n",
  "lefOutputFileName");
  return(2);
  }
  // Initialize the writer. This routine has to call first. Call this
  // routine instead of lefwInitCbk(f) if you are not using the
  // callback routines.
  res = lefwInit(f);
  ...
  res = lefwEnd();
  ...
  fclose(f);
  return 0;
  }

The following example uses the writer with callbacks.

int setupRoutine() {
  FILE* f;
  int res;
  int userData = 0x01020304;
  ...
  // Open the lef file for the writer to write.
  if ((f = fopen("lefOutputFileName","w")) == 0) {
  printf("Couldn't open output file '%s'\n",
  "lefOutputFileName");
  return(2);
  }
  // Initialize the writer. This routine has to call first. Call this
  // routine instead of lefwInit() if you are using the writer with
  // callbacks.
  res = lefwInitCbk(f);
  // Set the user callback routines
  lefwSetAntennaCbk(antennaCB);
  lefwSetBusBitCharsCbk(busBitCharsCB);
  lefwSetCaseSensitiveCbk(caseSensCB);
  lefwSetCorrectionTableCbk(correctTableCB);
  lefwSetEndLibCbk(endLibCB);
  ...
  // Invoke the parser
  res = lefrWrite(f, "lefInputFileName", (void*)userData);
  if (res != 0) {
  printf("LEF writer returns an error\n");
  return(2);
  }
  fclose(f);
  return 0;
  }

The following example shows how to use the callback routine to mark the end of the LEF file. The type is lefwEndLibCbkType.

#define CHECK_RES(res) \
  if (res) { \
  lefwPrintError(res); \
  return(res); \
  }
  int endLibCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwEndLibCbkType) {
  printf("Type is not lefwEndLibCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwEnd();
  CHECK_RES(res);
  return 0;
  }

## Bus Bit Characters

The Bus Bit Characters routine writes a LEF BUSBITCHARS statement. The BUSBITCHARS statement is optional and can be used only once in a LEF file. For syntax information about the LEF BUSBITCHARS statement, see "Bus Bit Characters" in the LEF/DEF Language Reference.

The BUSBITCHARS statement is part of the LEF file header (which also includes the VERSION, and DIVIDERCHAR statements). If the statements in the header section are not defined, many applications assume default values for them. However, the default values are not formally part of the language definition; therefore you cannot be sure that the same assumptions are used in all applications. You should always explicitly define these values.

This routine returns 0 if successful.

### lefwBusBitChars

Writes a BUSBITCHARS statement.

#### Syntax

int lefwBusBitChars(
  const char*
busBitChars)

#### Arguments

busBitChars

> Specifies the pair of characters used to specify bus bits when LEF names are mapped to or from other databases. The characters must be enclosed in double quotation marks.

### Bus Bit Characters Example

The following example shows a callback routine with the type lefwBusBitCharsCbkType.

int busBitCharsCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwBusBitCharsCbkType) {
  printf("Type is not lefwBusBitCharsCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwBusBitChars("<>");
  CHECK_RES(res);
  return 0;}

## Clearance Measure

The Clearance Measure routine writes a LEF CLEARANCEMEASURE statement. The CLEARANCEMEASURE statement is optional and can be used only once in a LEF file. For syntax information about the LEF CLEARANCEMEASURE section, see "Clearance Measure" in the LEF/DEF Language Reference.

This routine returns 0 if successful.

### lefwClearanceMeasure

Writes a CLEARANCEMEASURE statement.

#### Syntax

int lefwClearanceMeasure(
  const char*
type)

#### Arguments

type

> Specifies the type of clearance spacing that will be applied to obstructions (blockages) and pins in cells.
> Value: Specify one of the following:

| MAXXY | Uses the larger x and y distances for spacing between objects.
| EUCLIDEAN | Uses euclidean distance for spacing between objects.

## Divider Character

The Divider Character routine writes a LEF DIVIDERCHAR statement. The DIVIDERCHAR statement is optional and can be used only once in a LEF file. For syntax information about the LEF DIVIDERCHAR statement, see "Divider Character" in the LEF/DEF Language Reference.

The DIVIDERCHAR statement is part of the LEF file header (which also includes the VERSION, and BUSBITCHARS statements). If the statements in the header section are not defined, many applications assume default values for them. However, the default values are not formally part of the language definition; therefore you cannot be sure that the same assumptions are used in all applications. You should always explicitly define these values.

This routine returns 0 if successful.

### lefwDividerChar

Writes a DIVIDERCHAR statement.

#### Syntax

int lefwDividerChar(
  const char*
dividerChar)

#### Arguments

dividerChar

> Specifies the character used to express hierarchy when LEF names are mapped to or from other databases. The character must be enclosed in double quotation marks.
> Note: If the divider character appears in a LEF name as a regular character, you must use a backslash (\) before the character to prevent the LEF reader from interpreting the character as a hierarchy delimiter.

### Divider Character Examples

The following example shows a callback routine with the type lefwDividerCharCbkTyp.

int dividerCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwDividerCharCbkType) {
  printf("Type is not lefwDividerCharCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwDividerChar(":");
  CHECK_RES(res);
  res = lefwNewLine(); // add an empty line
  CHECK_RES(res);
  return 0;}

## Extensions

Extensions routines write a LEF BEGINEXT statement. The BEGINEXT statement is optional and can be used more than once in a LEF file.

Extensions routines let you add customized syntax to the LEF file that can be ignored by tools that do not use that syntax. You can also use extensions to add new syntax not yet supported by your version of LEF, if you are using version 5.1 or later. For syntax information about the LEF EXTENSIONS section, see "Extensions" in the LEF/DEF Language Reference.

You must begin and end a LEF BEGINEXT statement with the lefwStartBeginext and lefwEndBeginext routines. All LEF writer routines that define EXTENSIONS routines must be included between these routines.

For examples of the routines described here, see "Extensions Examples".

All routines return 0 if successful.

### lefwStartBeginext

Starts the EXTENSIONS statement using the specified tag.

#### Syntax

int lefwStartBeginext(
  const char*
tag)

#### Arguments

tag

> Identifies the extension block. The tag must be enclosed in double quotation marks.

### lefwEndBeginext

Writes the ENDEXT statement.

#### Syntax

int lefwEndBeginext()

### lefwBeginextCreator

Writes a CREATOR statement. The CREATOR statement is optional and can be used only once in an EXTENSIONS statement.

#### Syntax

int lefwBeginextCreator(
  const char*
creator)

#### Arguments

creator

> Specifies a string value that defines the creator value.

### lefwBeginextDate

Writes a DATE statement that specifies the current system time and date. The DATE statement is optional and can be used only once in an EXTENSIONS statement.

#### Syntax

int lefwBeginextDate()

### lefwBeginextRevision

Writes a REVISION statement. The REVISION statement is optional and can be used only once in an EXTENSIONS statement.

#### Syntax

int lefwBeginextRevision(
  int
vers1,
  int vers2)

#### Arguments

vers1, vers2

> Specify the values used for the revision number string.

### lefwBeginextSyntax

Adds customized syntax to the LEF file. This routine is optional and can be used more than once in an EXTENSIONS statement.

#### Syntax

int lefwBeginextSyntax(
  const char*
title,
  const char* string)

#### Arguments

title, string

> Specify any values you need.

### Extensions Examples

The following example shows a callback routine with the type lefwExtCbkType. This example only shows the usage of some functions related to array.

int extCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwExtCbkType) {
  printf("Type is not lefwExtCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartBeginext("SIGNATURE");
  CHECK_RES(res);
  res = lefwBeginextCreator("CADENCE");
  CHECK_RES(res);
  res = lefwBeginextDate();
  CHECK_RES(res);
  res = lefwEndBeginext();
  CHECK_RES(res);
  return 0;}

## Layer (Cut, Masterslice, Overlap, Implant)

The following layer routines write LAYER sections about cut, masterslice, overlap, and implant layers. At least one LAYER section is required in a LEF file, and more than one LAYER section is generally required to describe a layout. For syntax information about the LAYER sections for cut, masterslice, overlap, and implant layers, see "Layer (Cut)", "Layer (Masterslice or Overlap)", and "Layer (Implant)" in the LEF/DEF Language Reference.

You must begin and end a LEF LAYER section with the lefwStartLayer and lefwEndLayer routines. You create one LAYER section for each layer you need to define.

For examples of the routines described here, see "Layer Examples".

In addition to the routines described in this section, you can include a PROPERTY statement in a LAYER section. For more information about these routines, see "Property".

All routines return 0 if successful.

### Defining Masterslice and Overlap Layers

To define a masterslice or overlap layer, you only need to use the lefwStartLayer and lefwEndLayer routines. No additional routines are required to define these layers.

### Defining Cut Layers

To define a cut layer, you must use the lefwLayerCutSpacing routine to start the spacing and the lefwLayerCutSpacingEnd routine to end the spacing. These must be used between the lefwStartLayer and lefwEndLayer routines. Any other routines are optional and must be included after the lefwLayerCutSpacing routine.

### Defining Implant Layers

To define an implant layer, you must specify the lefwLayerWidth routine between the lefwStartLayer and lefwEndLayer routines.

### lefwStartLayer

Starts the LAYER section. Each cut, masterslice, overlap, and implant layer must be defined by a separate lefwStartLayer, lefwEndLayer routine pair.

#### Syntax

int lefwStartLayer(
  const char*
layerName,
  const char* type)

#### Arguments

layerName

> Specifies the name of the layer being defined.

type

> Specifies the type of layer being defined.
> Value: CUT, MASTERSLICE, OVERLAP, or IMPLANT

### lefwEndLayer

Ends the LAYER section for the specified layer.

#### Syntax

int lefwEndLayer(
  const char*
layerName)

### lefwLayerACCurrentDensity

Writes an ACCURRENTDENSITY statement for a cut layer. The ACCURENTDENSITY statement is optional, and can be used only once in a LAYER section.

#### Syntax

int lefwLayerACCurrentDensity(
  const char*
type,
  double value)

#### Arguments

type

> Specifies one of the AC current limits, PEAK, AVERAGE, or RMS.

value

> Specifies a maximum current limit for the layer in milliamps per square micron. If you specify 0, you must call the lefwLayerACFrequency and lefwLayerACTableEntries routines.

### lefwLayerACCutarea

Writes a CUTAREA statement for a cut layer. The CUTAREA statement is optional if you specify a FREQUENCY statement, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACCutarea(
  int
numCutareas,
  double* cutareas)

#### Arguments

numCutareas

> Specifies the number of cut area values.

cutareas

> Specifies the cut area values, in square microns. If you specify only one cut area value, there is no cut area dependency, and the table entries are assumed to apply to all cut areas.

### lefwLayerACFrequency

Writes a FREQUENCY statement for a cut layer. The FREQUENCY statement is required if you specify a value of 0 in the lefwLayerACCurrentDensity routine, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACFrequency(
  int
numFrequency,
  double* frequency)

#### Arguments

numFrequency

> Specifies the number of frequency values.

frequency

> Specifies the frequency values, in megahertz. If you specify only one frequency value, there is no frequency dependency, and the table entries are assumed to apply to all frequencies.

### lefwLayerACTableEntries

Writes a TABLEENTRIES statement for a cut layer. The TABLENTRIES statement is required if you specify a FREQUENCY statement, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACTableEntries(
  int
numEntries,
  double* entries)

#### Arguments

numEntries

> Specifies the number of table entry values.

entries

> Specifies the maximum cut area for each frequency and cut area pair specified in the FREQUENCY and CUTAREA statements, in milliamps per square micron.

### lefwLayerAntennaAreaFactor

Writes an ANTENNAAREAFACTOR statement for a cut layer. The ANTENNAAREAFACTOR statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaFactor(
  double
value
const char* diffUseOnly)

#### Arguments

value

> Specifies the adjust or multiply factor for the antenna metal calculation.

diffUseOnly

> Optional argument that specifies the current antenna factor should be used only when the corresponding layer is connected to the diffusion. Specify NULL to ignore this argument.

### lefwLayerAntennaAreaRatio

Writes an ANTENNAAREARATIO statement for a cut layer. The ANTENNAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaRatio(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the bottom area of the metal wire that is not connected to the diffusion diode.

### lefwLayerAntennaCumAreaRatio

Writes an ANTENNACUMAREARATIO statement for a cut layer. The ANTENNACUMAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaCumAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the bottom area of the metal wire that is not connected to the diffusion diode.

### lefwLayerAntennaCumDiffAreaRatio

Writes an ANTENNACUMDIFFAREARATIO statement for a cut layer. The ANTENNACUMDIFFAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffAreaRatioPWL in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the bottom area of the metal wire that is connected to the diffusion diode.

### lefwLayerAntennaCumDiffAreaRatioPwl

Writes an ANTENNACUMDIFFAREARATIOPWL statement for a cut layer. The ANTENNACUMDIFFAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffAreaRatio in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffAreaRatioPwl(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaDiffAreaRatio

Writes an ANTENNADIFFAREARATIO statement for a cut layer. The ANTENNADIFFAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffAreaRatioPWL in the same LAYER section.

#### Syntax

int lefwAntennaDiffAreaRatio(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the bottom area of the wire that is connected to the diffusion diode.

### lefwLayerAntennaDiffAreaRatioPwl

Writes an ANTENNADIFFAREARATIOPWL statement for a cut layer. The ANTENNADIFFAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffAreaRatio in the same LAYER section.

#### Syntax

int lefwAntennaDiffAreaRatioPWL(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaModel

Writes an ANTENNAMODEL statement for a cut layer. The ANTENNAMODEL statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerAntennaModel(
  const char*
oxide)

#### Arguments

oxide

> Specifies the oxide model for the layer. Each model can be specified once per layer. If you specify an ANTENNAMODEL statement, that value affects all ANTENNA* statements for the layer that follow it until you specify another ANTENNAMODEL statement.
> Value: OXIDE1, OXIDE2, OXIDE3, or OXIDE4
> Note: OXIDE1 and OXIDE2 are currently supported. If you specify OXIDE3 or OXIDE4, current tools parse and ignore them.

### lefwLayerArraySpacing

Writes an ARRAYSPACING statement for a cut layer. The ARRAYSPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerArraySpacing(
  int
longArray,
  double viaWidth,
  double cutSpacing,
  int numArrayCut,
  int* arrayCuts,
  double* arraySpacings)

#### Arguments

longArray

> Optional argument that indicates that the via can use N x M cut arrays, where N = arrayCuts and M can be any value, including one that is larger than N. Specify 0 to ignore this argument.

viaWidth

> Optional argument that specifies the via width. The array spacing rules only apply when the via metal width is greater than or equal to viaWidth. Specify 0 to ignore this argument.

cutSpacing

> Specifies the edge-of-cut to edge-of-cut spacing inside one cut array.

numArrayCuts

> Specifies the number of arrayCuts and arraySpacings pairs provided.

arrayCuts

> Specifies the size of the cut arrays.
> A large via array with a size greater than or equal to arrayCuts x arrayCuts in both dimensions must use N x N cut arrays (where N = arrayCuts) separated from other cut arrays by a distance greater than or equal to arraySpacing.
> If you specify multiple arrayCuts and arraySpacings, the arrayCuts values must be specified in increasing order.

arraySpacings

> Specifies the spacing between the cut arrays.

### lefwLayerCutSpacing

Starts a SPACING statement for a cut layer. Call lefwLayerCutSpacingEnd to end each spacing.

The SPACING statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerCutSpacing(
  double
spacing)

#### Arguments

spacing

> Specifies the minimum spacing allowed between via cuts, in microns.

### lefwLayerCutSpacingAdjacent

Writes an ADJACENTCUTS statement for a SPACING statement for a cut layer. The ADJACENTCUTS statement is optional. You can specify only one of the following statements per spacing: LAYER, ADJACENTCUTS, AREA, or PARALLELOVERLAP.

#### Syntax

int lefwLayerCutSpacingAdjacent(
  int
viaCuts,
  double distance,
  int stack)

#### Arguments

viaCuts

> Optional argument that specifies the number of via cuts--either 2, 3, or 4.

distance

> Specifies the distance between via cuts, in microns.

stack

> Optional argument that sets the EXCEPTSAMEPGNET keword for the spacing. If this keyword is set, the ADJACENTCUTS rule does not apply between cuts if they are on the same net, and are on a power and ground net.

### lefwLayerCutSpacingArea

Writes an AREA statement for a SPACING statement for a cut layer. The AREA statement is optional. You can specify only one of the following statements per spacing: LAYER, ADJACENTCUTS, AREA, or PARALLELOVERLAP.

#### Syntax

int lefwLayerCutSpacingArea(
  double
cutArea)

#### Arguments

cutArea

> Specifies the cut area. Any cut with an area equal to or greater than this number requires additional spacing.

### lefwLayerCutSpacingCenterToCenter

Writes a CENTERTOCENTER statement for a SPACING statement for a cut layer. The CENTERTOCENTER statement is optional.

#### Syntax

int lefwLayerCutSpacingCenterToCenter()

### lefwLayerCutSpacingEnd

Ends a SPACING statement for a cut layer.

#### Syntax

int lefwLayerCutSpacingEnd()

### lefwLayerCutSpacingLayer

Writes a LAYER statement for a SPACING statement for a cut layer. The LAYER statement is optional. You can specify only one of the following statements per spacing: LAYER, ADJACENTCUTS, AREA, or PARALLELOVERLAP.

#### Syntax

int lefwLayerCutSpacingLayer(
  const char*
name2,
  int stack)

#### Arguments

name2

> Specifies the second layer name.

stack

> Optional argument indicating that same-net cuts on two different layers can be stacked if they are exactly aligned; otherwise, the cuts must have cutSpacing between them. Specify 0 to ignore this argument.

### lefwLayerCutSpacingParallel

Writes a PARALLELOVERLAP statement for a SPACING statement for a cut layer. The PARALLELOVERLAP statement is optional. You can specify only one of the following statements per spacing: LAYER, ADJACENTCUTS, AREA, or PARALLELOVERLAP.

#### Syntax

int lefwLayerCutSpacingParallel()

### lefwLayerCutSpacingSamenet

Writes a SAMENET statement for a SPACING statement for a cut layer. The SAMENET statement is optional.

#### Syntax

int lefwLayerCutSpacingSameNet()

### lefwLayerCutSpacingTableOrtho

Writes a SPACINGTABLE ORTHOGONAL statement for a cut layer. The SPACINGTABLE ORTHOGONAL statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerCutSpacingTableOrtho(
  int
numSpacing,
  double* cutWithins,
  double* orthoSpacings)

#### Arguments

numSpacing

> Specifies the number of cutWithins and orthoSpacings pairs provided.

cutWithins

> Specifies the distance between cuts, in microns.
> If two cuts have parallel overlap greater than 0 and are less than cutWithin distance from each other, then any other cuts in an orthogonal direction must be equal to or greater than orthoSpacings.

orthoSpacings

> Specifies the orthogonal spacing, in microns.

### lefwLayerDCCurrentDensity

Writes the DCCURRENTDENSITY statement for a cut layer. The DCCURENTDENSITY statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerDCCurrentDensity(
  const char*
type,
  double value)

#### Arguments

type

> Specifies the DC current limit, AVERAGE.

value

> Specifies a current limit for the layer in milliamps per square microns. If you specify 0, you must call the lefwLayerDCCutarea and lefwLayerDCTableEntries routines.

### lefwLayerDCCutarea

Writes a CUTAREA statement for a cut layer. The CUTAREA statement is required if you specify a value of 0 in the lefwLayerDCCurrentDensity routine, and can be used only once in a DCCURENTDENSITY statement.

#### Syntax

int lefwLayerDCCutarea(
  int
numCutareas,
  double* cutareas)

#### Arguments

numCutareas

> Specifies the number of cut area values.

cutareas

> Specifies the cut area values, in square microns.

### lefwLayerDCTableEntries

Writes a TABLEENTRIES statement for a cut layer. The TABLENTRIES statement is required if you specify a CUTAREA statement, and can be used only once in a DCCURENTDENSITY statement.

#### Syntax

int lefwLayerDCTableEntries(
  int
numEntries,
  double* entries)

#### Arguments

numEntries

> Specifies the number of table entry values.

entries

> Specifies the maximum current density for each specified cut area, in milliamps per square micron.

### lefwLayerEnclosure

Writes an ENCLOSURE statement for a cut layer. The ENCLOSURE statement is optional and can be used more than once in a LAYER section.

#### Syntax

lefwLayerEnclosure(
  const char*
location,
  double overhang1,
  double overhang2,
  double width)

#### Arguments

location

> Optional argument that specifies whether the overhang is required on the routing layers above or below the cut layer. Specify "" to ignore this argument.
> Value: ABOVE or BELOW

overhang1 overhang2

> Specifies that any rectangle from this cut layer requires the routing layers to overhang by overhang1 on two opposite sides, and by overhang2 on the other two opposite sides.

width

> Optional argument that specifies that the enclosure rule only applies when the width of the routing layer is greater than or equal to width. Specify 0 to ignore this argument.

### lefwLayerEnclosureLength

Writes an ENCLOSURE statement with a LENGTH keyword for a cut layer. This routine lets you specify a minimum length instead of the width. The ENCLOSURE statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerEnclosureLength(
  const char*
location,
  double overhang1,
  double overhang2,
  double minLength)

#### Arguments

location

> Optional argument that specifies whether the overhang is required on the routing layers above or below the cut layer. If you don't specify this argument, the rule applies to both adjacent routing layers; specify "" to ignore this argument.
> Value: ABOVE or BELOW

overhang1 overhang2

> Overhange values. Any rectangle from this cut layer requires the routing layers to overhang by overhang1 on two opposite sides, and by overhang2 on the other two opposite sides.

minLength

> Optional argument that specifies that the total length of the longest opposite-side overhangs must be greater than or equal to minLength to make this enclosure valid. The minLength is measured at the center of the cut. Specify 0 to ignore this argument.

### lefwLayerEnclosureWidth

Writes an ENCLOSURE statement with an EXCEPTEXTRACUT keyword for a cut layer. This routine is similar to lefwLayerEnclosure except that it lets you specify EXCEPTEXTRACUT. The ENCLOSURE statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerEnclosureWidth(
  const char*
location,
  double overhang1,
  double overhang2,
  double width,
  double cutWithin)

#### Arguments

location

> Optional argument that specifies whether the overhang is required on the routing layers above or below the cut layer. If you don't specify this argument, the rule applies to both adjacent routing layers; specify "" to ignore this argument.
> Value: ABOVE or BELOW

overhang1 overhang2

> Overhange values. Any rectangle from this cut layer requires the routing layers to overhang by overhang1 on two opposite sides, and by overhang2 on the other two opposite sides.

width

> Optional argument that specifies that the enclosure rule only applies when the width of the routing layer is greater than or equal to width. Specify 0 to ignore this argument. If you do not specify this argument, the enclosure rule applies to all widths (as if width was 0).

cutWithin

> Optional argument that sets the EXCEPTEXTRACUT cutWithin keyword. Specifies that if there is another via cut less than or equal to cutWithin, then this ENCLOSURE with WIDTH rule is ignored and the ENCLOSURE rules for minimum width wires are applied to the via cuts instead. Specify 0 to ignore this argument.

### lefwLayerPreferEnclosure

Writes a PREFERENCLOSURE statement for a cut layer. The PREFERENCLOSURE statement is optional and can be used more than once in a LAYER section.

Note: The PREFERENCLOSURE statement specifies preferred enclosure rules that can improve manufacturing yield, instead of enclosure rules that absolutely must be met (ENCLOSURE statement).

#### Syntax

lefwLayerPreferEnclosure(
  const char*
location,
  double overhang1,
  double overhang2,
  double width)

#### Arguments

location

> Optional argument that specifies whether the overhang is required on the routing layers above or below the cut layer. Specify "" to ignore this argument.
> Value: ABOVE or BELOW

overhang1 overhang2

> Specifies that any rectangle from this cut layer requires the routing layers to overhang by overhang1 on two opposite sides, and by overhang2 on the other two opposite sides. The overhang values must be equal to or larger than the overhang values in the ENCLOSURE rule.

width

> Optional argument that specifies that the enclosure rule only applies when the width of the routing layer is greater than or equal to width. Specify 0 to ignore this argument.

### lefwLayerResistancePerCut

Writes a RESISTANCE statement for the cut layer. The RESISTANCE statement is optional and can be used only once in a LAYER section.

#### Syntax

lefwLayerResistancePerCut(
  double
resistance)

#### Arguments

resistance

> Specifies the resistance per cut on this layer. LEF vias without their own specific resistance value, or DEF vias from a via rule without a resistance per cut value, can use this resistance value.

### lefwLayerWidth

Writes a WIDTH statement for an implant or a cut layer. The WIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerWidth(
  double
minWidth)

#### Arguments

minWidth

> Specifies the minimum width for the layer.

### Layer Examples

The following example shows a callback routine with the type lefwLayerCbkType. This example shows how to create a cut, masterslice, or overlap layer. For an example of a routing layer, see the Layer (Routing) section.

int layerCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  double *current;
  // Check if the type is correct
  if (type != lefwLayerCbkType) {
  printf("Type is not lefwLayerCbkType, terminate
  writing.\n");
  return 1;
  }
  current = (double*)malloc(sizeof(double)*3);
  res = lefwStartLayer("CA", "CUT");
  CHECK_RES(res);
  res = lefwLayerDCCurrentDensity("AVERAGE", 0);
  CHECK_RES(res);
  current[0] = 2.0;
  current[1] = 5.0;
  current[2] = 10.0;
  res = lefwLayerDCWidth(3, current);
  CHECK_RES(res);
  current[0] = 0.6E-6;
  current[1] = 0.5E-6;
  current[2] = 0.4E-6;
  res = lefwLayerDCTableEntries(3, current);
  CHECK_RES(res);
  res = lefwEndLayer("CA");
  CHECK_RES(res);
  free((char*)current);
  res = lefwStartLayer("POLYS", "MASTERSLICE");
  CHECK_RES(res);
  res = lefwStringProperty("lsp", "top");
  CHECK_RES(res);
  res = lefwIntProperty("lip", 1);
  CHECK_RES(res);
  res = lefwRealProperty("lrp", 2.3);
  CHECK_RES(res);
  res = lefwEndLayer("POLYS");
  CHECK_RES(res);
  res = lefwStartLayer("OVERLAP", "OVERLAP");
  CHECK_RES(res);
  res = lefwEndLayer("OVERLAP");
  CHECK_RES(res);
  return 0;}

## Layer (Routing)

Routing layer routines write LAYER sections about routing layers. At least one LAYER section is required in a LEF file, and more than one LAYER section is generally required to describe a layout. For syntax information about the LAYER section for routing layers, see "Layer (Routing)" in the LEF/DEF Language Reference.

You must begin and end a LEF LAYER section with the lefwStartLayerRouting and lefwEndLayerRouting routines. The remaining routing layer routines defined in this section must be included between these routines. You create one LAYER section for each routing layer you need to define.

For examples of the routines described here, see "Routing Layer Examples"

In addition to the routines described in this section, you can include a PROPERTY statement within a LAYER section. For more information about these routines, see "Property".

All routines return 0 if successful.

### lefwStartLayerRouting

Starts the LAYER section. The LEF writer automatically writes the TYPE ROUTING statement. This routine is required to define a routing layer and can be used more than once. Each routing layer must be defined by a separate lefwStartLayerRouting, lefwEndLayerRouting routine pair.

#### Syntax

int lefwStartLayerRouting(
  const char*
layerName)

#### Arguments

layerName

> Specifies the name of the routing layer being defined.

### lefwEndLayerRouting

Ends the LAYER section for the specified routing layer.

#### Syntax

int lefwEndLayerRouting(
  const char*
layerName)

### lefwDensityCheckStep

Writes a DENSITYCHECKSTEP statement. The DENSITYCHECKSTEP statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwDensityCheckStep(
  double
stepValue)

#### Arguments

stepValue

> Specifies the stepping distance for metal density checks, in distance units.

### lefwDensityCheckWindow

Writes a DENSITYCHECKWINDOW statement. The DENSITYCHECKWINDOW statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwDensityCheckWindow(
  double
windowLength,
  double windowWidth)

#### Arguments

windowLength

> Specifies the length of the check window, in distance units.

windowWidth

> Specifies the width of the check window, in distance units.

### lefwFillActiveSpacing

Writes a FILLACTIVESPACING statement. The FILLACTIVESPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwFillActiveSpacing(
  double
spacing)

#### Arguments

spacing

> Specifies the spacing between metal fills and active geometries.

### lefwLayerACCurrentDensity

Writes an ACCURRENTDENSITY statement. The ACCURENTDENSITY statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerACCurrentDensity(
  const char*
type,
  double value)

#### Arguments

type

> Specifies the type of AC current limit.
> Value: PEAK, AVERAGE, or RMS

value

> Specifies a maximum current for the layer, in milliamps per micron. If you specify 0, you must specify the lefwLayerACFrequency and lefwLayerACTableEntries routines.

### lefwLayerACFrequency

Writes a FREQUENCY statement. The FREQUENCY statement is required if you specify a value of 0 in the lefwLayerACCurrentDensity routine, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACFrequency(
  int
numFrequency,
  double* frequency)

#### Arguments

numFrequency

> Specifies the number of frequency values.

frequency

> Specifies the frequency values, in megahertz.

### lefwLayerACTableEntries

Writes a TABLEENTRIES statement. The TABLENTRIES statement is required if you specify a FREQUENCY statement, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACTableEntries(
  int
numEntries,
  double* entries)

#### Arguments

numEntries

> Specifies the number of table entry values.

entries

> Specifies the maximum current for each of the frequency and width pairs specified in the FREQUENCY and WIDTH statements, in milliamps per micron.

### lefwLayerACWidth

Writes a WIDTH statement. The WIDTH statement is optional if you specify a FREQUENCY statement, and can be used only once in an ACCURENTDENSITY statement.

#### Syntax

int lefwLayerACWidth(
  int
numWidths,
  double* widths)

#### Arguments

numWidths

> Specifies the number of width values.

widths

> Specifies the wire width values, in microns.

### lefwLayerAntennaAreaDiffReducePwl

Writes an ANTENNAAREADIFFREDUCEPWL statement for a routing or cut layer. The ANTENNAAREADIFFREDUCEPWL statement is optional and can be used once after each lefwLayerAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaDiffReducePwl(
  int
numPwls,
  double* diffAreas,
  double* metalDiffFactors)

#### Arguments

numPwls

> Specifies the number of diffusion area and metalDiffFactor pairs.

diffAreas

> Specifies the diffArea values. The values are floating points, specified in microns squared. They should start with 0 and monotonically increase in value to the maximum size diffArea expected.

metalDiffFactors

> Specifies the metalDiffFactor values. The values are floating points with no units and are normally between 0.0 and 1.0.

### lefwLayerAntennaAreaFactor

Writes an ANTENNAAREAFACTOR statement. The ANTENNAAREAFACTOR statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaFactor(
  double
value
const char* diffUseOnly)

#### Arguments

value

> Specifies the adjust or multiply factor for the antenna metal calculation.

diffUseOnly

> Optional argument that specifies the current antenna factor should be used only when the corresponding layer is connected to the diffusion. Specify NULL to ignore this argument.

### lefwLayerAntennaAreaMinusDiff

Writes an ANTENNAAREAMINUSDIFF statement for a routing or cut layer. The ANTENNAAREAMINUSDIFF statement is optional and can be used once after each lefwLayerAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaMinusDiff(
  double
minusDiffFactor)

#### Arguments

minusDiffFactor

> Specifies the diffusion area. The antenna ratio metal area will subtract the diffusion area connected to it. minusDiffFactor is a floating point value and defaults to 0.0.

### lefwLayerAntennaAreaRatio

Writes the ANTENNAAREARATIO statement. The ANTENNAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaAreaRatio(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the bottom area of the metal wire that is not connected to the diffusion diode.

### lefwLayerAntennaCumAreaRatio

Writes an ANTENNACUMAREARATIO statement. The ANTENNACUMAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaCumAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the bottom area of the metal wire that is not connected to the diffusion diode.

### lefwLayerAntennaCumDiffAreaRatio

Writes an ANTENNACUMDIFFAREARATIO statement. The ANTENNACUMDIFFAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffAreaRatioPWL in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the bottom area of the metal wire that is connected to the diffusion diode.

### lefwLayerAntennaCumDiffAreaRatioPwl

Writes an ANTENNACUMDIFFAREARATIOPWL statement. The ANTENNACUMDIFFAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffAreaRatio in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffAreaRatioPwl(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaCumDiffSideAreaRatio

Writes an ANTENNACUMDIFFSIDEAREARATIO statement. The ANTENNACUMDIFFSIDEAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffSideAreaRatioPWL in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffSideAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the side wall area of the metal wire that is connected to the diffusion diode.

### lefwLayerAntennaCumDiffSideAreaRatioPwl

Writes an ANTENNACUMDIFFSIDEAREARATIOPWL statement. The ANTENNACUMDIFFSIDEAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaCumDiffSideAreaRatio in the same LAYER section.

#### Syntax

int lefwLayerAntennaCumDiffSideAreaRatioPwl(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaCumSideAreaRatio

Writes an ANTENNACUMSIDEAREARATIO statement. The ANTENNACUMSIDEAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwAntennaCumSideAreaRatio(
  double
value)

#### Arguments

value

> Specifies the cumulative antenna ratio, using the side wall area of the metal wire that is not connected to the diffusion diode.

### lefwLayerAntennaCumRoutingPlusCut

Writes an ANTENNACUMROUTINGPLUSCUT statement for a routing or cut layer. The ANTENNACUMROUTINGPLUSCUT statement is optional and can be used once after each lefwLayerAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaCumRoutingPlusCut()

### lefwLayerAntennaDiffAreaRatio

Writes an ANTENNADIFFAREARATIO statement. The ANTENNADIFFAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffAreaRatioPWL in the same LAYER section.

#### Syntax

int lefwAntennaDiffAreaRatio(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the bottom area of the wire that is connected to the diffusion diode.

### lefwLayerAntennaDiffAreaRatioPwl

Writes an ANTENNADIFFAREARATIOPWL statement. The ANTENNADIFFAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffAreaRatio in the same LAYER section.

#### Syntax

int lefwAntennaDiffAreaRatioPWL(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaDiffSideAreaRatio

Writes an ANTENNADIFFSIDEAREARATIO statement. The ANTENNADIFFSIDEAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffSideAreaRatioPwl in the same LAYER section.

#### Syntax

int lefwLayerAntennaDiffSideAreaRatio(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the side wall area of the wire that is connected to the diffusion diode.

### lefwLayerAntennaDiffSideAreaRatioPwl

Writes an ANTENNADIFFSIDEAREARATIOPWL statement. The ANTENNADIFFSIDEAREARATIOPWL statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section. If you specify this routine, you cannot specify lefwLayerAntennaDiffSideAreaRatio in the same LAYER section.

#### Syntax

int lefwLayerAntennaDiffSideAreaRatioPwl(
  int
numPwls,
double diffusions,
double ratios)

#### Arguments

numPwls

> Specifies the number of diffusion-ratio pairs.

diffusions

> Specifies the diffusion values.

ratios

> Specifies the ratio values.

### lefwLayerAntennaGatePlusDiff

Writes an ANTENNAGATEPLUSDIFF statement for a routing or cut layer. The ANTENNAGATEPLUSDIFF statement is optional and can be used once after each lefwLayerAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaGatePlusDiff(
  double
plusDiffFactor)

#### Arguments

plusDiffFactor

> Specifies that the antenna ratio gate area should include the diffusion area multiplied by plusDiffFactor. minusDiffFactor is a floating point value.

### lefwLayerAntennaModel

Writes an ANTENNAMODEL statement. The ANTENNAMODEL statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerAntennaModel(
  const char*
oxide)

#### Arguments

oxide

> Specifies the oxide model for the layer. Each model can be specified once per layer. If you specify an ANTENNAMODEL statement, that value affects all ANTENNA* statements for the layer that follow it until you specify another ANTENNAMODEL statement.
> Value: OXIDE1, OXIDE2, OXIDE3, or OXIDE4

Note: OXIDE1 and OXIDE2 are currently supported. If you specify OXIDE3 or OXIDE4, current tools parse and ignore them.

### lefwLayerAntennaSideAreaFactor

Writes an ANTENNASIDEAREAFACTOR statement. The ANTENNASIDEAREAFACTOR statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaSideAreaFactor(
  double
value
const char* diffUseOnly)

#### Arguments

value

> Specifies the adjust or multiply factor for the antenna metal calculation.

diffUseOnly

> Optional argument that specifies that the current antenna factor should only be used when the corresponding layer is connected to the diffusion. Specify NULL to ignore this argument.

### lefwLayerAntennaSideAreaRatio

Writes an ANTENNASIDEAREARATIO statement. The ANTENNASIDEAREARATIO statement is optional and can be used once after each lefwAntennaModel routine in a LAYER section.

#### Syntax

int lefwLayerAntennaSideAreaFactor(
  double
value)

#### Arguments

value

> Specifies the antenna ratio, using the side wall area of the wire that is not connected to the diffusion diode.

### lefwLayerDCCurrentDensity

Writes the DCCURRENTDENSITY statement. The DCCURENTDENSITY statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerDCCurrentDensity(
  const char*
type,
  double value)

#### Arguments

type

> Specifies the DC current limit, AVERAGE.

value

> Specifies the current limit for the layer, in milliamps per micron. If you specify 0, you must specify the lefwLayerDCWidth and lefwLayerDCTableEntries routines.

### lefwLayerDCTableEntries

Writes a TABLEENTRIES statement. The TABLENTRIES statement is required if you specify a WIDTH statement, and can be used only once in a DCCURENTDENSITY statement.

#### Syntax

int lefwLayerDCTableEntries(
  int
numEntries,
  double* entries)

#### Arguments

numEntries

> Specifies the number of table entry values.

entries

> Specifies the value of current density for each specified width, in milliamps per micron.

### lefwLayerDCWidth

Writes a WIDTH statement. The WIDTH statement is required if you specify a value of 0 in the lefwLayerDCCurrentDensity routine, and can be used only once in a DCCURENTDENSITY statement.

#### Syntax

int lefwLayerDCWidth(
  int
numWidths,
  double* widths)

#### Arguments

numWidths

> Specifies the number of width values.

widths

> Specifies the wire width values, in microns.

### lefwLayerRouting

Writes the DIRECTION and WIDTH statements for a LAYER section. The DIRECTION and WIDTH statements are required and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRouting(
  const char*
direction,
  double width)

#### Arguments

direction

> Specifies the preferred routing direction.
> Value: Specify one of the following:

| HORIZONTAL | Routing parallel to the x axis is preferred.
| VERTICAL | Routing parallel to the y axis is preferred.
| DIAG45 | Routing along a 45-degree angle is preferred.
| DIAG135 | Routing along a 135-degree angle is preferred.

width

> Specifies the default routing width to use for all regular wiring on the layer.

### lefwLayerRoutingArea

Writes an AREA statement. The AREA statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingArea (
  double
area)

#### Arguments

area

> Specifies the minimum metal area required for polygons on the layer, in distance units squared. All polygons must have an area that is greater than or equal to area, if no MINSIZE rule (lefwLayerRoutingMinsize) is specified. If a MINSIZE rule exists, all polygons must meet either the MINSIZE or the AREA rule.

### lefwLayerRoutingCapacitance

Writes a CAPACITANCE CPERSQDIST statement. The CAPACITANCE CPERSQDIST statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingCapacitance(
  const char*
capacitance)

#### Arguments

capacitance

> Specifies the capacitance for each square unit, in picofarads per square micron.

### lefwLayerRoutingCapMultiplier

Writes the CAPMULTIPLIER statement. The CAPMULTIPLIER statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingCapMultiplier(
  double
capMultiplier)

#### Arguments

capMultiplier

> Specifies the multiplier for interconnect capacitance to account for increases in capacitance caused by nearby wires.

### lefwLayerRoutingDiagMinEdgeLength

Writes a DIAGMINEDGELENGTH statement. The DIAGMINEDGELENGTH statement is optional and can be used only once in a LAYER section.

#### Syntax

lefwLayerRoutingDiagMinEdgeLength(
  double
diagLength)

#### Arguments

diagLength

> Specifies the minimum length for a diagonal edge. Any 45-degree diagonal edge must have a length that is greater than or equal to diagLength.

### lefwLayerRoutingDiagPitch

Writes a DIAGPITCH statement that contains one pitch value that is used for both the 45-degree angle and 135-degree angle directions. The DIAGPITCH statement is optional and can only be used once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingDiagPitchXYDistance routine.

#### Syntax

lefwLayerRoutingDiagPitch(
  double
distance)

#### Arguments

distance

> Specifies the 45-degree routing pitch for the layer.

### lefwLayerRoutingDiagPitchXYDistance

Writes a DIAGPITCH statement that contains separate values for the 45-degree angle and 135-degree angle directions. The DIAGPITCH statement is optional and can only be used once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingDiagPitch routine.

#### Syntax

lefwLayerRoutingDiagPitchXYDistance(
  double
diag45Distance,
  double diag135Distance)

#### Arguments

diag45Distance

> Specifies the 45-degree angle pitch (the center-to-center space between 45-degree angle routes).

diag135Distance

> Specifies the 135-degree angle pitch.

### lefwLayerRoutingDiagSpacing

Writes a DIAGSPACING statement. The DIAGSPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

lefwLayerRoutingDiagSpacing(
  double
diagSpacing)

#### Arguments

diagSpacing

> Specifies the minimum spacing allowed for a 45-degree angle shape.

### lefwLayerRoutingDiagWidth

Writes a DIAGWIDTH statement. The DIAGWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

lefwLayerRoutingDiagWidth(
  double
diagWidth)

#### Arguments

diagWidth

> Specifies the minimum width allowed for a 45-degree angle shape.

### lefwLayerRoutingEdgeCap

Writes an EDGECAPACITANCE statement. The EDGECAPACITANCE statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingEdgeCap(
  double
edgeCap)

#### Arguments

edgeCap

> Specifies a floating-point value of peripheral capacitance, in picoFarads per micron.

### lefwLayerRoutingHeight

Writes a HEIGHT statement. The HEIGHT statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingHeight(
  double
height)

#### Arguments

height

> Specifies the distance from the top of the ground plane to the bottom of the interconnect.

### lefwLayerRoutingMaxwidth

Writes a MAXIMUMWIDTH statement. The MAXIMUMWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingMaxwidth(
  double
width)

#### Arguments

width

> Specifies the maximum width a wire on the layer can have.

### lefwLayerRoutingMinenclosedarea

Writes a MINENCLOSEDAREA statement. The MINENCLOSEDAREA statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerRoutingMinenclosedarea(
  int
numMinenclosed,
  double* area,
  double* width)

#### Arguments

numMinenclosed

> Specifies the number of values defined in the routine.

area

> Specifies the minimum area size of a hole enclosed by metal. You can specify one or more values.

width

> Optional argument that applies the minimum area size limit only when the hole is created from a wire that has a width that is less than or equal to width. You can specify one or more values.

### lefwLayerRoutingMinimumcut

Writes a MINIMUMCUT statement. The MINIMUMCUT statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerRoutingMinimumcut(
  double
numCuts,
  double minWidth)

#### Arguments

numCuts

> Specifies the number of cuts a via must have when it is on a wide wire or pin whose width is greater than minWidth.

minWidth

> Specifies the minimum width of the wire or pin.

### lefwLayerRoutingMinimumcutConnections

Writes a FROMABOVE or FROMBELOW statement. This statement is optional and can be used only once after each lefwLayerRoutingMinimumcut routine.

#### Syntax

int lefwLayerRoutingMinimumcutConnections(
  const char*
direction)

#### Arguments

direction

> Specifies the MINIMUMCUT statement applies only to connections from above the layer or from below the layer.
> Value: FROMABOVE or FROMBELOW

### lefwLayerRoutingMinimumcutLengthWithin

Writes a LENGTH statement. This statement is optional and can be used only once after each lefwLayerRoutingMinimumcut routine.

#### Syntax

int lefwLayerRoutingMinimumcutLengthWithin(
  double
length,
  double distance)

#### Arguments

distance

> Applies the minimum cut rule to thin wires directly connected to wide wires, if the vias on the thin wires are less than distance from the wide wire, and the wide wire has a length that is greater than length.

length

> Specifies the minimum length of the wide wire.

### lefwLayerRoutingMinimumcutWithin

Writes a MINIMUMCUT statement with a WITHIN keyword. This routine is similar to the lefwLayerRoutingMinimumcut routine, except that it lets you specify a WITHIN value. The MINIMUMCUT statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingMinimumcutWithin(
  double
numCuts,
  double minWidth,
  double cutDistance)

#### Arguments

numCuts

> Specifies the number of cuts a via must have when it is on a wide wire or pin whose width is greater than minWidth.

minWidth

> Specifies the minimum width of the wire or pin.

cutDistance

> Specifies that numCuts via cuts must be less than cutDistance from each other to be counted together to meet the minimum cut rule.

### lefwLayerRoutingMinsize

Writes a MINSIZE statement. The MINSIZE statement is optional and can be used only once in a LAYER section.

#### Syntax

lefwLayerRoutingMinsize(
  int
numRect,
  double* minWidth,
  double* minLength)

#### Arguments

numRect

> Specifies the number of rectangles defined.

minWidth minLength

> Specifies the minimum width and length values for a rectangle that must be able to fit somewhere within each polygon on this layer. All polygons must meet this MINSIZE rule, if no AREA rule is specified (lefwLayerRoutingArea). If an AREA rule is specified, all polygons must meet either the MINSIZE or the AREA rule.

### lefwLayerRoutingMinstep

Writes a MINSTEP statement. The MINSTEP statement is optional and can be used more than once in a LAYER section.

#### Syntax

int lefwLayerRoutingMinstep(
  double
distance)

#### Arguments

distance

> Specifies the minimum step size, or shortest edge length, for a shape.

### lefwLayerRoutingMinstepMaxEdges

Writes a MINSTEP statement. This routine is similar to lefwLayerRoutingMinstep, except that it lets you specify the MAXEDGES option. The MINSTEP statement is optional and can be called only once after lefwStartLayerRouting.

#### Syntax

int lefwLayerRoutingMinstepMaxEdges(
  double
distance,
  double maxEdges)

#### Arguments

distance

> Specifies the minimum step size, or shortest edge length, for a shape.

maxEdges

> Specifies the maximum consecutive edges.

### lefwLayerRoutingMinstepWithOptions

Writes a MINSTEP statement that contains rule type and total edge length values. The MINSTEP statement is optional and can be more than once in a LAYER section.

#### Syntax

lefwLayerRoutingMinstepWithOptions(
  double
distance,
  const char* rule,
  double maxLength)

#### Arguments

distance

> Specifies the minimum step size, or shortest edge length, for a shape.

rule

> Indicates to which consecutive edges the MINSTEP rule applies. A DRC violation occurs if one or more consecutive edges of the specified type are less than distance. There can only be one rule of each type per layer.
> Value: Specify one of the following:

| INSIDECORNER | Applies to consecutive edges of an inside corner that are less than distance.
| OUTSIDECORNER | Applies to consecutive edges of an outside corner that are less than distance.
| STEP | Applies to consecutive edges of a step that are less than distance.

maxLength

> Specifies the maximum total edge length allowed that OPC can correct without causing new DRC violations. A violation only occurs if the total length of consecutive edges that are less than distance is greater than maxLength.

### lefwLayerRoutingMinwidth

Writes a MINWIDTH statement. The MINWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingMinwidth(
  double
width)

#### Arguments

width

> Specifies the minimum legal object width on the routing layer, in microns.

### lefwLayerRoutingOffset

Writes an OFFSET statement that contains one value for both the x and y offsets. The OFFSET statement is optional and can be used only once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingOffsetXYDistance routine.

#### Syntax

int lefwLayerRoutingOffset(
  double
offset)

#### Arguments

offset

> Specifies the offset, from the origin (0,0) for the routing grid for the layer.

### lefwLayerRoutingOffsetXYDistance

Writes an OFFSET statement that contains separate values for the x and y offsets. The OFFSET statement is optional and can be used only once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingOffset routine.

#### Syntax

lefwLayerRoutingOffsetXYDistance(
  double
xDistance,
  double yDistance)

#### Arguments

xDistance

> Specifies the x offset for vertical routing tracks.

yDistance

> Specifies the y offset for horizontal routing tracks.

### lefwLayerRoutingPitch

Writes a PITCH statement that contains one pitch value that is used for both the x and y pitch. The PITCH statement is required and can be used only once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingPitchXYDistance routine.

#### Syntax

int lefwLayerRoutingPitch(
  double
pitch)

#### Arguments

pitch

> Specifies the routing pitch for the layer.

### lefwLayerRoutingPitchXYDistance

Writes a PITCH statement that contains separate values for the x and y pitch. The PITCH statement is required and can be used only once in a LAYER section. If you specify this routine, you cannot specify the lefwLayerRoutingPitch routine.

#### Syntax

lefwLayerRoutingPitchXYDistance(
  double
xDistance,
  double yDistance)

#### Arguments

xDistance

> Specifies the x pitch (that is , the space between each vertical routing track).

yDistance

> Specifies the y pitch (that is, the space between each horizontal routing track).

### lefwLayerRoutingProtrusion

Writes a PROTRUSION statement. The PROTRUSION statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingProtrusion(
  double
width1,
  double length,
  double width2)

#### Arguments

length

> Specifies the maximum length of a protrusion.

width1

> Specifies the minimum width of a protrusion.

width2

> Specifies the minimum width of the wire to which the protrusion is connected.

### lefwLayerRoutingResistance

Writes a RESISTANCE RPERSQ statement. The RESISTANCE RPERSQ statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingResistance(
  const char*
resistance)

#### Arguments

resistance

> Specifies the resistance for a square of wire, in ohms per square micron.

### lefwLayerRoutingShrinkage

Writes a SHRINKAGE statement. The SHRINKAGE statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingShrinkage(
  double
shrinkage)

#### Arguments

shrinkage

> Specifies the value to account for shrinkage of interconnect wiring because of the etching process. Actual wire widths are determined by subtracting this constant value.

### lefwLayerRoutingSpacing

Writes a SPACING statement. The SPACING statement is optional and can be used more than once in a LAYER section.

Note: You must use either this routine or the lefwLayerRoutingStartSpacingtableParallel routine for all LAYER sections.

#### Syntax

int lefwLayerRoutingSpacing(
  double
Spacing)

#### Arguments

Spacing

> Specifies the minimum spacing allowed between two regular geometries on different nets, also known as the different-net spacing rule.

### lefwLayerRoutingSpacingEndOfLine

Writes an ENDOFLINE statement. The ENDOFLINE statement is optional and can be used only once after a SPACING statement.

#### Syntax

int lefwLayerRoutingSpacingEndOfLine(
  double
eolWidth,
  double eolWithin)

#### Arguments

eolWidth

> Specifies the end-of-line width. An end-of-line with a width less than eolWidth requires spacing greater than or equal to eolSpace beyond the end of the line anywhere within eolWIthin distance.

eolWithin

> The eolWithin distance. This value must be smaller than the minimum allowed spacing.

### lefwLayerRoutingSpacingEOLParallel

Writes a PARALLELEDGE statement. The PARALLELEDGE statement is optional and can be used only once after a SPACING statement.

#### Syntax

int lefwLayerRoutingSpacingEOLParallel(
  double
parSpace,
  double parWithin,
  int twoEdges)

#### Arguments

parSpace

> Specifies the parSpace value. The end-of-line rule applies only if there is a parallel edge less than parSpace away that is also less than parWithin from the end.

parWithin

> Specifies the parWithin value.

twoEdges

> Optional argument that writes the TWOEDGES keyword, which specifies that the end-of-line rule applies only if there are two parallel edges that meet the PARALLELEDGE parSpace and parWithin parameters. Specify 0 to ignore this argument.

### lefwLayerRoutingSpacingEndOfNotchWidth

Writes an ENDOFNOTCHWIDTH statement. The ENDOFNOTCHWIDTH statement is optional and can be used only once after a SPACING statement.

#### Syntax

int lefwLayerRoutingSpacingEndOfNotchWidth(
  double
eonWidth,
  double minNSpacing,
  double minNLength)

#### Arguments

eonWidth

> Specifies the end-of-notch width.

minNSpacing

> Specifies the minimum notch spacing.

minNLength

> Specifies the minimum notch length.

### lefwLayerRoutingSpacingLengthThreshold

Writes a LENGTHTHRESHOLD statement. The LENGTHTHRESHOLD statement is optional and can be used only once after a lefwLayerRoutingSpacing routine. If you specify this routine, you cannot specify the lefwLayerRoutingSpacingRange or lefwLayerRoutingSamenet routines.

#### Syntax

int lefwLayerRoutingSpacingLengthThreshold(
  double
lengthValue,
  double minWidth,
  double maxWidth)

#### Arguments

lengthValue

> Specifies the maximum parallel run length or projected length with an adjacent metal object.

minWidth, maxWidth

> Optional arguments that specify a width range. If you specify a range, the threshold spacing rule applies to all objects with widths that are greater than or equal to minWidth and less than or equal to maxWidth.

### lefwLayerRoutingSpacingNotchLength

Writes a NOTCHLENGTH statement. The NOTCHLENGTH statement is optional and can be used only once after lefwStartLayerRouting.

#### Syntax

int lefwLayerRoutingSpacingNotchLength(
  double
minNLength)

#### Arguments

minNLength

> Specifies the minimum notch length. Any notch with notch length less than minNLength must have a notch spacing greater than or equal to the minimum spacing. The value you specify must be only slightly larger than the normal minimum spacing (for example, between 1x or 2x minimum spacing).

### lefwLayerRoutingSpacingRange

Writes a RANGE statement. The RANGE statement is optional and can be used only once after a lefwLayerRoutingSpacing routine. If you specify this routine, you cannot specify the lefwLayerRoutingSpacingLengthThreshold or lefwLayerRoutingSameNet routines.

#### Syntax

int lefwLayerRoutingSpacingRange(
  double
minWidth,
  double maxWidth)

#### Arguments

minWidth, maxWidth

> Specifies a width range. If you specify a range, the minimum spacing rule applies to all wires on the layer with widths that are greater than or equal to minWidth and less than or equal to maxWidth.

### lefwLayerRoutingSpacingRangeInfluence

Writes an INFLUENCE statement. The INFLUENCE statement is optional and can be used only once after a lefwLayerRoutingSpacingRange routine. If you specify this routine, you cannot specify the lefwLayerRoutingSpacingRangeUseLengthThreshold or lefwLayerRoutingSpacingRangeRange routines in the same LAYER section.

#### Syntax

int lefwLayerRoutingSpacingRangeInfluence (
  double
infValue,
double stubMinWidth,
double stubMaxWidth)

#### Arguments

infValue

> Specifies the area of the stub wire which inherits the spacing from a wide wire.

stubMinWidth, stubMaxWidth

> Optional arguments that specify a wire width range. If you specify a range, the influence spacing rule applies to all stub wires on the layer with widths that are greater than or equal to stubMinWidth and less than or equal to stubMaxWidth.

### lefwLayerRoutingSpacingRangeRange

Writes a second RANGE statement. The second RANGE statement is optional and can be used only once after a lefwLayerRoutingSpacingRange routine. If you specify this routine, you cannot specify the lefwLayerRoutingSpacingRangeInfluence or lefwLayerRoutingSpacingRangeUseLengthThreshold routines in the same LAYER section.

#### Syntax

int lefwLayerRoutingSpacingRangeRange(
  double
minWidth,
  double maxWidth)

#### Arguments

minWidth, maxWidth

> Specify a second width range. If you specify a second range, the minimum spacing rule applies if the widths of both objects are greater than or equal to minWidth and less than or equal to maxWidth (each object in a different range).

### lefwLayerRoutingSpacingRangeUseLengthThreshold

Writes a USELENGTHTHRESHOLD statement. The USELENGTHTHRESHOLD statement is optional and can be used only once after a lefwLayerRoutingSpacingRange routine. If you specify this routine, you cannot specify the lefwLayerRoutingSpacingRangeRange or lefwLayerRoutingSpacingRangeInfluence routines in the same LAYER section.

This routine is only valid if one or both of the range values in the lefwLayerRoutingSpacingRange routine are not zero.

#### Syntax

int lefwLayerRoutingSpacingRangeUseLengthThreshold()

### lefwLayerRoutingSpacingSameNet

Writes a SAMENET keyword for a SPACING statement. Only one of lefwLayerRoutingSpacingSameNet, lefwLayerRoutingSpacingRange, or lefwLayerRoutingSpacingLengthThreshold can be called once after lefwLayerRoutingSpacing.

#### Syntax

int lefwLayerRoutingSpacingSameNet(
  int
PGOnly)

#### Arguments

PGOnly

> Optional argument that specifies the PGONLY keyword. If this keyword is specified, the minSpacing value only applies to same-net metal that is a power or ground net.

### lefwLayerRoutingStartSpacingtableInfluence

Writes a SPACINGTABLE INFLUENCE statement. The SPACINGTABLE INFLUENCE statement is optional and can be used only once after a lefwLayerRoutingStartSpacingtableParallel routine.

#### Syntax

int lefwLayerRoutingStartSpacingtableInfluence()

### lefwLayerRoutingStartSpacingInfluenceWidth

Writes a SPACINGTABLE INFLUENCE WIDTH statement. The SPACINGTABLE INFLUENCE WIDTH statement is required if you specify the lefwLayerRoutingStartSpacingtableInfluence routine, and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingStartSpacingInfluenceWidth(
  double
width,
  double distance,
  double spacing)

#### Arguments

distance

> Specifies an array of values that represent the distance between a wide wire and two perpendicular wires.

spacing

> Specifies an array of values that represent the spacing between the two perpendicular wires.

width

> Specifies an array of values that represent the width of the wide wire.

### lefwLayerRoutingStartSpacingtableParallel

Writes a SPACINGTABLE PARALLELRUNLENGTH statement. The SPACINGTABLE PARALLELRUNLENGTH statement is optional and can be used only once in a LAYER section.

Note: You must use either this routine or the lefwLayerRoutingSpacing routine for all LAYER sections.

#### Syntax

int lefwLayerRoutingStartSpacingtableParallel(
  int
numlength,
  double* length)

#### Arguments

length

> Specifies an array of values that represent the maximum parallel run length between two wires.

numLength

> Specifies the number of length values specified.

### lefwLayerRoutingStartSpacingtableParallelWidth

Writes a SPACINGTABLE PARALLELRUNLENGTH WIDTH statement. The SPACINGTABLE PARALLELRUNLENGTH WIDTH statement is required if you specify the lefwLayerRoutingStartSpacingtableParallel routine, and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingStartSpacingtableParallelWidth(
  double
width,
  int numSpacing,
  double* spacing)

#### Arguments

numSpacing

> Specifies the number of spacing values specified.

spacing

> Specifies an array of values that represent the spacing between the two wires.

width

> Specifies and array of values that represent the maximum width of the two wires.

### lefwLayerRoutingStartSpacingtableTwoWidths

Writes a SPACINGTABLE TWOWIDTHS statement. The SPACINGTABLE TWOWIDTHS statement is optional and can be used multiple times in a LAYER section after the lefwLayerRouting routine.

#### Syntax

int lefwLayerRoutingStartSpacingtableTwoWidths()

### lefwLayerRoutingStartSpacingtableTwoWidthsWidth

Writes a SPACINGTABLE TWOWIDTHS WIDTH statement. This routine is required after a lefwLayerRoutingStartSpacingtableTwoWidths routine.

#### Syntax

int lefwLayerRoutingSpacingtableTwoWidthsWidth(
  double
width,
  double runLength,
  int numSpacing,
  double* spacing)

#### Arguments

width

> The widths of the two objects.

runLength

> Optional argument that specifies the parallel run length between the two objects. Specify 0 to ignore this argument.

numSpacing

> Specifies the number of spacing values provided.

spacing

> The spacing values that represent the spacing between two objects.

### lefwLayerRoutingEndSpacingtable

Ends a SPACINGTABLE statement. This routine is required if you specify lefwLayerRoutingStartSpacingtableParallel.

#### Syntax

int lefwLayerRoutineEndSpacingtable()

### lefwLayerRoutingThickness

Writes a THICKNESS statement. The THICKNESS statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingThickness(
  double
thickness)

#### Arguments

thickness

> Specifies the thickness of the interconnect.

### lefwLayerRoutingWireExtension

Writes a WIREEXTENSION statement. The WIREEXTENSION statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwLayerRoutingWireExtension(
  double
wireExtension)

#### Arguments

wireExtension

> Specifies the distance by which wires are extended at vias. Enter 0 to specify no wire extension. Values other than 0 must be more than half of the default routing width for the layer.

### lefwMaxAdjacentSlotSpacing

Writes a MAXADJACENTSLOTSPACING statement. The MAXADJACENTSLOTSPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwMaxAdjacentSlotSpacing(
  double
maxSpacing)

#### Arguments

maxSpacing

> Specifies the maximum spacing, in distance units, allowed between two adjacent slot sections.

### lefwMaxCoaxialSlotSpacing

Writes a MAXCOAXIALSLOTSPACING statement. The MAXCOAXIALSLOTSPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwMaxCoaxialSlotSpacing(
  double
maxSpacing)

#### Arguments

maxSpacing

> Specifies the maximum spacing, in distance units, allowed between two slots in the same slot section.

### lefwMaxEdgeSlotSpacing

Writes a MAXEDGESLOTSPACING statement. The MAXEDGESLOTSPACING statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwMaxEdgeSlotSpacing(
  double
maxSpacing)

#### Arguments

maxSpacing

> Specifies the maximum spacing, in distance units, allowed between slot edges.

### lefwMaximumDensity

Writes a MAXIMUMDENSITY statement. The MAXIMUMDENSITY statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwMaximumDensity(
  double
maxDensity)

#### Arguments

maxDensity

> Specifies the maximum metal density allowed for the layer, as a percentage of its area.

### lefwMinimumDensity

Writes a MINIMUMDENSITY statement. The MINIMUMDENSITY statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwMinimumDensity(
  double
minDensity)

#### Arguments

minDensity

> Specifies the minimum metal density allowed for the layer, as a percentage of its area.

### lefwSlotLength

Writes a SLOTLENGTH statement. The SLOTLENGTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwSlotLength(
  double
minSlotLength)

#### Arguments

minSlotLength

> Specifies the minimum slot length, in distance units, allowed in the design.

### lefwSlotWidth

Wries a SLOTWIDTH statement. The SLOTWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwSlotWidth(
  double
minSlotWidth)

#### Arguments

minSlotWidth

> Specifies the minimum slot width, in distance units, allowed in the design.

### lefwSlotWireLength

Writes a SLOTWIRELENGTH statement. The SLOTWIRELENGTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwSlotWireLength(
  double
minWireLength)

#### Arguments

minWireLength

> Specifies the minimum wire length, in distance units, allowed for wires that need to be slotted.

### lefwSlotWireWidth

Writes a SLOTWIREWIDTH statement. The SLOTWIREWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwSlotWireWidth(
  double
minWireWidth)

#### Arguments

minWireWidth

> Specifies the minimum wire width, in distance units, allowed for wires that need to be slotted.

### lefwSplitWireWidth

Writes a SPLITWIREWIDTH statement. The SPLITWIREWIDTH statement is optional and can be used only once in a LAYER section.

#### Syntax

int lefwSplitWireWidth(
  double
minWireWidth)

#### Arguments

minWireWidth

> Specifies the minimum wire width, in distance units, allowed for wires that need to be split.

### Routing Layer Examples

The following example only shows the usage of some functions related to a routing layer. This example is part of the layer callback routine.

int layerCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  double *current;
  ...
  res = lefwStartLayerRouting("M3");
  CHECK_RES(res);
  res = lefwLayerRouting("HORIZONTAL", 0.9);
  CHECK_RES(res);
  res = lefwLayerRoutingPitch(1.8);
  CHECK_RES(res);
  res = lefwLayerRoutingWireExtension(8);
  CHECK_RES(res);
  res = lefwLayerRoutingSpacing(0.9, 0, 0);
  CHECK_RES(res);
  res = lefwLayerRoutingResistance("0.0608");
  CHECK_RES(res);
  res = lefwLayerRoutingCapacitance("0.000184");
  CHECK_RES(res);
  res = lefwLayerACCurrentDensity("AVERAGE",0);
  CHECK_RES(res);
  current[0] = 1E6;
  current[1] = 100E6;
  current[2] = 400E6;
  res = lefwLayerACFrequency(3, current);
  CHECK_RES(res);
  current[0] = 0.6E-6;
  current[1] = 0.5E-6;
  current[2] = 0.4E-6;
  res = lefwLayerACTableEntries(3, current);
  CHECK_RES(res);
  res = lefwEndLayerRouting("M3");
  CHECK_RES(res);
  ...
  return 0;}

## Macro

Macro routines write a LEF MACRO section. A MACRO section is optional and can be used more than once in a LEF file. For syntax information about the LEF MACRO section, see "Macro" in the LEF/DEF Language Reference.

You must begin and end a LEF MACRO section with the lefwStartMacro and lefwEndMacro routines. The macroName value in the start and end routines identifies the macro being defined. All LEF writer routines that define this macro must be included between the lefwStartMacro and lefwEndMacro routines specifying that macro name.

For examples of the routines described here, see "Macro Examples".

In addition to the routines described in this section, you can include an OBS, or PIN statement within a MACRO section. For more information about these routines, see "Macro Obstruction" , or "Macro Pin".

You can also include a PROPERTY statement within a MACRO section. For more information about these routines, see "Property".

All routines return 0 if successful.

### lefwStartMacro

Starts the MACRO section. This routine is required to begin each MACRO section.

#### Syntax

int lefwStartMacro(
  const char*
macroName)

#### Arguments

macroName

> Specifies the name of the macro being defined.

### lefwEndMacro

Ends the MACRO section for the specified macroName.

#### Syntax

int lefwEndMacro(
  const char*
macroName)

### lefwMacroClass

Writes a CLASS statement. The CLASS statement is optional and can be used only once in a MACRO section.

#### Syntax

int lefwMacroClass(
  const char*
value1,
  const char* value2)

#### Arguments

value1

> Specifies the macro type.
> Value: COVER, RING, BLOCK, PAD, CORE, or ENDCAP

value2

> Specifies a subtype for a macro type. If value1 is ENDCAP, you must specify this argument. Otherwise, specify NULL to ignore this argument.

If Value1 equals: | Then Value2 is:
COVER | Optional and can be BUMP.
BLOCK | Optional and can be BLACKBOX or SOFT.
PAD | Optional and can be INPUT, OUTPUT, INOUT, POWER, SPACER, or AREAIO.
CORE | Optional and can be FEEDTHRU, TIEHIGH, TIELOW, SPACER, ANTENNACELL, or WELLTAP.
ENDCAP | Required and can be PRE, POST, TOPLEFT, TOPRIGHT, BOTTOMLEFT, or BOTTOMRIGHT.

### lefwMacroEEQ

Writes an EEQ statement. The EEQ statement is optional and can be used only once in a MACRO section.

#### Syntax

int lefwMacroEEQ(
  const char*
macroName)

#### Arguments

macroName

> Specifies that the macro being defined should be electrically equivalent to the previously defined macroName.

### lefwMacroForeign

Writes a FOREIGN statement. The FOREIGN statement is optional and can be used more than once in a MACRO section.

#### Syntax

int lefwMacroForeign(
  const char*
cellName,
  double xl,
  double yl,
  int orient)

#### Arguments

cellName

> Specifies which foreign (GDSII) system name to use when placing an instance of this macro.

xl yl

> Optional arguments that specify the macro origin (lower left corner when the macro is in north orientation) offset from the foreign origin. Specify 0 to ignore these arguments.

orient

> Optional argument that specifies the orientation of the foreign cell when the macro is in north orientation. Specify -1 to ignore this argument.
> Value: 0 to 7. For more information, see "Orientation Codes".

### lefwMacroForeignStr

Also writes a FOREIGN statement. This routine is the same as the lefwMacroForeign routine with the exception of the orient argument, which takes a string instead of an integer. The FOREIGN statement is optional and can be used more than once in a MACRO section.

#### Syntax

int lefwMacroForeignStr(
  const char*
cellName,
  double xl,
  double yl,
  const char* orient)

#### Arguments

cellName

> Specifies which foreign (GDSII) system name to use when placing an instance of this macro.

xl yl

> Optional arguments that specify the macro origin (lower left corner when the macro is in north orientation) offset from the foreign origin. Specify 0 to ignore these arguments.

orient

> Optional argument that specifies the orientation of the foreign cell when the macro is in north orientation. Specify "" to ignore this argument.
> Value: N, W, S, E, FN, FW, FS, or FE

### lefwMacroOrigin

Writes an ORIGIN statement. The ORIGIN statement is optional and can be used only once in a MACRO section.

#### Syntax

int lefwMacroOrigin(
  double
xl,
  double yl)

#### Arguments

xl, yl

> Specifies the origin of the macro. xl, yl is the lower left corner point of the macro. The coordinates for macro sites, ports, and obstructions are specified with respect to the macro origin. The origin itself is specified with respect to the lower left corner of the bounding box of the sites of the macro.

### lefwMacroSite

Writes a SITE statement. The SITE statement is optional and can be used more than once in a MACRO section.

#### Syntax

int lefwMacroSite(
  const char*
siteName)

#### Arguments

siteName

> Specifies the site associated with the macro.

### lefwMacroSitePattern

Writes a SITE statement that includes a site pattern. The site pattern indicates that the cell is a gate-array cell rather that a row-based standard cell. The SITE statement is optional and can be used more than once in a MACRO section.

#### Syntax

lefwMacroSitePattern(
  const char*
name,
  double origX,
  double orgY,
  int orient,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

name

> Specifies the site associated with the macor.

origX origY

> Optional arguments that specify the origin of the site inside the macro. Specify 0 to ignore these arguments.

orient

> Optional argument that specifies the orientation of the site at that location. Specify -1 to ignore this argument.
> Value: 0 to 7. For more information, see "Orientation Codes".

numX numY

> Optional arguments that specify the number of sites to add in the x and y directions. Specify 0 to ignore these arguments.

spaceX spaceY

> Optional arguments that specify the spacing between sites in the x and y directions. Specify 0 to ignore these arguments.

### lefwMacroSitePatternStr

Also writes a SITE statement that includes a site pattern. This routine is the same as the lefwMacroSitePattern routine with the exception of the orient argument, which takes a string instead of an integer. The SITE statement is optional and can be used more than once in a MACRO section.

#### Syntax

lefwMacroSitePatternStr(
  const char*
name,
  double origX,
  double orgY,
  int orient,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

name

> Specifies the site associated with the macor.

origX origY

> Optional arguments that specify the origin of the site inside the macro. Specify 0 to ignore these arguments.

orient

> Optional argument that specifies the orientation of the site at that location. Specify "" to ignore this argument.
> Value: N, W, S, E, FN, FW, FS, or FE

numX numY

> Optional arguments that specify the number of sites to add in the x and y directions. Specify 0 to ignore these arguments.

spaceX spaceY

> Optional arguments that specify the spacing between sites in the x and y directions. Specify 0 to ignore these arguments.

### lefwMacroSize

Writes a SIZE statement. The SIZE statement is required and can be used only once in a MACRO section.

#### Syntax

int lefwMacroSize(
  double
width,
  double height)

#### Arguments

width, height

> Specify the minimum bounding rectangle, in microns, for the macro. The bounding rectangle should be a multiple of the placement grid.

### lefwMacroSymmetry

Writes a SYMMETRY statement. The SYMMETRY statement is optional and can be used only once in a MACRO section.

#### Syntax

int lefwMacroSymmetry(
  const char*
symmetry)

#### Arguments

symmetry

> Specifies the allowable orientations for the macro.
> Value: X, Y, or R90

### lefwStartMacroDensity

Starts a DENSITY statement in the MACRO statement.The DENSITY statement is optional and can be used only once in a MACRO statement.

Each DENSITY statement must start with this routine and end with the lefwEndMacroDensity routine. Each DENSITY statement also must include at least one lefwMacroDensityLayerRect routine.

#### Syntax

lefwStartMacroDensity(
  const char*
layerName)

#### Arguments

layerName

> Specifies the layer on which to create the density rectangles.

### lefwMacroDensityLayerRect

Writes a RECT statement in the DENSITY statement. The RECT statement is required and can be used more than once in a DENSITY statement.

#### Syntax

lefwMacroDensityLayerRect(
  double
x1,
  double y1,
  double x2,
  double y2,
  double densityValue)

#### Arguments

x1 y1 x2 y2

> Specifies the coordinates of a rectangle.

densityValue

> Specifies the percentage density of the rectangle.
> Value: 0 to 100

### lefwEndMacroDensity

Ends the DENSITY statement.

#### Syntax

lefwEndMacroDensity()

### Macro Examples

The following example shows a callback routine with the type lefwMacroCbkType. This example shows function calls to create a macro. It does not include function calls to create a macro obstruction. For an example of how to create a macro obstruction, see the Macro Obstruction section. This example only shows the usage of some functions related to Macro.

int macroCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  double *xpath;
  double *ypath;
  // Check if the type is correct
  if (type != lefwMacroCbkType) {
  printf("Type is not lefwMacroCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartMacro("INV");
  CHECK_RES(res);
  res = lefwMacroClass("CORE", NULL);
  CHECK_RES(res);
  res = lefwMacroForeign("INVS", 0, 0, -1);
  CHECK_RES(res);
  res = lefwMacroPower(1.0);
  CHECK_RES(res);
  res = lefwMacroSize(67.2, 24);
  CHECK_RES(res);
  res = lefwMacroSymmetry("X Y R90");
  CHECK_RES(res);
  res = lefwMacroSite("CORE1");
  CHECK_RES(res);
  return 0;}

## Macro Obstruction

Macro obstruction routines write an OBS (macro obstruction) section, which further defines a macro. An OBS section is optional and can be used more than once in a MACRO section. For syntax information about the LEF OBS section, see "Macro Obstruction Statement" in the
LEF/DEF Language Reference.

You must use the lefwStartMacroObs and lefwEndMacroObs routines to start and end the OBS section. The remaining macro obstruction routines described in this section must be included between these routines.

For examples of the routines described here, see "Macro Obstruction Examples".

All routines return 0 if successful.

### lefwStartMacroObs

Starts the OBS section in a MACRO section. This routine is required for each OBS section, and can be used more than once in a MACRO section.

#### Syntax

int lefwStartMacroObs()

### lefwEndMacroObs

Ends the OBS section.

#### Syntax

int lefwEndMacroObs()

### lefwMacroObsDesignRuleWidth

Writes a DESIGNRULEWIDTH statement. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined within an OBS section and can be used more than once.

#### Syntax

int lefwMacroObsDesignRuleWidth(
  const char*
layerName
double width)

#### Arguments

layerName

> Specifies the layer on which the geometry lies.

width

> Optional argument that specifies the effective design rule width. If specified, the obstruction is treated as a shape of this width for all spacing checks. Specify 0 to ignore this argument.

### lefwMacroObsLayer

Writes a LAYER statement. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined within an OBS section and can be used more than once.

#### Syntax

int lefwMacroObsLayer(
  const char*
layerName,
  double spacing)

#### Arguments

layerName

> Specifies the layer on which to place the obstruction.

spacing

> Optional argument that specifies the minimum spacing allowed between this obstruction and any other shape. Specify 0 to ignore this argument.

### lefwMacroObsLayerPath

Writes a PATH statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement and can be used more than once.

#### Syntax

int lefwMacroObsLayerPath(
  int
num_paths,
  double* xl,
  double* yl,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

numPaths

> Specifies the number of paths to create.

x1 y1

> Creates a path between the specified points. The path automatically extends the length by half of the current width on both end points to form a rectangle. (A previous WIDTH statement is required.) The line between each pair of points must be parallel to the x or y axis (45-degree angles are not allowed).

numX numY spaceX spaceY

> Optional arguments that specify the PATH ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroObsLayerPolygon

Writes a POLYGON statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement and can be used more than once.

#### Syntax

int lefwMacroObsLayerPolygon(
  int
num_polys,
  double* xl,
  double* yl,
  int numX,
  int numY,
  double spaceX,)
  double spaceY)

#### Arguments

num_polys

> Specifies the number of polygon sides.

x1 y1

> Specifies a sequence of points to generate a polygon geometry. Every polygon edge must be parallel to the x or y axis, or at a 45-degree angle.

numX numY spaceX spaceY

> Optional arguments that specify the POLYGON ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroObsLayerRect

Writes a RECT statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement and can be used more than once.

#### Syntax

int lefwMacroObsLayerRect(
  double
xl1,
  double yl1,
  double xl2,
  double yl2,
  int numX,
  int numY,)
  double spaceX,
  double spaceY)

#### Arguments

xl1 yl1 xl2 yl2

> Specifies a rectangle in the current layer, where the points specified are opposite corners of the rectangle.

numX numY spaceX spaceY

> Optional arguments that specify the RECT ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroObsLayerWidth

Writes a WIDTH statement. The WIDTH statement is optional and can be used only once in an LAYER section.

#### Syntax

int lefwMacroObsLayerWidth(
  double
width)

#### Arguments

width

> Specifies the width that the PATH statements use.

### lefwMacroObsVia

Writes a VIA statement. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined within an OBS section and can be used more than once.

#### Syntax

int lefwMacroObsVia(
  double
xl,
  double yl,
  const char* viaName,
  int numX,
  int numY,
  double spaceX,)
  double spaceY)

#### Arguments

x1 y1

> Specify the location to place the via.

viaName

> Specifies the name of the via to place.

numX numY spaceX spaceY

> Optional arguments that specify the VIA ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### Macro Obstruction Examples

The following example only shows the usage of some functions related to Macro Obstruction. This example is part of the Macro callback routine.

int macroCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  double *xpath;
  double *ypath;
  ...
  res = lefwStartMacroObs();
  CHECK_RES(res);
  res = lefwMacroObsLayer("M1", 0);
  CHECK_RES(res);
  res = lefwMacroObsLayerRect(24.1, 1.5, 43.5, 208.5, 0,
  0, 0, 0);
  CHECK_RES(res);
  xpath = (double*)malloc(sizeof(double)*2);
  ypath = (double*)malloc(sizeof(double)*2);
  xpath[0] = 8.4;
  ypath[0] = 3;
  xpath[1] = 8.4;
  ypath[1] = 124;
  res = lefwMacroObsLayerPath(2, xpath, ypath, 0, 0, 0, 0);
  CHECK_RES(res);
  free((char*)xpath);
  free((char*)ypath);
  res = lefwEndMacroObs();
  CHECK_RES(res);
  ...
  return 0;}

## Macro Pin

Macro Pin routines write a PIN section, which further defines a macro. A PIN section is optional in each MACRO section and can be defined more than once in a MACRO section. For syntax information about the LEF PIN section, see "Macro Pin Statement" in the LEF/DEF Language Reference.

You must use the lefwStartMacroPin and lefwEndMacroPin routines to start and end the PIN section. The remaining macro pin routines must be included between these routines.

For examples of the routines described here, see "Macro Pin Examples".

In addition to the routines described in this section, you can include a PORT section within a PIN section. For more information about these routines, see "Macro Pin Port".

All routines return 0 if successful.

### lefwStartMacroPin

Starts the PIN section in a MACRO section. This routine is required for each PIN section and can be used more than once in a MACRO section.

#### Syntax

int lefwStartMacroPin(
  const char*
pinName)

#### Arguments

pinName

> Specifies the name of the library pin.

### lefwEndMacroPin

Ends the PIN section for the specified pin.

#### Syntax

int lefwEndMacroPin(
  const char*
pinName)

#### Arguments

pinName

> Specifies the name of the library pin.

### lefwMacroPinAntennaDiffArea

Writes an ANTENNADIFFAREA statement. The ANTENNADIFFAREA statement is optional and can be used more than once in a PIN section.

#### Syntax

int lefwMacroPinAntennaDiffArea(
  double
value,
const char* layerName)

#### Arguments

value

> Specifies the diffusion area, in micron-squared units, to which the pin is connected on a layer.

layerName

> Optional argument that specifies the layer. If you do not specify a layer name, value applies to all layers. Specify NULL to ignore this argument.

### lefwMacroPinAntennaGateArea

Writes an ANTENNAGATEAREA statement. The ANTENNAGATEAREA statement is optional and can be used once after each lefwMacroPinAntennaModel routine in a PIN section.

#### Syntax

int lefwMacroPinAntennaGateArea(
  double
value,
const char* layerName)

#### Arguments

value

> Specifies the gate area, in micron-squared units, to which the pin is connected on a layer.

layerName

> Optional argument that specifies the layer. If you do not specify a layer name, value applies to all layers. Specify NULL to ignore this argument.

### lefwMacroPinAntennaMaxAreaCar

Writes an ANTENNAMAXAREACAR statement. The ANTENNAMAXAREACAR statement is optional and can be used once after each lefwMacroPinAntennaModel routine in a PIN section.

#### Syntax

int lefwMacroPinAntennaMaxAreaCar(
  double
value,
const char* layerName)

#### Arguments

value

> For hierarchical process antenna effect calculation, specifies the maximum cumulative antenna ratio value on the specified layerName, using the cut area below the current pin layer.

layerName

> Specifies the layer.

### lefwMacroPinAntennaMaxCutCar

Writes an ANTENNAMAXCUTCAR statement. The ANTENNAMAXCUTCAR statement is optional and can be used once after each lefwMacroPinAntennaModel routine in a PIN section.

#### Syntax

int lefwMacroPinAntennaMaxCutCar(
  double
value,
const char* layerName)

#### Arguments

value

> For hierarchical process antenna effect calculation, specifies the maximum cumulative antenna ratio value on the specified layerName, using the cut area below the current pin layer.

layerName

> Specifies the layer.

### lefwMacroPinAntennaMaxSideAreaCar

Writes an ANTENNAMAXSIDEAREACAR statement. The ANTENNAMAXSIDEAREACAR statement is optional and can be used once after each lefwMacroPinAntennaModel routine in a PIN section.

#### Syntax

int lefwMacroPinAntennaMaxSideAreaCar(
  double
value,
const char* layerName)

#### Arguments

value

> For hierarchical process antenna effect calculation, specifies the maximum cumulative antenna ratio value on the specified layerName, using the metal side wall area below the current pin layer.

layerName

> Specifies the layer.

### lefwMacroPinAntennaModel

Writes an ANTENNAMODEL statement. The ANTENNAMODEL statement is optional and can be used more than once in a PIN section.

#### Syntax

int lefwMacroPinAntennaModel(
  const char*
oxide)

#### Arguments

oxide

> Specifies the oxide model for the pin. Each model can be specified once per layer. If you specify an ANTENNAMODEL statement, that value affects all ANTENNAGATEAREA and ANTENNA*CAR statements for the pin that follow it until you specify another ANTENNAMODEL statement.
> Value: OXIDE1, OXIDE2, OXIDE3, or OXIDE4
> Note: OXIDE1 and OXIDE2 are currently supported. If you specify OXIDE3 or OXIDE4, current tools parse and ignore them.

### lefwMacroPinAntennaPartialCutArea

Writes an ANTENNAPARTIALCUTAREA statement. The ANTENNAPARTIALCUTAREA statement is optional and can be used more than once in a PIN section.

#### Syntax

int lefwMacroPinAntennaPartialCutArea(
  double
value,
const char* layerName)

#### Arguments

value

> Specifies the partial cut area, which is above the current pin layer and inside, or outside, the macro on a layer.

layerName

> Optional argument that specifies the layer. If you specify a layer name, value applies to antennas on that layer only. If you do not specify a layer name, value applies to all layers. Specify NULL to ignore this argument.

### lefwMacroPinAntennaPartialMetalArea

Writes an ANTENNAPARTIALMETALAREA statement. The ANTENNAPARTIALMETALAREA statement is optional and can be used more than once in a PIN section.

#### Syntax

int lefwMacroPinAntennaPartialMetalArea(
  double
value,
const char* layerName)

#### Argument

value

> Specifies the partial metal area, which is connected directly to the I/O pin and the inside, or outside, of the macro on a layer.

layerName

> Optional argument that specifies the layer. If you do not specify a layer name, value applies to all layers. Specify NULL to ignore this argument.

### lefwMacroPinAntennaPartialMetalSideArea

Writes an ANTENNAPARTIALMETALSIDEAREA statement. The ANTENNAPARTIALMETALSIDEAREA statement is optional and can be used more than once in a PIN section.

#### Syntax

int lefwMacroPinAntennaPartialMetalSideArea(
  double
value,
const char* layerName)

#### Arguments

value

> Specifies the partial metal side wall area, which is connected directly to the I/O pin and inside, or outside, of the macro on a layer.

layerName

> Optional argument that specifies the layer. If you do not specify a layer name, value applies to all layers. Specify NULL to ignore this argument.

### lefwMacroPinDirection

Writes a DIRECTION statement. The DIRECTION statement is optional and can be used only once in a PIN section.

#### Syntax

int lefwMacroPinDirection(
  const char*
direction)

#### Arguments

direction

> Specifies the pin type.
> Value: INPUT, OUTPUT, OUTPUT TRISTATE, INOUT, or FEEDTHRU

### lefwMacroPinGroundSensitivity

Writes a GROUNDSENSITIVITY statement. The GROUNDSENSITIVITY statement is optional and can be used only once in a PIN section.

#### Syntax

lefwMacroPinGroundSensitivity(
  const char*
pinName)

#### Arguments

pinName

> Specifies that if this pin is connected to a tie-low connection (such as 1'b0 in Verilog), it should connect to the same net to which pinName is connected.

### lefwMacroPinMustjoin

Writes a MUSTJOIN statement. The MUSTJOIN statement is optional and can be used only once in a PIN section.

#### Syntax

int lefwMacroPinMustjoin(
  const char*
pinName)

#### Arguments

pinName

> Specifies the name of another pin in the cell that must be connected with the pin being defined.

### lefwMacroPinNetExpr

Wries a NETEXPR statement in a PIN section. The NETEXPR statement is optional and can be used only once in a PIN section.

#### Syntax

lefwMacroPinNetExpr(
  const char*
name)

#### Arguments

name

> Specifies a net expression property name (such as power1 or power2). If name matches a net expression property in the netlist (such as in Verilog, VHDL, or OpenAccess), then the property is evaluated, and the software identifies a net to which to connect this pin.

### lefwMacroPinShape

Writes a SHAPE statement. The SHAPE statement is optional and can be used only once in a PIN section.

#### Syntax

int lefwMacroPinShape(
  const char*
name)

#### Arguments

name

> Specifies a pin with special connection requirements because of its shape.
> Value: ABUTMENT, RING, or FEEDTHRU

### lefwMacroPinSupplySensitivity

Writes a SUPPLYSENSITIVITY statement. The SUPPLYSENSITIVITY statement is optional and can be used only once in a PIN section.

#### Syntax

lefwMacroPinSupplySensitivity(
  const char*
pinName)

#### Arguments

pinName

> Specifies that if this pin is connected to a tie-high connection (such as 1'b1 in Verilog), it should connect to the same net to which pinName is connected.

### lefwMacroPinTaperRule

Writes a TAPERRULE statement. The TAPERRULE statement is optional and can be used only once in a PIN section.

#### Syntax

int lefwMacroPinTaperRule(
  const char*
ruleName)

#### Arguments

ruleName

> Specifies the nondefault rule to use when tapering wires to the pin.

### lefwMacroPinUse

Writes a USE statement. The USE statement is optional and can be used only once in a PIN section.

#### Syntax

int lefwMacroPinUse(
  const char*
use)

#### Arguments

use

> Specifies how the pin is used.
> Value: SIGNAL, ANALOG, POWER, GROUND, or CLOCK

### Macro Pin Examples

The following example only shows the usage of some functions related to Macro Pin.This example is part of the Macro callback routine.

int macroCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  ...
  res = lefwStartMacroPin("Z");
  CHECK_RES(res);
  res = lefwMacroPinDirection("OUTPUT");
  CHECK_RES(res);
  res = lefwMacroPinUse("SIGNAL");
  CHECK_RES(res);
  res = lefwMacroPinShape("ABUTMENT");
  CHECK_RES(res);
  res = lefwMacroPinPower(0.1);
  CHECK_RES(res);
  res = lefwStartMacroPinPort(NULL);
  CHECK_RES(res);
  res = lefwEndMacroPin("Z");
  CHECK_RES(res);
  ...
  return 0;}

## Macro Pin Port

Macro Pin Port routines write a PORT section, which further defines a macro pin. The PORT section is required for each PIN section and can be used more than once in a PIN section. For syntax information about the LEF PIN section, see "Macro Pin Statemen"t in the LEF/DEF Language Reference.

You must use the lefwStartMacroPinPort and lefwEndMacroPinPort routines to start and end the PORT section. The lefwStartMacroPinPort routine must be called after the lefwStartMacroPin routine.The remaining port routines must be included between these routines.

For examples of the routines described here, see "Macro Pin Port Examples".

All routines return 0 if successful.

### lefwStartMacroPinPort

Starts the PORT section.

#### Syntax

int lefwStartMacroPinPort(
  const char*
classType)

#### Arguments

classType

> Optional argument that specifies whether or not the port is a core port.
> Value: NONE or CORE.

### lefwEndMacroPinPort

Ends the PORT section.

#### Syntax

int lefwEndMacroPinPort()

### lefwMacroPinPortDesignRuleWidth

Writes a DESIGNRULEWIDTH statement. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined in a PORT section and can be used more than once.

#### Syntax

int lefwMacroPinPortDesignRuleWidth(
  const char*
layerName,
double width)

#### Argument

layerName

> Specifies the layer on which to place the geometry.

width

> Optional argument that specifies the effective design rule width. If specified, the router uses the spacing defined in the layer section that corresponds to width. Specify 0 to ignore this argument.

### lefwMacroPinPortLayer

Writes a LAYER statement in the PORT section. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined in a PORT section and can be used more than once.

#### Syntax

int lefwMacroPinPortLayer(
  const char*
layerName,
  double spacing)

#### Arguments

layerName

> Specifies the layer on which to place the geometry.

spacing

> Optional argument that specifies the minimum spacing allowed between this geometry and any other shape. Specify 0 to ignore this argument.

### lefwMacroPinPortLayerPath

Writes a PATH statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement.

#### Syntax

int lefwMacroPinPortLayerPath(
  int
num_paths,
  double* xl,
  double* yl,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

numPaths

> Specifies the number of paths to create.

x1 y1

> Create a path between the specified points. The path automatically extends the length by half of the current width on both end points to form a rectangle. (A previous WIDTH statement is required.) The line between each pair of points must be parallel to the x or y axis (45-degree angles are not allowed).

numX numY spaceX spaceY

> Optional arguments that specify the PATH ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroPinPortLayerPolygon

Writes a POLYGON statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement.

#### Syntax

int lefwMacroPinPortLayerPolygon(
  int
num_polys,
  double* xl,
  double* yl,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

num_polys

> Specifies the number of polygon sides.

x1 y1

> Specifies a sequence of points to generate a polygon geometry. Each polygon edge must be parallel to the x or y axis, or at a 45-degree angle.

numX numY spaceX spaceY

> Optional arguments that specify the POLYGON ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroPinPortLayerRect

Writes a RECT statement. Either a PATH, POLYGON, or RECT statement must follow a LAYER statement.

#### Syntax

int lefwMacroPinPortLayerRect(
  double
xl1,
  double yl1,
  double xl2,
  double yl2,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

xl1 yl1 xl2 yl2

> Specifies a rectangle in the current layer, where the points specified are opposite corners of the rectangle.

numX numY spaceX spaceY

> Optional arguments that specify the RECT ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### lefwMacroPinPortLayerWidth

Writes a WIDTH statement. The WIDTH statement is optional and can be used only once in a PORT section.

#### Syntax

int lefwMacroPinPortLayerWidth(
  double
width)

#### Arguments

width

> Specifies the width that the PATH statements use.

### lefwMacroPinPortVia

Writes a VIA statement. Either a LAYER statement, a DESIGNRULEWIDTH statement, or a VIA statement must be defined in a PORT section and can be used more than once.

#### Syntax

int lefwMacroPinPortVia(
  double
xl,
  double yl,
  const char* viaName,
  int numX,
  int numY,
  double spaceX,
  double spaceY)

#### Arguments

x1 y1

> Specify the location to place the via.

viaName

> Specifies the name of the via to place.

numX numY spaceX spaceY

> Optional arguments that specify the VIA ITERATE statement. numX and numy specify the number of columns and rows of points that make up the array. spaceX and spaceY specify the spacing, in distance units, between the columns and rows. Specify 0 to ignore these arguments.

### Macro Pin Port Examples

The following example only shows the usage of some functions related to Macro Pin Port. This example is part of the Macro callback routine.

int macroCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  double *xpath;
  double *ypath;
  ...
  res = lefwStartMacroPin("Z");
  CHECK_RES(res);
  ...
  res = lefwStartMacroPinPort(NULL);
  CHECK_RES(res);
  res = lefwMacroPinPortLayer("M2", 5.6);
  CHECK_RES(res);
  xpath = (double*)malloc(sizeof(double)*3);
  ypath = (double*)malloc(sizeof(double)*3);
  xpath[0] = 30.8;
  ypath[0] = 9;
  xpath[1] = 42;
  ypath[1] = 9;
  xpath[2] = 30.8;
  ypath[2] = 9;
  res = lefwMacroPinPortLayerPath(3, xpath, ypath, 0, 0,
  0, 0);
  CHECK_RES(res);
  res = lefwEndMacroPinPort();
  CHECK_RES(res);
  ...
  res = lefwEndMacroPin("Z");
  CHECK_RES(res);
  free((char*)xpath);
  free((char*)ypath);
  ...
  return 0;}

## Manufacturing Grid

The Manufacturing Grid routine writes a LEF MANUFACTURINGGRID statement. The MANUFACTURINGGRID statement is optional and can be used only once in a LEF file. For syntax information about the MANUFACTURINGGRID statement, see "Manufacturing Grid" in the LEF/DEF Language Reference.

This routine returns 0 if successful.

### lefwManufacturingGrid

Writes a MANUFACTURINGGRID statement.

#### Syntax

int lefwManufacturingGrid(
  double
grid)

#### Arguments

grid

> Specifies the value for the manufacturing grid. You must specify a positive number for a value.

## Maximum Via Stack

The Maximum Stack Via routine writes a LEF MAXVIASTACK statement. The MAXVIASTACK statement is optional and can be used only once in a LEF file. For syntax information about the MAXVIASTACK statement, see "Maximum Via Stack" in the LEF/DEF Language Reference.

|  | The lefwMaxviastack routine must be used only after all layer routines are used.

This routine returns 0 if successful.

### lefwMaxviastack

Writes a MAXVIASTACK statement.

#### Syntax

int lefwMaxviastack(
  int value,
  const char*
bottomlayer,
  const char* topLayer)

#### Arguments

value

> Specifies the maximum allowed number of single-stacked vias.

bottomLayer

> Optional argument that specifies the bottom layer in a range of layers for which the maximum stacked via rule applies. Specify NULL to ignore this argument.

topLayer

> Optional argument that specifies the top layer in a range of layers for which the maximum stacked via rule applies. Specify NULL to ignore this argument.

## Nondefault Rule

Nondefault Rule routines write a LEF NONDEFAULTRULE statement. The NONDEFAULTRULE statement is optional and can be used only once in a LEF file. For syntax information about the LEF NONDEFAULTRULE statement, see "Nondefault Rule" in the LEF/DEF Language Reference.

You must use the lefwStartNondefaultRules and lefwEndNondefaultRules routines to start and end the NONDEFAULTRULE section. The lefwNonDefaultRuleLayer routine must be included between these routines.

For examples of the routines described here, see "Nondefault Rules Example".

In addition to the routines described in this section, you can include a PROPERTY statement and a VIA statement within a NONDEFAULTRULE section. For more information about these routines, see "Property" , or "Via".

All routines return 0 if successful.

### lefwStartNonDefaultRule

Starts the NONDEFAULTRULE statement.

#### Syntax

int lefwStartNonDefaultRule(
  const char*
ruleName)

#### Arguments

ruleName

> Specifies the name of the nondefault rule to define.

### lefwEndNonDefaultRule

Ends the NONDEFAULTRULE statement for the specified ruleName.

#### Syntax

int lefwEndNonDefaultRule(
  const char*
ruleName)

### lefwNonDefaultRuleHardspacing

Writes a HARDSPACING statement. The HARDSPACING statement specifies that any spacing values that exceed the LEF LAYER spacing requirements are "hard" rules instead of "soft" rules. By default, routers treat extra spacing requirements as soft rules that are high cost to violate, but not real spacing violations. The HARDSPACING statement is optional and can be used only once in a NONDEFAULTRULE statement.

#### Syntax

lefwNonDefaultRuleHardspacing()

### lefwNonDefaultRuleLayer

Writes a LAYER statement in the NONDEFAULTRULE statement. The LAYER statement is required and can be used more than once in a NONDEFAULTRULE statement.

#### Syntax

int lefwNonDefaultRuleLayer(
  const char*
layerName,
  double width,
  double minSpacing,
  double wireExtension,
double resistance,
double capacitance,
  double edgecap)

#### Arguments

layerName

> Specifies the layer for the various width and spacing values. This layer must be a routing layer.

minSpacing

> Optional argument that specifies the recommended minimum spacing for layerName for routes using this NONDEFAULTRULE to other geometries.

width

> Specifies the required minimum width for layerName.

wireExtension

> Optional argument that specifies the distance by which wires are extended at vias.The value must be greater than or equal to half of the routing width for the layer, as defined in the nondefault rule. Specify 0 to ignore this argument.

resistance

> This argument is obsolete. Specify 0 to ignore this argument.

capacitance

> This argument is obsolete. Specify 0 to ignore this argument.

edgecap

> This argument is obsolete. Specify 0 to ignore this argument.

### lefwNonDefaultRuleMinCuts

Wries a MINCUTS statement in the NONDEFAULTRULE statement. The MINCUTS statement is optional and can be used more than once in a NONDEFAULTRULE statement.

#### Syntax

lefwNonDefaultRuleMinCuts(
  const char*
layerName,
  int numCuts)

#### Arguments

layerName

> Specifies the cut layer.

numCuts

> Specifies the minimum number of cuts allowed for any via using layerName.

### lefwNonDefaultRuleStartVia

Starts a VIA statement in the NONDEFAULTRULE statement. The VIA statement is optional and can be used more than once in a NONDEFAULTRULE statement.

Each VIA statement must start and end with the lefwNonDefaultRuleStartVia and lefwNonDefaultRuleEndVia routines. The following routines can be included within a VIA statement:

| lefwViaLayer

| lefwViaLayerPolygon

| lefwViaLayerRect

| lefwViaResistance

| lefwViaViarule (and its related routines)

#### Syntax

lefwNonDefaultRuleStartVia(
  const char*
viaName,
  const char* isDefault)

#### Arguments

viaName

> Specifies the name for the via.

isDefault

> Identifies the via as the default via between the specified layers.

| NULL | Ignores the argument.
| DEFAULT | Identifies the via as the default via.

### lefwNonDefaultRuleEndVia

Ends the VIA statement for the specified viaName. Each VIA statement must start and end with the lefwNonDefaultRuleStartVia and lefwNonDefaultRuleEndVia routines.

#### Syntax

lefwNonDefaultRuleEndVia(
  const char*
viaName)

### lefwNonDefaultRuleUseVia

Writes a USEVIA statement in a NONDEFAULTRULE statement. The USEVIA statement is optional and can be used more than once in a NONDEFAULTRULE statement.

#### Syntax

lefwNonDefaultRuleUseVia(
  const char*
viaName)

#### Arguments

viaName

> Specifies a previously defined via from the LEF VIA statement, or a previously defined NONDEFAULTRULE via to use with this routing rule.

### lefwNonDefaultRuleUseViaRule

Wrties a USEVIARULE statement in the NONDEFAULTRULE statement. The USEVIARULE statement is optional and can be used more than once in a NONDEFAULTRULE statement.

#### Syntax

lefwNonDefaultRuleUseViaRule(
  const char*
viaRuleName)

#### Arguments

viaRuleName

> Specifies a previously defined VIARULE GENERATE rule to use with this routing rule. You cannot specify a rule from a VIARULE without a GENERATE keyword.

### Nondefault Rules Example

The following example shows a callback routine with the type lefwNonDefaultCbkType. This example does not include information on how to create a via within the nondefault rule. For an example of how to create a via, see the Via section.

int nonDefaultCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwNonDefaultCbkType) {
  printf("Type is not lefwNonDefaultCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartNonDefaultRule("RULE1");
  CHECK_RES(res);
  res = lefwNonDefaultRuleLayer("RX", 10.0, 2.2, 6);
  CHECK_RES(res);
  res = lefwNonDefaultRuleLayer("PC", 10.0, 2.2, 0);
  CHECK_RES(res);
  res = lefwEndNonDefaultRule("RULE1");
  CHECK_RES(res);
  return 0;}

## Property

The Property routines write a LEF PROPERTY statement in a VIA, VIARULE, LAYER, MACRO, or NONDEFAULTRULE section. The PROPERTY statement is optional and can be used more than once in these sections.

For examples of the routines described here, see "Property Example".

All routines return 0 if successful.

### lefwIntProperty

Writes a PROPERTY statement that defines a named property with an integer value. The PROPERTY statement is optional and can be used more than once in a LEF file.

#### Syntax

int lefwIntProperty(
  const char*
propName,
  int propValue)

#### Arguments

propName

> Specifies the name of the property.

propValue

> Specifies an integer value.

### lefwRealProperty

Writes a PROPERTY statement that defines a named property with a real number value. The PROPERTY statement is optional and can be used more than once in a LEF file.

#### Syntax

int lefwRealProperty(
  const char*
propName,
  double propValue)

#### Arguments

propName

> Specifies the name of the property.

propValue

> Specifies a real value.

### lefwStringProperty

Writes a PROPERTY statement that defines a named property with a string value. The PROPERTY statement is optional and can be used more than once in a LEF file.

#### Syntax

int lefwStringProperty(
  const char*
propName,
  const char* propValue)

#### Arguments

propName

> Specifies the name of the property.

propValue

> Specifies a string value.

### Property Example

The following example shows how to create property inside a Macro callback routine. It can be used for Layer, Via, Via Rule, Via within the Nondefault Rule, and Macro.

int macroCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  ...
  res = lefwStringProperty("TYPE", "special");
  CHECK_RES(res);
  res = lefwIntProperty("intProp", 23);
  CHECK_RES(res);
  res = lefwRealProperty("realProp", 24.25);
  CHECK_RES(res);
  ...
  return 0;}

## Property Definitions

Property Definitions routines write a LEF PROPERTYDEFINTIONS statement. The PROPERTYDEFINTIONS statement is optional and can be used only once in a LEF file. For syntax information about the LEF PROPERTYDEFINTIONS statement, see "Property Definitions" in the LEF/DEF Language Reference.

You must use the lefwStartPropDef and lefwEndPropDef routines to start and end the PROPERTYDEFINTIONS statement. The lefwPropDef routine must be included between these routines.

For examples of the routines described here, see "Property Definitions Examples".

All routines return 0 if successful.

### lefwStartPropDef

Starts the PROPERTYDEFINTIONS statement.

#### Syntax

int lefwStartPropDef()

### lefwEndPropDef

Ends the PROPERTYDEFINTIONS statement.

#### Syntax

int lefwEndPropDef(

### lefwIntPropDef

Writes an integer property definition in the PROPERTYDEFINITIONS statement. The lefwIntProperty routine is optional and can be used more than once in a PROPERTYDEFINITIONS statement.

#### Syntax

int lefwIntPropDef(
  const char*
objType,
  const char* propName,
  double leftRange,
  double rightRange,
  int propValue)

#### Arguments

leftRange rightRange

> Optional arguments that limit integer property values to a specified range. Specify 0 to ignore these arguments.

objType

> Specifies the object type for which you are defining properties.
> Value: LIBRARY, LAYER, VIA, VIARULE, NONDEFAULTRULE, MACRO, or PIN

propName

> Specifies a unique property name for the object type.

propValue

> Optional argument that specifies an integer value for an object type. Specify NULL to ignore this argument.

### lefwRealPropDef

Writes a real property definition in the PROPERTYDEFINITIONS statement. The lefwRealPropDef routine is optional and can be used more than once in a PROPERTYDEFINITIONS statement.

#### Syntax

int lefwRealPropDef(
  const char*
objType,
  const char* propName,
  double leftRange,
  double rightRange,
  int propValue)

#### Arguments

leftRange rightRange

> Optional arguments that limit real property values to a specified range. Specify 0 to ignore these arguments.

objType

> Specifies the object type for which you are defining properties.
> Value: LIBRARY, LAYER, VIA, VIARULE, NONDEFAULTRULE, MACRO, or PIN

propName

> Specifies a unique property name for the object type.

propValue

> Optional argument that specifies a real value for an object type. Specify NULL to ignore this argument.

### lefwStringPropDef

Writes a string property definition in the PROPERTYDEFINITIONS statement. The lefwStringPropDef routine is optional and can be used more than once in a PROPERTYDEFINITIONS statement.

#### Syntax

int lefwStringPropDef(
  const char*
objType,
  const char* propName,
  double leftRange,
  double rightRange,
  int propValue)

#### Arguments

leftRange rightRange

> Optional arguments that limit property values to a specified range. Specify 0 to ignore these arguments.

objType

> Specifies the object type for which you are defining properties.
> Value: LIBRARY, LAYER, VIA, VIARULE, NONDEFAULTRULE, MACRO, or PIN

propName

> Specifies a unique property name for the object type.

propValue

> Optional argument that specifies a string value for an object type. Specify NULL to ignore this argument.

### Property Definitions Examples

The following example shows a callback routine with the type lefwPropDefCbkType. This example does not show all of the combinations of Property Definitions defined.

int propDefCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwPropDefCbkType) {
  printf("Type is not lefwPropDefCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartPropDef();
  CHECK_RES(res);
  res = lefwStringPropDef("LIBRARY", "NAME", 0, 0,
  "Cadence96");
  CHECK_RES(res);
  res = lefwIntPropDef("LIBRARY", "intNum", 0, 0, 20);
  CHECK_RES(res);
  res = lefwRealPropDef("LIBRARY", "realNum", 0, 0, 21.22);
  CHECK_RES(res);
  res = lefwEndPropDef();
  CHECK_RES(res);
  return 0;}

## Same-Net Spacing

Same-Net Spacing routines write a LEF SPACING statement. The SPACING statement is optional and can be used only once in a LEF file. For syntax information about the LEF SPACING statement, see "Same-Net Spacing" in the LEF/DEF Language Reference.

You must use the lefwStartSpacing and lefwEndSpacing routines to start and end the SPACING statement. The lefwSpacing routine must be included between these routines.

For examples of the routines described here, see "Same-Net Spacing Examples".

All routines return 0 if successful.

### lefwStartSpacing

Writes the SPACING statement.

#### Syntax

int lefwStartSpacing()

### lefwEndSpacing

Ends the SPACING statement.

#### Syntax

int lefwEndSpacing()

### lefwSpacing

Writes the SAMENET statement. The SAMENET statement is required and can be used more than once.

#### Syntax

int lefwSpacing(
  const char*
layerName1,
  const char* layerName2,
  double minSpace,
  const char* stack)

#### Arguments

layerName1, layerName2

> Specify the names of the layers for which the same-net spacing rule applies. You can specify spacing rules for routing layers and cut layers. For a routing layer, the same-net spacing rule is defined by specifying the same layer name twice.

minSpace

> Specifies the minimum spacing.

stack

> Optional argument that allows stacked vias at a routing layer. Specify NULL to ignore this argument.

### Same-Net Spacing Examples

The following example shows a callback routine with the type lefwSpacingCbkType.

int spacingCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwSpacingCbkType) {
  printf("Type is not lefwSpacingCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartSpacing();
  CHECK_RES(res);
  res = lefwSpacing("CUT01", "CA", 1.5, NULL);
  CHECK_RES(res);
  res = lefwEndSpacing();
  CHECK_RES(res);
  return 0;}

## Site

The Site routines write a LEF SITE statement. The SITE statement is optional and can be used more than once in a LEF file. For syntax information about the LEF SITE statement, see "Site" in the LEF/DEF Language Reference.

Each SITE statement must be defined with a lefwSite and lefwEndSite routine.

All routines return 0 if successful.

### lefwSite

Writes a SITE statement.

#### Syntax

int lefwSite(
  const char*
siteName,
  const char* classType,
  const char* symmetry,
  double width,
  double height)

#### Arguments

classType

> Specifies whether the site is a core site or an I/O pad site.
> Value: PAD or CORE.

siteName

> Specifies the name of the placement site.

symmetry

> Specifies how the site is symmetrical in normal orientation.
> Value: Specify one of the following:

| X | Defines the site as symmetric about the x axis.
| Y | Defines the site as symmetric about the y axis.
| R90 | Defines the site as symmetric when rotated 90 degrees.

width, height

> Specify the dimensions of the site in normal (or north) orientation, in microns.

### lefwEndSite

Ends a SITE statement.

#### Syntax

int lefwEndSite(
  const char*
siteName)

#### Arguments

siteName

> Specifies the name of the placement site.

### lefwSiteRowPattern

Writes a ROWPATTERN statement in the SITE statement. The ROWPATTERN statement is optional and can be used more than once in a SITE statement.

#### Syntax

lefwSiteRowPattern( const char* siteName,
  int
orient)

#### Arguments

siteName

> Specifies the name of a previously defined site.

orient

> Specifies the orientation for the previously defined site.
> Value: 0 to 7. For more information, see "Orientation Codes".

### lefwSiteRowPatternStr

Also writes a ROWPATTERN statement. This routine is the same as the lefwSiteRowPattern routine, with the exception of the orient argument, which takes a string instead of an integer. The ROWPATTERN statement is optional and can be used more than once in a SITE statement.

#### Syntax

lefwSiteRowPattern( const char* siteName,
  int
orient)

#### Arguments

siteName

> Specifies the name of a previously defined site.

orient

> Specifies the orientation for the previously defined site.
> Value: N, W, S, E, FN, FW, FS, or FE.

### Site Examples

The following example shows a callback routine with the type lefwSiteCbkType.

int siteCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwSiteCbkType) {
  printf("Type is not lefwSiteCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwSite("CORE1", "CORE", "X", 67.2, 6);
  CHECK_RES(res);
  return 0;}

## Units

Units routines write a LEF UNITS statement. The UNITS statement is optional and can be used only once in a LEF file. For syntax information about the LEF UNITS statement, see "Units" in the LEF/DEF Language Reference.

You must use the lefwStartUnits and lefwEndSpacing routines to start and end the UNITS statement. The lefwUnits routine must be included between these routines.

For examples of the routines described here, see "Units Examples".

All routines return 0 if successful.

### lefwStartUnits

Starts the UNITS statement.

#### Syntax

int lefwStartUnits()

### lefwEndUnits

Ends the UNITS statement.

#### Syntax

int lefwEndUnits()

### lefwUnits

Writes a UNITS statement. The UNITS statement is required whenever the lefwStartSpacing routine is specified.

#### Syntax

int lefwUnits(
  double
time,
  double capacitance,
  double resistance,
  double power,
  double current,
  double voltage,
  double database)

#### Arguments

time

> Optional argument that specifies a TIME NANOSECONDS statement. This interprets one LEF time unit as one nanosecond. Specify 0 to ignore this argument.

capacitance

> Optional argument that specifies a CAPACITANCE PICOFARADS statement. This interprets one LEF capacitance unit as one picofarad. Specify 0 to ignore this argument.

resistance

> Optional argument that specifies a RESISTANCE OHMS statement. This interprets one LEF resistance unit as one ohm. Specify 0 to ignore this argument.

power

> Optional argument that specifies a POWER MILLIWATTS statement. This interprets one LEF power unit as one milliwatt. Specify 0 to ignore this argument.

current

> Optional argument that specifies a CURRENT MILLIAMPS statement. This interprets one LEF current unit as one milliamp. Specify 0 to ignore this argument.

voltage

> Optional argument that specifies a VOLTAGE VOLTS statement. This interprets one LEF voltage unit as one volt. Specify 0 to ignore this argument.

database

> Optional argument that specifies a DATABASE MICRONS statement. This interprets one LEF distance unit as multiplied when converted into database units. Specify 0 to ignore this argument.

### lefwUnitsFrequency

Writes a FREQUENCY statement in the UNITS statement. The FREQUENCY statement is optional and can be used only once in a UNITS statement.

#### Syntax

int lefwUnitsFrequency(
  double
frequency)

#### Arguments

frequency

> Specifies a FREQUENCY MEGAHERTZ statement. This interprets one LEF frequency unit as one megahertz.

### Units Examples

The following example shows a callback routine with the type lefwUnitsCbkType.

int unitsCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwUnitsCbkType) {
  printf("Type is not lefwUnitsCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartUnits();
  CHECK_RES(res);
  res = lefwUnits(100, 10, 10000, 10000, 10000, 1000, 0);
  CHECK_RES(res);
  res = lefwEndUnits();
  CHECK_RES(res);
  return 0;}

## Use Min Spacing

The Use Min Spacing routine writes a LEF USEMINSPACING statement, which defines how minimum spacing is calculated for obstruction geometries. The USEMINSPACING statement is optional and can be used more than once in a LEF file.

For syntax information about the LEF USEMINSPACING statement, see "Use Min Spacing" in the LEF/DEF Language Reference.

This routine returns 0 if successful.

### lefwUseMinSpacing

Writes a USEMINSPACING statement.

#### Syntax

int lefwUseMinSpacing(
  const char*
type,
  const char* onOff)

#### Arguments

type

> Specifies that the minimum spacing applies to obstruction geometries.
> Value: OBS

onOff

> Specifies how to calculate the minimum spacing.
> Value: Specify one of the following:

| ON | Spacing is computed as if the MACRO OBS shapes were min-width wires. Some LEF models abstract many min-width wires as a single large OBS shape; therefore using wide wire spacing would be too conservative.
| OFF | Spacing is computed to MACRO OBS shapes as if they were actual routing shapes. A wide OBS shape would use wide wire spacing rules, and a thin OBS shapes would use thin wire spacing rules.

## Version

The version routine writes a LEF VERSION statement. For syntax information about the LEF VERSION statement, see "Version" in the LEF/DEF Language Reference.

The VERSION statement is part of the LEF file header (which also includes the BUSBITCHARS, and DIVIDERCHAR statements). If the statements in the header section are not defined, many applications assume default values for them. However, the default values are not formally part of the language definition; therefore you cannot be sure that the same assumptions are used in all applications. You should always explicitly define these values.

This routine returns 0 if successful.

### lefwVersion

Writes a VERSION statement. The VERSION statement can be used only once in a LEF file.

#### Syntax

int lefwVersion(
  int
vers1,
  int vers2)

#### Arguments

vers1, vers2

> Specify which version of the LEF syntax is being used. vers1 is the major value. vers2 is the minor value.

### Version Examples

The following example shows a callback routine with the type lefwVersionCbkType.

int versionCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwVersionCbkType) {
  printf("Type is not lefwVersionCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwVersion(5, 3);
  CHECK_RES(res);
  return 0;}

## Via

Via routines write a LEF VIA section. A VIA section is optional and can be used more than once in a LEF file. For syntax information about the LEF VIA section, see "Via" in the LEF/DEF Language Reference.

Each VIA section must start and end with the lefwStartVia and lefwEndVia routines. The remaining via routines must be included between these routines.

In addition to the routines described in this section, you can include a PROPERTY statement within a VIA section. For more information about these routines, see "Property".

For examples of the routines described here, see "Via Examples".

All routines return 0 if successful.

### lefwStartVia

Starts a VIA section.

#### Syntax

int lefwStartVia(
  const char*
viaName,
  const char* isDefault)

#### Arguments

viaName

> Specifies the name for the via.

isDefault

> Optional argument that identifies the via as the default via between the specified layers.

| NULL | Ignores the argument.
| DEFAULT | Identifies the via as the default via.

### lefwEndVia

Ends the VIA section for the specified viaName value.

#### Syntax

int lefwEndVia(
  const char*
viaName)

### lefwViaLayer

Writes a LAYER statement for a via. Either a LAYER or a VIARULE statement is required in a VIA section. A LAYER statement can be used more than once for a via.

If you specify this routine, you must also specify one of the following routines:

| lefwViaLayerPolygon

| lefwViaLayerRect

You can also optionally specify the following routine:

| lefwViaResistance

#### Syntax

int lefwViaLayer(
  const char*
layerName)

#### Arguments

layerName

> Specifies the layer on which to create the rectangles that make up the via. Normal vias have exactly three layers used: a cut layer and two layers that touch the cut layer (routing or masterslice).

### lefwViaLayerPolygon

Writes a POLYGON statement for a via. Either a POLYGON or RECT statement is required if a LAYER statement is specified in a VIA section, and can be used more than once.

#### Syntax

lefwViaLayerPolygon(
  int num_polys,
  double* xl,
  double* yl)

#### Arguments

num_polys

> Specifies the number of polygon sides.

xl yl

> Specifies a sequence of points to generate a polygon geometry. The polygon edges must be parallel to the x axis, the y axis, or at a 45-degree angle. The polygon is generated by connecting each successive point, then connecting the first and last points.

### lefwViaLayerRect

Writes a RECT statement. Either a POLYGON or RECT statement is required if a LAYER statement is specified in a VIA section, and can be used more than once.

#### Syntax

int lefwViaLayerRect(
  double
x1l,
double y1l,
  double x2l,
  double y2l)

#### Arguments

x1l, y1l, x2l, y2l

> Specify the points that make up the via.

### lefwViaResistance

Writes a RESISTANCE statement. The RESISTANCE statement is optional and can be used only once with a LAYER statement in a VIA section.

#### Syntax

int lefwViaResistance(
  double
resistance)

#### Arguments

resistance

> Specifies the total resistance of the via, in units of ohms, given as the resistance per via. Note that this is not a resistance per via-cut value; it is the total resistance of the via.

### lefwViaViarule

Writes a VIARULE statement for the via. Either a LAYER or a VIARULE statement is required in a VIA section. A VIARULE statement can be used only once in a VIA section.

If you specify this routine, you can optionally specify the following routines:

| lefwViaViaruleOffset

| lefwViaViaruleOrigin

| lefwViaViarulePattern

| lefwViaViaruleRowCol

#### Syntax

lefwViaViarule(
  const char*
viaRuleName,
  double xCutSize,
  double yCutSize,
  const char* botMetalLayer,
  const char* cutLayer,
  const char* topMetalLayer,
  double xCutSpacing,
  double yCutSpacing,
  double xBotEnc,
  double yBotEnc,
  double xTopEnc,
  double yTopEnc)

#### Arguments

viaRuleName

> Specifies the name of the LEF VIARULE that produced this via. This name must refer to a previouslydefined VIARULE GENERATE rule name. This indicates that the via is the result of automatic via generation, and that the via name is only used locally inside this LEF file.

xCutSize yCutSize

> Specifies the required width (xSize) and height (ySize) of the cut layer rectangles.

botMetalLayer cutLayer topMetalLayer

> Specifies the required names of the bottom routing layer, cut layer, and top routing layer. These layers must be previously defined in layer definitions, and must match the layer names defined in the specified LEF viaRuleName.

xCutSpacing yCutSpacing

> Specifies the required x and y spacing between cuts. The spacing is measured between one cut edge and the next cut edge.

xBotEnc yBotEnc xTopEnc yTopEnc

> Specifies the required x and y enclosure values for the bottom and top metal layers. The enclosure measures the distance from the cut array edge to the metal edge that encloses the cut array.

### lefwViaViaruleOffset

Writes an OFFSET statement for the via. The OFFSET statement is optional with a VIARULE statement and can be used only once in a VIA section.

#### Syntax

lefwViaViaruleOffset(
  double
xBotOffset,
  double yBotOffset,
  double xTopOffset,
  double yTopOffset)

#### Arguments

xBotOffset yBotOffset xTopOffset yTopOffset

> Specifies the x and y offset for the bottom and top metal layers. By default, the 0,0 origin of the via is the center of the cut array and the enclosing metal rectangles. These values allow each metal layer to be offset independently.
> After the non-shifted via is computed, the metal layer rectangles are offset by adding the appropriate values--the x/y BotOffset values to the metal layer below the cut layer, and the x/ y TopOffset values to the metal layer above the cut layer. These offsets are in addition to any offset caused by the ORIGIN values.

### lefwViaViaruleOrigin

Writes an ORIGIN statement for the via. The ORIGIN statement is optional with a VIARULE statement and can be used only once in a VIA section.

#### Syntax

lefwViaViaruleOrigin(
  double
xOffset,
  double yOffset)

#### Arguments

xOffset yOffset

> Specifies the x and y offset for all of the via shapes. By default, the 0,0 origin of the via is the center of the cut array and the enclosing metal rectangles. After the non-shifted via is computed, all cut and metal rectangles are offset by adding these values.

### lefwViaViarulePattern

Writes a PATTERN statement for the via. The PATTERN statement is optional with a VIARULE statement and can be used only once in a VIA section.

#### Syntax

lefwViaViarulePattern(
  const char*
cutPattern)

#### Arguments

cutPattern

> Specifies the cut pattern encoded as an ASCII string. This parameter is only required when some of the cuts are missing from the array of cuts, and defaults to "all cuts are present," if not specified.

### lefwViaViaruleRowCol

Writes a ROWCOL statement for the via. The ROWCOL statement is optional with a VIARULE statement and can be used only once in a VIA section.

#### Syntax

lefwViaViaRuleRowCol(
  int
numCutRows,
  int numCutCols)

#### Arguments

numCutRows numCutCols

> Specifies the number of cut rows and columns that make up the via array.

### Via Examples

The following example shows a callback routine with the type lefwViaCbkType.

int viaCB (lefwCallbackType_e type,
  lefiUserData userData) {
  int res;
  // Check if the type is correct
  if (type != lefwViaCbkType) {
  printf("Type is not lefwViaCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartVia("RX_PC", "DEFAULT");
  CHECK_RES(res);
  res = lefwViaResistance(2);
  CHECK_RES(res);
  res = lefwViaForeign("IN1X", 0, 0, -1);
  CHECK_RES(res);
  res = lefwViaLayer("RX");
  CHECK_RES(res);
  res = lefwViaLayerRect(-0.7, -0.7, 0.7, 0.7);
  CHECK_RES(res);
  res = lefwViaLayer("CUT12");
  CHECK_RES(res);
  res = lefwViaLayerRect(-0.25, -0.25, 0.25, 0.25);
  CHECK_RES(res);
  res = lefwRealProperty("realProperty", 32.33);
  CHECK_RES(res);
  res = lefwIntProperty("COUNT", 34);
  CHECK_RES(res);
  res = lefwEndVia("RX_PC");
  CHECK_RES(res);
  return 0;}

## Via Rule

Via Rule routines write a LEF VIARULE statement. A VIARULE or a VIARULE GENERATE statement is required in a LEF file. You can create more than one VIARULE statement in a LEF file. For syntax information about the LEF VIARULE statement, see "Via Rule" in the
LEF/DEF Language Reference.

You must use the lefwStartViaRule and lefwEndViaRule routines to start and end the VIARULE statement. The lefwViaRuleLayer and lefwViaRuleVia routines must be included between these routines.

For examples of the routines described here, see "Via Rule Examples".

In addition to the routines described in this section, you can include a PROPERTY statement within a VIARULE statement. For more information about these routines, see "Property".

All routines return 0 if successful.

### lefwStartViaRule

Starts a VIARULE statement.

#### Syntax

int lefwStartViaRule(
  const char*
viaRuleName)

#### Arguments

viaRuleName

> Specifies the name to identify the via rule.

### lefwEndViaRule

Ends the VIARULE statement for the specified viaRuleName value.

#### Syntax

int lefwEndViaRule(
  const char*
viaRuleName)

### lefwViaRuleLayer

Writes a LAYER statement. The LAYER statement is required and must be used exactly twice in a VIARULE statement.

#### Syntax

int lefwViaRuleLayer(
  const char*
layerName,
  const char* direction,
  double minWidth,
  double maxWidth,
double overhang,
double metalOverhang)

#### Arguments

layerName

> Specifies the top or bottom routing layer of the via.

direction

> Specifies the wire direction. If you specify a width range, the rule applies to wires of the specified direction that fall within the range. Otherwise, the rule applies to all wires on the layer of the specified direction.
> Value: HORIZONTAL or VERTICAL

minWidth maxWidth

> Optional arguments that specify a wire width range within which the wire must fall in order for the rule to apply. That is, the wire width must be greater than or equal to minWidth and less than or equal to maxWidth. Specify 0 to ignore these arguments.

overhang

> This argument is obsolete. Specify 0 to ignore this argument.

metalOverhang

> This argument is obsolete. Specify 0 to ignore this argument.

### lefwViaRuleVia

Writes a VIA statement. The VIA statement is required and can be used more than once after both lefwViaRuleLayer routines are used.

#### Syntax

int lefwViaRuleVia(
  const char*
viaName)

#### Arguments

viaName

> Specifies a previously defined via to test for the current via rule. The first via in the list that can be placed at the location without design rule violations is selected. The vias must all have exactly three layers in them. The three layers must include the same routing layers as listed in the LAYER statements of the VIARULE, and a cut layer that is between the two routing layers.

### Via Rule Examples

The following example shows a callback routine with the type lefwViaRuleCbkType.

int viaRuleCB(lefwCallbackType_e c, lefiUserData ud) {
  int res;
  // Check if the type is correct
  if (type != lefwViaCbkType) {
  printf("Type is not lefwViaCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartViaRule("VIALIST12");
  CHECK_RES(res);
  lefwAddComment("Break up the old lefwViaRule into 2
  routines");
  lefwAddComment("lefwViaRuleLayer and lefwViaRuleVia");
  res = lefwViaRuleLayer("M1", "VERTICAL", 9.0, 9.6, 4.5,
  0);
  CHECK_RES(res);
  res = lefwViaRuleLayer("M2", "HORIZONTAL", 3.0, 3.0, 0,
  0);
  CHECK_RES(res);
  res = lefwViaRuleVia("VIACENTER12");
  CHECK_RES(res);
  res = lefwStringProperty("vrsp", "new");
  CHECK_RES(res);
  res = lefwIntProperty("vrip", 1);
  CHECK_RES(res);
  res = lefwRealProperty("vrrp", 4.5);
  CHECK_RES(res);
  res = lefwEndViaRule("VIALIST12");
  CHECK_RES(res);
  return 0;}

## Via Rule Generate

The Via Rule Generate routines write a LEF VIARULE GENERATE statement. A VIARULE GENERATE or a VIARULE statement is required in a LEF file. You can create more than one VIARULE GENERATE statement in a LEF file. For syntax information the LEF VIARULE GENERATE statement, see "Via Rule Generate" in the LEF/DEF Language Reference.

You must use the lefwStartViaRuleGen and lefwEndViaRuleGen routines to start and end the VIARULE GENERATE statement. All other routines must be included between these routines.

Use the Via Rule Generate routines to cover special wiring that is not explicitly defined in the Via Rule routines.

All routines return 0 if successful.

### lefwStartViaRuleGen

Starts a VIARULE GENERATE statement.

#### Syntax

int lefwStartViaRuleGen(
  const char*
viaRuleName)

#### Arguments

viaRuleName

> Specifies the name for the via rule (formula).

### lefwEndViaRuleGen

Ends the VIARULE GENERATE statement for the specified viaRuleName value.

#### Syntax

int lefwEndViaRuleGen(
  const char*
viaRuleName)

### lefwViaRuleGenDefault

Writes a DEFAULT statement for the via.The DEFAULT statement specifies that the via rule can be used to generate vias for the default routing rule, and to supplement any DEFAULT fixed vias that might be predefined in the LEF VIA statement, as the router needs them. The DEFAULT statement is optional and can be used only once for a VIARULE GENERATE statement.

#### Syntax

lefwViaRuleGenDefault()

### lefwViaRuleGenLayer

Writes a routing LAYER statement. Either the routing LAYER statement or the ENCLOSURE statement is required and must be used exactly twice in a VIARULE GENERATE statement.

#### Syntax

int lefwViaRuleGenLayer(
  const char*
layerName,
  const char* direction,
  double minWidth,
  double maxWidth,
  double overhang,
  double metalOverhang)

#### Arguments

layerName

> Specifies the routing layer for the top or bottom of the via.

direction

> Specifies the wire direction. If you specify a width range, the rule applies to wires of the specified direction that fall within the range. Otherwise, the rule applies to all wires on the layer of the specified direction.
> Value: HORIZONTAL or VERTICAL

minWidth maxWidth

> Optional arguments that specify a wire width range within which the wire must fall in order for the rule to apply. That is, the wire width must be greater than or equal to minWidth and less than or equal to maxWidth. Specify 0 to ignore these arguments.

overhang

> This argument is obsolete. Specify 0 to ignore this argument.

metalOverhang

> This argument is obsolete. Specify 0 to ignore this argument.

### lefwViaRuleGenLayer3

Writes a cut LAYER statement. The cut LAYER statement is required and can be used only once after either both lefwViaRuleGenLayer, or both lefwViaRuleGenLayerEnclosure routines are used.

#### Syntax

int lefwViaRuleGenLayer3(
  const char*
layerName,
  double xl,
  double yl,
  double xh,
  double yh,
  double xSpacing,
  double ySpacing,
  double resistance)

#### Arguments

layerName

> Specifies the cut layer for the generated via.

xl yl xh yh

> Specifies the location of the lower left contact cut rectangle.

xSpacing ySpacing

> Defines center-to-center spacing in the x and y dimensions to create an array of contact cuts.The number of cuts of an array in each direction is the most that can fit within the bounds of the intersection formed by the two special wires. Cuts are only generated where they do not violate stacked or adjacent via design rules.

resistance

> Optional argument that specifies the resistance of the cut layer, given as the resistance per contact cut. Specify 0 to ignore this argument.

### lefwViaRuleGenLayerEnclosure

Writes an ENCLOSURE statement. Either the ENCLOSURE statement or the routing LAYER statement is required and must be used exactly twice in a VIARULE GENERATE statement.

#### Syntax

int lefwViaRuleGenLayerEnclosure(
  const char*
layerName,
  double overhang1,
  double overhang2,
  double minWidth,
  double maxWidth)

#### Arguments

layerName

> Specifies the routing layer for the top or bottom of the via.

overhang1 overhang2

> Specifies that the via must be covered by metal on two opposite sides by at least overhang1, and on the other two sides by at least overhang2. The via generation code then chooses the direction of overhang that best maximizes the number of cuts that can fit in the via.

minWidth maxWidth

> Optional arguments that specify a wire width range within which the wire must fall in order for the rule to apply. That is, the wire width must be greater than or equal to minWidth and less than or equal to maxWidth. Specify 0 to ignore this argument.

### Via Rule Generate Examples

The following example shows a callback routine with the type lefwViaRuleCbkType with Generate.

int viaRuleCB(lefwCallbackType_e c, lefiUserData ud) {
  int res;
  // Check if the type is correct
  if (type != lefwViaCbkType) {
  printf("Type is not lefwViaCbkType, terminate
  writing.\n");
  return 1;
  }
  res = lefwStartViaRuleGen("VIAGEN12");
  CHECK_RES(res);
  res = lefwViaRuleGenLayer("M1", "VERTICAL", 0.1, 19, 1.4,
  0);
  CHECK_RES(res);
  res = lefwViaRuleGenLayer("M2", "HORIZONTAL", 0, 0, 1.4,
  0);
  CHECK_RES(res);
  res = lefwViaRuleGenLayer3("V1", -0.8, -0.8, 0.8, 0.8,
  5.6, 6.0, 0.2);
  CHECK_RES(res);
  res = lefwEndViaRuleGen("VIAGEN12");
  CHECK_RES(res);
  return 0;}

Return to top of page

For support, see Cadence Online Support service.
Copyright © 2016, Cadence Design Systems, Inc.
All rights reserved.