# DEF 5.8 C/C++ Programming Interface -- 1
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)

# 1

# Introduction

This chapter contains the following sections:

| Overview

| DEF Reader Working Modes

| Comparison Utility

| Compressed DEF Files

| Orientation Codes

## Overview

This manual describes the application programming interface (API) routines for the following Cadence® Design Exchange Format (DEF) components:

| DEF reader

| DEF writer

Cadence Design Systems, Inc. uses these routines internally with many tools that read and write DEF. The API supports DEF version 5.8, but also reads earlier versions of DEF.

You can use the API routines documented in this manual with tools that write these older versions, as long as none of the tools in an interdependent flow introduce newer constructs.

Note: The writer portion of the API does not always optimize the DEF output.

## DEF Reader Working Modes

The DEF reader can work in two modes - compatibility mode and session-based mode.

| Compatibility mode (session-less mode) - This mode is compatible with the old parser behavior. You can call the parser initialization once with defrInit(), adjust parsing settings and initialize the parser callbacks any time. The properties once defined in PROPERTYDEFINITIONS sections will be also defined in all subsequent file reads.

| Session-based mode - This mode introduces the concept of the parsing session. In this mode, the order of calling parsing configuration and processing API is strict:

a.
Parser initialization: Call defrInitSession() instead of defrInit() to start a new parsing session and close any old parsing session, if opened.

b.
Parser configuration: Call multiple callback setters and parsing parameters setting functions.

c.
Data processing: Do one or multiple parsing of DEF files with the defrRead() function.

d.
Cleaning of the parsing configuration: Call the defrClear() function (optional). The call releases all parsing session data and closes the parsing session. If this is skipped, the data cleaning and the session closing is done by the next defrInitSession() call.

> In the session-based mode, the properties once defined in PROPERTYDEFINITIONS remain active in all the DEF file parsing cycles in the session and the properties definition data is cleaned when the parsing session ends.

> The session-based mode does not require you to call callbacks and property unsetter functions. All callbacks and properties are set to default by the next defrInitSession() call.

> The session-based mode allows you to avoid the lasting PROPERTYDEFINITIONS data effect when not required as you can just configure your application to parse one file per session.

By default, the DEF parser works in the compatibility mode. To activate the session-based mode, you must use defrInitSession() instead of defrInit().

Note: Currently, the compatibility mode can be used in all old applications where the code has not been adjusted. The def2oa translator has already been adjusted to use the session-based parsing mode.

## Comparison Utility

The DEF file comparison utility, lefdefdiff, helps you verify that your usage of the API is consistent and complete. This utility reads two DEF files, generally an initial file and the resulting file from reading in an application, then writes out a DEF file. The comparison utility reads and writes the data so that the UNIX diff utility can be used to compare the files.

Because the DEF file comparison utility works incrementally (writing out as it operates), the size of files it can process has no limitation. However, large files can have performance restrictions. In general, the utility is intended only to verify the use of the API; that is, the utility is not a component of a production design flow.

## Compressed DEF Files

The DEF reader can parse compressed DEF files. To do so, you must link the libdef.a and libdefzlib.a libraries.

A zlib compression library is also required in order to read compressed DEF files. The zlib source code is free software that can be downloaded from www.gnu.com.

For information on compressed file routines, see "DEF Compressed File Routines."

## Orientation Codes

Orientation codes are used throughout the DEF reader routines. The orientation codes are the same for all routines.

A number from 0 to 7, corresponding to the compass direction orientations, represents the orientation of a site or component. The following figure shows the combination of mirroring and rotation that is used for each of the eight possible orientations.

orient 0 = N | orient 4 = FN
orient 1 = W | orient 5 = FW
orient 2 = S | orient 6 = FS
orient 3 = E | orient 7 = FE

Note: The location given is the lower left corner of the resulting site or component after the mirroring and rotation are applied. It is not the location of the origin of the child cell.

Return to top of page

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