1 /*
2  *   Copyright (C) 1989-1992 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 FILE:	    ucxxp.c
42 DESCRIPTION:pairwise exchange.
43 CONTENTS:   ucxxp( a , b , anxcenter , bnxcenter )
44 		INT a , b , anxcenter , bnxcenter ;
45 DATE:	    Mar 27, 1989
46 REVISIONS:
47 ----------------------------------------------------------------- */
48 
49 #include "ucxxglb.h"
50 #include <yalecad/debug.h>
51 
ucxxp(a,b,anxcenter,bnxcenter)52 INT ucxxp( a , b , anxcenter , bnxcenter )
53 INT a , b , anxcenter , bnxcenter ;
54 {
55 
56 CBOXPTR acellptr , bcellptr ;
57 PINBOXPTR atermptr , btermptr ;
58 
59 INT cost ;
60 INT aorient , borient ;
61 INT aycenter , bycenter ;
62 INT newtimepenal ;
63 
64 acellptr = carrayG[ a ]    ;
65 aycenter = acellptr->cycenter ;
66 aorient  = acellptr->corient  ;
67 atermptr = acellptr->pins ;
68 
69 bcellptr = carrayG[ b ]    ;
70 bycenter = bcellptr->cycenter ;
71 borient  = bcellptr->corient  ;
72 btermptr = bcellptr->pins ;
73 
74 term_newpos( atermptr , anxcenter , bycenter , aorient ) ;
75 term_newpos( btermptr , bnxcenter , aycenter , borient ) ;
76 
77 cost = funccostG ;
78 
79 clear_net_set() ; /* reset set to mark nets that have changed position */
80 /* dimbox routines mark the nets that have changed */
81 new_dbox2( atermptr , btermptr , &cost ) ;
82 
83 newtimepenal = timingcostG ;
84 newtimepenal += calc_incr_time2( a, b ) ;
85 
86 D( "twsc/check_timing",
87     ASSERT( dcalc_full_penalty(newtimepenal),NULL,"time problem") ;
88 ) ;
89 
90 
91 if( acceptt( funccostG - cost, timingcostG - newtimepenal, 0 ) ){
92 
93     dbox_pos( atermptr ) ;
94     dbox_pos( btermptr ) ;
95     update_time2() ;
96 
97     G( erase_a_cell( a, acellptr->cxcenter, aycenter ) ) ;
98     G( erase_a_cell( b, bcellptr->cxcenter, bycenter ) ) ;
99 
100     acellptr->cxcenter = anxcenter ;
101     acellptr->cycenter = bycenter ;
102     bcellptr->cxcenter = bnxcenter ;
103     bcellptr->cycenter = aycenter ;
104 
105     funccostG = cost ;
106     timingcostG  = newtimepenal ;
107     G( graphics_cell_update( a ) ) ;
108     G( graphics_cell_update( b ) ) ;
109     return( 1 ) ;
110 } else {
111     G( graphics_cell_attempt( a ) ) ;
112     G( graphics_cell_attempt( b ) ) ;
113     return( 0 ) ;
114 }
115 }
116