.LEF File Format

Library Exchange Format

Introduction

LEF, the Library Exchange Format, describes as text what a chip is built from: the process layers and their rules, vias, placement sites, and the outline, pins and blockages of each cell or block. It is the library that a DEF design file refers to by name. One library is often split into a technology LEF (layers, vias, sites) and cell LEF files (macros). LEF/DEF comes from Cadence, which released its version 5.8 reader and writer as open source under the Apache 2.0 licence. This page follows the grammar of that reader.

Text rules

  • Tokens are separated by spaces, tabs or line breaks, so each semicolon needs white space before it.
  • A token beginning # starts a comment that runs to the end of the line.
  • A string in double quotes may contain spaces and may run over lines; \ makes the next character literal.
  • Characters are 7-bit ASCII.
  • From version 5.6 names are case sensitive.
  • Statements end with ;. A block such as a layer or macro opens with its keyword and name and closes with END and the same name.
  • Lengths are decimal numbers in micrometres. A point is x y, with or without brackets.
VERSION 5.8 ;
BUSBITCHARS "[]" ;
DIVIDERCHAR "/" ;
UNITS
  DATABASE MICRONS 1000 ;
END UNITS
MANUFACTURINGGRID 0.005 ;
LAYER metal1
  TYPE ROUTING ;
  DIRECTION HORIZONTAL ;
  PITCH 0.2 ;
  WIDTH 0.1 ;
  SPACING 0.1 ;
END metal1
SITE core
  CLASS CORE ;
  SIZE 0.2 BY 1.4 ;
END core
MACRO INV
  CLASS CORE ;
  ORIGIN 0 0 ;
  SIZE 0.4 BY 1.4 ;
  SITE core ;
  PIN A
    DIRECTION INPUT ;
    PORT
      LAYER metal1 ;
      RECT 0.05 0.4 0.15 0.6 ;
    END
  END A
END INV
END LIBRARY

File structure

A file is a series of statements and blocks, then optional extension blocks, then END LIBRARY, which is optional from version 5.6. The reader stops at a version newer than its own.

Statement or blockMeaning
VERSION 5.8 ;language version
NAMESCASESENSITIVE ON ; or OFF ;case of names before 5.6; obsolete from 5.6, where OFF is an error
BUSBITCHARS "[]" ;characters round a bus bit number
DIVIDERCHAR "/" ;separator in hierarchical names
UNITS … END UNITSunit scales
MANUFACTURINGGRID value ;manufacturing grid; goes after UNITS
USEMINSPACING OBS ON ;OBS or PIN, then ON or OFF
CLEARANCEMEASURE EUCLIDEAN ;EUCLIDEAN or MAXXY distance
NOWIREEXTENSIONATPIN ON ;ON or OFF
FIXEDMASK ;mask assignments are fixed
MAXVIASTACK n [RANGE bottom top] ;limit on stacked vias, optionally between two layers
PROPERTYDEFINITIONSdeclares properties
LAYER, VIA, VIARULE, SITE, MACRO, NONDEFAULTRULEnamed blocks, described below
SPACING … END SPACINGspacing between layers or nets
ARRAY namegate array description

Units

Each line of UNITS names a quantity, its unit and a factor: TIME NANOSECONDS, CAPACITANCE PICOFARADS, RESISTANCE OHMS, POWER MILLIWATTS, CURRENT MILLIAMPS, VOLTAGE VOLTS, DATABASE MICRONS (database units per micrometre) and FREQUENCY MEGAHERTZ.

Orientations

Both the DEF letters and rotation names are accepted: N = R0, W = R90, S = R180, E = R270, FN = MY, FW = MYR90, FS = MX, FE = MXR90.

Property definitions

Inside PROPERTYDEFINITIONS … END PROPERTYDEFINITIONS each line is an object type, a property name and a value type. Object types are LIBRARY, LAYER, VIA, VIARULE, NONDEFAULTRULE, MACRO, PIN and COMPONENTPIN. Value types are INTEGER and REAL (each with optional RANGE low high and value), STRING ["value"] and NAMEMAPSTRING name. Blocks then carry PROPERTY name value … ;.

Layers

LAYER name … END name. TYPE is ROUTING, CUT, MASTERSLICE, OVERLAP, IMPLANT or VIRTUAL. In the following, [ ] marks an optional part.

