~ubuntu-branches/ubuntu/wily/electric/wily-proposed

« back to all changes in this revision

Viewing changes to com/sun/electric/tool/routing/seaOfGates/SoGWireQualityMetric.java

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2015-08-12 13:15:54 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20150812131554-k4amekjrk0qw6cju
Tags: 9.06+dfsg-1
* Imported Upstream version 9.06+dfsg.
* Use --download-current-version for get-orig-source target.
* Declare compliance with Debian Policy 3.9.6.
* Vcs-Browser field: Switch to cgit.
* debian/control: Add all build-dependencies only to Build-Depends.
* Install ElectricIcon64x64.png icon. Drop debian/icons directory.
  Convert ElectricIcon64x64.png with imagemagick to electric.xpm at
  build-time.
* Update copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- tab-width: 4 -*-
 
2
 *
 
3
 * Electric(tm) VLSI Design System
 
4
 *
 
5
 * File: SoGWireQualityMetric.java
 
6
 *
 
7
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
 
8
 *
 
9
 * Electric(tm) is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * Electric(tm) is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 */
 
22
package com.sun.electric.tool.routing.seaOfGates;
 
23
 
 
24
import java.net.UnknownHostException;
 
25
 
 
26
import com.sun.electric.tool.Job;
 
27
import com.sun.electric.tool.routing.metrics.WireQualityMetric;
 
28
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.NeededRoute;
 
29
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.RouteBatch;
 
30
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.SearchVertex;
 
31
import com.sun.electric.tool.routing.seaOfGates.SeaOfGatesEngine.Wavefront;
 
32
 
 
33
public class SoGWireQualityMetric extends WireQualityMetric
 
