abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mapperCore.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mapperCore.c]
4 
5  PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
6 
7  Synopsis [Generic technology mapping engine.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 2.0. Started - June 1, 2004.]
14 
15  Revision [$Id: mapperCore.c,v 1.7 2004/10/01 23:41:04 satrajit Exp $]
16 
17 ***********************************************************************/
18 
19 #include "mapperInt.h"
20 //#include "resm.h"
21 
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// DECLARATIONS ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// FUNCTION DEFINITIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 /**Function*************************************************************
34 
35  Synopsis [Performs technology mapping for the given object graph.]
36 
37  Description [The object graph is stored in the mapping manager.
38  First, the AND nodes that fanout into POs are collected in the DFS order.
39  Two preprocessing steps are performed: the k-feasible cuts are computed
40  for each node and the truth tables are computed for each cut. Next, the
41  delay-optimal matches are assigned for each node, followed by several
42  iterations of area recoveryd: using area flow (global optimization)
43  and using exact area at a node (local optimization).]
44 
45  SideEffects []
46 
47  SeeAlso []
48 
49 ***********************************************************************/
51 {
52  int fShowSwitching = 0;
53  int fUseAreaFlow = 1;
54  int fUseExactArea = !p->fSwitching;
55  int fUseExactAreaWithPhase = !p->fSwitching;
56  abctime clk;
57 
58  //////////////////////////////////////////////////////////////////////
59  // perform pre-mapping computations
60  if ( p->fVerbose )
62  Map_MappingSetChoiceLevels( p ); // should always be called before mapping!
63 // return 1;
64 
65  // compute the cuts of nodes in the DFS order
66  clk = Abc_Clock();
67  Map_MappingCuts( p );
68  p->timeCuts = Abc_Clock() - clk;
69  // derive the truth tables
70  clk = Abc_Clock();
71  Map_MappingTruths( p );
72  p->timeTruth = Abc_Clock() - clk;
73  //////////////////////////////////////////////////////////////////////
74 //ABC_PRT( "Truths", Abc_Clock() - clk );
75 
76  //////////////////////////////////////////////////////////////////////
77  // compute the minimum-delay mapping
78  clk = Abc_Clock();
79  p->fMappingMode = 0;
80  if ( !Map_MappingMatches( p ) )
81  return 0;
82  p->timeMatch = Abc_Clock() - clk;
83  // compute the references and collect the nodes used in the mapping
84  Map_MappingSetRefs( p );
85  p->AreaBase = Map_MappingGetArea( p );
86 if ( p->fVerbose )
87 {
88 printf( "Delay : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
89  fShowSwitching? "Switch" : "Delay",
90  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
91  Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 );
92 ABC_PRT( "Time", p->timeMatch );
93 }
94  //////////////////////////////////////////////////////////////////////
95 
96  if ( !p->fAreaRecovery )
97  {
98  if ( p->fVerbose )
100  return 1;
101  }
102 
103  //////////////////////////////////////////////////////////////////////
104  // perform area recovery using area flow
105  clk = Abc_Clock();
106  if ( fUseAreaFlow )
107  {
108  // compute the required times
110  // recover area flow
111  p->fMappingMode = 1;
112  Map_MappingMatches( p );
113  // compute the references and collect the nodes used in the mapping
114  Map_MappingSetRefs( p );
115  p->AreaFinal = Map_MappingGetArea( p );
116 if ( p->fVerbose )
117 {
118 printf( "AreaFlow : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
119  fShowSwitching? "Switch" : "Delay",
120  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
121  Map_MappingGetAreaFlow(p), p->AreaFinal,
122  100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
123 ABC_PRT( "Time", Abc_Clock() - clk );
124 }
125  }
126  p->timeArea += Abc_Clock() - clk;
127  //////////////////////////////////////////////////////////////////////
128 
129  //////////////////////////////////////////////////////////////////////
130  // perform area recovery using exact area
131  clk = Abc_Clock();
132  if ( fUseExactArea )
133  {
134  // compute the required times
136  // recover area
137  p->fMappingMode = 2;
138  Map_MappingMatches( p );
139  // compute the references and collect the nodes used in the mapping
140  Map_MappingSetRefs( p );
141  p->AreaFinal = Map_MappingGetArea( p );
142 if ( p->fVerbose )
143 {
144 printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
145  fShowSwitching? "Switch" : "Delay",
146  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
147  0.0, p->AreaFinal,
148  100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
149 ABC_PRT( "Time", Abc_Clock() - clk );
150 }
151  }
152  p->timeArea += Abc_Clock() - clk;
153  //////////////////////////////////////////////////////////////////////
154 
155  //////////////////////////////////////////////////////////////////////
156  // perform area recovery using exact area
157  clk = Abc_Clock();
158  if ( fUseExactAreaWithPhase )
159  {
160  // compute the required times
162  // recover area
163  p->fMappingMode = 3;
164  Map_MappingMatches( p );
165  // compute the references and collect the nodes used in the mapping
166  Map_MappingSetRefs( p );
167  p->AreaFinal = Map_MappingGetArea( p );
168 if ( p->fVerbose )
169 {
170 printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
171  fShowSwitching? "Switch" : "Delay",
172  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
173  0.0, p->AreaFinal,
174  100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
175 ABC_PRT( "Time", Abc_Clock() - clk );
176 }
177  }
178  p->timeArea += Abc_Clock() - clk;
179  //////////////////////////////////////////////////////////////////////
180 
181  //////////////////////////////////////////////////////////////////////
182  // perform area recovery using exact area
183  clk = Abc_Clock();
184  if ( p->fSwitching )
185  {
186  // compute the required times
188  // recover switching activity
189  p->fMappingMode = 4;
190  Map_MappingMatches( p );
191  // compute the references and collect the nodes used in the mapping
192  Map_MappingSetRefs( p );
193  p->AreaFinal = Map_MappingGetArea( p );
194 if ( p->fVerbose )
195 {
196 printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
197  fShowSwitching? "Switch" : "Delay",
198  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
199  0.0, p->AreaFinal,
200  100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
201 ABC_PRT( "Time", Abc_Clock() - clk );
202 }
203 
204  // compute the required times
206  // recover switching activity
207  p->fMappingMode = 4;
208  Map_MappingMatches( p );
209  // compute the references and collect the nodes used in the mapping
210  Map_MappingSetRefs( p );
211  p->AreaFinal = Map_MappingGetArea( p );
212 if ( p->fVerbose )
213 {
214 printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ",
215  fShowSwitching? "Switch" : "Delay",
216  fShowSwitching? Map_MappingGetSwitching(p) : p->fRequiredGlo,
217  0.0, p->AreaFinal,
218  100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase );
219 ABC_PRT( "Time", Abc_Clock() - clk );
220 }
221  }
222  p->timeArea += Abc_Clock() - clk;
223  //////////////////////////////////////////////////////////////////////
224 
225  // print the arrival times of the latest outputs
226  if ( p->fVerbose )
228  return 1;
229 }
231 
float Map_MappingGetSwitching(Map_Man_t *pMan)
Definition: mapperSwitch.c:187
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Map_MappingSetRefs(Map_Man_t *pMan)
Definition: mapperRefs.c:441
int Map_MappingMatches(Map_Man_t *p)
Definition: mapperMatch.c:553
static abctime Abc_Clock()
Definition: abc_global.h:279
void Map_MappingTruths(Map_Man_t *pMan)
FUNCTION DEFINITIONS ///.
Definition: mapperTruth.c:47
void Map_MappingSetChoiceLevels(Map_Man_t *pMan)
Definition: mapperUtils.c:821
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
float Map_MappingGetAreaFlow(Map_Man_t *p)
Definition: mapperUtils.c:487
typedefABC_NAMESPACE_HEADER_START struct Map_ManStruct_t_ Map_Man_t
INCLUDES ///.
Definition: mapper.h:40
void Map_TimeComputeRequiredGlobal(Map_Man_t *p)
Definition: mapperTime.c:381
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Map_MappingReportChoices(Map_Man_t *pMan)
Definition: mapperUtils.c:842
float Map_MappingGetArea(Map_Man_t *pMan)
Definition: mapperRefs.c:474
void Map_MappingCuts(Map_Man_t *p)
GLOBAL VARIABLES ///.
Definition: mapperCut.c:172
ABC_NAMESPACE_IMPL_START int Map_Mapping(Map_Man_t *p)
DECLARATIONS ///.
Definition: mapperCore.c:50
ABC_INT64_T abctime
Definition: abc_global.h:278
void Map_MappingPrintOutputArrivals(Map_Man_t *p)
Definition: mapperUtils.c:289