1 /**CFile****************************************************************
2 
3   FileName    [timInt.h]
4 
5   SystemName  [ABC: Logic synthesis and verification system.]
6 
7   PackageName [Hierarchy/timing manager.]
8 
9   Synopsis    [Internal declarations.]
10 
11   Author      [Alan Mishchenko]
12 
13   Affiliation [UC Berkeley]
14 
15   Date        [Ver. 1.0. Started - April 28, 2007.]
16 
17   Revision    [$Id: timInt.h,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__aig__tim__timInt_h
22 #define ABC__aig__tim__timInt_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 ///                          INCLUDES                                ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 
34 #include "misc/vec/vec.h"
35 #include "misc/mem/mem.h"
36 #include "tim.h"
37 
38 ////////////////////////////////////////////////////////////////////////
39 ///                         PARAMETERS                               ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 ABC_NAMESPACE_HEADER_START
43 
44 ////////////////////////////////////////////////////////////////////////
45 ///                         BASIC TYPES                              ///
46 ////////////////////////////////////////////////////////////////////////
47 
48 typedef struct Tim_Box_t_           Tim_Box_t;
49 typedef struct Tim_Obj_t_           Tim_Obj_t;
50 
51 // timing manager
52 struct Tim_Man_t_
53 {
54     Vec_Ptr_t *      vBoxes;         // the timing boxes
55     Vec_Ptr_t *      vDelayTables;   // pointers to the delay tables
56     Mem_Flex_t *     pMemObj;        // memory manager for boxes
57     int              nTravIds;       // traversal ID of the manager
58     int              fUseTravId;     // enables the use of traversal ID
59     int              nCis;           // the number of PIs
60     int              nCos;           // the number of POs
61     Tim_Obj_t *      pCis;           // timing info for the PIs
62     Tim_Obj_t *      pCos;           // timing info for the POs
63 };
64 
65 // timing box
66 struct Tim_Box_t_
67 {
68     int              iBox;           // the unique ID of this box
69     int              TravId;         // traversal ID of this box
70     int              nInputs;        // the number of box inputs (POs)
71     int              nOutputs;       // the number of box outputs (PIs)
72     int              iDelayTable;    // index of the delay table
73     int              iCopy;          // copy of this box
74     int              fBlack;         // this is black box
75     int              Inouts[0];      // the int numbers of PIs and POs
76 };
77 
78 // timing object
79 struct Tim_Obj_t_
80 {
81     int              Id;             // the ID of this object
82     int              TravId;         // traversal ID of this object
83     int              iObj2Box;       // mapping of the object into its box
84     int              iObj2Num;       // mapping of the object into its number in the box
85     float            timeArr;        // arrival time of the object
86     float            timeReq;        // required time of the object
87 };
88 
89 ////////////////////////////////////////////////////////////////////////
90 ///                      MACRO DEFINITIONS                           ///
91 ////////////////////////////////////////////////////////////////////////
92 
Tim_ManCi(Tim_Man_t * p,int i)93 static inline Tim_Obj_t * Tim_ManCi( Tim_Man_t * p, int i )                           { assert( i < p->nCis ); return p->pCis + i;      }
Tim_ManCo(Tim_Man_t * p,int i)94 static inline Tim_Obj_t * Tim_ManCo( Tim_Man_t * p, int i )                           { assert( i < p->nCos ); return p->pCos + i;      }
Tim_ManBox(Tim_Man_t * p,int i)95 static inline Tim_Box_t * Tim_ManBox( Tim_Man_t * p, int i )                          { return (Tim_Box_t *)Vec_PtrEntry(p->vBoxes, i); }
96 
Tim_ManCiBox(Tim_Man_t * p,int i)97 static inline Tim_Box_t * Tim_ManCiBox( Tim_Man_t * p, int i )                        { return Tim_ManCi(p,i)->iObj2Box < 0 ? NULL : (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, Tim_ManCi(p,i)->iObj2Box ); }
Tim_ManCoBox(Tim_Man_t * p,int i)98 static inline Tim_Box_t * Tim_ManCoBox( Tim_Man_t * p, int i )                        { return Tim_ManCo(p,i)->iObj2Box < 0 ? NULL : (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, Tim_ManCo(p,i)->iObj2Box ); }
99 
Tim_ManBoxInput(Tim_Man_t * p,Tim_Box_t * pBox,int i)100 static inline Tim_Obj_t * Tim_ManBoxInput( Tim_Man_t * p, Tim_Box_t * pBox, int i )   { assert( i < pBox->nInputs  ); return p->pCos + pBox->Inouts[i];               }
Tim_ManBoxOutput(Tim_Man_t * p,Tim_Box_t * pBox,int i)101 static inline Tim_Obj_t * Tim_ManBoxOutput( Tim_Man_t * p, Tim_Box_t * pBox, int i )  { assert( i < pBox->nOutputs ); return p->pCis + pBox->Inouts[pBox->nInputs+i]; }
102 
103 ////////////////////////////////////////////////////////////////////////
104 ///                             ITERATORS                            ///
105 ////////////////////////////////////////////////////////////////////////
106 
107 #define Tim_ManForEachCi( p, pObj, i )                                  \
108     for ( i = 0; (i < (p)->nCis) && ((pObj) = (p)->pCis + i); i++ )
109 #define Tim_ManForEachCo( p, pObj, i )                                  \
110     for ( i = 0; (i < (p)->nCos) && ((pObj) = (p)->pCos + i); i++ )
111 
112 #define Tim_ManForEachPi( p, pObj, i )                                  \
113     Tim_ManForEachCi( p, pObj, i ) if ( pObj->iObj2Box >= 0 ) {} else
114 #define Tim_ManForEachPo( p, pObj, i )                                  \
115     Tim_ManForEachCo( p, pObj, i ) if ( pObj->iObj2Box >= 0 ) {} else
116 
117 #define Tim_ManForEachBox( p, pBox, i )                                 \
118     Vec_PtrForEachEntry( Tim_Box_t *, p->vBoxes, pBox, i )
119 
120 #define Tim_ManBoxForEachInput( p, pBox, pObj, i )                      \
121     for ( i = 0; (i < (pBox)->nInputs) && ((pObj) = Tim_ManBoxInput(p, pBox, i)); i++ )
122 #define Tim_ManBoxForEachOutput( p, pBox, pObj, i )                     \
123     for ( i = 0; (i < (pBox)->nOutputs) && ((pObj) = Tim_ManBoxOutput(p, pBox, i)); i++ )
124 
125 #define Tim_ManForEachTable( p, pTable, i )                             \
126     Vec_PtrForEachEntry( float *, p->vDelayTables, pTable, i )
127 
128 ////////////////////////////////////////////////////////////////////////
129 ///                     SEQUENTIAL ITERATORS                         ///
130 ////////////////////////////////////////////////////////////////////////
131 
132 ////////////////////////////////////////////////////////////////////////
133 ///                    FUNCTION DECLARATIONS                         ///
134 ////////////////////////////////////////////////////////////////////////
135 
136 /*=== time.c ===========================================================*/
137 
138 
139 ABC_NAMESPACE_HEADER_END
140 
141 
142 
143 #endif
144 
145 ////////////////////////////////////////////////////////////////////////
146 ///                       END OF FILE                                ///
147 ////////////////////////////////////////////////////////////////////////
148 
149