source: vis_dev/vis-2.3/src/tbl/tblInt.h @ 83

Last change on this file since 83 was 14, checked in by cecile, 13 years ago

vis2.3

File size: 11.5 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [tblInt.h]
4
5  PackageName [tbl]
6
7  Synopsis    [Include the internals of the table package]
8
9  Description [Describes the internal structs in the table package. The
10  Tbl_Table_t data structure consists of an array of inputs, and array of
11  outputs and a data struct (Tbl_Data_t). This data struct is shared between
12  tables that are duplicated (using soft dup). The data struct contains a
13  reference count to indicate the number of tables that share it. If a
14  free is called, the data struct reference count is decremented and only
15  if this drops to 0 is the struct actually freed. The Tbl_Data_t also
16  contains an array of default values, and an array of Tbl_Row_t's to
17  represent the actual data. The Tbl_row_t consists of two arrays (inputs and
18  outputs), which contain Tbl_Entry_t's (representing entries in a table.]
19
20  SeeAlso     [tbl.h]
21
22  Author      [Gitanjali M. Swamy]
23
24  Copyright   [Copyright (c) 1994-1996 The Regents of the Univ. of California.
25  All rights reserved.
26
27  Permission is hereby granted, without written agreement and without license
28  or royalty fees, to use, copy, modify, and distribute this software and its
29  documentation for any purpose, provided that the above copyright notice and
30  the following two paragraphs appear in all copies of this software.
31
32  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
33  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
34  OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
35  CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
38  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
39  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
40  "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
41  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]
42
43  Revision    [$Id: tblInt.h,v 1.11 2009/04/11 02:01:29 fabio Exp $]
44
45******************************************************************************/
46
47#ifndef _TBLINT
48#define _TBLINT
49
50#include "tbl.h"
51#include "cmd.h"
52#include "io.h"
53#include <string.h>
54
55/*---------------------------------------------------------------------------*/
56/* Stucture declarations                                                     */
57/*---------------------------------------------------------------------------*/
58
59/**Struct*************************************************************
60
61  Synopsis      [ This is basic blif_mv table data structure ]
62
63  Description   [ This datastructure consists of struct with 3 fields; an
64  array of inputs, an array of ouputs and a Tbl_Data_t for the actual
65  table data.]
66
67  SeeAlso       [ TblEntryStruct TblRowStruct TblDataStruct]
68**********************************************************************/
69struct TblTableStruct {
70    array_t * inputNames; /* An array of the Var_Variable_ts corresponding to
71                               the inputs to the table */
72    array_t * outputNames; /* An array of Var_Variable_ts corresponding to
73                                the outputs of the table */
74    Tbl_Data_t * data; /* A Tbl_Data_t that represents actual data in the table  */ 
75};
76
77/**Struct*************************************************************
78
79  Synopsis      [ This is the struct used to represent each row in the table]
80
81  Description   [ There are 2 fields in this struct; a row array and a column
82                  array.]
83
84  SeeAlso       [ TblStruct TblEntryStruct ]
85 
86**********************************************************************/
87
88struct TblRowStruct {
89    array_t * inputs; /* An array of inputs */
90    array_t * outputs; /* An array of outputs */
91};
92
93/**Struct**********************************************************************
94
95  Synopsis    [Struct used to represent table data]
96
97  Description [This struct has three fields; a reference count that is used
98  for memory management, an array of default values, and an array of Tbl_Row_t's
99  that represents the actual table data. Each Tbl_Row_t within this data array
100  has an input part and an output part; each of these is an array of Tbl_Entry_t's.]
101
102  SeeAlso     [ TblEntryStruct TblTableStruct TblRowStruct]
103
104******************************************************************************/
105
106struct TblDataStruct {
107    int refCount; /* a reference count to indicate how many duplicates exist
108                   */
109    array_t *defaults; /* An array with the defaults */ 
110    array_t *actualData;
111};
112
113
114/**Struct*************************************************************
115
116  Synopsis      [ This struct represents a range]
117
118  Description   [ This struct represents a range and has 2 fields;
119                  the beginning and the end. The data within a Tbl_Entry_t
120                  is represented as a linked list of such ranges (if the entry
121                  is of type Tbl_EntryNormal_c.]
122
123  SeeAlso       [ TblRangeAlloc TblRangeFree ]
124 
125**********************************************************************/
126
127struct TblRangeStruct {
128    int begin; /* The beginning of the range */
129    int end; /* The end of the range */
130};
131   
132/**Struct*************************************************************
133
134  Synopsis      [ This is the struct used to represent each entry in the table ]
135
136  Description   [ This struct has 4 fields; an enumerated  type, an integer to
137  indicate if it is an input or output, an integer for the  column number, and
138  a union with either a list of ranges or a var (this depends on the type of
139  the struct.]
140
141  SeeAlso       [ TblRowStruct TblTableStruct TblDataStruct]
142 
143**********************************************************************/
144
145struct TblEntryStruct {
146    Tbl_EntryType_t type; /* Type of the table entry. This may be one of 2 types;
147                  either equal  or normal*/
148    int ioType; /* to indicate whether its input or output */
149    int varColNum; /* corresponding Var_Variable_t column number */
150    union{
151        int var; /* This indicates the related column  if the entry is
152                           of the type equal */
153        lsList  listOfRanges; /* This indicates the contents of the table
154                                  entry if its type is normal */
155    }EntryData;
156};
157
158
159/**Macro***********************************************************************
160
161  Synopsis     [return refcount associated with table]
162
163  Description  [This functions returns the number of tables that share data
164  with the given table. This count is used for memory management.]
165
166  SideEffects  []
167
168  SeeAlso      []
169
170******************************************************************************/
171#define TblTableReadRefCount(                                                \
172/* Tbl_Table_t * */ table   /* The table to iterate over */                  \
173)                                                                            \
174table->data->refCount
175
176/**Macro***********************************************************************
177
178  Synopsis    [Return the data array associated with a table.]
179
180  Description []
181
182  SideEffects [This array is NOT to be modified. The user is encouraged not
183  to use this function. It is exported so as to make the macros for iteration over
184  items in the table possible. The user should use these macros for accessing data.
185  The macros that can be used are mentioned in the SeeAlso list]
186
187  SeeAlso     [Tbl_TableForEachEntry Tbl_TableForEachInputEntry Tbl_TableForEachOutputEntry
188  Tbl_TableForEachInputVar Tbl_TableForEachOutputVar Tbl_TableForEachDefault]
189
190******************************************************************************/
191#define TblTableReadData(                                                    \
192/* Tbl_Table_t * */ table   /* The table to iterate over */                  \
193)                                                                            \
194table->data->actualData
195
196/**Macro***********************************************************************
197
198  Synopsis    [Return the defaults array associated with a table.]
199
200  Description []
201
202  SideEffects [This array is NOT to be modified. The user is encouraged not
203  to use this function. It is exported so as to make the macros for iteration over
204  items in the table possible. The user should use these macros for accessing data.
205  The macros that can be used are mentioned in the SeeAlso list]
206
207  SeeAlso     [Tbl_TableForEachEntry Tbl_TableForEachInputEntry Tbl_TableForEachOutputEntry
208  Tbl_TableForEachInputVar Tbl_TableForEachOutputVar Tbl_TableForEachDefault]
209
210******************************************************************************/
211#define TblTableReadDefaults(                                                \
212/* Tbl_Table_t * */ table   /* The table to iterate over */                  \
213)                                                                            \
214 table->data->defaults
215
216
217/**Macro***********************************************************************
218
219  Synopsis     [ Generates all rows on the table ]
220
221  Description  [ Given a table this iterates over all its rows in smallest colum
222n
223                 first order.]
224
225  SideEffects  [ ]
226
227  SeeAlso      [ ]
228
229******************************************************************************/
230#define TblTableForEachRow(                                                  \
231/* Tbl_Table_t * */ table   /* The table to iterate over */,                 \
232/* Tbl_Row_t *  */  row    /* The current row */,                            \
233/* int          */ rowNum  /* The row number  */                             \
234)                                                                            \
235 for(rowNum=0; (rowNum <array_n(TblTableReadData(table)))\
236                   &&(row = array_fetch(Tbl_Row_t*,(TblTableReadData(table)),rowNum));rowNum++)
237
238/**AutomaticStart*************************************************************/
239
240/*---------------------------------------------------------------------------*/
241/* Function prototypes                                                       */
242/*---------------------------------------------------------------------------*/
243
244EXTERN mAigEdge_t TblEntryNormalConstructAig(mAig_Manager_t *manager, Tbl_Entry_t *entry, array_t *mAigArray);
245EXTERN mAigEdge_t TblEntryEqualConstructMAig(mAig_Manager_t * manager, Tbl_Entry_t * entry, MvfAig_Function_t * mAigArray, MvfAig_Function_t * mEigArray);
246EXTERN mdd_t * TblEntryNormalConstructMdd(mdd_manager *manager, Tbl_Entry_t * entry, array_t * mddArray);
247EXTERN mdd_t * TblEntryEqualConstructMdd(mdd_manager *manager, Tbl_Entry_t * entry, Mvf_Function_t * mddArray, Mvf_Function_t * mddEArray);
248EXTERN void TblEntryWriteBlifMv(Tbl_Table_t *table, Tbl_Entry_t *entry, FILE *fp);
249EXTERN void TblEntryWriteSmv(Tbl_Table_t *table, Tbl_Entry_t *entry, boolean varnameflag, FILE *fp);
250EXTERN void TblEntryWriteBlif(Tbl_Table_t *table, Tbl_Entry_t *entry, FILE *fp);
251EXTERN void TblRangeFree(Tbl_Range_t * range);
252EXTERN boolean TblTableDeleteLastRow(Tbl_Table_t* table);
253EXTERN void TblTableSetRow(Tbl_Table_t *table, Tbl_Row_t *row, int i);
254EXTERN array_t* TblRowReadOutputs(Tbl_Row_t * row);
255EXTERN array_t* TblRowReadInputs(Tbl_Row_t * row);
256EXTERN Tbl_Row_t* TblTableReadRow(Tbl_Table_t *table, int rowNum);
257EXTERN Tbl_Row_t* TblRowAlloc(void);
258EXTERN Tbl_Row_t* TblRowDup(Tbl_Row_t * row);
259EXTERN void TblRowSetEntry(Tbl_Row_t *row, Tbl_Entry_t * entry, int i, int flag);
260EXTERN void TblRowFree(Tbl_Row_t *row);
261EXTERN Tbl_Entry_t* TblRowReadEntry(Tbl_Row_t *row, int i, int flag);
262
263/**AutomaticEnd***************************************************************/
264
265#endif /* _TBLINT */
Note: See TracBrowser for help on using the repository browser.