~ubuntu-branches/ubuntu/vivid/electric/vivid

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/placement/Placement.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2014-07-08 21:54:23 UTC
  • mfrom: (1.1.6) (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20140708215423-4zrgsca1e28tzcoc
Tags: 9.05+dfsg-1
* Imported Upstream version 9.05+dfsg.
* Add signing-key.pgp and check for valid upstream tarballs with uscan's
  pgpsigurlmangle feature.
* Move the package to Git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
import com.sun.electric.tool.placement.PlacementAdapter.PlacementNode;
45
45
import com.sun.electric.tool.placement.PlacementAdapter.PlacementPort;
46
46
import com.sun.electric.tool.placement.PlacementFrame.PlacementNetwork;
 
47
import com.sun.electric.tool.routing.Routing;
 
48
import com.sun.electric.tool.routing.SeaOfGates;
 
49
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine;
 
50
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngineFactory;
 
51
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngineFactory.SeaOfGatesEngineType;
 
52
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesHandlers;
 
53
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesHandlers.Save;
47
54
import com.sun.electric.tool.user.User;
48
55
import com.sun.electric.tool.user.ui.WindowFrame;
49
56
import com.sun.electric.util.CollectionFactory;
52
59
import java.io.Serializable;
53
60
import java.util.ArrayList;
54
61
import java.util.HashMap;
 
62
import java.util.HashSet;
55
63
import java.util.Iterator;
56
64
import java.util.List;
57
65
import java.util.Map;
 
66
import java.util.Set;
58
67
import java.util.prefs.Preferences;
59
68
 
60
69
/**
129
138
 
130
139
                public boolean doIt() throws JobException
131
140
                {
132
 
                        newCell = placeCellNoJob(cell, getEditingPreferences(), prefs, false, this);
133
141
                        PlacementFrame pla = getCurrentPlacementAlgorithm(prefs);
 
142
                        newCell = placeCellNoJob(cell, getEditingPreferences(), pla, prefs, false, this);
134
143
                        Cell redispCell = pla.getRedispCell();
135
144
                        if (redispCell != null) newCell = redispCell;
136
145
                        fieldVariableChanged("newCell");
145
154
                                if (User.isShowCellsInNewWindow()) wf = null;
146
155
                                if (wf == null) wf = WindowFrame.createEditWindow(newCell);
147
156
                    wf.setCellWindow(newCell, null);
 
157
 
 
158
                    List<Cell> cellsToRoute = new ArrayList<Cell>();
 
159
                    Set<Cell> cellsScheduled = new HashSet<Cell>();
 
160
                    if (prefs.placementRunRouting)
 
161
                    {
 
162
                        // see if general placement was done, with partitioning into subcells
 
163
                        if (prefs.placementAlgorithm.equals(PlacementAdapter.GEN.getAlgorithmName()))
 
164
                        {
 
165
                                // first route the subcells
 
166
                                for(Iterator<NodeInst> it = newCell.getNodes(); it.hasNext(); )
 
167
                                {
 
168
                                        NodeInst ni = it.next();
 
169
                                        if (ni.isCellInstance())
 
170
                                        {
 
171
                                                Cell cell = (Cell)ni.getProto();
 
172
                                                if (cell.getName().startsWith("CLUSTER"))
 
173
                                                {
 
174
                                                        if (!cellsScheduled.contains(cell))
 
175
                                                        {
 
176
                                                                cellsScheduled.add(cell);
 
177
                                                                cellsToRoute.add(cell);
 
178
                                                        }
 
179
                                                }
 
180
                                        }
 
181
                                }
 
182
                        }
 
183
 
 
184
                        // route the top-level cell
 
185
                        cellsToRoute.add(newCell);
 
186
 
 
187
                        // now do all the routings
 
188
                        new AllRoutingJob(cellsToRoute);
 
189
                    }
148
190
                        }
149
191
                }
150
192
        }
151
193
 
 
194
    /**
 
195
     * Class to run sea-of-gates routing, cell by cell, in new jobs.
 
196
     */
 
197
    private static class AllRoutingJob extends Job
 
198
    {
 
199
        private final List<Cell> cells;
 
200
        private final SeaOfGates.SeaOfGatesOptions prefs = new SeaOfGates.SeaOfGatesOptions();
 
201
 
 
202
        protected AllRoutingJob(List<Cell> cells)
 
203
        {
 
204
            super("Sea-Of-Gates Route", Routing.getRoutingTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);
 
205
            this.cells = cells;
 
206
            prefs.getOptionsFromPreferences(false);
 
207
            startJob();
 
208
        }
 
209
 
 
210
        @Override
 
211
        public boolean doIt() throws JobException
 
212
        {
 
213
                Cell cell = cells.get(0);
 
214
            SeaOfGatesEngine router = SeaOfGatesEngineFactory.createSeaOfGatesEngine(SeaOfGatesEngineType.defaultVersion);
 
215
            router.setPrefs(prefs);
 
216
            SeaOfGatesEngine.Handler handler = SeaOfGatesHandlers.getDefault(cell, null, this, getEditingPreferences(), Save.SAVE_ONCE);
 
217
            router.routeIt(handler, cell, true);
 
218
            return true;
 
219
        }
 
220
 
 
221
                public void terminateOK()
 
222
                {
 
223
                        cells.remove(0);
 
224
                        if (cells.size() > 0)
 
225
                        {
 
226
                                new AllRoutingJob(cells);
 
227
                        }
 
228
                }
 
229
    }
 
230
 
152
231
        /**
153
232
         * Entry point to do Placement of a Cell and create a new, placed Cell.
154
233
         * Gathers the requirements for Placement into a collection of shadow
162
241
         * @param job the Job (for detecting abort).
163
242
         * @return the new Cell with the placement results.
164
243
         */
165
 
        public static Cell placeCellNoJob(Cell cell, EditingPreferences ep, PlacementPreferences prefs, boolean quiet, Job job)
 
244
        public static Cell placeCellNoJob(Cell cell, EditingPreferences ep, PlacementFrame pla, PlacementPreferences prefs, boolean quiet, Job job)
166
245
    {
167
246
                if (!quiet)
168
247
                {
170
249
                        Job.getUserInterface().setProgressNote("Acquiring netlist...");
171
250
                }
172
251
                System.out.println();
173
 
                PlacementFrame pla = getCurrentPlacementAlgorithm(prefs);
174
 
        // get network information for the Cell
 
252
 
 
253
                // get network information for the Cell
175
254
                Netlist netList = cell.getNetlist();
176
255
                if (netList == null) {
177
256
                        System.out.println("Sorry, a deadlock aborted routing (network information unavailable).  Please try again");
206
285
                                        if (fun != PrimitiveNode.Function.CONNECT && fun != PrimitiveNode.Function.CONTACT && !fun.isPin())
207
286
                                                validNode = true;
208
287
                                }
209
 
                                if (ni.hasExports())
210
 
                                        validNode = true;
 
288
                                // TODO: should ignore pins, but can't ignore exports
 
289
                                if (ni.hasExports()) validNode = true;
211
290
                        }
212
291
                        if (validNode) {
213
292
                                // make a list of PlacementPorts on this NodeInst
251
330
                                }
252
331
 
253
332
                                // make the PlacementNode for this NodeInst
254
 
                                PlacementNode plNode = new PlacementNode(ni, null, null, ni.getTechSpecific(), np.getDefWidth(ep),
255
 
                                        np.getDefHeight(ep), pl, ni.isLocked());
 
333
                                double paddingRatio = (prefs.placementPadding + 100.0) / 100.0;
 
334
                                double width = np.getDefWidth(ep) * paddingRatio;
 
335
                                double height = np.getDefHeight(ep) * paddingRatio;
 
336
                                PlacementNode plNode = new PlacementNode(ni, null, null, ni.getTechSpecific(), width,
 
337
                                        height, pl, ni.isLocked());
256
338
 
257
339
                                nodesToPlace.add(plNode);
258
340
                                for (PlacementFrame.PlacementPort plPort : pl)
297
379
                        if (portInstsByNetwork != null)
298
380
                                portInsts = portInstsByNetwork.get(net);
299
381
                        else {
300
 
                                List<PortInst> portList = new ArrayList<PortInst>();
301
 
                                for (Iterator<PortInst> pIt = net.getPorts(); pIt.hasNext();)
302
 
                                        portList.add(pIt.next());
303
 
                                portInsts = portList.toArray(new PortInst[] {});
 
382
                                portInsts = net.getPortsList().toArray(new PortInst[] {});
304
383
                        }
305
384
                        for (int i = 0; i < portInsts.length; i++) {
306
385
                                PortInst pi = portInsts[i];
328
407
                pla.setOriginalCell(cell);
329
408
                pla.setFailure(false);
330
409
                Cell newCell = PlacementAdapter.doPlacement(pla, cell.getLibrary(), cell.noLibDescribe(), nodesToPlace,
331
 
                        allNetworks, exportsToPlace, iconToPlace, ep, prefs, quiet, job);
 
410
                        allNetworks, exportsToPlace, iconToPlace, ep, prefs, quiet?0:1, job);
332
411
 
333
412
                return newCell;
334
413
        }
340
419
        /** The name of the Placement algorithm to use. The default is "Min-Cut". */
341
420
        @StringPref(node = PLACEMENT_NODE, key = "AlgorithmName", factory = "Min-Cut")
342
421
        public String placementAlgorithm;
 
422
 
 
423
        /** The percentage of padding to use. The default is 0. */
 
424
        @IntegerPref(node = PLACEMENT_NODE, key = "PlacementPadding", factory = 0)
 
425
        public int placementPadding;
 
426
 
 
427
        /** True to run routing after placement finishes. */
 
428
        @BooleanPref(node = PLACEMENT_NODE, key = "PlacementRunRouting", factory = false)
 
429
        public boolean placementRunRouting;
343
430
        
344
431
        private Object[][] values;
345
432
        
471
558
                }
472
559
                return PlacementAdapter.getPlacementAlgorithms()[0];
473
560
        }
474
 
 
475
561
}