• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How to pass parameters to sub-cells parameter in pcell?

Stats

  • Replies 2
  • Subscribers 143
  • Views 325
  • Members are here 0

How to pass parameters to sub-cells parameter in pcell?

Yuto Lau
Yuto Lau 2 days ago

Hi everyone,

Based on Andrew's bussetp.il script, (the script is in this link: https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1Od0000000nX1lEAE&pageName=ArticleContent.)

I want to add two cell "vdc" from analogLib into pcell "bussetp", and assign parameter "vhi" and "vlo" as the value of vdc. And I want "vhi" and "vlo" to be  type "string", so that I can assign either number or variable as its value in simulation. I insert below script in the schematic section. With the new script, pcell is created successfully, but whenever I assign a variable, like "vhigh", to parameter "vhi", there is a warning in CIW 

*WARNING* (DB-270000): dbReplaceInstParamList: Datatype for input parameter 'vhi' does not match the definition.

Moreover, if "vhi" and "vlo" value is a string, I have to place the symbol in the schematic first, and then fill in the string in CDF window. Otherwise, all parameters' value remain as default value regardless my edit.

It looks that I did not define "vhi" and "vlo" in a correct way. I would like to know how to define them and assign value to them correctly. Or any other reason to the warning and weird issue in schematic edit.

Regards,

Yutao 

Below is script for inserting cell vdc and assign its value in pcell "bussetp".
;----------------------------------------------------------------
;Create vdc instances for hi and lo
;----------------------------------------------------------------
vhiInst = dbCreateInst(cv vdcMaster "VHI_SRC" -1:0 "R0")
vloInst = dbCreateInst(cv vdcMaster "VLO_SRC" -1:-0.5 "R0")
;----------------------------------------------------------------
; Set DC voltage parameters
;----------------------------------------------------------------
vhiInst->vdc = sprintf(nil "pPar(\"vcvs_hi\")")
vloInst->vdc = sprintf(nil "pPar(\"vcvs_lo\")")
;----------------------------------------------------------------
;Connect Nets to vdc
;----------------------------------------------------------------
dbCreateConnByName(netH vhiInst "PLUS")
dbCreateConnByName(gnd vhiInst "MINUS")
dbCreateConnByName(netL vloInst "PLUS")
dbCreateConnByName(gnd vloInst "MINUS")

  • Sign in to reply
  • Cancel
