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:
- Query CDF descriptions for information.
- Access and retrieve CDF parameters and information.
- Access CDF information, including simulation and label information.
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
Return Values
|
The effective CDF description attached to a library. If the library does not exist, this function returns |
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
Return Values
|
The base-level CDF description attached to a library. If the library does not exist, this function returns |
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
Return Values
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
Return Values
|
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 |
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
Return Values
|
The effective CDF description associated with an instance. If the instance does not exist, this function returns |
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 |
Arguments
Return Values
|
The data type of a particular identifier of a CDF description. If the |
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
Return Values
|
The parameter identifier. If the parameter does not exist, this function returns |
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
|
The |
Return Values
|
The record structure containing the CDF parameter. If the function is unable to retrieve this record structure, it returns |
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
Return Values
|
The record structure containing information about a CDF description. If the CDF description does not exist, this function returns |
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
Return Values
|
The generator state identifier. If the CDF description does not exist, this function returns |
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
|
Pointer to a generated parameter identifier, if the function returns TRUE. |
Return Values
|
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
Return Values
|
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
Return Values
|
The identifier of the CDF description. If the description does not exist, this function returns |
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( ddIdlibId, StringdoneProc, StringformInitProc, intfieldWidth, intfieldHeight, intbuttonFieldWidth, intpromptWidth);
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
Return Values
|
The base-level description attached to the specified library. If the library does not exist, this function returns |
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
Return Value
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
Return Values
|
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
Return Values
|
If the |
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
Return Values
|
The destination identifier for the description’s copy. The function returns |
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
Return Values
|
If the copy is successful, the new |
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
Return Values
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
Return Values
|
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
Return Values
|
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
Return Values
|
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