let((library cell PCellSchematicId PCellSymbolId) ; library/cell of PCell library = ddGetObj("mylib") cell = "forumSchPCell" ; define the schematic PCellSchematicId = pcDefinePCell( list(library cell "schematic" "schematic") () let((cv PatchCordMaster ResistorMaster patchcord1 patchcord2 Resistor1 Resistor2 Resistor3 net wire text internet internet1 internet2) cv = pcCellView ; load symbols for instantiation PatchCordMaster = dbOpenCellViewByType("basic" "patch" "symbol") ResistorMaster = dbOpenCellViewByType("analogLib" "res" "symbol") patchcord1 = dbCreateParamInst(cv PatchCordMaster nil 3.5:0 "MY" 1 list( list("schPatchExpr" "string" "0:255=0:255"))) patchcord2 = dbCreateParamInst(cv PatchCordMaster nil 3.5:-0.25 "MY" 1 list( list("schPatchExpr" "string" "256:511=0:255"))) Resistor1 = dbCreateParamInst(cv ResistorMaster nil 3:0 "R90" 256 list( list("r" "string" "0"))) Resistor2 = dbCreateParamInst(cv ResistorMaster nil 3:-0.25 "R90" 256 list( list("r" "string" "0"))) Resistor3 = dbCreateParamInst(cv ResistorMaster nil 4.875:-0.25 "R90" 512 list( list("r" "string" "0"))) net = dbCreateNet(cv "input<0:255>") wire = dbCreateLine(cv list("wire" "drawing") list(2:0 3:0)) text = dbCreateLabel(cv '("wire" "label") 2:0 "input<0:255>" "lowerLeft" "R0" "stick" 0.0625) text~>parent = wire dbAddFigToNet(wire net) dbCreateConnByName(net Resistor1 "PLUS") net = dbCreateNet(cv "input<256:511>") wire = dbCreateLine(cv list("wire" "drawing") list(2:-0.25 3:-0.25)) text = dbCreateLabel(cv '("wire" "label") 2:-0.25 "input<256:511>" "lowerLeft" "R0" "stick" 0.0625) text~>parent = wire dbAddFigToNet(wire net) dbCreateConnByName(net Resistor2 "PLUS") net = dbCreateNet(cv "internet1<0:255>") internet1 = net wire = dbCreateLine(cv list("wire" "drawing") list(3.375:0 3.5:0)) dbAddFigToNet(wire net) dbCreateConnByName(net Resistor1 "MINUS") ; dbCreateConnByName(net patchcord1 "dst") net = dbCreateNet(cv "internet2<0:255>") internet2 = net wire = dbCreateLine(cv list("wire" "drawing") list(3.375:-0.25 3.5:-0.25)) dbAddFigToNet(wire net) dbCreateConnByName(net Resistor2 "MINUS") ; dbCreateConnByName(net patchcord2 "dst") net = dbCreateNet(cv "internet<0:511>") internet = net wire = dbCreateLine(cv list("wire" "drawing") list(3.6:0 4.15:0)) dbAddFigToNet(wire net) wire = dbCreateLine(cv list("wire" "drawing") list(3.6:-0.25 4.875:-0.25)) dbAddFigToNet(wire net) wire = dbCreateLine(cv list("wire" "drawing") list(4.15:0 4.15:-0.25)) dbAddFigToNet(wire net) ; dbCreateConnByName(net patchcord1 "src") ; dbCreateConnByName(net patchcord2 "src") dbCreateConnByName(net Resistor3 "PLUS") ; now create the aliases (in other words, do what the patchcord does) foreach((s1 s2) internet~>signals append(internet1~>signals internet2~>signals) dbMergeSignal(s1 s2) ) net = dbCreateNet(cv "output<0:511>") wire = dbCreateLine(cv list("wire" "drawing") list(5.25:-0.25 6:-0.25)) text = dbCreateLabel(cv '("wire" "label") 5.25:-0.25 "output<0:511>" "lowerLeft" "R0" "stick" 0.0625) text~>parent = wire dbAddFigToNet(wire net) dbCreateConnByName(net Resistor3 "MINUS") ) ) dbSave(PCellSchematicId) dbClose(PCellSchematicId) PCellSymbolId = pcDefinePCell( list( library cell "symbol" "schematicSymbol") ( ) let(() dbCreateRect(pcCellView '("device" "drawing") list(0:1 1:0)) dbCreateRect(pcCellView '("instance" "drawing") list(0:0 1:1)) dbCreateLabel(pcCellView '("wire" "label") 0.5:0.5 "TEST" "centerCenter" "R0" "stick" 0.0625) ) ) dbSave(PCellSymbolId) dbClose(PCellSymbolId) )