Parents
  • Yuto Lau
    Yuto Lau 1 day ago

    Include parameter definition in CDF section as below. Tried to make "vhi", "vlo" the same type as "busvalue".

    Because "busvalue" can support either numeric value or string value, without any issue.

    ;;; Parameters
    cdfCreateParam( cdfId
    ?name "mode"
    ?prompt "Encoding Mode"
    ?defValue "binary"
    ?type "cyclic"
    ?choices '("binary" "thermometer" "onehot")
    ?display "t"
    )

    cdfCreateParam( cdfId
    ?name "buswidth"
    ?prompt "Bus Width"
    ?defValue 6
    ?type "int"
    ?display "t"
    )
    cdfCreateParam( cdfId
    ?name "busvalue"
    ?prompt "Bus Value"
    ?defValue "0"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    cdfCreateParam( cdfId
    ?name "vhi"
    ?prompt "Voltage High"
    ?defValue "1"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    cdfCreateParam( cdfId
    ?name "vlo"
    ?prompt "Voltage Low"
    ?defValue "0"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Andrew Beckett
    Andrew Beckett 1 day ago in reply to Yuto Lau

    I don't get that error with those modifications to my code (I omitted the "Encoding Mode" parameter, because I didn't implement that). Note that I had to also change the parameters passed in the pPar because they didn't match your CDF parameters (this didn't cause the error you saw, just that it wouldn't work correctly as vcvs_hi wasn't defined otherwise). Here's the code (indentation not fixed - the unindented parts are the changed pieces - in italics - and the parts I fixed are in red):

    /* bussetp.il (forum variant)
    
    Date       Jul 11, 2004 
    Modified   Sep 07, 2025 
    
    SKILL code for creating the "bussetp" pcell schematic, symbol,
    and the CDF as well.
    
    bussetp is a parameterisable version of busset - it allows
    the bus value to be parameterized. Instead of using
    cds_thru, it uses vcvs components - so there is no
    direct connection to the hi and lo inputs - these 
    are buffered by the vcvs.
    
    Updated Mar 21, 2013 to add support for AMS Cell Based Netlister
    
    Note that have to go to Simulation->Options->AMS and then set
    any design variables passed to bussetp to be netlisted as
    integer rather than real.
    
    Also need to ensure you have ams in switch view list and stop view
    list (or specifically pick the ams view in the config) to stop
    CBN trying to descend into the schematic for the bussetp.
    
    Call CCScreateBussetp("mylib" "bussetp") to create the component
    in the library you want - this only needs to be done once.
    
    If you want to use the bussetp component with AMS (using cell-based
    netlisting), then load this code from your .cdsinit (or from the libInit.il
    of the library containing bussetp) and call (in the same file):
    
    CCSinitBussetpNetlistProc()
    
    This customizes ADE so that the "DesVar(s) to be netlisted as integer" 
    appears on the Simulation->Options->AMS Simulator form (Netlist tab).
    
    ***************************************************
    
    SCCS Info: @(#) bussetp.il 03/22/13.06:45:19 1.4 ***
    
    */
    
    /*******************************************************************************
    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *
    *   their own risk. The code may require modification to satisfy the           *
    *   requirements of any user. The code and any modifications to the code may   *
    *   not be compatible with current or future versions of Cadence products.     *
    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *
    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *
    *   OR FITNESS FOR A PARTICULAR USE.                                           *
    *******************************************************************************/
    
    procedure(CCScreateForumBussetp(library @optional (cell "forumbussetp"))
     let( (pcellId)
        unless(ddGetObj(library)
    	error("Couldn't open library %L" library)
        )
    
        ;--------------------------------------------------------------------
        ; First the schematic
        ;--------------------------------------------------------------------
        pcellId=pcDefinePCell(
    	list(ddGetObj(library) cell "schematic" "schematic")
    
    	;----------------------------------------------------------------
    	; Formal parameters
    	;----------------------------------------------------------------
    	(
    	    (buswidth 6)
    	    (busvalue 0)
    	)
    
    	;----------------------------------------------------------------
    	; Code itself
    	;----------------------------------------------------------------
    	let(( cv master instHiId instLoId netH netL busOut gnd
    	    midNet)
    
    	cv = pcCellView
    	;----------------------------------------------------------------
    	; Convert parameters
    	;----------------------------------------------------------------
    	when(buswidth<1 buswidth=1)
    
    	;----------------------------------------------------------------
    	; open master cell view
    	;----------------------------------------------------------------
    	master = dbOpenCellViewByType( "analogLib" "vcvs" "symbol" nil "r" )
    	;----------------------------------------------------------------
    	; create the nets
    	;----------------------------------------------------------------
    	netH=dbMakeNet(cv "hi")
    	netL=dbMakeNet(cv "lo")
    	busOut=dbMakeNet(cv sprintf(nil "bus<%d:0>" buswidth-1))
    	gnd=dbMakeNet(cv "gnd!")
    	gnd~>signals~>isGlobal=t
    	;----------------------------------------------------------------
    	; create the terminals
    	;----------------------------------------------------------------
    	dbCreateTerm(netH netH~>name "inputOutput")
    	dbCreateTerm(netL netL~>name "inputOutput")
    	dbCreateTerm(busOut busOut~>name "inputOutput")
    	;----------------------------------------------------------------
    	; create the instances of vcvs (two per bit)
    	;----------------------------------------------------------------
    	for(bit 0 buswidth-1
    	    instHiId = 
    		dbCreateInst(
    		    cv master sprintf(nil "vhi%d" bit)
    		    0:0 "R0"
    		)
    	    instLoId = 
    		dbCreateInst(
    		    cv master sprintf(nil "vlo%d" bit)
    		    0:0 "R0"
    		)
    	    ;------------------------------------------------------------
    	    ; Create the properties on each instance
    	    ;------------------------------------------------------------
    	    instHiId~>egain=
    		sprintf(nil "(pPar(\"busvalue\")&%d)>>%d"
    		    1<<bit bit)
    	    instLoId~>egain=
    		sprintf(nil "1-((pPar(\"busvalue\")&%d)>>%d)"
    		    1<<bit bit)
    	    ;------------------------------------------------------------
    	    ; Connect it up
    	    ;------------------------------------------------------------
    	    midNet=dbMakeNet(cv sprintf(nil "mid%d" bit))
    	    topNet=dbMakeNet(cv sprintf(nil "bus<%d>" bit))
    	    dbCreateConnByName(gnd instLoId "NC-");
    	    dbCreateConnByName(gnd instHiId "NC-");
    	    dbCreateConnByName(netL instLoId "NC+");
    	    dbCreateConnByName(netH instHiId "NC+");
    	    dbCreateConnByName(gnd instLoId "MINUS");
    	    dbCreateConnByName(midNet instLoId "PLUS");
    	    dbCreateConnByName(midNet instHiId "MINUS");
    	    dbCreateConnByName(topNet instHiId "PLUS");
    	) ; for
    
    let((vdcMaster vhiInst vloInst)
    vdcMaster=dbOpenCellViewByType("analogLib" "vdc" "symbol")
    ;----------------------------------------------------------------
    ;Create vdc instances for hi and lo
    ;----------------------------------------------------------------
    vhiInst = dbCreateInst(cv vdcMaster "VHI_SRC" -1:0 "R0")
    vloInst = dbCreateInst(cv vdcMaster "VLO_SRC" -1:-0.5 "R0")
    ;----------------------------------------------------------------
    ; Set DC voltage parameters
    ;----------------------------------------------------------------
    ;; parameters were wrongly named
    ;;;vhiInst->vdc = sprintf(nil "pPar(\"vcvs_hi\")")
    ;;;vloInst->vdc = sprintf(nil "pPar(\"vcvs_lo\")")
    vhiInst->vdc = sprintf(nil "pPar(\"vhi\")")
    vloInst->vdc = sprintf(nil "pPar(\"vlo\")")
    ;----------------------------------------------------------------
    ;Connect Nets to vdc
    ;----------------------------------------------------------------
    dbCreateConnByName(netH vhiInst "PLUS")
    dbCreateConnByName(gnd vhiInst "MINUS")
    dbCreateConnByName(netL vloInst "PLUS")
    dbCreateConnByName(gnd vloInst "MINUS")
    )
    
    	;----------------------------------------------------------------
    	; Make the connectivity look up to date - not always needed, but
    	; Assura needs this, for example.
    	;----------------------------------------------------------------
    	dbSetConnCurrent(cv)
    
    	dbClose( master )
    	t
    	) ; let
        )
        dbSave(pcellId)
        dbClose(pcellId) 
        
        ;--------------------------------------------------------------------
        ; Now the symbol
        ;--------------------------------------------------------------------
        pcellId=pcDefinePCell(
    	list(ddGetObj(library) cell "symbol" "schematicSymbol")
    
    	;----------------------------------------------------------------
    	; Formal parameters
    	;----------------------------------------------------------------
    	(
    	    (buswidth 6)
    	)
    
    	;----------------------------------------------------------------
    	; Code itself
    	;----------------------------------------------------------------
    	let(( cv netH netL 
    	    busOut figH figL figBus hp ps pl bw lh
    	    pxc label)
    
    	cv = pcCellView
    
    	;----------------------------------------------------------------
    	; Various dimensions
    	;----------------------------------------------------------------
    	; half pin size
    	hp=0.025
    	; pin spacing
    	ps=0.125
    	; pin length
    	pl=0.250
    	; box width
    	bw=1.4375
    	; label height
    	lh=0.0625
    	; param label x coord
    	pxc=0.5
    
    	;----------------------------------------------------------------
    	; create the shapes - first the pins
    	;----------------------------------------------------------------
    	figH = dbCreateRect(cv list("pin" "drawing") list(-hp:-hp hp:hp)) 
    	dbCreateLine(cv list("device" "drawing") list(0:0 pl:0))
    	figL = dbCreateRect(cv list("pin" "drawing") list(-hp:-ps-hp hp:-ps+hp))
    	dbCreateLine(cv list("device" "drawing") list(0:-ps pl:-ps))
    	figBus = dbCreateRect(cv list("pin" "drawing")
    	    list(2*pl+bw-hp:-hp 2*pl+bw+hp:hp)
    	) ; dbCreateRect
    	dbCreateLine(cv list("device" "drawing") list(pl+bw:0 2*pl+bw:0))
    	;----------------------------------------------------------------
    	; Then the boxes
    	;----------------------------------------------------------------
    	dbCreateRect(cv list("device" "drawing") list(pl:-2*ps pl+bw:ps))
    	dbCreateRect(cv list("instance" "drawing") list(0:-2*ps 2*pl+bw:ps))
    
    	;----------------------------------------------------------------
    	; create the nets
    	;----------------------------------------------------------------
    	netH=dbMakeNet(cv "hi")
    	netL=dbMakeNet(cv "lo")
    	busOut=dbMakeNet(cv sprintf(nil "bus<%d:0>" buswidth-1))
    	;----------------------------------------------------------------
    	; create the terminals
    	;----------------------------------------------------------------
    	dbCreateTerm(netH netH~>name "inputOutput")
    	dbCreateTerm(netL netL~>name "inputOutput")
    	dbCreateTerm(busOut busOut~>name "inputOutput")
    	;----------------------------------------------------------------
    	; create the pins
    	;----------------------------------------------------------------
    	dbCreatePin(netH figH)
    	dbCreatePin(netL figL)
    	dbCreatePin(busOut figBus)
    
    	;----------------------------------------------------------------
    	; Put some labels for the pins
    	;----------------------------------------------------------------
    	dbCreateLabel(cv list("pin" "drawing") pl+ps/2:0
    	    netH~>name "centerLeft" "R0" "stick" lh)
    	dbCreateLabel(cv list("pin" "drawing") pl+ps/2:-ps
    	    netL~>name "centerLeft" "R0" "stick" lh)
    	dbCreateLabel(cv list("pin" "drawing") bw+pl-ps/2:0
    	    busOut~>name "centerRight" "R0" "stick" lh)
    
    	;----------------------------------------------------------------
    	; And other symbol labels
    	;----------------------------------------------------------------
    	label=dbCreateLabel(cv list("annotate" "drawing7") bw+pl-ps/2:ps*1.5
    	    "cdsName()" "centerRight" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    	label=dbCreateLabel(cv list("annotate" "drawing") pxc:0
    	    "cdsParam(1)" "centerLeft" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    	label=dbCreateLabel(cv list("annotate" "drawing") pxc:-ps
    	    "cdsParam(2)" "centerLeft" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    
    	t
    	) ; let
        )
        dbSave(pcellId)
        ; copy the symbol to the ams view and close it
        amsView=dbCopyCellView(pcellId library cell "ams")
        dbSave(amsView)
        dbClose(amsView)
        dbClose(pcellId) 
    
    ;------------------------------------------------------------------------
    ; Now create the CDF
    ;------------------------------------------------------------------------
        let( (cellId cdfId )
    	unless( cellId = ddGetObj( library cell )
    	    error( "Could not get cell %s." cell )
    	)
    	when( cdfId = cdfGetBaseCellCDF( cellId )
    	    cdfDeleteCDF( cdfId )
    	)
    	cdfId  = cdfCreateBaseCellCDF( cellId )
    
    	;;; Parameters
    	cdfCreateParam( cdfId
    	    ?name           "buswidth"
    	    ?prompt         "Bus Width"
    	    ?defValue       6
    	    ?type           "int"
    	    ?display        "t"
    	)
    	cdfCreateParam( cdfId
    	    ?name           "busvalue"
    	    ?prompt         "Bus Value"
    	    ?defValue       "0"
    	    ?type           "string"
    	    ?parseAsCEL     "yes"
    	    ?parseAsNumber  "yes"
    	    ?display        "t"
    	)
    cdfCreateParam( cdfId
    ?name "vhi"
    ?prompt "Voltage High"
    ?defValue "1"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    cdfCreateParam( cdfId
    ?name "vlo"
    ?prompt "Voltage Low"
    ?defValue "0"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    
    	
    
    	;;; Simulator Information
    	cdfId->simInfo = list( nil )
    	cdfId->simInfo->UltraSim = '( nil )
    	cdfId->simInfo->ams = '( nil
    	    isPrimitive       nil
    	    extraTerminals    nil
    	    propMapping       nil
    	    termMapping       nil
    	    termOrder         nil
    	    componentName     nil
    	    excludeParameters nil
    	    arrayParameters   nil
    	    stringParameters  nil
    	    referenceParameters nil
    	    enumParameters    nil
    	    instParameters    (buswidth busvalue)
    	    otherParameters   nil
    	    netlistProcedure  (CCSbussetpAMSNetlistingProc)
    	)
    	cdfId->simInfo->auCdl = '( nil )
    	cdfId->simInfo->auLvs = '( nil )
    	cdfId->simInfo->cdsSpice = '( nil )
    	cdfId->simInfo->hspiceD = '( nil )
    	cdfId->simInfo->hspiceS = '( nil )
    	cdfId->simInfo->spectre = '( nil )
    	cdfId->simInfo->spectreS = '( nil )
    
    	;;; Properties
    	cdfId->formInitProc            = ""
    	cdfId->doneProc                = ""
    	cdfId->buttonFieldWidth        = 340
    	cdfId->fieldHeight             = 35
    	cdfId->fieldWidth              = 350
    	cdfId->promptWidth             = 175
    	cdfId->paramLabelSet           = "buswidth busvalue"
    	cdfId->paramDisplayMode        = "parameter"
    	cdfId->paramEvaluate           = "t nil nil nil nil"
    	cdfSaveCDF( cdfId )
        ) ; let
     ) ; let
    )
    
    ;AMS Cell-Based netlisting procedure (OSS doesn't need this, at
    ;least not with UNL).
    procedure(CCSbussetpAMSNetlistingProc(formatterId cvId instanceId)
        let((buswidth busvalue params ports instPrefix busPat curBit 
    	(gnd "cds_globals.\\gnd!") lo hi leftAngle rightAngle mappedMem)
    	busPat=pcreCompile("^bus<")
    	leftAngle=pcreCompile("<")
    	rightAngle=pcreCompile(">")
    	params=makeTable('params nil)
    	ports=makeTable('ports nil)
    	foreach(param instanceId~>parameters
    	    params[param~>name]=param~>value
    	)
    	buswidth=params["buswidth"]||6
    	busvalue=params["busvalue"]||0
    	printf("width %L value %L\n" buswidth busvalue)
    	; don't want to use instanceId~>ports for the bus pin because
    	; using the Verilog mapped name syntax so harder to pull apart
    	; but will use it for the hi and lo pins
    	foreach(port instanceId~>ports
    	    ports[port~>name]=port~>expr
    	)
    	lo=ports["lo"]
    	hi=ports["hi"]
    	busTerm=car(exists(instTerm instanceId~>id~>instTerms 
    	    pcreExecute(busPat instTerm~>name)))
    	instPrefix=strcat(instanceId~>name "__")
    	curBit=0
    ; aborted attempt to introduce a decent rounding function to cope
    ; with CBN producing global variables as real type.
    ;	amsPrint(formatterId
    ;	    sprintf(nil "function integer %sround;\n  input n1;\n  real n1;  %sround = floor(n1+0.001);\nendfunction\n"
    ;		instPrefix instPrefix
    ;	    )
    ;	)
    	foreach(mem reverse(dbProduceMemName(busTerm~>net~>name))
    	    mappedMem=pcreReplace(leftAngle mem "[" 0)
    	    mappedMem=pcreReplace(rightAngle mappedMem "]" 0)
    	    amsPrint(formatterId
    		sprintf(nil "vcvs #(.gain(1-(((%s )&%d)>>%d))) %svlo%d(%smid%d ,%s ,%s ,%s );"
    		    busvalue 1<<curBit curBit instPrefix curBit instPrefix curBit gnd lo gnd)
    	    )
    	    amsPrint(formatterId
    		sprintf(nil "vcvs #(.gain(((%s )&%d)>>%d)) %svhi%d(%s ,%smid%d ,%s ,%s );"
    		    busvalue 1<<curBit curBit instPrefix curBit mappedMem instPrefix curBit hi gnd)
    	    )
    	    curBit++
    	)
        )
    )
    
    procedure(CCSinitBussetpNetlistProc()
        when(isCallable('axlIsICRPProcess) && isCallable('asiChangeSimOption) && 
    	!axlIsICRPProcess()
    	; Force the Des vars to be netlisted as Int to show all the time
    	; For some reason it only shows up for OSS (although it works for CBN
    	; too)
    	asiChangeSimOption(
    	    asiGetTool('ams)
    	    ?name 'desVarsToBeNetlistedAsInt
    	    ?partition 'netlisterOpts
    	    ?display t
    	)
        )
    )
    

    Perhaps you can post your full code that shows the problem if this doesn't clear things up?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett 1 day ago in reply to Yuto Lau

    I don't get that error with those modifications to my code (I omitted the "Encoding Mode" parameter, because I didn't implement that). Note that I had to also change the parameters passed in the pPar because they didn't match your CDF parameters (this didn't cause the error you saw, just that it wouldn't work correctly as vcvs_hi wasn't defined otherwise). Here's the code (indentation not fixed - the unindented parts are the changed pieces - in italics - and the parts I fixed are in red):

    /* bussetp.il (forum variant)
    
    Date       Jul 11, 2004 
    Modified   Sep 07, 2025 
    
    SKILL code for creating the "bussetp" pcell schematic, symbol,
    and the CDF as well.
    
    bussetp is a parameterisable version of busset - it allows
    the bus value to be parameterized. Instead of using
    cds_thru, it uses vcvs components - so there is no
    direct connection to the hi and lo inputs - these 
    are buffered by the vcvs.
    
    Updated Mar 21, 2013 to add support for AMS Cell Based Netlister
    
    Note that have to go to Simulation->Options->AMS and then set
    any design variables passed to bussetp to be netlisted as
    integer rather than real.
    
    Also need to ensure you have ams in switch view list and stop view
    list (or specifically pick the ams view in the config) to stop
    CBN trying to descend into the schematic for the bussetp.
    
    Call CCScreateBussetp("mylib" "bussetp") to create the component
    in the library you want - this only needs to be done once.
    
    If you want to use the bussetp component with AMS (using cell-based
    netlisting), then load this code from your .cdsinit (or from the libInit.il
    of the library containing bussetp) and call (in the same file):
    
    CCSinitBussetpNetlistProc()
    
    This customizes ADE so that the "DesVar(s) to be netlisted as integer" 
    appears on the Simulation->Options->AMS Simulator form (Netlist tab).
    
    ***************************************************
    
    SCCS Info: @(#) bussetp.il 03/22/13.06:45:19 1.4 ***
    
    */
    
    /*******************************************************************************
    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *
    *   their own risk. The code may require modification to satisfy the           *
    *   requirements of any user. The code and any modifications to the code may   *
    *   not be compatible with current or future versions of Cadence products.     *
    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *
    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *
    *   OR FITNESS FOR A PARTICULAR USE.                                           *
    *******************************************************************************/
    
    procedure(CCScreateForumBussetp(library @optional (cell "forumbussetp"))
     let( (pcellId)
        unless(ddGetObj(library)
    	error("Couldn't open library %L" library)
        )
    
        ;--------------------------------------------------------------------
        ; First the schematic
        ;--------------------------------------------------------------------
        pcellId=pcDefinePCell(
    	list(ddGetObj(library) cell "schematic" "schematic")
    
    	;----------------------------------------------------------------
    	; Formal parameters
    	;----------------------------------------------------------------
    	(
    	    (buswidth 6)
    	    (busvalue 0)
    	)
    
    	;----------------------------------------------------------------
    	; Code itself
    	;----------------------------------------------------------------
    	let(( cv master instHiId instLoId netH netL busOut gnd
    	    midNet)
    
    	cv = pcCellView
    	;----------------------------------------------------------------
    	; Convert parameters
    	;----------------------------------------------------------------
    	when(buswidth<1 buswidth=1)
    
    	;----------------------------------------------------------------
    	; open master cell view
    	;----------------------------------------------------------------
    	master = dbOpenCellViewByType( "analogLib" "vcvs" "symbol" nil "r" )
    	;----------------------------------------------------------------
    	; create the nets
    	;----------------------------------------------------------------
    	netH=dbMakeNet(cv "hi")
    	netL=dbMakeNet(cv "lo")
    	busOut=dbMakeNet(cv sprintf(nil "bus<%d:0>" buswidth-1))
    	gnd=dbMakeNet(cv "gnd!")
    	gnd~>signals~>isGlobal=t
    	;----------------------------------------------------------------
    	; create the terminals
    	;----------------------------------------------------------------
    	dbCreateTerm(netH netH~>name "inputOutput")
    	dbCreateTerm(netL netL~>name "inputOutput")
    	dbCreateTerm(busOut busOut~>name "inputOutput")
    	;----------------------------------------------------------------
    	; create the instances of vcvs (two per bit)
    	;----------------------------------------------------------------
    	for(bit 0 buswidth-1
    	    instHiId = 
    		dbCreateInst(
    		    cv master sprintf(nil "vhi%d" bit)
    		    0:0 "R0"
    		)
    	    instLoId = 
    		dbCreateInst(
    		    cv master sprintf(nil "vlo%d" bit)
    		    0:0 "R0"
    		)
    	    ;------------------------------------------------------------
    	    ; Create the properties on each instance
    	    ;------------------------------------------------------------
    	    instHiId~>egain=
    		sprintf(nil "(pPar(\"busvalue\")&%d)>>%d"
    		    1<<bit bit)
    	    instLoId~>egain=
    		sprintf(nil "1-((pPar(\"busvalue\")&%d)>>%d)"
    		    1<<bit bit)
    	    ;------------------------------------------------------------
    	    ; Connect it up
    	    ;------------------------------------------------------------
    	    midNet=dbMakeNet(cv sprintf(nil "mid%d" bit))
    	    topNet=dbMakeNet(cv sprintf(nil "bus<%d>" bit))
    	    dbCreateConnByName(gnd instLoId "NC-");
    	    dbCreateConnByName(gnd instHiId "NC-");
    	    dbCreateConnByName(netL instLoId "NC+");
    	    dbCreateConnByName(netH instHiId "NC+");
    	    dbCreateConnByName(gnd instLoId "MINUS");
    	    dbCreateConnByName(midNet instLoId "PLUS");
    	    dbCreateConnByName(midNet instHiId "MINUS");
    	    dbCreateConnByName(topNet instHiId "PLUS");
    	) ; for
    
    let((vdcMaster vhiInst vloInst)
    vdcMaster=dbOpenCellViewByType("analogLib" "vdc" "symbol")
    ;----------------------------------------------------------------
    ;Create vdc instances for hi and lo
    ;----------------------------------------------------------------
    vhiInst = dbCreateInst(cv vdcMaster "VHI_SRC" -1:0 "R0")
    vloInst = dbCreateInst(cv vdcMaster "VLO_SRC" -1:-0.5 "R0")
    ;----------------------------------------------------------------
    ; Set DC voltage parameters
    ;----------------------------------------------------------------
    ;; parameters were wrongly named
    ;;;vhiInst->vdc = sprintf(nil "pPar(\"vcvs_hi\")")
    ;;;vloInst->vdc = sprintf(nil "pPar(\"vcvs_lo\")")
    vhiInst->vdc = sprintf(nil "pPar(\"vhi\")")
    vloInst->vdc = sprintf(nil "pPar(\"vlo\")")
    ;----------------------------------------------------------------
    ;Connect Nets to vdc
    ;----------------------------------------------------------------
    dbCreateConnByName(netH vhiInst "PLUS")
    dbCreateConnByName(gnd vhiInst "MINUS")
    dbCreateConnByName(netL vloInst "PLUS")
    dbCreateConnByName(gnd vloInst "MINUS")
    )
    
    	;----------------------------------------------------------------
    	; Make the connectivity look up to date - not always needed, but
    	; Assura needs this, for example.
    	;----------------------------------------------------------------
    	dbSetConnCurrent(cv)
    
    	dbClose( master )
    	t
    	) ; let
        )
        dbSave(pcellId)
        dbClose(pcellId) 
        
        ;--------------------------------------------------------------------
        ; Now the symbol
        ;--------------------------------------------------------------------
        pcellId=pcDefinePCell(
    	list(ddGetObj(library) cell "symbol" "schematicSymbol")
    
    	;----------------------------------------------------------------
    	; Formal parameters
    	;----------------------------------------------------------------
    	(
    	    (buswidth 6)
    	)
    
    	;----------------------------------------------------------------
    	; Code itself
    	;----------------------------------------------------------------
    	let(( cv netH netL 
    	    busOut figH figL figBus hp ps pl bw lh
    	    pxc label)
    
    	cv = pcCellView
    
    	;----------------------------------------------------------------
    	; Various dimensions
    	;----------------------------------------------------------------
    	; half pin size
    	hp=0.025
    	; pin spacing
    	ps=0.125
    	; pin length
    	pl=0.250
    	; box width
    	bw=1.4375
    	; label height
    	lh=0.0625
    	; param label x coord
    	pxc=0.5
    
    	;----------------------------------------------------------------
    	; create the shapes - first the pins
    	;----------------------------------------------------------------
    	figH = dbCreateRect(cv list("pin" "drawing") list(-hp:-hp hp:hp)) 
    	dbCreateLine(cv list("device" "drawing") list(0:0 pl:0))
    	figL = dbCreateRect(cv list("pin" "drawing") list(-hp:-ps-hp hp:-ps+hp))
    	dbCreateLine(cv list("device" "drawing") list(0:-ps pl:-ps))
    	figBus = dbCreateRect(cv list("pin" "drawing")
    	    list(2*pl+bw-hp:-hp 2*pl+bw+hp:hp)
    	) ; dbCreateRect
    	dbCreateLine(cv list("device" "drawing") list(pl+bw:0 2*pl+bw:0))
    	;----------------------------------------------------------------
    	; Then the boxes
    	;----------------------------------------------------------------
    	dbCreateRect(cv list("device" "drawing") list(pl:-2*ps pl+bw:ps))
    	dbCreateRect(cv list("instance" "drawing") list(0:-2*ps 2*pl+bw:ps))
    
    	;----------------------------------------------------------------
    	; create the nets
    	;----------------------------------------------------------------
    	netH=dbMakeNet(cv "hi")
    	netL=dbMakeNet(cv "lo")
    	busOut=dbMakeNet(cv sprintf(nil "bus<%d:0>" buswidth-1))
    	;----------------------------------------------------------------
    	; create the terminals
    	;----------------------------------------------------------------
    	dbCreateTerm(netH netH~>name "inputOutput")
    	dbCreateTerm(netL netL~>name "inputOutput")
    	dbCreateTerm(busOut busOut~>name "inputOutput")
    	;----------------------------------------------------------------
    	; create the pins
    	;----------------------------------------------------------------
    	dbCreatePin(netH figH)
    	dbCreatePin(netL figL)
    	dbCreatePin(busOut figBus)
    
    	;----------------------------------------------------------------
    	; Put some labels for the pins
    	;----------------------------------------------------------------
    	dbCreateLabel(cv list("pin" "drawing") pl+ps/2:0
    	    netH~>name "centerLeft" "R0" "stick" lh)
    	dbCreateLabel(cv list("pin" "drawing") pl+ps/2:-ps
    	    netL~>name "centerLeft" "R0" "stick" lh)
    	dbCreateLabel(cv list("pin" "drawing") bw+pl-ps/2:0
    	    busOut~>name "centerRight" "R0" "stick" lh)
    
    	;----------------------------------------------------------------
    	; And other symbol labels
    	;----------------------------------------------------------------
    	label=dbCreateLabel(cv list("annotate" "drawing7") bw+pl-ps/2:ps*1.5
    	    "cdsName()" "centerRight" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    	label=dbCreateLabel(cv list("annotate" "drawing") pxc:0
    	    "cdsParam(1)" "centerLeft" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    	label=dbCreateLabel(cv list("annotate" "drawing") pxc:-ps
    	    "cdsParam(2)" "centerLeft" "R0" "stick" lh)
    	label~>labelType="ILLabel"
    
    	t
    	) ; let
        )
        dbSave(pcellId)
        ; copy the symbol to the ams view and close it
        amsView=dbCopyCellView(pcellId library cell "ams")
        dbSave(amsView)
        dbClose(amsView)
        dbClose(pcellId) 
    
    ;------------------------------------------------------------------------
    ; Now create the CDF
    ;------------------------------------------------------------------------
        let( (cellId cdfId )
    	unless( cellId = ddGetObj( library cell )
    	    error( "Could not get cell %s." cell )
    	)
    	when( cdfId = cdfGetBaseCellCDF( cellId )
    	    cdfDeleteCDF( cdfId )
    	)
    	cdfId  = cdfCreateBaseCellCDF( cellId )
    
    	;;; Parameters
    	cdfCreateParam( cdfId
    	    ?name           "buswidth"
    	    ?prompt         "Bus Width"
    	    ?defValue       6
    	    ?type           "int"
    	    ?display        "t"
    	)
    	cdfCreateParam( cdfId
    	    ?name           "busvalue"
    	    ?prompt         "Bus Value"
    	    ?defValue       "0"
    	    ?type           "string"
    	    ?parseAsCEL     "yes"
    	    ?parseAsNumber  "yes"
    	    ?display        "t"
    	)
    cdfCreateParam( cdfId
    ?name "vhi"
    ?prompt "Voltage High"
    ?defValue "1"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    cdfCreateParam( cdfId
    ?name "vlo"
    ?prompt "Voltage Low"
    ?defValue "0"
    ?type "string"
    ?parseAsCEL "yes"
    ?parseAsNumber "yes"
    ?display "t"
    )
    
    	
    
    	;;; Simulator Information
    	cdfId->simInfo = list( nil )
    	cdfId->simInfo->UltraSim = '( nil )
    	cdfId->simInfo->ams = '( nil
    	    isPrimitive       nil
    	    extraTerminals    nil
    	    propMapping       nil
    	    termMapping       nil
    	    termOrder         nil
    	    componentName     nil
    	    excludeParameters nil
    	    arrayParameters   nil
    	    stringParameters  nil
    	    referenceParameters nil
    	    enumParameters    nil
    	    instParameters    (buswidth busvalue)
    	    otherParameters   nil
    	    netlistProcedure  (CCSbussetpAMSNetlistingProc)
    	)
    	cdfId->simInfo->auCdl = '( nil )
    	cdfId->simInfo->auLvs = '( nil )
    	cdfId->simInfo->cdsSpice = '( nil )
    	cdfId->simInfo->hspiceD = '( nil )
    	cdfId->simInfo->hspiceS = '( nil )
    	cdfId->simInfo->spectre = '( nil )
    	cdfId->simInfo->spectreS = '( nil )
    
    	;;; Properties
    	cdfId->formInitProc            = ""
    	cdfId->doneProc                = ""
    	cdfId->buttonFieldWidth        = 340
    	cdfId->fieldHeight             = 35
    	cdfId->fieldWidth              = 350
    	cdfId->promptWidth             = 175
    	cdfId->paramLabelSet           = "buswidth busvalue"
    	cdfId->paramDisplayMode        = "parameter"
    	cdfId->paramEvaluate           = "t nil nil nil nil"
    	cdfSaveCDF( cdfId )
        ) ; let
     ) ; let
    )
    
    ;AMS Cell-Based netlisting procedure (OSS doesn't need this, at
    ;least not with UNL).
    procedure(CCSbussetpAMSNetlistingProc(formatterId cvId instanceId)
        let((buswidth busvalue params ports instPrefix busPat curBit 
    	(gnd "cds_globals.\\gnd!") lo hi leftAngle rightAngle mappedMem)
    	busPat=pcreCompile("^bus<")
    	leftAngle=pcreCompile("<")
    	rightAngle=pcreCompile(">")
    	params=makeTable('params nil)
    	ports=makeTable('ports nil)
    	foreach(param instanceId~>parameters
    	    params[param~>name]=param~>value
    	)
    	buswidth=params["buswidth"]||6
    	busvalue=params["busvalue"]||0
    	printf("width %L value %L\n" buswidth busvalue)
    	; don't want to use instanceId~>ports for the bus pin because
    	; using the Verilog mapped name syntax so harder to pull apart
    	; but will use it for the hi and lo pins
    	foreach(port instanceId~>ports
    	    ports[port~>name]=port~>expr
    	)
    	lo=ports["lo"]
    	hi=ports["hi"]
    	busTerm=car(exists(instTerm instanceId~>id~>instTerms 
    	    pcreExecute(busPat instTerm~>name)))
    	instPrefix=strcat(instanceId~>name "__")
    	curBit=0
    ; aborted attempt to introduce a decent rounding function to cope
    ; with CBN producing global variables as real type.
    ;	amsPrint(formatterId
    ;	    sprintf(nil "function integer %sround;\n  input n1;\n  real n1;  %sround = floor(n1+0.001);\nendfunction\n"
    ;		instPrefix instPrefix
    ;	    )
    ;	)
    	foreach(mem reverse(dbProduceMemName(busTerm~>net~>name))
    	    mappedMem=pcreReplace(leftAngle mem "[" 0)
    	    mappedMem=pcreReplace(rightAngle mappedMem "]" 0)
    	    amsPrint(formatterId
    		sprintf(nil "vcvs #(.gain(1-(((%s )&%d)>>%d))) %svlo%d(%smid%d ,%s ,%s ,%s );"
    		    busvalue 1<<curBit curBit instPrefix curBit instPrefix curBit gnd lo gnd)
    	    )
    	    amsPrint(formatterId
    		sprintf(nil "vcvs #(.gain(((%s )&%d)>>%d)) %svhi%d(%s ,%smid%d ,%s ,%s );"
    		    busvalue 1<<curBit curBit instPrefix curBit mappedMem instPrefix curBit hi gnd)
    	    )
    	    curBit++
    	)
        )
    )
    
    procedure(CCSinitBussetpNetlistProc()
        when(isCallable('axlIsICRPProcess) && isCallable('asiChangeSimOption) && 
    	!axlIsICRPProcess()
    	; Force the Des vars to be netlisted as Int to show all the time
    	; For some reason it only shows up for OSS (although it works for CBN
    	; too)
    	asiChangeSimOption(
    	    asiGetTool('ams)
    	    ?name 'desVarsToBeNetlistedAsInt
    	    ?partition 'netlisterOpts
    	    ?display t
    	)
        )
    )
    

    Perhaps you can post your full code that shows the problem if this doesn't clear things up?

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information