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

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

# 3

# DEF Reader Callback Routines

The Cadence® Design Exchange Format (DEF) reader calls all callback routines when it reads in the appropriate part of the DEF file. Some routines, such as the design name callback, are called only once. Other routines, such as the net callback, can be called more than once.

This chapter contains the following sections:

| Callback Function Format

| Callback Types and Setting Routines

| User Callback Routines

## Callback Function Format

All callback functions use the following format.

int UserCallbackFunction(
  defrCallbackType_e
callBackType
DEF_type DEF_data
defiUserData data)

Each user-supplied callback routine is passed three arguments.

### Callback Type

The callBackType argument is a list of objects that contains a unique number assignment for each callback from the parser. This list allows you to use the same callback routine for different types of DEF data.

### DEF_Data

The DEF_data argument provides the data specified by the callback. Data types returned by the callbacks vary for each callback. Examples of the types of arguments passed include const char*, double, int, and defiProp. Two points to note:

| The data returned in the callback is not checked for validity.

| If you want to keep the data, you must make a copy of it.

### User Data

The data argument is a four-byte data item that is set by the user. Note that the DEF reader contains only user data. The user data is most often set to a pointer to the design data so that it can be passed to the routines. This is more effective than using a global variable.

The callback functions can be set or reset at any time. If you want a callback to be available when the DEF file parsing begins, you must set the callback before you call defrRead.

Note: You can unset a callback by using the set function with a null argument.

## Callback Types and Setting Routines

You must set a callback before you can use it. When you set a callback, the callback routine used for each type of DEF information is passed in the appropriate setting routine. Each callback routine returns a callback type.

The following table lists the DEF reader callback setting routines and the associated callback types. The contents of the setting routines are described in detail in the section "User Callback Routines".

