summaryrefslogtreecommitdiffstats
path: root/src/base/seq/seqMan.c
blob: 7dae5b239d5e13dd3a50dad04968b52f5bec46ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**CFile****************************************************************

  FileName    [seqMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Construction and manipulation of sequential AIGs.]

  Synopsis    [Manager of sequential AIG containing.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

  Revision    [$Id: seqMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

#include "seqInt.h"

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Allocates sequential AIG manager.]

  Description [The manager contains all the data structures needed to 
  represent sequential AIG and compute stand-alone retiming as well as 
  the integrated mapping/retiming of the sequential AIG.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Abc_Seq_t * Seq_Create( Abc_Ntk_t * pNtk )
{
    Abc_Seq_t * p;
    // start the manager
    p = ALLOC( Abc_Seq_t, 1 );
    memset( p, 0, sizeof(Abc_Seq_t) );
    p->pNtk  = pNtk;
    p->nSize = 1000;
    p->nMaxIters = 15;
    p->pMmInits  = Extra_MmFixedStart( sizeof(Seq_Lat_t) );
    p->fEpsilon  = (float)0.001;
    // create internal data structures
    p->vNums     = Vec_IntStart( 2 * p->nSize ); 
    p->vInits    = Vec_PtrStart( 2 * p->nSize ); 
    p->vLValues  = Vec_IntStart( p->nSize ); 
    p->vLags     = Vec_StrStart( p->nSize ); 
    p->vLValuesN = Vec_IntStart( p->nSize ); 
    p->vLagsN    = Vec_StrStart( p->nSize ); 
    p->vUses     = Vec_StrStart( p->nSize ); 
    return p;
}

/**Function*************************************************************

  Synopsis    [Deallocates sequential AIG manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Seq_Resize( Abc_Seq_t * p, int nMaxId )
{
    if ( p->nSize > nMaxId )
        return;
    p->nSize = nMaxId + 1;
    Vec_IntFill( p->vNums,     2 * p->nSize, 0 ); 
    Vec_PtrFill( p->vInits,    2 * p->nSize, NULL ); 
    Vec_IntFill( p->vLValues,  p->nSize, 0 ); 
    Vec_StrFill( p->vLags,     p->nSize, 0 ); 
    Vec_IntFill( p->vLValuesN, p->nSize, 0 ); 
    Vec_StrFill( p->vLagsN,    p->nSize, 0 ); 
    Vec_StrFill( p->vUses,     p->nSize, 0 ); 
}


/**Function*************************************************************

  Synopsis    [Deallocates sequential AIG manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Seq_Delete( Abc_Seq_t * p )
{
    if ( p->fStandCells )
    {
        void * pVoid; int i;
        Vec_PtrForEachEntry( p->vMapAnds, pVoid, i )
            free( pVoid );
    }
    if ( p->vMapAnds )  Vec_PtrFree( p->vMapAnds );  // the nodes used in the mapping
    if ( p->vMapCuts )  Vec_VecFree( p->vMapCuts );  // the cuts used in the mapping
    if ( p->vLValues )  Vec_IntFree( p->vLValues );  // the arrival times (L-Values of nodes)
    if ( p->vLags )     Vec_StrFree( p->vLags );     // the lags of the mapped nodes
    if ( p->vLValuesN ) Vec_IntFree( p->vLValuesN ); // the arrival times (L-Values of nodes)
    if ( p->vLagsN )    Vec_StrFree( p->vLagsN );    // the lags of the mapped nodes
    if ( p->vUses )     Vec_StrFree( p->vUses );     // the uses of phases
    if ( p->vInits )    Vec_PtrFree( p->vInits );    // the initial values of the latches
    if ( p->vNums )     Vec_IntFree( p->vNums );     // the numbers of latches
    Extra_MmFixedStop( p->pMmInits, 0 );
    free( p );
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////