Steven Rubin
Tue, 31 Mar 2009 11:23:47 -0700
At 12:09 AM 3/31/2009, you wrote:
Hello,we are kind of new to electric but really want to explore that path. However, we have a background with extensive scripting of our layouts and would like to see how that can be done in electric.Now, initially, I get lost in the java classes and methods. I've seen the example in this group: "Any BeanShell example for 8.0.1?", but I would like to know if anyone has examples in beanshell on how to e.g.create a (layout) cell view and a library ... instantiate a transistor into that cell ... add a couple of vias and arcs, i.e., generate a simple inverter? Essentially I use the following meta-approach (and fail): Cell lay = WindowFrame.getCurrentCell(); NodeInst node1 = newInstance(lay, proto, "pmos", <etc>) lay.addNode() But I get stuck... should I (search and) use other primitives, such as e.g. // assume technology information is properly inherited pTransId = lay.addTransistor("pmos", pPoint2D, paramHash, orien); nTransId = lay.addTransistor("nmos", nPoint2D, paramHash, orien); polyArcId = lay.connectNodes(nTransId.G, pTransId.G); metArcId = lay.connectNodes(nTransId.D, pTransId.D); etc. Any simple example to start with would be highly appreciated. Thanks in advance
Unfortunately, the Bean Shell isn't the greatest scripting environment. Besides the fact that you must access the Electric API, which is vast and difficult to access from outside of Electric, there is also the disadvantage that the Bean Shell doesn't help much with debugging. In general, I create my scripts inside of Electric and debug them there, then I save them as external Bean Shell code pieces.
Here is an example of a Bean Shell script that creates an inverter. Note one other problem with the script: the term "Export" is a Bean Shell term, and so the Electric version of it must always be fully qualified (i.e. it must be called "com.sun.electric.database.hierarchy.Export".
Also, although you used the GNU mailing list to discuss this issue, the Google group is more active, so I have posted this reply to both lists.
-Steven Rubin
--------------------------------------------------------------------------------------------
import com.sun.electric.database.geometry.EPoint;
import com.sun.electric.database.hierarchy.Cell;
import com.sun.electric.database.prototype.NodeProto;
import com.sun.electric.database.topology.ArcInst;
import com.sun.electric.database.topology.NodeInst;
import com.sun.electric.technology.ArcProto;
import com.sun.electric.technology.PrimitiveNode;
// get all necessary objects to be placed
PrimitiveNode trP = (PrimitiveNode)Cell.findNodeProto("mocmos:P-Transistor");
PrimitiveNode trN = (PrimitiveNode)Cell.findNodeProto("mocmos:N-Transistor");
PrimitiveNode coP =
(PrimitiveNode)Cell.findNodeProto("mocmos:Metal-1-P-Active-Con");
PrimitiveNode coN =
(PrimitiveNode)Cell.findNodeProto("mocmos:Metal-1-N-Active-Con");
PrimitiveNode m1p = (PrimitiveNode)Cell.findNodeProto("mocmos:Metal-1-Pin");
PrimitiveNode pop =
(PrimitiveNode)Cell.findNodeProto("mocmos:Polysilicon-1-Pin");
ArcProto m1 = ArcProto.findArcProto("mocmos:Metal-1");
ArcProto aN = ArcProto.findArcProto("mocmos:N-Active");
ArcProto aP = ArcProto.findArcProto("mocmos:P-Active");
ArcProto po = ArcProto.findArcProto("mocmos:Polysilicon-1");
// create the new cell with the placed circuitry
Cell newCell = Cell.makeInstance(Library.getCurrent(), "BigCell{lay}");
// place two transistors
NodeInst tN = NodeInst.makeInstance(trN, new EPoint(0, 0),
trN.getDefWidth(), trN.getDefHeight(), newCell);
NodeInst tP = NodeInst.makeInstance(trP, new EPoint(0, 30),
trP.getDefWidth(), trP.getDefHeight(), newCell);
// place two metal-Active contacts and an intermediate M1 pinNodeInst maN = NodeInst.makeInstance(coN, new EPoint(0, 6), coN.getDefWidth(), coN.getDefHeight(), newCell); NodeInst maP = NodeInst.makeInstance(coP, new EPoint(0, 24), coP.getDefWidth(), coP.getDefHeight(), newCell); NodeInst mJ = NodeInst.makeInstance(m1p, new EPoint(0, 15), m1p.getDefWidth(), m1p.getDefHeight(), newCell);
// place three poly pins to connect the gatesNodeInst ppN = NodeInst.makeInstance(pop, new EPoint(-10, 0), pop.getDefWidth(), pop.getDefHeight(), newCell); NodeInst ppP = NodeInst.makeInstance(pop, new EPoint(-10, 30), pop.getDefWidth(), pop.getDefHeight(), newCell); NodeInst ppJ = NodeInst.makeInstance(pop, new EPoint(-10, 15), pop.getDefWidth(), pop.getDefHeight(), newCell);
// place input/output pinsNodeInst inPin = NodeInst.makeInstance(pop, new EPoint(-20, 15), pop.getDefWidth(), pop.getDefHeight(), newCell); NodeInst outPin = NodeInst.makeInstance(m1p, new EPoint(10, 15), m1p.getDefWidth(), m1p.getDefHeight(), newCell);
// wire the transistors to the contactsArcInst.makeInstance(aN, tN.findPortInst("diff-top"), maN.findPortInst("metal-1-n-act")); ArcInst.makeInstance(aP, tP.findPortInst("diff-bottom"), maP.findPortInst("metal-1-p-act"));
// wire the contacts togetherArcInst.makeInstance(m1, maN.findPortInst("metal-1-n-act"), mJ.findPortInst("metal-1")); ArcInst.makeInstance(m1, mJ.findPortInst("metal-1"), maP.findPortInst("metal-1-p-act")); ArcInst.makeInstance(m1, mJ.findPortInst("metal-1"), outPin.findPortInst("metal-1"));
// wire the gates togetherArcInst.makeInstance(po, tN.findPortInst("poly-left"), ppN.findPortInst("polysilicon-1")); ArcInst.makeInstance(po, tP.findPortInst("poly-left"), ppP.findPortInst("polysilicon-1")); ArcInst.makeInstance(po, ppN.findPortInst("polysilicon-1"), ppJ.findPortInst("polysilicon-1")); ArcInst.makeInstance(po, ppP.findPortInst("polysilicon-1"), ppJ.findPortInst("polysilicon-1")); ArcInst.makeInstance(po, inPin.findPortInst("polysilicon-1"), ppJ.findPortInst("polysilicon-1"));
// export input and outputcom.sun.electric.database.hierarchy.Export.newInstance(newCell, inPin.findPortInst("polysilicon-1"), "IN", PortCharacteristic.IN); com.sun.electric.database.hierarchy.Export.newInstance(newCell, outPin.findPortInst("metal-1"), "OUT", PortCharacteristic.OUT);
_______________________________________________ Discuss-gnu-electric mailing list Discuss-gnu-electric@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnu-electric