~ubuntu-branches/ubuntu/natty/electric/natty

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/io/input/Spice.java

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2010-01-09 16:26:04 UTC
  • mfrom: (1.1.4 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100109162604-1ypvmy8ijmlc6oq7
Tags: 8.10-1
* New upstream version.
* debian/control
  - Add libjava3d-java and quilt build dependencies.
  - Update standards version to 3.8.3.
  - Add libjava3d-java as recommends to binary package.
* debian/rules
  - Use quilt patch system instead of simple patchsys.
  - Add java3d related jar files to DEB_JARS.
* debian/patches/*
  - Update as per current upstream source. Convert to quilt.
* debian/ant.properties
  - Do not disable 3D plugin anymore.
  - Use new property to disable compilation of OS X related classes.
* debian/wrappers/electric
  - Add java3d related jar files to runtime classpath.
* debian/README.source
  - Change text to the appropriate one for quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
import com.sun.electric.database.geometry.EPoint;
29
29
import com.sun.electric.database.geometry.Orientation;
 
30
import com.sun.electric.database.geometry.Poly;
30
31
import com.sun.electric.database.hierarchy.Cell;
31
32
import com.sun.electric.database.hierarchy.Export;
32
33
import com.sun.electric.database.hierarchy.Library;
 
34
import com.sun.electric.database.id.CellId;
33
35
import com.sun.electric.database.prototype.PortCharacteristic;
34
36
import com.sun.electric.database.prototype.PortProto;
35
37
import com.sun.electric.database.text.TextUtils;
36
38
import com.sun.electric.database.topology.ArcInst;
37
39
import com.sun.electric.database.topology.NodeInst;
38
40
import com.sun.electric.database.topology.PortInst;
39
 
import com.sun.electric.database.variable.MutableTextDescriptor;
40
41
import com.sun.electric.database.variable.TextDescriptor;
41
 
import com.sun.electric.database.variable.Variable;
42
42
import com.sun.electric.technology.ArcProto;
43
43
import com.sun.electric.technology.PrimitiveNode;
44
44
import com.sun.electric.technology.Technology;
45
45
import com.sun.electric.technology.technologies.Artwork;
46
46
import com.sun.electric.technology.technologies.Schematics;
47
47
import com.sun.electric.tool.Job;
 
48
import com.sun.electric.tool.placement.Placement;
 
49
import com.sun.electric.tool.placement.PlacementFrame;
 
50
import com.sun.electric.tool.placement.Placement.PlacementPreferences;
 
51
import com.sun.electric.tool.placement.PlacementFrame.PlacementExport;
 
52
import com.sun.electric.tool.placement.PlacementFrame.PlacementNetwork;
 
53
import com.sun.electric.tool.placement.PlacementFrame.PlacementNode;
 
54
import com.sun.electric.tool.placement.PlacementFrame.PlacementPort;
48
55
 
49
56
import java.io.File;
50
57
import java.io.IOException;
51
58
import java.net.URL;
52
59
import java.util.ArrayList;
 
60
import java.util.BitSet;
53
61
import java.util.HashMap;
54
62
import java.util.HashSet;
55
63
import java.util.List;
67
75
 
68
76
        public static class SpicePreferences extends InputPreferences
69
77
    {
 
78
                public String placementAlgorithm;
 
79
 
70
80
                public SpicePreferences(boolean factory) { super(factory); }
71
81
 
72
 
        public Library doInput(URL fileURL, Library lib, Technology tech, Map<Library,Cell> currentCells, Job job)
 
82
                public void initFromUserDefaults()
 
83
                {
 
84
                        placementAlgorithm = Placement.getAlgorithmName();
 
85
                }
 
86
 
 
87
        @Override
 
88
        public Library doInput(URL fileURL, Library lib, Technology tech, Map<Library,Cell> currentCells, Map<CellId,BitSet> nodesToExpand, Job job)
73
89
        {
74
90
                Spice in = new Spice(this);
75
91
                        in.readDirectory(fileURL, lib);
164
180
                                for(int i=6; i<traPieces.length; i++)
165
181
                                {
166
182
                                        if (traPieces[i].toLowerCase().startsWith("w="))
167
 
                                                td.width = traPieces[i];
 
183
                                                td.width = traPieces[i].substring(2);
168
184
                                        if (traPieces[i].toLowerCase().startsWith("l="))
169
 
                                                td.length = traPieces[i];
 
185
                                                td.length = traPieces[i].substring(2);
170
186
                                }
171
187
                                continue;
172
188
                        }
230
246
 
231
247
        private void placeCells(Library lib)
232
248
        {
 
249
                PlacementPreferences prefs = new PlacementPreferences(false);
 
250
                prefs.placementAlgorithm = localPrefs.placementAlgorithm;
 
251
                PlacementFrame pla = Placement.getCurrentPlacementAlgorithm(prefs);
 
252
                System.out.println("Placing cells using the " + pla.getAlgorithmName() + " algorithm");
 
253
 
233
254
                // make icons
234
255
                for(String name : allCells.keySet())
235
256
                {
260
281
                        EPoint center = new EPoint(7, (yPos-2+lowY)/2);
261
282
                        PrimitiveNode np = Artwork.tech().boxNode;
262
283
                        NodeInst ni = NodeInst.makeInstance(np, center, width, height, cell);
263
 
                        ni.setName(name);
 
284
                        ni.setName(name.replaceAll("@", "_"));
264
285
                        TextDescriptor newTD = ni.getTextDescriptor(NodeInst.NODE_NAME).withRelSize(2);
265
286
                        ni.setTextDescriptor(NodeInst.NODE_NAME, newTD);
266
287
                }
267
 
                
 
288
 
268
289
                // now make the schematic cells
269
290
                for(String name : allCells.keySet())
270
291
                {
271
292
                        SubcktDef sd = allCells.get(name);
272
 
                        Cell cell = Cell.makeInstance(lib, name + "{sch}");
273
 
                        if (sd.iconCell != null)
274
 
                        {
275
 
                                EPoint center = new EPoint(0, 15);
276
 
                                NodeInst.makeInstance(sd.iconCell, center, sd.iconCell.getDefWidth(), sd.iconCell.getDefHeight(), cell);
277
 
                        }
278
 
 
279
 
                        // place transistors
280
 
                        double pPos = 0, nPos = 0;
 
293
 
 
294
                        // use the placement tool to situate the objects
 
295
                        List<PlacementNode> nodesToPlace = new ArrayList<PlacementNode>();
 
296
                        Map<String,PlacementNetwork> allNetworks = new HashMap<String,PlacementNetwork>();
 
297
                        List<PlacementExport> exportsToPlace = new ArrayList<PlacementExport>();
 
298
 
 
299
                        // make PlacementNodes for the transistors
281
300
                        for(TransistorDef td : sd.transistors)
282
301
                        {
283
 
                                EPoint center = null;
284
 
                                PrimitiveNode.Function func = null;
285
 
                                if (td.type.equals("p"))
286
 
                                {
287
 
                                        center = new EPoint(pPos, 5);
288
 
                                        pPos += 10;
289
 
                                        func = PrimitiveNode.Function.TRAPMOS;
290
 
                                } else
291
 
                                {
292
 
                                        center = new EPoint(nPos, -5);
293
 
                                        nPos += 10;
294
 
                                        func = PrimitiveNode.Function.TRANMOS;
295
 
                                }
 
302
                                int bits = 0;
 
303
                                if (td.type.equals("p")) bits = Schematics.getPrimitiveFunctionBits(PrimitiveNode.Function.TRAPMOS); else
 
304
                                        bits = Schematics.getPrimitiveFunctionBits(PrimitiveNode.Function.TRANMOS);
296
305
                                PrimitiveNode np = Schematics.tech().transistorNode;
297
 
                                Orientation o = Orientation.R;
298
 
                                NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
299
 
                                        cell, o, "m" + td.name, func);
300
 
                                TextDescriptor tdesc = TextDescriptor.newTextDescriptor(MutableTextDescriptor.getNodeTextDescriptor());
301
 
                        TextDescriptor.Rotation r = TextDescriptor.Rotation.getRotation(270);
302
 
                                ni.setTextDescriptor(NodeInst.NODE_NAME, tdesc.withRotation(r).withPos(TextDescriptor.Position.DOWNLEFT));
303
 
                                if (td.width != null)
304
 
                                {
305
 
                                        Variable var = ni.newDisplayVar(Schematics.ATTR_WIDTH, td.width);
306
 
                                        TextDescriptor newTD = var.getTextDescriptor().
307
 
                                                withRotation(r).withOff(0.5, -0.5).withRelSize(1).withPos(TextDescriptor.Position.DOWN);
308
 
                                        ni.setTextDescriptor(Schematics.ATTR_WIDTH, newTD);
309
 
                                }
310
 
                                if (td.length != null)
311
 
                                {
312
 
                                        Variable var = ni.newDisplayVar(Schematics.ATTR_LENGTH, td.length);
313
 
                                        TextDescriptor newTD = var.getTextDescriptor().
314
 
                                                withRotation(r).withOff(-0.5, -0.75).withRelSize(0.5).withPos(TextDescriptor.Position.DOWN);
315
 
                                        ni.setTextDescriptor(Schematics.ATTR_LENGTH, newTD);
316
 
                                }
317
 
                                PortInst piSource = ni.getTransistorSourcePort();
318
 
                                addLead(piSource, 0, -2, cell, td.source, sd.exports, sd.usedExports);
319
 
                                PortInst piGate = ni.getTransistorGatePort();
320
 
                                addLead(piGate, -2, 0, cell, td.gate, sd.exports, sd.usedExports);
321
 
                                PortInst piDrain = ni.getTransistorDrainPort();
322
 
                                addLead(piDrain, 0, 2, cell, td.drain, sd.exports, sd.usedExports);
 
306
                                NodeInst niDummy = NodeInst.makeDummyInstance(np);
 
307
 
 
308
                                List<PlacementPort> ports = new ArrayList<PlacementPort>();
 
309
                                PortInst piSource = niDummy.getTransistorSourcePort();
 
310
                                ports.add(addPlacementPort(niDummy, piSource, td.source, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
311
                                PortInst piGate = niDummy.getTransistorGatePort();
 
312
                                ports.add(addPlacementPort(niDummy, piGate, td.gate, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
313
                                PortInst piDrain = niDummy.getTransistorDrainPort();
 
314
                                ports.add(addPlacementPort(niDummy, piDrain, td.drain, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
315
 
 
316
                                PlacementNode plNode = new PlacementNode(np, "m" + td.name, bits, np.getDefWidth(), np.getDefHeight(), ports);
 
317
                                nodesToPlace.add(plNode);
 
318
                                for(PlacementPort plPort : ports)
 
319
                                        plPort.setPlacementNode(plNode);
 
320
                                plNode.setOrientation(Orientation.IDENT);
 
321
                                if (td.width != null) plNode.addVariable(Schematics.ATTR_WIDTH, td.width);
 
322
                                if (td.length != null) plNode.addVariable(Schematics.ATTR_LENGTH, td.length);
323
323
                        }
324
324
 
325
325
                        // place resistors and capacitors
326
326
                        for(ResistorDef rd : sd.resistors)
327
327
                        {
328
 
                                EPoint center = new EPoint(pPos, 5);
329
 
                                pPos += 10;
330
328
                                PrimitiveNode np = Schematics.tech().resistorNode;
331
 
                                NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
332
 
                                        cell, Orientation.IDENT, "r" + rd.name);
333
 
                                if (rd.resistance != null)
334
 
                                {
335
 
                                        Variable var = ni.newDisplayVar(Schematics.SCHEM_RESISTANCE, rd.resistance);
336
 
                                        TextDescriptor newTD = var.getTextDescriptor().
337
 
                                                withOff(0, 0.5).withPos(TextDescriptor.Position.UP);
338
 
                                        ni.setTextDescriptor(Schematics.SCHEM_RESISTANCE, newTD);
339
 
                                }
340
 
                                PortInst piSource = ni.getPortInst(0);
341
 
                                addLead(piSource, -2, 0, cell, rd.left, sd.exports, sd.usedExports);
342
 
                                PortInst piGate = ni.getPortInst(1);
343
 
                                addLead(piGate, 2, 0, cell, rd.right, sd.exports, sd.usedExports);
 
329
                                NodeInst niDummy = NodeInst.makeDummyInstance(np);
 
330
 
 
331
                                List<PlacementPort> ports = new ArrayList<PlacementPort>();
 
332
                                PortInst piSource = niDummy.getPortInst(0);
 
333
                                ports.add(addPlacementPort(niDummy, piSource, rd.left, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
334
                                PortInst piGate = niDummy.getPortInst(1);
 
335
                                ports.add(addPlacementPort(niDummy, piGate, rd.right, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
336
 
 
337
                                PlacementNode plNode = new PlacementNode(np, "r" + rd.name, 0, np.getDefWidth(), np.getDefHeight(), ports);
 
338
                                nodesToPlace.add(plNode);
 
339
                                for(PlacementPort plPort : ports)
 
340
                                        plPort.setPlacementNode(plNode);
 
341
                                plNode.setOrientation(Orientation.IDENT);
 
342
                                if (rd.resistance != null) plNode.addVariable(Schematics.SCHEM_RESISTANCE, rd.resistance);
344
343
                        }
345
344
                        for(CapacitorDef cd : sd.capacitors)
346
345
                        {
347
 
                                EPoint center = new EPoint(nPos, -5);
348
 
                                nPos += 10;
349
346
                                PrimitiveNode np = Schematics.tech().capacitorNode;
350
 
                                NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
351
 
                                        cell, Orientation.IDENT, "c" + cd.name);
352
 
                                if (cd.capacitance != null)
353
 
                                        ni.newDisplayVar(Schematics.SCHEM_CAPACITANCE, cd.capacitance);
354
 
                                PortInst piSource = ni.getPortInst(0);
355
 
                                addLead(piSource, 0, 2, cell, cd.top, sd.exports, sd.usedExports);
356
 
                                PortInst piGate = ni.getPortInst(1);
357
 
                                addLead(piGate, 0, -2, cell, cd.bottom, sd.exports, sd.usedExports);
 
347
                                NodeInst niDummy = NodeInst.makeDummyInstance(np);
 
348
 
 
349
                                List<PlacementPort> ports = new ArrayList<PlacementPort>();
 
350
                                PortInst piSource = niDummy.getPortInst(0);
 
351
                                ports.add(addPlacementPort(niDummy, piSource, cd.top, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
352
                                PortInst piGate = niDummy.getPortInst(1);
 
353
                                ports.add(addPlacementPort(niDummy, piGate, cd.bottom, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
354
 
 
355
                                PlacementNode plNode = new PlacementNode(np, "c" + cd.name, 0, np.getDefWidth(), np.getDefHeight(), ports);
 
356
                                nodesToPlace.add(plNode);
 
357
                                for(PlacementPort plPort : ports)
 
358
                                        plPort.setPlacementNode(plNode);
 
359
                                plNode.setOrientation(Orientation.IDENT);
 
360
                                if (cd.capacitance != null) plNode.addVariable(Schematics.SCHEM_CAPACITANCE, cd.capacitance);
358
361
                        }
359
362
 
360
363
                        // place instances
361
 
                        double iPos = 0;
362
364
                        for(InstanceDef id : sd.instances)
363
365
                        {
364
366
                                SubcktDef subSD = allCells.get(id.instName);
368
370
                                        continue;
369
371
                                }
370
372
                                Cell np = subSD.iconCell;
371
 
                                EPoint center = new EPoint(iPos, -10-np.getDefHeight());
372
 
                                iPos += 30;
373
 
                                NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(), cell);
374
 
                                ni.setName(id.name.replace('@', '_'));
375
 
                                TextDescriptor newTD = ni.getTextDescriptor(NodeInst.NODE_NAME).
376
 
                                        withOff(1, -1).withPos(TextDescriptor.Position.DOWN);
377
 
                                ni.setTextDescriptor(NodeInst.NODE_NAME, newTD);
 
373
                                NodeInst niDummy = NodeInst.makeDummyInstance(np);
378
374
                                if (subSD.exports.size() != id.signals.size())
379
375
                                {
380
376
                                        System.out.println("Error: Subcircuit " + id.instName + " has " + subSD.exports.size() +
381
 
                                                " exports but instance " + id.name + " of it in cell " + cell.describe(false) +
 
377
                                                " exports but instance " + id.name + " of it in cell " + name + "{sch}" +
382
378
                                                " has " + id.signals.size() + " signals on it");
383
379
                                        continue;
384
380
                                }
 
381
                                List<PlacementPort> ports = new ArrayList<PlacementPort>();
385
382
                                for(int i=0; i<subSD.exports.size(); i++)
386
383
                                {
387
384
                                        PortProto pp = subSD.iconCell.findPortProto(subSD.exports.get(i));
388
385
                                        if (pp == null) continue;
389
 
                                        PortInst pi = ni.findPortInstFromProto(pp);
 
386
                                        PortInst pi = niDummy.findPortInstFromProto(pp);
390
387
                                        String sigName = id.signals.get(i);
391
 
                                        addLead(pi, -2, 0, cell, sigName, sd.exports, sd.usedExports);
 
388
                                        ports.add(addPlacementPort(niDummy, pi, sigName, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
392
389
                                }
 
390
 
 
391
                                PlacementNode plNode = new PlacementNode(np, id.name.replace('@', '_'), 0, np.getDefWidth(), np.getDefHeight(), ports);
 
392
                                nodesToPlace.add(plNode);
 
393
                                for(PlacementPort plPort : ports)
 
394
                                        plPort.setPlacementNode(plNode);
 
395
                                plNode.setOrientation(Orientation.IDENT);
393
396
                        }
394
397
 
395
398
                        // add dummy pins for unused exports
396
 
                        double dummyPos = 30;
397
399
                        for(String export : sd.exports)
398
400
                        {
399
401
                                if (sd.usedExports.contains(export)) continue;
400
 
                                EPoint ctr = new EPoint(dummyPos, 15);
401
 
                                dummyPos += 10;
402
402
                                PrimitiveNode np = Schematics.tech().wirePinNode;
403
 
                                NodeInst ni = NodeInst.makeInstance(np, ctr, np.getDefWidth(), np.getDefHeight(), cell);
404
 
                                Export.newInstance(cell, ni.getOnlyPortInst(), export, PortCharacteristic.UNKNOWN);
405
 
                        }
 
403
                                NodeInst niDummy = NodeInst.makeDummyInstance(np);
 
404
                                List<PlacementPort> ports = new ArrayList<PlacementPort>();
 
405
                                PortInst pi = niDummy.getPortInst(0);
 
406
                                ports.add(addPlacementPort(niDummy, pi, export, allNetworks, sd.exports, sd.usedExports, exportsToPlace));
 
407
 
 
408
                                PlacementNode plNode = new PlacementNode(np, null, 0, np.getDefWidth(), np.getDefHeight(), ports);
 
409
                                nodesToPlace.add(plNode);
 
410
                                for(PlacementPort plPort : ports)
 
411
                                        plPort.setPlacementNode(plNode);
 
412
                                plNode.setOrientation(Orientation.IDENT);
 
413
                        }
 
414
 
 
415
                        // make a list of PlacementNetworks
 
416
                        List<PlacementNetwork> nets = new ArrayList<PlacementNetwork>();
 
417
                        for(String netName : allNetworks.keySet())
 
418
                        {
 
419
                                PlacementNetwork net = allNetworks.get(netName);
 
420
                                for(PlacementPort port : net.getPortsOnNet())
 
421
                                        port.setPlacementNetwork(net);
 
422
                                if (net.getPortsOnNet() == null || net.getPortsOnNet().size() <= 1) continue;
 
423
                                nets.add(net);
 
424
                        }
 
425
 
 
426
                        // run placement
 
427
                        pla.doPlacement(lib, name + "{sch}", nodesToPlace, nets, exportsToPlace, sd.iconCell);
 
428
 
 
429
                        // the old way...
 
430
//                      Cell cell = Cell.makeInstance(lib, name + "{sch}");
 
431
//                      if (sd.iconCell != null)
 
432
//                      {
 
433
//                              EPoint center = new EPoint(0, 15);
 
434
//                              NodeInst.makeInstance(sd.iconCell, center, sd.iconCell.getDefWidth(), sd.iconCell.getDefHeight(), cell);
 
435
//                      }
 
436
//
 
437
//                      // place transistors
 
438
//                      double pPos = 0, nPos = 0;
 
439
//                      for(TransistorDef td : sd.transistors)
 
440
//                      {
 
441
//                              EPoint center = null;
 
442
//                              PrimitiveNode.Function func = null;
 
443
//                              if (td.type.equals("p"))
 
444
//                              {
 
445
//                                      center = new EPoint(pPos, 5);
 
446
//                                      pPos += 10;
 
447
//                                      func = PrimitiveNode.Function.TRAPMOS;
 
448
//                              } else
 
449
//                              {
 
450
//                                      center = new EPoint(nPos, -5);
 
451
//                                      nPos += 10;
 
452
//                                      func = PrimitiveNode.Function.TRANMOS;
 
453
//                              }
 
454
//                              PrimitiveNode np = Schematics.tech().transistorNode;
 
455
//                              Orientation o = Orientation.R;
 
456
//                              NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
 
457
//                                      cell, o, "m" + td.name, func);
 
458
//                              TextDescriptor tdesc = TextDescriptor.newTextDescriptor(MutableTextDescriptor.getNodeTextDescriptor());
 
459
//                      TextDescriptor.Rotation r = TextDescriptor.Rotation.getRotation(270);
 
460
//                              ni.setTextDescriptor(NodeInst.NODE_NAME, tdesc.withRotation(r).withPos(TextDescriptor.Position.DOWNLEFT));
 
461
//                              if (td.width != null)
 
462
//                              {
 
463
//                                      Variable var = ni.newDisplayVar(Schematics.ATTR_WIDTH, td.width);
 
464
//                                      TextDescriptor newTD = var.getTextDescriptor().
 
465
//                                              withRotation(r).withOff(0.5, -0.5).withRelSize(1).withPos(TextDescriptor.Position.DOWN);
 
466
//                                      ni.setTextDescriptor(Schematics.ATTR_WIDTH, newTD);
 
467
//                              }
 
468
//                              if (td.length != null)
 
469
//                              {
 
470
//                                      Variable var = ni.newDisplayVar(Schematics.ATTR_LENGTH, td.length);
 
471
//                                      TextDescriptor newTD = var.getTextDescriptor().
 
472
//                                              withRotation(r).withOff(-0.5, -0.75).withRelSize(0.5).withPos(TextDescriptor.Position.DOWN);
 
473
//                                      ni.setTextDescriptor(Schematics.ATTR_LENGTH, newTD);
 
474
//                              }
 
475
//                              PortInst piSource = ni.getTransistorSourcePort();
 
476
//                              addLead(piSource, 0, -2, cell, td.source, sd.exports, sd.usedExports);
 
477
//                              PortInst piGate = ni.getTransistorGatePort();
 
478
//                              addLead(piGate, -2, 0, cell, td.gate, sd.exports, sd.usedExports);
 
479
//                              PortInst piDrain = ni.getTransistorDrainPort();
 
480
//                              addLead(piDrain, 0, 2, cell, td.drain, sd.exports, sd.usedExports);
 
481
//                      }
 
482
//
 
483
//                      // place resistors and capacitors
 
484
//                      for(ResistorDef rd : sd.resistors)
 
485
//                      {
 
486
//                              EPoint center = new EPoint(pPos, 5);
 
487
//                              pPos += 10;
 
488
//                              PrimitiveNode np = Schematics.tech().resistorNode;
 
489
//                              NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
 
490
//                                      cell, Orientation.IDENT, "r" + rd.name);
 
491
//                              if (rd.resistance != null)
 
492
//                              {
 
493
//                                      Variable var = ni.newDisplayVar(Schematics.SCHEM_RESISTANCE, rd.resistance);
 
494
//                                      TextDescriptor newTD = var.getTextDescriptor().
 
495
//                                              withOff(0, 0.5).withPos(TextDescriptor.Position.UP);
 
496
//                                      ni.setTextDescriptor(Schematics.SCHEM_RESISTANCE, newTD);
 
497
//                              }
 
498
//                              PortInst piSource = ni.getPortInst(0);
 
499
//                              addLead(piSource, -2, 0, cell, rd.left, sd.exports, sd.usedExports);
 
500
//                              PortInst piGate = ni.getPortInst(1);
 
501
//                              addLead(piGate, 2, 0, cell, rd.right, sd.exports, sd.usedExports);
 
502
//                      }
 
503
//                      for(CapacitorDef cd : sd.capacitors)
 
504
//                      {
 
505
//                              EPoint center = new EPoint(nPos, -5);
 
506
//                              nPos += 10;
 
507
//                              PrimitiveNode np = Schematics.tech().capacitorNode;
 
508
//                              NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(),
 
509
//                                      cell, Orientation.IDENT, "c" + cd.name);
 
510
//                              if (cd.capacitance != null)
 
511
//                                      ni.newDisplayVar(Schematics.SCHEM_CAPACITANCE, cd.capacitance);
 
512
//                              PortInst piSource = ni.getPortInst(0);
 
513
//                              addLead(piSource, 0, 2, cell, cd.top, sd.exports, sd.usedExports);
 
514
//                              PortInst piGate = ni.getPortInst(1);
 
515
//                              addLead(piGate, 0, -2, cell, cd.bottom, sd.exports, sd.usedExports);
 
516
//                      }
 
517
//
 
518
//                      // place instances
 
519
//                      double iPos = 0;
 
520
//                      for(InstanceDef id : sd.instances)
 
521
//                      {
 
522
//                              SubcktDef subSD = allCells.get(id.instName);
 
523
//                              if (subSD == null)
 
524
//                              {
 
525
//                                      System.out.println("Cannot find subcircuit "+id.instName);
 
526
//                                      continue;
 
527
//                              }
 
528
//                              Cell np = subSD.iconCell;
 
529
//                              EPoint center = new EPoint(iPos, -10-np.getDefHeight());
 
530
//                              iPos += 30;
 
531
//                              NodeInst ni = NodeInst.makeInstance(np, center, np.getDefWidth(), np.getDefHeight(), cell);
 
532
//                              ni.setName(id.name.replace('@', '_'));
 
533
//                              TextDescriptor newTD = ni.getTextDescriptor(NodeInst.NODE_NAME).
 
534
//                                      withOff(1, -1).withPos(TextDescriptor.Position.DOWN);
 
535
//                              ni.setTextDescriptor(NodeInst.NODE_NAME, newTD);
 
536
//                              if (subSD.exports.size() != id.signals.size())
 
537
//                              {
 
538
//                                      System.out.println("Error: Subcircuit " + id.instName + " has " + subSD.exports.size() +
 
539
//                                              " exports but instance " + id.name + " of it in cell " + cell.describe(false) +
 
540
//                                              " has " + id.signals.size() + " signals on it");
 
541
//                                      continue;
 
542
//                              }
 
543
//                              for(int i=0; i<subSD.exports.size(); i++)
 
544
//                              {
 
545
//                                      PortProto pp = subSD.iconCell.findPortProto(subSD.exports.get(i));
 
546
//                                      if (pp == null) continue;
 
547
//                                      PortInst pi = ni.findPortInstFromProto(pp);
 
548
//                                      String sigName = id.signals.get(i);
 
549
//                                      addLead(pi, -2, 0, cell, sigName, sd.exports, sd.usedExports);
 
550
//                              }
 
551
//                      }
 
552
//
 
553
//                      // add dummy pins for unused exports
 
554
//                      double dummyPos = 30;
 
555
//                      for(String export : sd.exports)
 
556
//                      {
 
557
//                              if (sd.usedExports.contains(export)) continue;
 
558
//                              EPoint ctr = new EPoint(dummyPos, 15);
 
559
//                              dummyPos += 10;
 
560
//                              PrimitiveNode np = Schematics.tech().wirePinNode;
 
561
//                              NodeInst ni = NodeInst.makeInstance(np, ctr, np.getDefWidth(), np.getDefHeight(), cell);
 
562
//                              Export.newInstance(cell, ni.getOnlyPortInst(), export, PortCharacteristic.UNKNOWN);
 
563
//                      }
406
564
                }
407
565
        }
408
566
 
409
 
        private void addLead(PortInst pi, double dX, double dY, Cell cell, String name, List<String> exports, Set<String> usedExports)
 
567
        private PlacementPort addPlacementPort(NodeInst ni, PortInst pi, String name, Map<String,PlacementNetwork> allNetworks,
 
568
                List<String> exports, Set<String> usedExports, List<PlacementExport> exportsToPlace)
410
569
        {
411
 
                EPoint ctr1 = pi.getCenter();
412
 
                EPoint ctr2 = new EPoint(ctr1.getX()+dX, ctr1.getY()+dY);
413
 
 
414
 
                PrimitiveNode np = Schematics.tech().wirePinNode;
415
 
                NodeInst ni = NodeInst.makeInstance(np, ctr2, np.getDefWidth(), np.getDefHeight(), cell);
416
 
                ArcProto ap = Schematics.tech().wire_arc;
417
 
                PortInst pi2 = ni.getOnlyPortInst();
418
 
                ArcInst ai = ArcInst.makeInstance(ap, pi, pi2);
419
 
 
420
 
                name = name.replace('@', '_');
 
570
                PlacementNetwork net = allNetworks.get(name);
 
571
                if (net == null) allNetworks.put(name, net = new PlacementNetwork(new ArrayList<PlacementPort>()));
 
572
                List<PlacementPort> portsOnNet = net.getPortsOnNet();
 
573
 
 
574
                Poly poly = pi.getPoly();
 
575
                double offX = poly.getCenterX() - ni.getTrueCenterX();
 
576
                double offY = poly.getCenterY() - ni.getTrueCenterY();
 
577
                PlacementPort plPort = new PlacementPort(offX, offY, pi.getPortProto());
 
578
                portsOnNet.add(plPort);
 
579
 
 
580
                // see if this port is exported
421
581
                if (exports.contains(name) && !usedExports.contains(name))
422
582
                {
423
583
                        usedExports.add(name);
424
 
                        Export.newInstance(cell, pi2, name, PortCharacteristic.UNKNOWN);
425
 
                } else
426
 
                {
427
 
                        ai.setName(name);
428
 
                        TextDescriptor.Position p = (dX == 0) ? TextDescriptor.Position.LEFT : TextDescriptor.Position.DOWN;
429
 
                        TextDescriptor newTD = ai.getTextDescriptor(ArcInst.ARC_NAME).withPos(p);
430
 
                        ai.setTextDescriptor(ArcInst.ARC_NAME, newTD);
 
584
                        PlacementExport plExport = new PlacementExport(plPort, name, PortCharacteristic.UNKNOWN);
 
585
                        exportsToPlace.add(plExport);
431
586
                }
 
587
                return plPort;
432
588
        }
433
589
 
 
590
//      private void addLead(PortInst pi, double dX, double dY, Cell cell, String name, List<String> exports, Set<String> usedExports)
 
591
//      {
 
592
//              EPoint ctr1 = pi.getCenter();
 
593
//              EPoint ctr2 = new EPoint(ctr1.getX()+dX, ctr1.getY()+dY);
 
594
//
 
595
//              PrimitiveNode np = Schematics.tech().wirePinNode;
 
596
//              NodeInst ni = NodeInst.makeInstance(np, ctr2, np.getDefWidth(), np.getDefHeight(), cell);
 
597
//              ArcProto ap = Schematics.tech().wire_arc;
 
598
//              PortInst pi2 = ni.getOnlyPortInst();
 
599
//              ArcInst ai = ArcInst.makeInstance(ap, pi, pi2);
 
600
//
 
601
//              name = name.replace('@', '_');
 
602
//              if (exports.contains(name) && !usedExports.contains(name))
 
603
//              {
 
604
//                      usedExports.add(name);
 
605
//                      Export.newInstance(cell, pi2, name, PortCharacteristic.UNKNOWN);
 
606
//              } else
 
607
//              {
 
608
//                      ai.setName(name);
 
609
//                      TextDescriptor.Position p = (dX == 0) ? TextDescriptor.Position.LEFT : TextDescriptor.Position.DOWN;
 
610
//                      TextDescriptor newTD = ai.getTextDescriptor(ArcInst.ARC_NAME).withPos(p);
 
611
//                      ai.setTextDescriptor(ArcInst.ARC_NAME, newTD);
 
612
//              }
 
613
//      }
 
614
 
434
615
        private String lastLine = null;
435
616
 
436
617
        private String getNextLine()