Product Documentation
Cadence Integrators Toolkit Database Reference
Product Version IC23.1, June 2023

11


CDF Read and Write Access Functions

This chapter describes Component Description Format (CDF) C-level read and write access functions for simulation applications. Read-access functions include query, CDF data retrieval, and generator functions. Write-access functions include those that create, delete, copy, update, and save data.

For more information on the use model for Component Description Format and on the CDF SKILL functions that work with the C functions described in this chapter, see the Component Description Format User Guide.

This chapter covers the following topics:

CDF Read-Access Functions

You can use CDF read-access functions to do the following:

Cadence® digital applications use CDF descriptions.

The data structures for CDF read-access functions are defined in the ITKDB/include/itkDB.h file. For an example of the use of CDF read-access functions, see the itkDB/Sample/CDF/main.c file.

Additional CDF write-access functions have been added to versions of ITKDB. For an example of the use of write-access functions, see the itkDB/Sample/CDF/CDFmainCreate.c file.

See the Component Description Format User Guide for more detailed information on CDF descriptions.

Query Functions

The following functions query existing CDF descriptions to determine if a cell or library has any base- or user-defined CDF. Use the returned CDF handle to find a specific parameter or find all the parameters. (A handle is the identifier of the CDF data object through which the CDF data is accessed.)

cdfGetLibCDF

cdfDataId
cdfGetLibCDF(
ddId libId
); 

Description

Returns the effective CDF description attached to a library. If neither a base- nor user-level CDF description is defined, the function returns cdfcNullDataId. The resulting CDF description represents the overlay of the user-level CDF onto the base-level CDF.

Arguments

libId

The database identifier of the library.

Return Values

cdfDataId

The effective CDF description attached to a library. If the library does not exist, this function returns cdfcNullDataId.

Example

cdfDataId cdfData;
ddId libId;
cdfData = cdfGetLibCDF( libId);

cdfGetBaseLibCDF

cdfDataId
cdfGetBaseLibCDF(
ddId libId
); 

Description

Returns the base-level CDF description attached to a library.

Arguments

libId

The database identifier of the library.

Return Values

cdfDataId

The base-level CDF description attached to a library. If the library does not exist, this function returns cdfcNullDataId.

Example

cdfDataId cdfData;
ddId libId;
cdfData = cdfGetBaseLibCDF( libId);

cdfGetCellCDF

cdfDataId
cdfGetCellCDF(
ddId cellId
);

Description

Returns the effective CDF description attached to a cell.The resulting CDF description represents the overlay of the user-level cell CDF onto the base-level cell CDF; the base-level cell CDF onto the user-level library CDF; and the user-level library CDF onto the base-level library CDF.

Arguments

cellId

The database identifier of the cell.

Return Values

cdfDataId

The effective CDF description attached to a cell. If the cell does not exist, or if neither a base- nor user-level CDF description is defined for the cell or its library, the function returns cdfcNullDataId.

Example

cdfDataId cdfData;
ddId cellId;
cdfData = cdfGetBaseCellCDF( cellId);

cdfGetBaseCellCDF

cdfDataId
cdfGetBaseCellCDF(
ddId cellId
);

Description

Returns the base-level CDF description attached to a cell.

Arguments

cellId

The database identifier of the specified cell.

Return Values

cdfDataId

The effective CDF description attached to a cell. If the cell does not exist, or if the base-level CDF description is not defined, this function returns cdfcNullDataId.

Example

cdfDataId cdfData;
ddId cellId;
cdfData = cdfGetBaseCellCDF( cellId);

cdfGetInstCDF

cdfDataId
cdfGetInstCDF(
dbAnyInstId anyInstId
);

Description

Returns the effective CDF description associated with an instance. The difference between the instance’s effective CDF description and the cell’s effective CDF description is that the values of any CDF parameters take into account values of the parameters stored on the instance.

Arguments

anyInstId

The database identifier of a specified instance.

Return Values

cdfDataId

The effective CDF description associated with an instance. If the instance does not exist, this function returns cdfcNullDataId.

Example

cdfDataId cdfData;
dbAnyInstId anyInstId;
cdfData = cdfGetInstCDF( anyInstId);

cdfGetCDFType