Geometry of wires

StatementMeaning
DIRECTION d ;preferred direction: HORIZONTAL, VERTICAL, DIAG45 or DIAG135
PITCH p ; or PITCH x y ;routing pitch; DIAGPITCH likewise
OFFSET o ; or OFFSET x y ;track offset
WIDTH w ;default wire or cut width; also MINWIDTH, MAXWIDTH, DIAGWIDTH
AREA a ;minimum area
MINENCLOSEDAREA a [WIDTH w] ;minimum area of an enclosed hole
MINSIZE x y x y … ;pairs giving minimum rectangle sizes
MINSTEP s [INSIDECORNER | OUTSIDECORNER | STEP] [LENGTHSUM l] [MAXEDGES n] ;minimum jog in an outline
PROTRUSIONWIDTH w1 LENGTH l WIDTH w2 ;protrusion rule
WIREEXTENSION e ;extension of wires past a via
HEIGHT, THICKNESS, SHRINKAGEvertical position, metal thickness, shrinkage
MASK n ;number of masks for multiple patterning

Spacing

SPACING s may be followed by CENTERTOCENTER, SAMENET [PGONLY] or PARALLELOVERLAP, and by one of these conditions, before ;:

  • LAYER other [STACK]
  • ADJACENTCUTS n WITHIN d [EXCEPTSAMEPGNET]
  • AREA a
  • RANGE low high, optionally with USELENGTHTHRESHOLD, INFLUENCE v [RANGE low high] or a second RANGE
  • LENGTHTHRESHOLD l [RANGE low high]
  • ENDOFLINE w WITHIN d [PARALLELEDGE s WITHIN d [TWOEDGES]]
  • NOTCHLENGTH l
  • ENDOFNOTCHWIDTH w NOTCHSPACING s NOTCHLENGTH l

Masterslice and overlap layers may not have SPACING. Tables replace or extend single values:

SPACINGTABLE
  PARALLELRUNLENGTH 0.0 0.5 3.0
  WIDTH 0.0   0.1 0.1 0.1
  WIDTH 0.3   0.1 0.15 0.2 ;
SPACINGTABLE INFLUENCE WIDTH 1.5 WITHIN 0.5 SPACING 0.5 ;
SPACINGTABLE TWOWIDTHS
  WIDTH 0.0           0.15 0.2
  WIDTH 0.25 PRL 0.0  0.2  0.25 ;
SPACINGTABLE ORTHOGONAL WITHIN 0.3 SPACING 0.2 ;

Each WIDTH row of a parallel-run table has as many spacings as there are lengths. A layer has at most one PARALLELRUNLENGTH or TWOWIDTHS table; INFLUENCE follows a parallel-run table. TWOWIDTHS and ORTHOGONAL need version 5.7.

Cut layers

  • ENCLOSURE [ABOVE | BELOW] overhang1 overhang2 [WIDTH w [EXCEPTEXTRACUT d]] [LENGTH l] ;
  • PREFERENCLOSURE [ABOVE | BELOW] overhang1 overhang2 [WIDTH w] ;
  • ARRAYSPACING [LONGARRAY] [WIDTH w] CUTSPACING s ARRAYCUTS n SPACING s … ; with the cut counts in rising order.
  • RESISTANCE r ; gives the resistance of a cut.

Wide metal

  • MINIMUMCUT n WIDTH w [WITHIN d] [FROMABOVE | FROMBELOW] [LENGTH l WITHIN d] ;
  • Slotting: SLOTWIREWIDTH, SLOTWIRELENGTH, SLOTWIDTH, SLOTLENGTH, MAXADJACENTSLOTSPACING, MAXCOAXIALSLOTSPACING, MAXEDGESLOTSPACING, SPLITWIREWIDTH, each with one value.
  • Density: MINIMUMDENSITY, MAXIMUMDENSITY, DENSITYCHECKWINDOW x y, DENSITYCHECKSTEP, FILLACTIVESPACING.
  • DIAGSPACING and DIAGMINEDGELENGTH cover diagonal wiring.

