View Library Table of Contents Previous Next Open PDF to print book Email Comments Help Using Documentation Shut Down Cadence Documentation Server


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


2 

LEF Reader Setup and Control Routines

The Cadence® Library Exchange Format (LEF) reader provides several routines to initialize the reader and set global variables that are used by the reader.

The following routines set options for reading a LEF file.

ParagraphBullet
lefrInit
ParagraphBullet
lefrInitSession
ParagraphBullet
lefrClear
ParagraphBullet
lefrGetUserData
ParagraphBullet
lefrPrintUnusedCallbacks
ParagraphBullet
lefrRead
ParagraphBullet
lefrRegisterLef58Type
ParagraphBullet
lefrReset
ParagraphBullet
lefrSetCommentChar
ParagraphBullet
lefrSetRegisterUnusedCallbacks
ParagraphBullet
lefrSetShiftCase
ParagraphBullet
lefrSetUserData
ParagraphBullet
lefrSetVersionValue
ParagraphBullet
Examples

Calling the API Routines

Follow these steps to use the application programming interface (API) routines.

1.
Call the lefrInit() routine. You must call this routine first.
2.
Call the callback registration routines for those constructs your application uses.
3.
Call any additional setup and control routines required to prepare for reading the LEF file.
4.
Call the lefrRead() routine to start reading the LEF file.

As each construct in the LEF file is read, the reader calls the appropriate registered callbacks. These callbacks handle storing the associated data in a format appropriate for the application. The callbacks can call additional setup and control routines for the LEF reader as required.

For examples of API routine usage, see Appendix A, "LEF Reader and Writer Examples."

LEF API Routines

The following LEF reader setup and control routines are available in the API.

lefrInit

Initializes internal variables in the LEF reader. You must use this routine before using lefrRead. You can use routines to set callback functions before or after this routine.

Syntax

int lefrInit()

lefrInitSession

Starts a new parsing session and closes any old parsing session, if open. You must use this routine before using lefrRead.

Syntax

int lefrInitSession(
int startSession = 1)

Arguments

startSession

Boolean. If is non-zero, performs the parser initialization in session-based mode; otherwise, the function will initialize the parsing in the compatibility mode, working exactly as lefrInit() call.

lefrClear

Releases all parsing session data and closes the parsing session. if the call to lefrClear() is skipped, the data cleaning and the session closing is done by the next lefrInitSession() call.

Syntax

int lefrClear()

lefrGetUserData

Retrieves the user-provided data. The LEF reader returns an opaque lefiUserData pointer, which you set using lefrSetUserData. You can set or change the user data at any time with the lefrSetUserData and lefrGetUserData calls. Every callback returns the user data as the third argument.

Syntax

lefiUserData lefrGetUserData()

lefrPrintUnusedCallbacks

Prints all callback routines that are not set but have constructs in the LEF file.

Syntax

void lefrPrintUnusedCallbacks(FILE* f)

lefrRead

Specifies the LEF file to read. If the file parses with no errors (that is, all callbacks return condition codes that indicate success), this routine returns a value of 0.

Syntax

int lefrRead(
FILE* file,
const char* fileName,
lefiUserData* data)

Arguments

file

Specifies a pointer to an already open file. This allows the parser to work with either a disk file or a piped stream. This argument is required. Any callbacks that have been set will be called from within this routine.

fileName

Specifies a UNIX filename using either a complete or a relative path specification.

data

Specifies the data type. For information about the lefiUserData type, see "lefiUserData".

lefrRegisterLef58Type

Registers new LEF layers LEF58_TYPE - TYPE pairs. As LEF syntax requires that any layer LEF58_TYPE can be used only for certain layer types, you have to set a number of allowed layer LEF58_TYPE - TYPE pairs, calling the function several times (if necessary). For example, to register a new LEF58_TYPE XXX for the CUT and ROUTING type layers, you have to call the API twice:

lefrRegisterLef58Type(`XXX', `CUT');
lefrRegisterLef58Type(`XXX', `ROUTING');

Use this feature only for the development of new `experimental' types, which can now be introduced without parser code update. All types mentioned in LEF documentation are already pre-set and do not require to be registered.

Syntax

void lefrRegisterLef58Type(
const char* lef58Type,
const char* layerType);

Arguments

lef58Type

Specifies the LEF layer lef58Type.

layerType

Specifies the LEF layer type.

lefrReset

Resets all of the internal variables of the LEF reader to their initial values.

Syntax

int lefrReset(void)

lefrSetCommentChar

Changes the character used to indicate comments in the LEF file.

Syntax

void lefrSetCommentChar(char c)

c

Specifies the comment character. The default character is a pound sign (#).

lefrSetRegisterUnusedCallbacks

Keeps track of all the callback routines that are not set. You can use this routine to keep track of LEF constructs that are in the input file but do not trigger a callback. This statement does not require any additional arguments.

Syntax

void lefrSetRegisterUnusedCallbacks(void)

lefrSetShiftCase

Allows the parser to upshift all names if the LEF file is case insensitive.

Syntax

void lefrSetShiftCase(void)

lefrSetUserData

Sets the user-provided data. The LEF reader does not look at this data, but passes an opaque lefiUserData pointer back to the application with each callback. You can set or change the user data at any time using the lefrSetUserData and lefrGetUserData routines. Every callback returns the user data as the third argument.

Syntax

void lefrSetUserData(
lefiUserData* data)

Arguments

data

Specifies the user-provided data.

lefrSetVersionValue

Sets a default version number for a LEF file that does not conrtain a VERSION statement.

Syntax

void lefrSetVersionValue(
char* version)

Arguments

version

Specifies the version number to assign to the LEF file.

Examples

The following example shows how to initialize the reader.

int setupRoutine() {
FILE* f;
int res;
int userData = 0x01020304;
...
// Initialize the reader. This routine is called first.
lefrInit();
// Set user data
    lefrSetUserData ((void*)3);
// Open the lef file for the reader to read
if ((f = fopen("lefInputFileName","r")) == 0) {
printf("Couldn't open input file '%s'\n",
        "lefInputFileName");
return(2);
}
// Invoke the parser
res = lefrRead(f, "lefInputFileName", (void*)userData);
if (res != 0) {
printf("LEF parser returns an error\n");
return(2);
}
fclose(f);
return 0;}

 


Return to top of page

View Library Table of Contents Previous Next Open PDF to print book Email Comments Help Using Documentation Shut Down Cadence Documentation Server

For support, see Cadence Online Support service.

Copyright © 2016, Cadence Design Systems, Inc.
All rights reserved.