cdfDataType
cdfGetCDFType(
cdfDataId dataId
); 

Description

Returns the data type of the identifier of a CDF description.

The following table lists possible CDF types and a description of each.

CDF Data Types Description

cdfcLibDataType

Effective-level library CDF

cdfcBaseLibDataType

Base-level library CDF

cdfcUserLibDataType

User-level library CDF

cdfcCellDataType

Effective-level cell CDF

cdfcBaseCellDataType

Base-level cell CDF

cdfcUserCellDataType

User-level cell CDF

cdfcInstDataType

Effective instance CDF

Arguments

dataId

The identifier of a CDF description.

Return Values

cdfDataType

The data type of a particular identifier of a CDF description. If the dataId is not valid, cdfcUnknownDataType is returned.

Example

cdfDataType dataType;
cdfDataId dataId;
dataType = cdfGetCDFType( dataId);

CDF Data Retrieval Functions

The following functions retrieve CDF parameters and information.

cdfFindParamByName

cdfParamId
cdfFindParamByName(
cdfDataId dataId, String name
); 

Description

Returns the parameter identifier attached to a specified name and identifier of a CDF description, if the CDF description exists.

Arguments

dataId

The identifier of a CDF description.

name

The parameter name to search for.

Return Values

cdfParamId

The parameter identifier. If the parameter does not exist, this function returns cdfcNullParamId.

Example

cdfParamId param;
cdfDataId dataId;
String name;
param = cdfFindParamByName( dataId, name);

cdfGetParamRec

cdfParamRec*
cdfGetParamRec(
cdfParamId paramId
); 

Description

Returns a record structure containing the CDF parameter information about the specified parameter. The record structure is static within this routine. Subsequent calls to this function overwrite old data. The returned parameter information includes parameter type, parameter value, and default value.

Arguments

paramId

The paramId is the parameter identifier returned by either cdfFindParamByName or cdfGenParam.

Return Values

cdfParamRec

The record structure containing the CDF parameter. If the function is unable to retrieve this record structure, it returns cdfcNullParamRec.

Example

cdfParamId paramId;
cdfParamRec *paramRec;
paramRec = cdfGetParamRec( paramId);

cdfGetDataRec

cdfDataRec*
cdfGetDataRec(
cdfDataId dataId
); 

Description

Returns a record structure containing information about the CDF description. The information includes the simulation, label, and other CDF information, such as doneProc, fieldWidth, and fieldHeight. The simulation and label information is stored as a SKILL list. You need to use the IL accessing/traversing functions (such as ilCar) to convert the lists to C data types. The record structure is static within this routine. Subsequent calls to this function overwrite old data.

Arguments

dataId

The identifier of a CDF description.

Return Values

cdfDataRec

The record structure containing information about a CDF description. If the CDF description does not exist, this function returns cdfcNullDataRec.

Example

cdfDataRec *cdfData;
cdfDataId dataId;
cdfData = cdfGetDataRec( dataId);

Generator Functions

The following functions work together in the process of starting the generator, of generating, and of stopping the generator for parameters of a given CDF identifier.

cdfStartGenParam

cdfStateId
cdfStartGenParam(
cdfDataId dataId
); 

Description

Initializes the generator for generating all parameters on the specified dataId. Returns the generator state identifier. You must call cdfStopGenParam to stop the generator.

Arguments

dataId

The identifier of a CDF description.

Return Values

cdfStateId

The generator state identifier. If the CDF description does not exist, this function returns cdfcNullStateId.

Example

cdfStateId state;
cdfDataId dataId;
state = cdfStartGenParam( dataId);

cdfGenParam

Boolean
cdfGenParam(
cdfStateId state, cdfParamId *pParamId
); 

Description

Generates the parameters of a CDF description, given the generator state identifier initialized with the call to cdfStartGenParam. The generator state is updated to reflect the new state. The pParamID returns a pointer to the parameter identifier.

Arguments

state

The generator state.

pParamId

Pointer to a generated parameter identifier, if the function returns TRUE.

Return Values

Boolean

The function returns FALSE if there are no more parameters. Otherwise, the function returns TRUE.

Example