Electrical values

  • RESISTANCE RPERSQ r ; or RESISTANCE RPERSQ PWL ( ( width r ) … ) ;, resistance per square.
  • CAPACITANCE CPERSQDIST c ; or the same with PWL, capacitance per square unit.
  • EDGECAPACITANCE, CAPMULTIPLIER, CURRENTDEN (a value, a pair, or a PWL list).
  • ACCURRENTDENSITY PEAK | AVERAGE | RMS, followed by one value, or by a FREQUENCY list, optional CUTAREA or WIDTH list and TABLEENTRIES.
  • DCCURRENTDENSITY AVERAGE, followed by one value, or by a CUTAREA or WIDTH list and TABLEENTRIES.

Antenna rules

ANTENNAMODEL OXIDE1 to OXIDE4 selects the oxide that later values belong to. Ratios: ANTENNAAREARATIO, ANTENNACUMAREARATIO, ANTENNASIDEAREARATIO, ANTENNACUMSIDEAREARATIO, and the DIFF forms ANTENNADIFFAREARATIO, ANTENNACUMDIFFAREARATIO, ANTENNADIFFSIDEAREARATIO, ANTENNACUMDIFFSIDEAREARATIO, which take a value or a PWL ( ( x y ) … ) curve. Factors: ANTENNAAREAFACTOR and ANTENNASIDEAREAFACTOR (optionally DIFFUSEONLY), ANTENNALENGTHFACTOR. Also ANTENNACUMROUTINGPLUSCUT, ANTENNAGATEPLUSDIFF, ANTENNAAREAMINUSDIFF and ANTENNAAREADIFFREDUCEPWL.

Layer properties

Newer rules are carried as properties whose names begin LEF58_, with the rule as a quoted string that the grammar does not parse. The reader's settings register these LEF58_TYPE refinements:

RefinementLayer types
POLYROUTINGrouting
MIMCAProuting, cut
TSV, PASSIVATIONcut
TRIMPOLY, MEOLmasterslice
NWELL, PWELL, BELOWDIEEDGE, ABOVEDIEEDGE, DIFFUSION, TRIMMETALmasterslice, overlap

Vias

VIA name [DEFAULT | GENERATED] … END name has one of two bodies.

Explicit geometry

RESISTANCE r ;, then for each layer LAYER name ; followed by RECT [MASK n] pt pt ; or POLYGON [MASK n] pt pt pt … ;. FOREIGN, PROPERTY and TOPOFSTACKONLY may also appear.

Built from a via rule

VIA via1_2x2
  VIARULE via1gen ;
  CUTSIZE 0.1 0.1 ;
  LAYERS metal1 via1 metal2 ;
  CUTSPACING 0.1 0.1 ;
  ENCLOSURE 0.05 0.01 0.01 0.05 ;
  ROWCOL 2 2 ;
END via1_2x2

The five statements shown first are required in that order: rule name, cut width and height, bottom, cut and top layers, spacing between cuts, and the x and y enclosure for the bottom then the top layer. Optional: ROWCOL rows columns, ORIGIN x y, OFFSET xBottom yBottom xTop yTop and PATTERN string.

Where a via instance carries a mask number, KLayout reads its three decimal digits as the top, cut and bottom masks.

Via rules

VIARULE name [GENERATE [DEFAULT]] … END name holds layer entries, each LAYER name ; and its options, then optionally VIA name ; lines and properties. Layer options are:

  • DIRECTION HORIZONTAL ; or VERTICAL ;
  • ENCLOSURE overhang1 overhang2 ;
  • WIDTH min TO max ;
  • RECT pt pt ; and SPACING x BY y ; for the cut
  • RESISTANCE r ;
  • OVERHANG v ; and METALOVERHANG v ;

Spacing and non-default rules

The SPACING block holds lines SAMENET layer1 layer2 distance [STACK] ;.

NONDEFAULTRULE name … END name defines a wiring rule other than the default. It may hold HARDSPACING ;; layer blocks LAYER name … END name with WIDTH (first) and optionally SPACING, WIREEXTENSION, DIAGWIDTH, RESISTANCE RPERSQ, CAPACITANCE CPERSQDIST and EDGECAPACITANCE; its own VIA and SPACING blocks; USEVIA name ;, USEVIARULE name ;, MINCUTS cutLayer n ; and properties.

Sites

SITE name … END name defines a placement unit: CLASS CORE, PAD or VIRTUAL; SIZE width BY height ;; SYMMETRY with any of X, Y, R90; and ROWPATTERN site orient … ; for a site made from other sites.

Macros