34
{
 
35
        public SoGWireQualityMetric(String s)
 
36
        {
 
37
                super(s, null);
 
38
        }
 
39
 
 
40
        /**
 
41
         * Method to calculate net quality
 
42
         * @param net Network to analyze
 
43
         */
 
44
        public QualityResults calculate(RouteBatch batch)
 
45
        {
 
46
                QualityResults result = null;
 
47
                boolean atLeastOneSegment = false;
 
48
                
 
49
                numberOfTotalNets++;
 
50
                
 
51
                try {
 
52
                        result = startLogging(batch.netName);
 
53
                        
 
54
                        result.wireLength = new Double(0);
 
55
                        result.vias = new Integer(0);
 
56
                        double minX = Double.MAX_VALUE, maxX = -Double.MAX_VALUE;
 
57
                        double minY = Double.MAX_VALUE, maxY = -Double.MAX_VALUE;
 
58
                        
 
59
                        for(NeededRoute nr : batch.routesInBatch)
 
60
                        {
 
61
                                if (nr.getRoutedSucess())
 
62
                                {
 
63
                                        numRoutedSegments++;
 
64
                                        
 
65
                                        Wavefront winningWF = nr.getWavefront();
 
66
                                        
 
67
                                        if (winningWF.vertices.size() < 2)
 
68
                                        {
 
69
                                                System.out.println("WARNING: Review net '" + batch.netName + "' - it has less than 2 vertices");
 
70
                                                continue;
 
71
                                        }
 
72
                                        // ideal HPWL from start and end points
 
73
                                        SearchVertex theFirst = winningWF.vertices.get(0);
 
74
                                        SearchVertex theLast = winningWF.vertices.get(winningWF.vertices.size()-1);
 
75
                                        double theSegMinX = Math.min(theFirst.getX(), theLast.getX());
 
76
                                        double theSegMaxX = Math.max(theFirst.getX(), theLast.getX());
 
77
                                        double theSegMinY = Math.min(theFirst.getY(), theLast.getY());
 
78
                                        double theSegMaxY = Math.max(theFirst.getY(), theLast.getY());
 
79
                                        result.addSegmentHPWL((theSegMaxX - theSegMinX) + (theSegMaxY - theSegMinY), false);
 
80
                                        int startZ = theFirst.getZ();
 
81
                                        int endZ = theLast.getZ();
 
82
                                        int maxZ = Math.max(startZ, endZ);
 
83
                                        int countVias = 0;
 
84
                                        
 
85
                                        // TODO: gather statistics for routeBatches[b].netName
 
86
                                        for (int i=1; i<winningWF.vertices.size(); i++)
 
87
                                        {
 
88
                                                SearchVertex svLast = winningWF.vertices.get(i-1);
 
89
                                                /// Collecting data for HPWL
 
90
                                                if (i == 1)
 
91
                                                {
 
92
                                                        minX = Math.min(minX, svLast.getX());
 
93
                                                        minY = Math.min(minY, svLast.getY());
 
94
                                                        maxX = Math.max(maxX, svLast.getX());
 
95
                                                        maxY = Math.max(maxY, svLast.getY());
 
96
                                                }
 
97
                                                
 
98
                                                SearchVertex sv = winningWF.vertices.get(i);
 
99
                                                if (svLast.getZ() != sv.getZ())
 
100
                                                {
 
101
                                                        // changed layer, count via
 
102
//                                                      result.vias++;
 
103
                                                        countVias++;
 
104
                                                        maxZ = Math.max(maxZ, sv.getZ());
 
105
                                                } else
 
106
                                                {
 
107
                                                        /// Collecting data for HPWL
 
108
                                                        minX = Math.min(minX, sv.getX());
 
109
                                                        minY = Math.min(minY, sv.getY());
 
110
                                                        maxX = Math.max(maxX, sv.getX());
 
111
                                                        maxY = Math.max(maxY, sv.getY());
 
112
                                                        // ran wire
 
113
                                                        double dX = Math.abs(svLast.getX() - sv.getX());
 
114
                                                        double dY = Math.abs(svLast.getY() - sv.getY());
 
115
                                                        result.wireLength += Math.sqrt(dY*dY + dX*dX);
 
116
                                                }
 
117
                                        }
 
118
                                        result.vias += countVias;
 
119
                                        result.addSegmentViaValues(countVias, (maxZ-startZ) + (maxZ-endZ)); // zero value
 
120
                                        atLeastOneSegment = true;
 
121
                                } else
 
122
                                {
 
123
                                        if (nr.getErrorMessage() != null)
 
124
                                        {
 
125
                                                numFailedSegments++;
 
126
                                        }
 
127
                                }
 
128
                        }
 
129
                        
 
130
                        // Only when routing was found
 
131
                        double avgWLHPWLReal = 0, avgWLHPWLIdeal = 0;
 
132
                        if (atLeastOneSegment)
 
133
                        {
 
134
                                result.addSegmentHPWL((maxX - minX) + (maxY - minY), true); //.hpwlOLD = (maxX - minX) + (maxY - minY);
 
135
                                avgHpwlReal += result.getSegmentHPWL(false, true);
 
136
                                avgHpwlIdeal += result.getSegmentHPWL(false, false);
 
137
                        totalWL += result.wireLength; 
 
138
                        avgVias += result.vias;
 
139
                        avgWLHPWLReal = result.getWLDivHPWL(true);
 
140
                        avgWLHPWLIdeal = result.getWLDivHPWL(false);
 
141
                        addWLLengthToBucket(avgWLHPWLReal, result.resultName, true);
 
142
                        addWLLengthToBucket(avgWLHPWLIdeal, result.resultName, false);
 
143
                        addViaZeroBucket(result.getSegmentViaValue(), result.resultName);
 
144
                                avgWlDivHpwlReal += avgWLHPWLReal;
 
145
                                avgWlDivHpwlIdeal += avgWLHPWLIdeal;
 
146
                                numberOfRoutedNets++;
 
147
                        }
 
148
                        else
 
149
                                numFailedBatches++;
 
150
 
 
151
                //logger.trace("calculate wire length");
 
152
                info("wire length metric for net '" + batch.netName + "': " + result.wireLength);
 
153
        
 
154
//              logger.trace("calculate unrouted nets");
 
155
//              result.unroutedSegments = new UnroutedNetsMetric().calculate(cell);
 
156
//              logger.debug("unrouted nets metric: " + result.unroutedSegments);
 
157
//
 
158
                        //logger.trace("calculate via amount metric...");
 
159
                        info("via amount metric for net '" + batch.netName + "': " + result.vias);
 
160
                        info("routed segment metric for net '" + batch.netName + "': " + result.numOfSegments(true));
 
161
                        info("via++ metric for net '" + batch.netName + "': " + result.getSegmentViaValue());
 
162
                        
 
163
                        //logger.trace("calculate HPWL amount metric...");
 
164
                        info("Real HPWL amount metric for net '" + batch.netName + "': " + result.getSegmentHPWL(true, true));
 
165
                        info("Ideal HPWL amount metric for net '" + batch.netName + "': " + result.getSegmentHPWL(true, false));
 
166
        
 
167
                        info("Real WL v/s HPWL for net '" + batch.netName + "': " + avgWLHPWLReal);
 
168
                        info("Ideal WL v/s HPWL for net '" + batch.netName + "': " + avgWLHPWLIdeal);
 
169
                        
 
170
                        info("============================");
 
171
                } catch (UnknownHostException e) {
 
172
                        if (Job.getDebug())
 
173
                                e.printStackTrace();
 
174
                        else
 
175
                                System.out.println("No name or service not known");
 
176
                }
 
177
                return result;
 
178
        }
 
179
}