cdfStateId state;
cdfDataId dataId;
cdfParamId paramId;
state = cdfStartGenParam( dataId);
while (cdfGenParam(state, & paramId))
{/*process paramId*/}
cdfStopGen(state);

The /*process paramId*/ comment in the example indicates that you, the programmer are to specify what to do to process the paramId.

cdfStopGen

Boolean
cdfStopGen(
cdfStateId state
); 

Description

Stops the specified generator and invalidates the generator state structure at the end of the parameter generator loop.

Arguments

state

The identifier of the generator state.

Return Values

Boolean

If the state is not valid, this function returns FALSE. Otherwise, the function returns TRUE.

Example

cdfStateId state;
cdfcDataId dataId;
cdfParamId paramId;
state = cdfStartGenParam( dataId);
while (cdfGenParam(state, & paramId))
{/*process paramId*/}
cdfStopGen(state);

CDF Write-Access Functions

CDF write-access functions include those that create, delete, copy, update, or save data.

Functions to Create Data

The functions in this section create CDF information in the specified cell or library.

cdfCreateBaseCellCDF

cdfDataId
cdfCreateBaseCellCDF(
ddId cellId, String doneProc, String formInitProc, int fieldWidth, int fieldHeight, int buttonFieldWidth, int promptWidth
);

Description

Creates and returns a new identifier for a base-level CDF description (cdfDataId) of the specified cell identifier (cellId). The cell must not already have a base-level CDF description defined.

Arguments

cellId

The database identifier of the cell.

doneProc

An optional SKILL procedure name (a string) that is evaluated after any change to a parameter on a component instance. You can use doneProc for postprocessing. The procedure must take a single argument which is a list that contains the instance that has been modified.

For examples of the forms that use this argument, see Chapter 8 of the Component Description Format User Guide.

formInitProc

An optional SKILL procedure name that you specify. The procedure is executed when the contents of the CDF are displayed on a form such as the Edit Object Properties form.

This procedure runs when you use the Add Component and Edit Properties menu commands. You can use the procedure for preprocessing CDF data. This procedure must take a single argument, the cdfDataId being added to the form.

For examples of the forms that use this argument, see Chapter 8 of the Component Description Format User Guide.

When you modify a parameter field value using the formInitProc, the Edit Properties Object command for the schematic application is not aware of the modification and does not update the changes made with formInitProc. You can avoid this problem by setting the variable cdfgForm->cdfModified to the value t.

fieldWidth

The width of the field on the instantiation form. The default is 350 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

fieldHeight

The height of the field on the instantiation form. The default is 35 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

buttonFieldWidth

The width of a button on the instantiation form. The default is 350 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

promptWidth

The width of the prompt window on the instantiation form. The default is 175 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

Return Values

cdfDataId

The identifier of the CDF description. If the description does not exist, this function returns cdfcNullDataId.

Example

cdfDataId cdfData;
ddId cellId;
String doneProc;
String formInitProc;
int fieldWidth, fieldHeight, buttonFieldWidth, promptWidth;
cdfData = cdfCreateBaseCellCDF( cellId, doneProc, formInitProc,
fieldWidth, fieldHeight,
buttonFieldWidth, promptWidth);

cdfCreateBaseLibCDF

cdfDataId
cdfCreateBaseLibCDF(
ddId libId, 
String doneProc, 
String formInitProc, 
int fieldWidth, 
int fieldHeight, 
int buttonFieldWidth, 
int promptWidth 
);

Description

Creates and returns the base-level CDF description (cdfDataId) attached to a library (specified by libId). The library must not already have a base-level CDF description defined.

Arguments

libId

The database object (library identifier) to which the cdfDataId is attached.

doneProc

An optional SKILL procedure name (a string) that is evaluated after any change to a parameter on a component instance. You can use doneProc for postprocessing. The procedure must take a single argument which is a list that contains the instance that has been modified.

  

For examples of the forms that use this argument, see Chapter 8 of the Component Description Format User Guide.

formInitProc

An optional SKILL procedure name. If specified, the procedure is executed when the contents of the CDF are displayed on a form. The default value is cdfcNullDataId.

  

This procedure runs when you use the Add Component and Edit Properties commands. You can use the procedure for preprocessing CDF data. This procedure must take a single argument, the cdfDataId being added to the form.

  