MACRO name … END name describes one cell or block.

StatementMeaning
CLASS …kind of macro, see below
ORIGIN x y ;offset of the macro's coordinate origin from the lower left of its outline
SIZE width BY height ;outline size
FOREIGN name [pt] [orient] ;matching cell in a layout file
SYMMETRY X Y R90 ;allowed flips and rotation, any subset
SITE name ;site the macro occupies; may add x y orient [DO nx BY ny STEP sx sy]
EEQ name ;, LEQ name ;electrically or logically equivalent macro
SOURCE USER | GENERATE | BLOCK ;origin of the description
GENERATOR name ;, GENERATE name name ;generator names
FUNCTION BUFFER ; or INVERTER ;logic function
POWER v ;, CLOCKTYPE name ;power value, clock type
FIXEDMASK ;masks in this macro are fixed
PIN, OBS, DENSITY, TIMING, PROPERTYpins, obstructions, density, timing, properties

Classes

  • COVER [BUMP], BUMP
  • RING
  • BLOCK [BLACKBOX | SOFT]
  • PAD [INPUT | OUTPUT | INOUT | POWER | SPACER | AREAIO]
  • CORE [FEEDTHRU | TIEHIGH | TIELOW | SPACER | ANTENNACELL | WELLTAP]
  • ENDCAP PRE | POST | TOPLEFT | TOPRIGHT | BOTTOMLEFT | BOTTOMRIGHT
  • CORNER, VIRTUAL, NONE

Pins

PIN name … END name inside a macro.

StatementMeaning
DIRECTION d ;INPUT, OUTPUT [TRISTATE], INOUT or FEEDTHRU
USE u ;SIGNAL, ANALOG, POWER, GROUND, CLOCK or DATA
SHAPE s ;ABUTMENT, RING or FEEDTHRU
PORT … ENDone connection point; a pin may have several. May begin CLASS and a macro class
MUSTJOIN pin ;pin that must be connected to this one
TAPERRULE name ;wiring rule to taper to
NETEXPR "…" ;net expression
SUPPLYSENSITIVITY pin ;, GROUNDSENSITIVITY pin ;related supply and ground pins
SCANUSE u ;INPUT, OUTPUT, START or STOP
FOREIGN name [STRUCTURE] [pt] [orient] ;, LEQ name ;foreign name, equivalent pin

Antenna values on pins, each optionally followed by LAYER name: ANTENNAGATEAREA, ANTENNADIFFAREA, ANTENNAPARTIALMETALAREA, ANTENNAPARTIALMETALSIDEAREA, ANTENNAPARTIALCUTAREA, ANTENNAMETALAREA, ANTENNAMETALLENGTH, ANTENNASIZE. ANTENNAMAXAREACAR, ANTENNAMAXSIDEAREACAR and ANTENNAMAXCUTCAR require the layer. ANTENNAMODEL selects the oxide.

The grammar also accepts older electrical statements: POWER, LEAKAGE, CAPACITANCE, RESISTANCE, PULLDOWNRES, MAXDELAY, MAXLOAD, RISETHRESH, FALLTHRESH, RISESATCUR, FALLSATCUR, VLO, VHI, TIEOFFR, RISEVOLTAGETHRESHOLD, FALLVOLTAGETHRESHOLD, RISESLEWLIMIT, FALLSLEWLIMIT, CURRENTSOURCE ACTIVE | RESISTIVE, IV_TABLES name name, and INPUTNOISEMARGIN, OUTPUTNOISEMARGIN and OUTPUTRESISTANCE with two values.

Ports and obstructions

A PORT and the OBS block (OBS … END) use the same geometry list.

StatementMeaning
LAYER name [EXCEPTPGNET] [SPACING s | DESIGNRULEWIDTH w] ;layer of the following shapes
WIDTH w ;width for following paths
RECT [MASK n] pt pt ;rectangle by two corners
POLYGON [MASK n] pt pt pt … ;polygon
PATH [MASK n] pt … ;wire along points
VIA [MASK n] pt name ;via instance

Each of the last four may repeat in an array: put ITERATE after the keyword and DO nx BY ny STEP dx dy before the semicolon. For vias, ITERATE comes before MASK.

DENSITY … END lists LAYER name ; followed by RECT pt pt value ; lines giving a density for each rectangle.

Arrays

