1 /*
2  *   Copyright (C) 1990 Yale University
3  *
4  *   This work is distributed in the hope that it will be useful; you can
5  *   redistribute it and/or modify it under the terms of the
6  *   GNU General Public License as published by the Free Software Foundation;
7  *   either version 2 of the License,
8  *   or any later version, on the following conditions:
9  *
10  *   (a) YALE MAKES NO, AND EXPRESSLY DISCLAIMS
11  *   ALL, REPRESENTATIONS OR WARRANTIES THAT THE MANUFACTURE, USE, PRACTICE,
12  *   SALE OR
13  *   OTHER DISPOSAL OF THE SOFTWARE DOES NOT OR WILL NOT INFRINGE UPON ANY
14  *   PATENT OR
15  *   OTHER RIGHTS NOT VESTED IN YALE.
16  *
17  *   (b) YALE MAKES NO, AND EXPRESSLY DISCLAIMS ALL, REPRESENTATIONS AND
18  *   WARRANTIES
19  *   WHATSOEVER WITH RESPECT TO THE SOFTWARE, EITHER EXPRESS OR IMPLIED,
20  *   INCLUDING,
21  *   BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
22  *   PARTICULAR
23  *   PURPOSE.
24  *
25  *   (c) LICENSEE SHALL MAKE NO STATEMENTS, REPRESENTATION OR WARRANTIES
26  *   WHATSOEVER TO
27  *   ANY THIRD PARTIES THAT ARE INCONSISTENT WITH THE DISCLAIMERS BY YALE IN
28  *   ARTICLE
29  *   (a) AND (b) above.
30  *
31  *   (d) IN NO EVENT SHALL YALE, OR ITS TRUSTEES, DIRECTORS, OFFICERS,
32  *   EMPLOYEES AND
33  *   AFFILIATES BE LIABLE FOR DAMAGES OF ANY KIND, INCLUDING ECONOMIC DAMAGE OR
34  *   INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER YALE SHALL BE
35  *   ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE
36  *   POSSIBILITY OF THE FOREGOING.
37  *
38  */
39 
40 
41 #include <custom.h>
42 #include <yalecad/debug.h>
43 
44 DOUBLE val1 , val2 ;
45 
Vside(kArray,cellptr,x,yy1,yy2,flag)46 INT Vside( kArray, cellptr , x , yy1 , yy2 , flag )
47 KBOXPTR kArray ;
48 CELLBOXPTR cellptr ;
49 INT x , yy1 , yy2 , flag ;
50 {
51 
52 DOUBLE aspFactor , aspect , aspLB ;
53 INT worstLen , pPinLocs , k , length , base ;
54 INT TotSites ;
55 DOUBLE siteSpace ;
56 
57 length = ABS(yy2 - yy1) ;
58 aspect = cellptr->aspect ;
59 aspLB  = cellptr->aspLB ;
60 if( aspLB + 0.01 > cellptr->aspUB ) {
61     aspFactor = 1.0 ;
62 } else {
63     aspFactor = sqrt( aspLB / aspect ) ;
64 }
65 
66 worstLen = (INT) (aspFactor * (DOUBLE) length) ;
67 if( (DOUBLE)(worstLen + 1) / aspFactor - (DOUBLE) length <
68 		(DOUBLE) length - (DOUBLE) worstLen / aspFactor ) {
69     worstLen++ ;
70 }
71 
72 pPinLocs = worstLen / track_spacingYG - 1 ;
73 if( flag ) {
74     if( pPinLocs > MAXSITES ) {
75 	for( k = 1 ; k <= MAXSITES ; k++ ) {
76 	    kArray[ k ].cap = 0 ;
77 	    kArray[ k ].HV = 0 ;
78 	    kArray[ k ].sp = 0 ;
79 	    kArray[ k ].x = 0 ;
80 	    kArray[ k ].y = 0 ;
81 	}
82 	base = pPinLocs / MAXSITES ;
83 	for( k = 1 ; k <= MAXSITES ; k++ ) {
84 	    kArray[ k ].cap += base ;
85 	}
86 	for( k = 1 ; k <= pPinLocs % MAXSITES ; k++ ) {
87 	    kArray[ k ].cap++ ;
88 	}
89     } else {  /* prepare pPinLocs sites */
90 	for( k = 1 ; k <= pPinLocs ; k++ ) {
91 	    kArray[ k ].cap = 0 ;
92 	    kArray[ k ].HV = 0 ;
93 	    kArray[ k ].sp = 0 ;
94 	    kArray[ k ].x = 0 ;
95 	    kArray[ k ].y = 0 ;
96 	}
97 	for( k = 1 ; k <= pPinLocs ; k++ ) {
98 	    kArray[ k ].cap = 1 ;
99 	}
100     }
101 }
102 
103 /*
104     TotSites = minimum of ( MAXSITES and pPinLocs )
105 */
106 if( pPinLocs <= MAXSITES ) {
107     TotSites = pPinLocs ;
108 } else {
109     TotSites = MAXSITES ;
110 }
111 siteSpace = (DOUBLE) length / (DOUBLE) (TotSites + 1) ;
112 
113 /*
114     Suppose we encountered coordinates yy1 and yy2 for a given
115     vertical side, and of course that the x-coordinate is simply x.
116     ( yy1 < yy2 is required )
117 */
118 
119 if( flag ) {
120     if( yy2 > yy1 ) {
121 	for( k = 1 ; k <= TotSites ; k++ ) {
122 	    kArray[ k ].x = x ;
123 	    val1 = (k + 1) * siteSpace ;
124 	    val2 = k * siteSpace ;
125 	    kArray[ k ].y = ROUND( val2 ) + yy1 ;
126 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
127 	    kArray[ k ].HV = 1 ;
128 	}
129     } else {
130 	for( k = 1 ; k <= TotSites ; k++ ) {
131 	    kArray[ k ].x = x ;
132 	    val1 = (k + 1) * siteSpace ;
133 	    val2 = k * siteSpace ;
134 	    kArray[ k ].y = yy1 - ROUND( val2 ) ;
135 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
136 	    kArray[ k ].HV = 1 ;
137 	}
138     }
139 }
140 
141 /*
142  *
143  *   --- BIG NOTE ---
144  *
145  *   Any fixed terminals intersecting a site cause the contents
146  *   of that site to be incremented by one. This will inhibit
147  *   sequences from passing on thru. ( try to remember to
148  *   get the check pointer to reflect this fact )
149  */
150 
151 return( TotSites ) ;
152 }
153 
154 
155 
156 
Hside(kArray,cellptr,xx1,xx2,y,flag)157 INT Hside( kArray, cellptr , xx1 , xx2 , y , flag )
158 KBOXPTR kArray ;
159 CELLBOXPTR cellptr ;
160 INT xx1 , xx2 , y , flag ;
161 {
162 
163 DOUBLE aspFactor , aspect , aspUB ;
164 INT worstLen , pPinLocs , k , length , base ;
165 INT TotSites ;
166 DOUBLE siteSpace ;
167 
168 length = ABS(xx2 - xx1) ;
169 aspect = cellptr->aspect ;
170 aspUB  = cellptr->aspUB ;
171 if( cellptr->aspLB + 0.01 > aspUB ) {
172     aspFactor = 1.0 ;
173 } else {
174     aspFactor = sqrt( aspect / aspUB ) ;
175 }
176 worstLen = (INT) (aspFactor * (DOUBLE) length) ;
177 if( (DOUBLE)(worstLen + 1) / aspFactor - (DOUBLE) length <
178 		(DOUBLE) length - (DOUBLE) worstLen / aspFactor ) {
179     worstLen++ ;
180 }
181 
182 pPinLocs = worstLen / track_spacingXG - 1 ;
183 if( flag ) {
184     if( pPinLocs > MAXSITES ) {
185 	for( k = 1 ; k <= MAXSITES ; k++ ) {
186 	    kArray[ k ].cap = 0 ;
187 	    kArray[ k ].HV = 0 ;
188 	    kArray[ k ].sp = 0 ;
189 	    kArray[ k ].x = 0 ;
190 	    kArray[ k ].y = 0 ;
191 	}
192 	base = pPinLocs / MAXSITES ;
193 	for( k = 1 ; k <= MAXSITES ; k++ ) {
194 	    kArray[ k ].cap += base ;
195 	}
196 	for( k = 1 ; k <= pPinLocs % MAXSITES ; k++ ) {
197 	    kArray[ k ].cap++ ;
198 	}
199     } else {  /* prepare pPinLocs sites */
200 	for( k = 1 ; k <= pPinLocs ; k++ ) {
201 	    kArray[ k ].cap = 0 ;
202 	    kArray[ k ].HV = 0 ;
203 	    kArray[ k ].sp = 0 ;
204 	    kArray[ k ].x = 0 ;
205 	    kArray[ k ].y = 0 ;
206 	}
207 	for( k = 1 ; k <= pPinLocs ; k++ ) {
208 	    kArray[ k ].cap = 1 ;
209 	}
210     }
211 }
212 
213 /*
214     TotSites = minimum of ( MAXSITES and pPinLocs )
215 */
216 if( pPinLocs <= MAXSITES ) {
217     TotSites = pPinLocs ;
218 } else {
219     TotSites = MAXSITES ;
220 }
221 siteSpace = (DOUBLE) length / (DOUBLE) (TotSites + 1) ;
222 
223 /*
224    Suppose we encountered coordinates xx1 and xx2 for a given
225    horizontal side, and of course that the y-coordinate is simply y.
226 */
227 
228 if( flag ) {
229     if( xx2 > xx1 ) {
230 	for( k = 1 ; k <= TotSites ; k++ ) {
231 	    kArray[ k ].y = y ;
232 	    val1 = (k + 1) * siteSpace ;
233 	    val2 = k * siteSpace ;
234 	    kArray[ k ].x = ROUND( val2 ) + xx1 ;
235 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
236 	    kArray[ k ].HV = 0 ;
237 	}
238     } else {
239 	for( k = 1 ; k <= TotSites ; k++ ) {
240 	    kArray[ k ].y = y ;
241 	    val1 = (k + 1) * siteSpace ;
242 	    val2 = k * siteSpace ;
243 	    kArray[ k ].x = xx1 - ROUND( val2 ) ;
244 	    kArray[ k ].sp = ROUND( val1 ) - ROUND( val2 ) ;
245 	    kArray[ k ].HV = 0 ;
246 	}
247     }
248 }
249 
250 /*
251  *
252  *   --- BIG NOTE ---
253  *
254  *   Any fixed terminals intersecting a site cause the contents
255  *   of that site to be incremented by one. This will inhibit
256  *   sequences from passing on thru. ( try to remember to
257  *   get the check pointer to reflect this fact )
258  */
259 
260 return( TotSites ) ;
261 }
262