For examples of the forms that use this argument, see Chapter 8 of the Component Description Format User Guide.

  

When you modify a parameter field value using the formInitProc, the Edit Properties Object command for the schematic application is not aware of the modification and does not update the changes made with formInitProc. You can avoid this problem by setting the variable

  

cdfgForm->cdfModified to the value t.

fieldWidth

The width of the field. The default is 350 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

fieldHeight

The height of the field. The default is 35 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

buttonFieldWidth

The width of the field of a button. The default is 340 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

promptWidth

The width of the prompt window. The default is 175 pixels. For examples of the forms that use this argument, see Chapter 6 of the Component Description Format User Guide.

Return Values

cdfDataId

The base-level description attached to the specified library. If the library does not exist, this function returns cdfcNullDataId.

Example

The following example, creates base Lib CDF for analogLib library:

/*ddId of analogLib */
ddId analogLibId  = ddGetObj("analogLib"); 
String doneProc = "formDoneProcedure()";
String formInitProc = "formInitProcedure()";
int fieldWidth = 350;
int fieldHeight = 35;
int buttonFieldWidth = 340;
int promptWidth = 175;
cdfDataId cdfData = cdfCreateBaseLibCDF(analogLibId,  doneProc, formInitProc, fieldWidth, fieldHeight, buttonFieldWidth, promptWidth);
 

cdfCreateParam

cdfParamId
cdfCreateParam(
cdfDataId dataId, String name, cdfParamType type, Boolean setDefValue, cdfParamValue defValue, cdfUnitType units, cdfOptBoolean parseAsNumber, unsigned int nChoices, String *choices, String prompt, String use, String display, String editable, String dontSave, String callback, cdfOptBoolean storeDefault, cdfOptBoolean parseAsCEL
);

Description

Creates and returns a new parameter with the specified attributes attached to the specified dataId. The parameter has the specified name. The new parameter's name must not match an existing parameter's name on the same dataId.

If the dataId is a baseCDF, the user must have write permission on the object of the baseCDF. If the operation is successful, the new parameter’s cdfParamId is returned.

Arguments

dataId

The identifier of the CDF description.

name

The name of the new parameter.

type

The data type of the new parameter.

setDefValue

Specifies whether to set the default value or not.

defValue

The default value for the new parameter.

units

The unit type of the parameter. You often modify parameters that represent values such as resistance, capacitance, length, time, or power, and expect to see the parameter value scaled to appropriate units (such as pF, uM, dBm). See the type cdfUnitTypeEnums in the itkDB.h file for a list of valid values for this argument.

This argument determines the units suffix and scale factor to use when displaying the parameter value. For example, by setting a parameter’s units field to capacitance, the parameter value is displayed as 5 pF instead of 5e-12.

parseAsNumber

If you specify this argument as cdfcYes, the system parses the value of a string parameter to check if the value is a number.

If the value is a number, the system converts the string to a floating point number, converts the string to the most efficient notation (taking into account any units field specified), then reconverts the number into a string.

If the parameter value is not a number, the system does no conversion.

For example, if the parameter value is the string 5.4e-12 and the parameter value has a units field of capacitance (that is, the suffix is F), the parameter value is converted to the string 5.4pF before being displayed. If, however, the parameter value is c1, no conversion takes place.

nChoices

The number of choices.

*choices

Possible values (a list of strings) of a cyclic or radio type parameter. For other types of parameters, specify as NULL and specify nChoices as 0.

prompt

Prompt that appears in a field on a form such as the Edit Object Properties form when an application asks for the value of this parameter.

use

Specifies whether to use this parameter. The use attribute is context-specific and is evaluated when necessary. In this field, you can specify parameters that you are not using because of the value of other parameters, or because of the function you are using.

The system evaluates the use field as a SKILL expression. If the argument is evaluated as non-nil, the system uses the parameter. If the argument is evaluated as nil, the system does not use the parameter. If you specify this argument as dbcNullString or NULL, t is assumed, so the system always uses the field.

See the “Global Variables” section in chapter 8 of the Component Description Format User Guide for a description of several global variables for constructing the use expression.

display