ARRAY name … END name describes a gate array.

  • SITE, CANPLACE and CANNOTOCCUPY, each followed by site x y orient [DO nx BY ny STEP sx sy] ;.
  • TRACKS X | Y start DO n STEP s LAYER names ;
  • GCELLGRID X | Y start DO n STEP s ;
  • FLOORPLAN name with CANPLACE and CANNOTOCCUPY lines, closed by END name.
  • DEFAULTCAP n with lines MINPINS pins WIRECAP value ;, closed by END DEFAULTCAP.

Older library statements

Statement or blockContent
DIELECTRIC v ;dielectric value
MINFEATURE x y ;minimum feature size
IRDROP … END IRDROPlines TABLE name value value … ; in pairs
UNIVERSALNOISEMARGIN a b ;noise margin pair
EDGERATETHRESHOLD1, EDGERATETHRESHOLD2, EDGERATESCALEFACTORone value each
NOISETABLE n ; … END NOISETABLEEDGERATE, OUTPUTRESISTANCE lists, VICTIMLENGTH and VICTIMNOISE lists; obsolete from 5.4
CORRECTIONTABLE n ; … END CORRECTIONTABLEthe same shape with CORRECTIONFACTOR lists; obsolete from 5.4
INPUTPINANTENNASIZE, OUTPUTPINANTENNASIZE, INOUTPINANTENNASIZElibrary-wide antenna sizes (5.3 syntax)
ANTENNAINPUTGATEAREA, ANTENNAINOUTDIFFAREA, ANTENNAOUTPUTDIFFAREAlibrary-wide antenna areas

Timing blocks

TIMING … END TIMING in a macro contains FROMPIN and TOPIN name lists; RISE or FALL with INTRINSIC a b, or with DELAY or TRANSITIONTIME, UNATENESS (INVERT, NONINVERT, NONUNATE) and TABLEDIMENSION a b c; TABLEAXIS and TABLEENTRIES; slope and delay coefficients such as RISERS, FALLRS, RISECS, FALLCS, RISESATT1, FALLSATT1, RISET0 and FALLT0; checks SETUP, HOLD, RECOVERY and SKEW with edges ANYEDGE, POSEDGE, NEGEDGE; MPWH, MPWL, PERIOD; STABLE SETUP a HOLD b; and the condition strings SDFCOND, SDFCONDSTART and SDFCONDEND.

Definitions and extensions

  • &DEFINE name = expression (arithmetic with IF … THEN … ELSE), &DEFINES (strings) and &DEFINEB (true or false conditions), ended by ; or a line break.
  • &ALIAS name = … &ENDALIAS defines a text substitution.
  • BEGINEXT "tag" … ENDEXT wraps a user extension that other readers can skip.

Reading the file

  • There is no signature. A LEF file usually has VERSION near the top and LAYER or MACRO blocks.
  • Layers and sites must be known before the macros that name them, so a technology file is read before cell files.
  • Macro geometry is relative to the macro's origin. KLayout draws the outline from minus ORIGIN to minus ORIGIN plus SIZE.
  • For a PATH, KLayout takes the width from the last WIDTH, or the layer's default after a LAYER line, and extends each end by half of it.
  • KLayout skips timing, array, noise table and IR drop blocks, and rejects a duplicate macro name unless told to skip it.

Not described

The explorer has no LEF viewer, so a dropped file shows as text.

Known, not yet covered

  • Reference: the exact meaning of many rules, which the Cadence LEF/DEF Language Reference defines and the grammar alone does not: how the spacing, cut array, current density, antenna, array and timing values are applied, and some of their units. That manual was not used here.
  • Reference: the text inside LEF58_ property strings.
  • Reference: limits that apply by version, and the required order of statements within blocks.
  • Viewer: no layout view.

Links

Software

  • KLayout – layout viewer and editor that imports LEF and DEF (Windows, macOS, Linux)
  • OpenROAD – open source place-and-route flow built round LEF and DEF (Linux)

Developers

  • OpenDB – archived chip database that includes the Cadence LEF/DEF reader and writer (C++)

Reference

  • lef.y – grammar of the LEF 5.8 reader, Cadence, Apache 2.0 licence
  • KLayout LEF/DEF reader – how macros, vias and shapes are turned into geometry
  • Si2 – the industry body through which LEF and DEF have been distributed