DEF Information | Setting Routine | Callback Types
Blockages Beginning | void defrSetBlockageStartCbk ( defrIntegerCbkFnType ) | defrBlockageStartCbkType
Blockages | void defrSetBlockageCbk ( defrBlockageCbkFnType ) | defrBlockageCbkType
Blockages End | void defrSetBlockageEndCbk ( defrVoidCbkFnType ) | defrBlockageEndCbkType
Bus Bit Characters | void defrSetBusBitCbk ( defrStringCbkFnType ) | defrBusBitCbkType
Components Beginning | void defrSetComponentStartCbk ( defrIntegerCbkFnType ) | defrComponentStartCbkType
Components | void defrSetComponentCbk ( defrComponentCbkFnType ) | defrComponentCbkType
Components End | void defrSetComponentEndCbk ( defrVoidCbkFnType | defrComponentEndCbkType
Components Mask Layer | void defrComponentMaskShiftLayerCbk ( defrComponentMaskShiftLayerCbkFnType)
| defrComponentMaskShiftLayerCbkType
Constraints Path | void defrSetPathCbk ( defrPathCbkFnType | defrPathCbkType
Design Beginning | void defrSetDesignCbk ( defrStringCbkFnType | defrDesignStartCbkType
Design End | void defrSetDesignEndCbk ( defrVoidCbkFnType ) | defrDesignEndCbkType
Die Area | void defrSetDieAreaCbk ( defrBoxCbkFnType ) | defrDieAreaCbkType
Divider Character | void defrSetDividerCbk ( defrStringCbkFnType ) | defrDividerCbkType
Extensions Components | void defrSetComponentExtCbk ( defrStringCbkFnType ) | defrComponentExtCbkType
Extensions Groups | void defrSetGroupExtCbk ( defrStringCbkFnType ) | defrGroupExtCbkType
Extensions Net | void defrSetNetExtCbk ( defrStringCbkFnType ) | defrNetExtCbkType
Extensions Net Connection | void defrSetNetConnectionExtCbk ( defrStringCbkFnType ) | defrNetConnectionExtCbkType
Extensions Pin | void defrSetPinExtCbk ( defrStringCbkFnType ) | defrPinExtCbkType
Extensions Scan Chains | void defrSetScanChainExtCbk ( defrStringCbkFnType ) | defrScanChainExtCbkType
Extensions Vias | void defrSetViaExtCbk ( defrStringCbkFnType ) | defrViaExtCbkType
Fills Beginning | void defrSetFillStartCbk ( defrIntegerCbkFnType ) | defrFillStartCbkType
Fills | void defrSetFillCbk ( defrFillCbkFnType ) | defrFillCbkType
Fills End | void defrSetFillEndCbk ( defrVoidCbkFnType ) | defrFillEndCbkType
GCell Grid | void defrSetGcellGridCbk ( defrGcellGridCbkFnType ) | defrGcellGridCbkType
Groups Beginning | void defrSetGroupsStartCbk ( defrIntegerCbkFnType ) | defrGroupsStartCbkType
Groups Name | void defrSetGroupNameCbk ( defrStringCbkFnType ) | defrGroupNameCbkType
Groups Member | void defrSetGroupMemberCbk ( defrStringCbkFnType ) | defrGroupMemberCbkType
Groups | void defrSetGroupCbk ( defrGroupCbkFnType ) | defrGroupCbkType
Groups End | void defrSetGroupsEndCbk ( defrVoidCbkFnType ) | defrGroupsEndCbkType
History | void defrSetHistoryCbk ( defrStringCbkFnType ) | defrHistoryCbkType
Nets Beginning | void defrSetNetStartCbk ( defrIntegerCbkFnType ) | defrNetStartCbkType
Nets | void defrSetNetCbk ( defrNetCbkFnType ) | defrNetCbkType
Nets End | void defrSetNetEndCbk ( defrVoidCbkFnType ) | defrNetEndCbkType
Nondefault Rules Beginning | void defrNonDefaultStartCbk (defrIntegerCbkFnType) | defrNonDefaultStartCbkType
Nondefault Rules | void defrSetNonDefaultCbk (defrNonDefaultCbkFnType) | defrNonDefaultCbkType
Nondefault Rules End | void defrNonDefaultEndCbk (defrVoidCbkFnType) | defrNonDefaultEndCbkType
Pins Beginning | void defrSetStartPinsCbk ( defrIntegerCbkFnType ) | defrStartPinsCbkType
Pins | void defrSetPinCbk ( defrPinCbkFnType ) | defrPinCbkType
Pins End | void defrSetPinEndCbk ( defrVoidCbkFnType ) | defrPinEndCbkType
Pin Properties Beginning | void defrSetPinPropStartCbk ( defrIntegerCbkFnType ) | defrPinPropStartCbkType
Pin Properties | void defrSetPinPropCbk ( defrPinPropCbkFnType ) | defrPinPropCbkType
Pin Properties End | void defrSetPinPropEndCbk ( defrVoidCbkFnType ) | defrPinPropEndCbkType
Property Definitions Beginning | void defrSetPropDefStartCbk ( defrVoidCbkFnType ) | defrPropDefStartCbkType
Property Definitions | void defrSetPropCbk ( defrPropCbkFnType ) | defrPropCbkType
Property Definitions End | void defrSetPropDefEndCbk ( defrVoidCbkFnType ) | defrPropDefEndCbkType
Regions Beginning | void defrSetRegionStartCbk ( defrIntegerCbkFnType ) | defrRegionStartCbkType
Regions | void defrSetRegionCbk ( defrRegionCbkFnType ) | defrRegionCbkType
Regions End | void defrSetRegionEndCbk ( defrVoidCbkFnType ) | defrRegionEndCbkType
Rows | void defrSetRowCbk ( defrRowCbkFnType ) | defrRowCbkType
Scan Chains Beginning | void defrSetScanchainsStartCbk ( defrIntegerCbkFnType ) | defrScanchainsStartCbkType
Scan Chains | void defrSetScanchainCbk ( defrScanchainCbkFnType ) | defrScanchainCbkType
Scan Chains End | void defrSetScanchainsEndCbk ( defrVoidCbkFnType ) | defrScanchainsEndCbkType
Slots Beginning | void defrSetSlotStartCbk (defrIntegerCbkFnType) | defrSlotStartCbkType
Slots | void defrSetSlotCbk (defrSlotCbkFnType) | defrSlotCbkType
Slots End | void defrSlotEndCbk ( defrVoidCbkFnType ) | defrSlotEndCbkType
Special Nets Beginning | void defrSetSNetStartCbk ( defrIntegerCbkFnType ) | defrSNetStartCbkType
Special Nets | void defrSetSNetCbk ( defrNetCbkFnType ) | defrSNetCbkType
Special Nets End | void defrSetSNetEndCbk ( defrVoidCbkFnType ) | defrSNetEndCbkType
Styles Beginning | void defrSetStylesStartCbk ( defrIntegerCbkFnType) | defrStylesStartCbkType
Styles | void defrSetStylesCbk ( defrStylesCbkFnType) | defrStylesCbkType
Styles End | void defrSetStylesEndCbk ( defrVoidCbkFnType) | defrStylesEndCbkType
Technology | void defrSetTechnologyCbk ( defrStringCbkFnType ) | defrTechNameCbkType
Tracks | void defrSetTrackCbk ( defrTrackCbkFnType ) | defrTrackCbkType
Units | void defrSetUnitsCbk ( defrDoubleCbkFnType ) | defrUnitsCbkType
Version | void defrSetVersionCbk ( defrDoubleCbkFnType ) | defrVersionCbkType
Version String | void defrSetVersionStrCbk ( defrStringCbkFnType ) | defrVersionStrCbkType
Vias Beginning | void defrSetViaStartCbk ( defrIntegerCbkFnType ) | defrViaStartCbkType
Vias | void defrSetViaCbk ( defrViaCbkFnType ) | defrViaCbkType
Vias End | void defrSetViaEndCbk ( defrVoidCbkFnType ) | defrViaEndCbkType

### Examples

The following example shows how to create a setup routine so the reader can parse the DEF file and call the callback routines you defined.

int setupRoutine() {
  FILE* f;
  int res;
  int userData = 0x01020304;
  ...

  // Initialize the reader. This routine has to call first.
  defrInit();

  // Set the user callback routines
  defrSetDesignCbk(designCB);
  defrSetTechnologyCbk(technologyCB);
  defrSetDesignEndCbk(designEndCB);
  defrSetPropCbk(propertyDefCB);
  defrSetPropDefEndCbk(properyDefEndCB);
  defrSetNetCbk(netCB);
  ...

  defrSetRegisterUnusedCallback();
  // Open the def file for the reader to read
  if ((f = fopen("defInputFileName","r")) == 0) {
  printf("Couldn't open input file '%s'\n",
  "defInputFileName");
  return(2);
  }
  // Invoke the parser
  res = defrRead(f, "defInputFileName", (void*)userData);
  if (res != 0) {
  printf("DEF parser returns an error\n");
  return(2);
  }
  (void)defrPrintUnusedCallbacks(f);
  fclose(f);
  return 0;}

## User Callback Routines

This section describes the following routines:

| defrBlockageCbkFnType

| defrBoxCbkFnType

| defrComponentCbkFnType

| defrComponentMaskShiftLayerCbkFnType

| defrDoubleCbkFnType

| defrFillCbkFnType

| defrGcellGridCbkFnType

| defrGroupCbkFnType

| defrIntegerCbkFnType

| defrNetCbkFnType

| defrNonDefaultCbkFnType

| defrPathCbkFnType

| defrPinCbkFnType

| defrPinPropCbkFnType

| defrPropCbkFnType

| defrRegionCbkFnType

| defrRowCbkFnType

| defrScanchainCbkFnType

| defrSlotCbkFnType

| defrStringCbkFnType

| defrStylesCbkFnType

| defrTrackCbkFnType

| defrViaCbkFnType

| defrVoidCbkFnType

### defrBlockageCbkFnType

Retrieves data from the BLOCKAGES statement in the DEF file. Use the arguments defined in the defiBlockage class to retrieve the data. For syntax information about the DEF BLOCKAGES statement, see Blockages in the LEF/DEF Language Reference.

#### Syntax

int defrBlockageCbkFnType(
  defrCallbackType_e
typ,
  defiBlockage* blockage,
  defiUserData* data)

#### Arguments

typ

> Returns the defrBlockageCbkType type, which indicates that the blockage callback was called.

blockage

> Returns a pointer to a defiBlockage structure. For more information, see defiBlockage.

data

> Returns four bytes of user-defined data. User data is most often set to a pointer to the design data.

### defrBoxCbkFnType

Retrieves data from the DIEAREA statement in the DEF file. Use the arguments defined in the defiBox class to retrieve the data. For syntax information about the DEF DIEAREA statement, see Die Area in the LEF/DEF Language Reference.

#### Syntax

int defrBoxCbkFnType(
  defrCallbackType_e
typ,
  defiBox* box,
  defiUserData* data)

#### Arguments

typ

> Returns the defrDieAreaCbkType type, which indicates that the die area callback was called.

box

> Returns a pointer to a defiBox structure. For more information, see defiBox.

data

> Returns four bytes of user-defined data. User data is most often set to a pointer to the design data.

### defrComponentCbkFnType

Retrieves data from the COMPONENTS statement in the DEF file. Use the arguments defined in the defiComponent class to retrieve the data. For syntax information about the DEF COMPONENTS statement, see Components in the LEF/DEF Language Reference.

#### Syntax

int defrComponentCbkFnType(
  defrCallbackType_e
typ,
  defiComponent* comp,
  defiUserData* data)

#### Arguments

typ

> Returns the defrComponentCbkType, which indicates that the component callback was called.

comp

> Returns a pointer to a defiComponent structure. For more information, see defiComponent.

data

> Returns four bytes of user-defined data. User data is most often set to a pointer to the design data.

### defrComponentMaskShiftLayerCbkFnType

Retrieves data from the COMPONENTMASKSHIFT statement of the DEF file. The format of the data returned is always the same, but the actual data represented varies depending on the calling routine.

For syntax information about the DEF COMPONENTMASKSHIFT statement, see "Component Mask Shift" in the LEF/DEF Language Reference.

#### Syntax

int defrComponentMaskShiftLayerCbkFnType (
  defrCallbackType_e
type,
  defiComponentMaskShiftLayer* shiftLayers,
  defiUserData* data)

#### Arguments

type

> Returns the defrComponentMaskShiftLayerCbkFnType. This allows you to verity within your program that this is a correct callback.

shiftLayers

> Returns a pointer to a defiComponentMaskShiftLayer. For more information, see defiComponentMaskShiftLayer.

data

> Returns four bytes of user-defined data. User data is most often set to a pointer to the design data.

### defrDoubleCbkFnType

Retrieves data from the UNITS and VERSION statements of the DEF file. The format of the data returned is always the same, but the actual data represented varies depending on the calling routine.

For syntax information about the DEF UNITS and VERSION statements, see Units and Version in the LEF/DEF Language Reference.

Note: DEF version 5.1 and later always has a version number. Earlier versions of DEF will not have a version number.

#### Syntax

int defrDoubleCbkFnType(
  defrCallbackType_e
typ,
  double* number,
  defiUserData* data)

#### Arguments

typ

> Returns a type that varies depending on the callback routine used. The following types can be returned.

DEF Data | Type Returned
Units | defrUnitsCbkType
Version | defrVersionCbkType

number

> Returns data that varies depending on the callback used. The following kinds of data can be returned.

DEF Data | Returns the Value of
Units | DEFconvertFactor in the UNITS statement
Version | versionNumber in the VERSION statement

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

#### Examples

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

int versionCB (defrCallbackType_e type,
  double versionNum,
  defiUserData userData) {
  // Check if the type is correct
  if (type != defrVersionCbkType) {
  printf("Type is not defrVersionCbkType, terminate
  parsing.\n");
  return 1;
  }

// Write out the version number
  printf("VERSION %g\n", versionNum);
  return 0;}

### defrFillCbkFnType

Retrieves data from the FILLS statement in the DEF file. Use the arguments defined in the defiFill class to retrieve the data. For syntax information about the DEF FILLS statement, see Fills in the LEF/DEF Language Reference.

#### Syntax

int defrFillCbkFnType(
  defrCallbackType_e
typ,
  defiFill* fill,
  defiUserData* data)

#### Arguments

typ

> Returns the defrFillCbkFnType, which indicates that the fill callback was called.

fill

> Returns a pointer to a defifill structure. For more information, see defiFill.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrGcellGridCbkFnType

Retrieves data from the GCELLGRID statement in the DEF file. Use the arguments defined in the defiGcellGrid class to retrieve the data. For syntax information about the DEF GCELLGRID statement, see GCell Grid in the LEF/DEF Language Reference.

#### Syntax

int defrGcellGridCbkFnType(
  defrCallbackType_e
typ,
  defiGcellGrid* grid,
  defiUserData* data)

#### Arguments

typ

> Returns the defrGcellGridCbkType, which indicates that the gcell grid callback was called.

grid

> Returns a pointer to a defiGcellGrid structure. For more information, see defiGcellGrid.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrGroupCbkFnType

Retrieves data from the GROUPS statement in the DEF file. Use the arguments defined in the defiGroup class to retrieve the data. For syntax information about the DEF GROUPS statement, see Groups in the LEF/DEF Language Reference.

#### Syntax

int defrGroupCbkFnType(
  defrCallbackType_e
typ,
  defiGroup* group,
  defiUserData* data)

#### Arguments

typ

> Returns the defrGroupCbkType, which indicates that the group callback was called.

group

> Returns a pointer to a defiGroup structure. For more information, see defiGroup.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrIntegerCbkFnType

Marks the beginning of sections of DEF statements. The format of the data returned is always the same, but the actual data represented varies depending on the calling routine.

#### Syntax

int defrIntegerCbkFnType(
  defrCallbackType_e
typ,
  int number,
  defiUserData* data)

#### Arguments

typ

> Returns a type that varies depending on the callback routine used. The following types can be returned.

DEF Data | Type Returned
Blockages | defrBlockageStartCbkType
Components | defrComponentStartCbkType
Fills | defrFillStartCbkType
Groups | defrGroupsStartCbkType
Nets | defrNetStartCbkType
Nondefault Rules | defrNonDefaultStartCbkType
Pin Properties | defrPinPropStartCbkType
Pins | defrStartPinsCbkType
Regions | defrRegionStartCbkType
Scan Chains | defrScanchainsStartCbkType
Slots | defrSlotStartCbkType
Special Nets | defrSNetStartCbkType
Styles | defrStylesStartCbkType
Vias | defrViaStartCbkType

number

> Returns data that varies depending on the callback used. The following kinds of data can be returned.

DEF Data | Returns the Value of
Blockages | numBlockages in the BLOCKAGES statement
Components | numComps in the COMPONENTS statement
Fills | numFills in the FILLS statement
Groups | numGroups in the GROUPS statement
Nets | numNets in the NETS statement
Nondefault rules | numRules in the NONDEFAULTRULES statement
Pin Properties | num in the PINPROPERTIES statement
Pins | numPins in the PINS statement
Regions | numRegions in the REGIONS statement
Scan Chains | numScanChains in the SCANCHAINS statement
Slots | numSlots in the SLOTS statement
Special Nets | numNets in the SPECIALNETS statement
Styles | numStyles in the STYLES statement
Vias | numVias in the VIAS statement

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrNetCbkFnType

Retrieves data from the NETS and SPECIALNETS sections of the DEF file. Use the arguments defined in the defiNet class to retrieve the data.

For syntax information about the DEF NETS and SPECIALNETS statements, see Nets and Special Nets in the LEF/DEF Language Reference.

#### Syntax

int defrNetCbkFnType(
  defrCallbackType_e
typ,
  defiNet* net,
  defiUserData* data)

#### Arguments

typ

> Returns a type that varies depending on the callback routine used. The following types can be returned.

DEF Data | Type Returned
Net | defrNetCbkType
Special Nets | defrSNetCbkType

net

> Returns a pointer to a defiNet structure. For more information, see defiNet.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrNonDefaultCbkFnType

Retrieves data from the NONDEFAULTRULES statement in the DEF file. Use the arguments defined in the defiNonDefault class to retrieve the data. For syntax information about the DEF NONDEFAULTRULES statement, see "Nondefault Rules," in the LEF/DEF Language Reference.

#### Syntax

int defrNonDefaultCbkFnType(
  defrCallbackType_e
typ,
  defiNonDefault* rule,
  defiUserData* data)

#### Arguments

typ

> Returns the defrNonDefaultCbkType type, which indicates that the nondefault rule callback was called.

rule

> Returns a pointer to a defiNonDefault structure. For more information, see defiNonDefault.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrPathCbkFnType

Retrieves data from the regularWiring and specialWiring specifications in the NETS and SPECIALNETS statements of the DEF file. Use the arguments defined in the defiPath class to retrieve the data.

For syntax information about the DEF NETS and SPECIALNETS statements, see Nets and Special Nets in the LEF/DEF Language Reference.

#### Syntax

int defrPathCbkFnType(
  defrCallbackType_e
typ,
  defiPath* path,
  defiUserData* data)

#### Arguments

typ

> Returns the defrPathCbkType type, which indicates that the path callback was called.

path

> Returns a pointer to a defiPath structure. For more information, see defiPath.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrPinCbkFnType

Retrieves data from the PINS statement in the DEF file. Use the arguments defined in the defiPin class to retrieve the data. For syntax information about the DEF PINS statement, see Pins in the LEF/DEF Language Reference.

#### Syntax

int defrPinCbkFnType(
  defrCallbackType_e
typ,
  defiPin* pin,
  defiUserData* data)

#### Arguments

typ

> Returns the defrPinCbkType type, which indicates that the Pin callback was called.

pin

> Returns a pointer to a defiPin structure. For more information, see defiPin.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrPinPropCbkFnType

Retrieves data from the PINPROPERTIES statement in the DEF file. Use the arguments defined in the defiPinProp class to retrieve the data. For syntax information about the DEF PINPROPERTIES statement, see Pin Properties in the LEF/DEF Language Reference.

#### Syntax

int defrPinPropCbkFnType(
  defrCallbackType_e
typ,
  defiPinProp* pp,
  defiUserData* data)

#### Arguments

typ

> Returns the defrPinPropCbkType type, which indicates that the pin property callback was called.

pp

> Returns a pointer to a defiPinProp structure. For more information, see defiPinProp.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrPropCbkFnType

Retrieves data from the PROPERTYDEFINITIONS statement in the DEF file. Use the arguments defined in the defiProp class to retrieve the data. For syntax information about the DEF PROPERTYDEFINITIONS statement, see Property Definitions in the LEF/DEF Language Reference.

#### Syntax

int defrPropCbkFnType(
  defrCallbackType_e
typ,
  defiProp* prop,
  defiUserData* data)

#### Arguments

typ

> Returns the defrPropCbkType type, which indicates that the property callback was called.

prop

> Returns a pointer to a defiProp structure. For more information, see defiProp.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrRegionCbkFnType

Retrieves data from the REGIONS statement in the DEF file. Use the arguments defined in the defiRegion class to retrieve the data. For syntax information about the DEF REGIONS statement, see Regions in the LEF/DEF Language Reference.

#### Syntax

int defrRegionCbkFnType(
  defrCallbackType_e
typ,
  defiRegion* reg,
defiUserData* data)

#### Arguments

typ

> Returns the defrRegionCbkType type, which indicates that the region callback was called.

reg

> Returns a pointer to a defiRegion structure. For more information, see defiRegion.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrRowCbkFnType

Retrieves data from the ROWS statement in the DEF file. Use the arguments defined in the defiRow class to retrieve the data. For syntax information about the DEF ROWS statement, see Rows in the LEF/DEF Language Reference.

#### Syntax

int defrRowCbkFnType(
  defrCallbackType_e
typ,
  defiRow* row,
  defiUserData* data)

#### Arguments

typ

> Returns the defrRowCbkType type, which indicates that the row callback was called.

row

> Returns a pointer to a defiRow structure. For more information, see defiRow.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrScanchainCbkFnType

Retrieves data from the SCANCHAINS statement in the DEF file. Use the arguments defined in the defiScanchain class to retrieve the data. For syntax information about the DEF SCANCHAINS statement, see Scan Chains in the LEF/DEF Language Reference.

#### Syntax

int defrScanchainCbkFnType(
  defrCallbackType_e
typ,
  defiScanchain* sc,
  defiUserData* data)

#### Arguments

typ

> Returns the defrScanchainCbkType type, which indicates that the scan chains callback was called.

sc

> Returns a pointer to a defiScanchain structure. For more information, see defiScanchain.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrSlotCbkFnType

Retrieves data from the SLOTS statement in the DEF file. Use the arguments defined in the defiSlot class to retrieve the data. For syntax information about the DEF SLOTS statement, see Slots in the LEF/DEF Language Reference.

#### Syntax

int defrSlotCbkFnType(
  defrCallbackType_e
typ,
  defiSlot* slot,
  defiUserData* data)

#### Arguments

typ

> Returns the type, defrSlotCbkFnType, which indicates that the slot callback was called.

slot

> Returns a pointer to a defiSlot structure. For more information, see defiSlot.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data

### defrStringCbkFnType

Retrieves different kinds of LEF data. The format of the data returned is always the same, but the actual data represented varies depending on the calling routine.

#### Syntax

int defrStringCbkFnType(
  defrCallbackType_e
typ,
  const char* string,
  defiUserData* data)

#### Arguments

typ

> Returns a type that varies depending on the callback routine used. The following types can be returned.

DEF Data | Type Returned
Bus Bit Characters | defrBusBitCbkType
Design | defrDesignStartCbkType
Component Extension | defrComponentExtCbkType
Divider Character | defrDividerCbkType
Group Extension | defrGroupExtCbkType
Groups Member | defrGroupMemberCbkType
Groups Name | defrGroupNameCbkType
History | defrHistoryCbkType
Net Connection Extension | defrNetConnectionExtCbkType
Net Extension | defrNetExtCbkType
Pin Extension | defrPinExtCbkType
Scan Chain Extension | defrScanChainExtCbkType
Technology | defrTechNameCbkType
Version | defrVersionStrCbkType
Via Extension | defrViaExtCbkType

string

> The data returned varies depending on the callback used.The following table shows the kinds of data returned.

DEF Data | Returns a Value of
Bus Bit Characters | delimiterPair in the BUSBITCHARS statement
Design | designName in the DESIGN statement
Component Extension | tag in the EXTENSIONS statement
Divider Character | character in the DIVIDERCHAR statement
Group Extension | tag in the EXTENSION statement
Groups Member | compNameRegExpr in the GROUPS statement
Groups Name | groupName in the GROUPS statement
History | anyText in the HISTORY statement
Net Connection Extension | tag in the EXTENSION statement
Net Extension | tag in the EXTENSION statement
Pin Extension | tag in the EXTENSION statement
Scan Chain Extension | tag in the EXTENSION statement
Technology | technologyName in the TECHNOLOGY statement
Version | versionNumber in VERSION statement
Via Extension | tag in the EXTENSION statement

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrStylesCbkFnType

Retrieves data from the STYLES statement in the DEF file. Use the arguments defined in the defiStyles class to retrieve the data. For syntax information about the DEF STYLES statement, see "Styles," in the LEF/DEF Language Reference.

#### Syntax

defrStylesCbkFnType(
  defCallbackType_e
typ,
  defiStyles* style,
  defiUserData* data)

#### Arguments

typ

> Returns the defrStylesCbkType, which indicates that the style callback was called.

style

> Returns a pointer to a defiStyles structure. For more information, see defiStyles.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrTrackCbkFnType

Retrieves data from the TRACKS statement in the DEF file. Use the arguments defined in the defiTrack class to retrieve the data. For syntax information about the DEF TRACKS statement, see Tracks in the LEF/DEF Language Reference.

#### Syntax

int defrTrackCbkFnType(
  defrCallbackType_e
typ,
  defiTrack* track,
  defiUserData* data)

#### Arguments

typ

> Returns the defrTrackCbkType, which indicates that the track callback was called.

sc

> Returns a pointer to a defiTrack structure. For more information, see defiTrack.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrViaCbkFnType

Retrieves data from the VIAS statement in the DEF file. Use the arguments defined in the defiVia class to retrieve the data. For syntax information about the DEF VIAS statement, see Vias in the LEF/DEF Language Reference.

#### Syntax

int defrViaCbkFnType(
  defrCallbackType_e
typ,
  defiVia* via,
  defiUserData* data)

#### Arguments

typ

> Returns the defrViaCbkType, which indicates that the via callback was called.

via

> Returns a pointer to a defiVia structure. For more information, see defiVia.

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### defrVoidCbkFnType

Marks the end of DEF data sections. The format of the data returned is always the same, but the actual data represented varies depending on the calling routine.

#### Syntax

int defrVoidCbkFnType(
  defrCallbackType_e
typ,
  void* variable,
  defiUserData* data)

#### Arguments

typ

> Returns a type that varies depending on the callback routine used. The following types can be returned.

DEF Data | Type Returned
Blockages, End | defrBlockageEndCbkType
Component, End | defrComponentEndCbkType
Design, End | defrDesignEndCbkType
Fills, End | defrFillEndCbkType
Groups, End | defrGroupsEndCbkType
Net, End | defrSNetEndCbkType
Nondefault Rules, End | defrNonDefaultEndCbkType
Pin Properties, End | defrPinPropEndCbkType
Pins, End | defrPinEndCbkType
Property Definitions, End | defrPropDefEndCbkType
Property Definitions, Start | defrPropDefStartCbkType
Region, End | defrRegionEndCbkType
Scan Chains, End | defrConstraintsEndCbkType
Slots, End | defrSlotEndCbkType
Special Nets, End | defrSNetEndCbkType
Styles, End | defrStylesEndCbkType
Via, End | defrViaEndCbkType

variable

> Returns data that varies depending on the callback used. The following kinds of data can be returned. For all data types, the variable returns NULL.

DEF Data
Blockages, End |
Component, End |
Design, End |
Fills, End |
Groups, End |
Net, End |
Nondefault Rules, End |
Pins, End |
Pin Properties, End |
Property Definitions, End |
Property Definitions Start |
Region, End |
Scan Chains, End |
Slots, End |
Special Nets, End |
Styles, End |
Via, End |

data

> Specifies four bytes of user-defined data. User data is set most often to a pointer to the design data.

### Examples

The following example shows a callback routine using the arguments for defrCallbackType_e, char*, and defiUserData.

int designCB (defrCallbackType_e type,
  const char *designName,
  defiUserData userData) {
  // Incorrect type was passed in, expecting the type defrDesignStartCbk
  Type
  if (type != defrDesignStartCbkType) {
  printf("Type is not defrDesignStartCbkType,
  terminate parsing.\n");
  return 1;}
  // Expect a non null char* designName
  if (!designName || !*designName) {
  printf("Design name is null, terminate parsing.\n");
  return 1;}
  // Write out the design name
  printf("design name is %s\n", desginName);
  return 0;}

The following example shows a callback routine using the arguments for defrCallbackType_e, int, and defiUserData.

int viaStartCB (defrCallbackType_e c,
  int numVias,
  defiUserData ud) {
  // Check if the type is correct
  if (type != defrViaStartCbkType) {
  printf("Type is not defrViaStartCbkType, terminate
  parsing.\n");
  return 1;}
  printf("VIA %d\n", numVias);
  return 0;}

The following example shows a callback routine using the arguments for defrCallbackType_e, defiVia, and defiUserData.

int viaCB (defrCallbackType_e type,
  defiVia *viaInfo,
  defiUserData userData) {
  int i, xl, yl, xh, yh;
  char *name
  // Check if the type is correct
  if (type != defrViaCbkType) {
  printf("Type is not defrViaCbkType, terminate
  parsing.\n");
  return 1;}
  printf("VIA %s\n", viaInfo->name());
  if (viaInfo->hasPattern())
  printf(" PATTERNNAME %s\n", viaInfo->pattern());
  for (i = 0; i < viaInfo->numLayers(); i++) {
  viaInfo->layer(i, &name, &xl, &yl, &xh, &yh);
  printf(" RECT %s %d %d %d %d\n", name, xl, yl, xh, yh);}
  return 0;}

Return to top of page

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