Writing a C++ Pcell Generator


OpenAccess includes a Pcell evaluator plug-in named oaPcellCPP. This Pcell evaluator is for C++ based Pcells. Applications can provide Pcell generators to create content on a design through this evaluator. This Pcell evaluator uses the IPcellGen interface, which applications implement to create a Pcell generator. A Pcell generator is provided by applications in the form of a shared library. This implementation is similar to those for the primary plug-ins oaDMTurbo and oaDMFileSys. The difference between the IPcellGen plug-in and the oaDMTurbo and oaDMFileSys plug-ins is that the IPcellGen plug-in is associated with a design library instead of an OpenAccess installation.

Pcell Generators

All the shared libraries for Pcell generators must be in the design library as an oaDMFile in order for the oaPcellCPP superMaster to function properly. oaPcellCPP organizes Pcell generators by the PcellGen definitions in a design library. A PcellGen definition consists of a name, the name of a platform that its shared library supports, and the name of the oaDMFile associated with the shared library. The platform name used by oaPcellCPP to lookup a Pcell generator is obtained at runtime through the oaBuildInfo::getPlatformName() API.

PcellGen Definition Manager

A PcellGen definition manager, IPcellCPPDefMgr, is the interface provided by oaPcellCPP to facilitate Pcell generator definition management. An application uses this interface to create, modify, locate, and remove Pcell generators in a library.

An application must setup the PcellGen definitions before any superMaster is created, and modification to the definitions must be done before any superMaster is opened. Once a supermaster is opened, the associated shared library for the Pcell generator is loaded, and it cannot be unloaded and reloaded in the same process.

An application can create a IPcellCPPDefMgr by including the header file oaPcellCPPInterfaces.h and using a smart pointer as follows:

	SPtr<IPcellCPPDefMgr>	defMgr("oaPcellCPP");

The following example shows how you create a Pcell generator definition by using this definition manager:

    oaNativeNS	ns;
    oaScalarName	libName(ns, "myLib");
    oaLib		*lib = oaLib::find(libName);
    SPtr<IPcellCPPDefMgr>	pgDefMgr("oaPcellCPP");
    try {
	pgDefMgr->open(lib);
	pgDefMgr->createDef("Win32", "gateGen", "gateGen_win32", "gateGen.dll");
	pgDefMgr->createDef("sunos_58_32 Forte_8", "gateGen", "gateGen_sun32", "libgateGen.so");
	pgDefMgr->save();
	pgDefMgr->close();
    }
    catch (IException	&err) {
	pgDefMgr->close();
	printf("Error in PG def Mgr: %s\n", err.getMsg());
    }

Implementing A Pcell generator

An application implements a Pcell generator by creating a shared library that can be loaded by oaPcellCPP at runtime. The shared library is platform dependent and the application must provide a shared library for each platform that the application supports. The shared library needs to do the following:

After the shared library is created, a PcellGen definition for this generator must be defined in the library where superMasters will be created using this generator.

Implementing the Entry Point Function

Each IPcellGen plug-in shared library must implement the entry point function getClassObject(). This function must have the function prototype:

	extern "C" long	getClassObject(const char		*classID,
						  const Guid		&interfaceID,
						  void			**ptr);

In a primary plugIn, getClassObject() returns a factory, but in a Pcell generator plugIn, this function returns the IPcellGen object directly. getClassObject() is implemented this way to avoid the overhead of every generator implementing its IFactory interface. The utility class Factory from oaCommon is only suitable for primary plugIns. oaPcellCPP calls getClassObject() when it needs an IPcellGen object for its superMaster.

Implementing a Function to Validate Compatibility

A plug-in can optionally implement an ICompatibility::validate function to verify whether or not the version of OpenAccess is compatible with the plug-in. The validate() function should check the OpenAccess API version and either throw an exception with a description of the requirements or simply return false. REVIEWERS: Need to describe how an app might check if an interface has an ICompatibility component and if so, how to use it.

virtual bool                validate();

Implementing the IPcellGen Interface

An application must derive an object from IPcellGen. It can use the utility class PlugInBase to implement the IBase interfaces. An application overwrites the genPcell member function to create content in the design passed to this function. The design is usually a subMaster with a parameter list that can be obtained through the oaDesign::getParam() API. It is suggested that applications implement one Pcell generator per library, and use the argument masterType passed to the genPcell function to differentiate various content generators.

Creating oaPcellCPP superMaster

Before an oaPcellCPP supermaster is created, an oaPcellDef must be obtained from the oaPcellCPP evaluator, and the Pcell generator name and master type must be set as data values in the oaPcellDef. The Pcell generator name is specified with the data value named PcellGenName, and the master type is specified with the data value named MasterType.

A Pcell generator needs to publish its name, available master types, and its parameter list to its user for the superMaster creation. The following is an example of how you create an oaPcellCPP supermaster using a Pcell generator named gateGen, a supported master type of nand, and a parameter list that is an integer parameter name numInputs:

    oaParam	p1;
    p1.setName("numInputs");
    p1.setIntVal(2);

    oaParamArray    paramArray(1);
    paramArray.append(p1);

    oaNativeNS		ns;
    oaScalarName	libName(ns, "myLib"); 
   oaScalarName	cellName(ns, "cppPcell_master");
    oaScalarName	viewName(ns, "layout");
    oaViewType	*viewType	 = oaViewType::get(oacMaskLayout);
    oaDesign		*superMaster	= oaDesign::open(libName, cellName,
						     	     viewName,
     viewType, 'w');

    oaPcellDef		*def = oaPcellLink::getPcellDef("oaPcellCPP");

    def->addData("PcellGenName", "gateGen");
    def->addData("MasterType", "nand");

    superMaster->defineSuperMaster(def, paramArray);
    superMaster->save();

Return to top of page

Copyright © 2001-2010 Cadence Design Systems, Inc.
All rights reserved.