Determines if this parameter is displayed in forms that display CDF parameters, such as the Edit Properties form or the Add Component form. You must enter a string "t", "nil", or a SKILL expression that is evaluated as t or nil in this argument to determine if this parameter is to be displayed. If the argument is evaluated as non-nil (the default), the parameter is displayed. If the argument is evaluated as nil, the parameter is not displayed. If you specify this argument as dbcNullString or NULL, t is assumed and the system displays the field.

editable

the field specifies a displayed parameter that you cannot change. (Other parameters’ callbacks can change the parameter.) Use this argument only on int, float, and string type parameters.

The editable argument is evaluated as a SKILL expression.

If the argument is evaluated as non-nil, the parameter is editable. out when displayed as a form field.

If you specify this argument as dbcNullString or NULL, t is assumed, meaning that the field is editable.

dontSave

Specifies that the parameter cannot be stored in any instance that corresponds to the component.

The system evaluates the argument as a SKILL expression. If the argument is evaluated as non-nil, the parameter is not stored. If you specify this argument as dbcNullString or NULL, nil is assumed and the parameter value is stored.

This is the recommended usage. See Appendix A in the Component Description Format User Guide for additional usage advice.

callback

SKILL code to be executed whenever the value of a parameter changes. Using callback, you can cause any parameter’s value to affect any other parameter’s value. The value of this argument is a string that represents a SKILL expression or function.

This argument is optional. If you specify the callback as dbcNullString or NULL, no callback is executed.

See the “Global Variables” section in chapter 8 of the Component Description Format User Guide for a description of several global variables you can use in the callback function.

storeDefault

Specifies whether the parameter default value is saved as a property of the instance.

If set to cdfcNo (the default) or cdfcUnsetBoolean, a property is not saved on the instance when the parameter value is the default. Also, if the default value of the parameter changes, all instances that use the default automatically get the new default value. (To see the change in an open window, you must select Window – Redraw from the Cadence menu.)

If set to cdfcYes and the parameter value is set to the same value as the default, a property is saved on the instance. One disadvantage of this usage is that if the default value of a parameter changes, the default value will not change automatically on all the instances that have this parameter.

parseAsCEL

If set to cdfcYes, the associated CDF parameter is processed as a CDF Expression Language (CEL) expression. If the expression can be resolved to a numeric value (the usual case), the parseAsNumber flag should also be set to yes.

Return Value

cdfParamId

The identifier of the new parameter.

Example

The following example, creates an integer type parameter length for the cellview analogLib/cap attached to the Base CDF:

/* get cdfDataId of analogLib/cap */
ddId cellId = ddGetObj("analogLib", "cap");
cdfDataId dataId = cdfGetBaseCellCDF(cellId);
String name = "l";
cdfParamType type = cdfcIntParamType;
Boolean setDefValue = 1;
cdfParamValue defValue.aInt =  10;
cdfUnitType units = cdfcLenMetricUnit;
cdfOptBoolean parseAsNumber = cdfcYes; 
String prompt = "length";
String use = NULL;     
String display = "t"; 
String editable = "t";
String dontSave = NULL;  
String callback = "modelNameChanged()";
cdfOptBoolean storeDefault = cdfcNo;
cdfOptBoolean parseAsCEL = cdfcYes;
cdfParamId paramId = cdfCreateParam( dataId, name, type, setDefValue, defValue, units, parseAsNumber, 0, 0, prompt, use, display, editable, dontSave, callback, storeDefault, parseAsCEL);

Functions to Delete Data

The following functions delete identifier information from the specified cell or library.

cdfDeleteCDF

Boolean
cdfDeleteCDF(
cdfDataId dataId
);

Description

Deletes the specified cdfDataId from the cell or library that owns it. If the cdfDataId is a base CDF, you must have write permission.

Arguments

dataId

The identifier of the CDF description.

Return Values

Boolean

If the data identifier is not valid, the function returns FALSE.

Example

cdfDataId dataId;
cdfDeleteCDF( dataId);

cdfDeleteParam

Boolean
cdfDeleteParam(
cdfParamId paramId
);

Description

Deletes the specified cdfParamId from the cdfDataId that owns it. If this parameter is from a baseCDF, the user must have write permission on the object of the baseCDF.

Arguments

paramId

The parameter to delete.

Return Values

Boolean

If the cdfParamId is successfully deleted, TRUE is returned. The function returns FALSE, if the parameter identifier is not valid.

Example

cdfParamId paramId;
cdfDeleteParam( paramId);

Functions to Copy Data

The following functions copy identifiers to other identifiers.

cdfCopyCDF

cdfDataId
cdfCopyCDF(
ddId id, cdfDataType type, cdfDataId dataId
);

Description

Copies a CDF description to a specified identifier, changing the copy to be the specified type.

Arguments

id

Library or cell data identifier.

type

The data type of the CDF description to be copied.

dataId

The identifier of the CDF description to be copied.

Return Values

cdfDataId

The destination identifier for the description’s copy. The function returns cdfcNullDataId if the copy operation is not successful.

Example

ddId id;
cdfDataType type;
cdfDataId dataId;
cdfDataId copyId;
copyId = cdfCopyCDF( id, type, dataId);

cdfCopyParam

cdfParamId
cdfCopyParam(
cdfDataId dataId, cdfParamId paramId
);

Description

Copies the specified parameter to the specified data CDF. If the data CDF identifier is a base-level CDF description (of type baseCDF), the user must have write permission on the object of the CDF. The specified parameter must not already exist in the destination CDF.

Arguments

dataId

The data identifier of the CDF description.

paramId

The parameter identifier of the CDF description.

Return Values

cdfParamId

If the copy is successful, the new cdfParamId is returned. Otherwise, cdfcNullParamId is returned.

Example

cdfParamId destParam;
cdfDataId dataId;
cdfParamId sourceParam;
destParam = cdfCopyParam( dataId, sourceParam);

Functions to Update Data

The following functions update instances, CDFs, cells, or libraries, with the specified information.

cdfUpdateInstParam

Boolean
cdfUpdateInstParam(
dbAnyInstId anyInstId
);

Description

Stores the parameters specified in the instance master’s effective cell CDF onto the specified instance. The doneProc function is called if the instance exists.

Arguments

anyInstId

The database identifier for the instance.

Return Values

Boolean

Returns TRUE if the operation is successful.

Example

Boolean status;
ddId anyInstId;
status = cdfUpdateInstParam( anyInstId);

cdfUpdateInstSingleParam

Boolean
cdfUpdateInstSingleParam(
dbAnyInstId anyInstId, cdfParamId paramId
);

Description

Stores the specified parameter in the instance master’s effective cell CDF onto the specified instance.

Arguments

anyInstId

The database identifier of the instance.

paramId

The identifier of the parameter to be updated.

Return Values

Boolean

The function returns TRUE if the operation is successful. Otherwise, it returns FALSE.

Example

Boolean status;
dbAnyInstId anyInstId;
cdfParamId paramId;
status = cdfUpdateInstSingleParam( anyInstId, paramId);

cdfSyncInstParamValue

Boolean
cdfSyncInstParamValue(
dbAnyInstId anyInstId1, dbAnyInstId anyInstId2
);

Description

Generates all of the CDF parameters for an instance (anyInstId1) and updates a second instance (anyInstId2) to have the same values.

Arguments

anyInstId1

The parameter for which CDF parameters are being generated.

anyInstId2

The instance whose values are being updated.

Return Values

Boolean

The function returns TRUE if the operation is successful. Otherwise, the function returns FALSE.

Example

Boolean status;
dbAnyInstId anyInstId1;
dbAnyInstId anyInstId2;
status = cdfSyncInstParamValue( anyInstId1, AnyInstId2);

The Function to Save Data

The following function saves data to the cell or library that owns it.

cdfSaveCDF

Boolean
cdfSaveCDF(
cdfDataId dataId
);

Description

This function saves the specified CDF description (cdfDataId) to the cell or library that owns that CDF description.

Arguments

dataId

The identifier of the effective CDF description.

Return Values

Boolean

This function returns TRUE if the CDF description is successfully saved. Otherwise, it returns FALSE.

Example

Boolean status;
cdfDataId dataId;
status = cdfSaveCDF( dataId);


Return to top
 ⠀
X