00001 00024 #ifndef _BNET 00025 #define _BNET 00026 00027 /*---------------------------------------------------------------------------*/ 00028 /* Nested includes */ 00029 /*---------------------------------------------------------------------------*/ 00030 00031 #include "util.h" 00032 #include "st.h" 00033 #include "cudd.h" 00034 00035 /*---------------------------------------------------------------------------*/ 00036 /* Constant declarations */ 00037 /*---------------------------------------------------------------------------*/ 00038 00039 /* Different types of nodes. (Used in the "BnetNode" type.) */ 00040 #define BNET_CONSTANT_NODE 0 00041 #define BNET_INPUT_NODE 1 00042 #define BNET_PRESENT_STATE_NODE 2 00043 #define BNET_INTERNAL_NODE 3 00044 #define BNET_OUTPUT_NODE 4 00045 #define BNET_NEXT_STATE_NODE 5 00046 00047 /* Type of DD of a node. */ 00048 #define BNET_LOCAL_DD 0 00049 #define BNET_GLOBAL_DD 1 00050 00051 00052 /*---------------------------------------------------------------------------*/ 00053 /* Stucture declarations */ 00054 /*---------------------------------------------------------------------------*/ 00055 00056 /*---------------------------------------------------------------------------*/ 00057 /* Type declarations */ 00058 /*---------------------------------------------------------------------------*/ 00059 00060 /* The following types implement a very simple data structure for a boolean 00061 ** network. The intent is to be able to read a minimal subset of the blif 00062 ** format in a data structure from which it's easy to build DDs for the 00063 ** circuit. 00064 */ 00065 00066 /* Type to store a line of the truth table of a node. The entire truth table 00067 ** implemented as a linked list of objects of this type. 00068 */ 00069 typedef struct BnetTabline { 00070 char *values; /* string of 1, 0, and - */ 00071 struct BnetTabline *next; /* pointer to next table line */ 00072 } BnetTabline; 00073 00074 /* Node of the boolean network. There is one node in the network for each 00075 ** primary input and for each .names directive. This structure 00076 ** has a field to point to the DD of the node function. The function may 00077 ** be either in terms of primary inputs, or it may be in terms of the local 00078 ** inputs. The latter implies that each node has a variable index 00079 ** associated to it at some point in time. The field "var" stores that 00080 ** variable index, and "active" says if the association is currently valid. 00081 ** (It is indeed possible for an index to be associated to different nodes 00082 ** at different times.) 00083 */ 00084 typedef struct BnetNode { 00085 char *name; /* name of the output signal */ 00086 int type; /* input, internal, constant, ... */ 00087 int ninp; /* number of inputs to the node */ 00088 int nfo; /* number of fanout nodes for this node */ 00089 char **inputs; /* input names */ 00090 BnetTabline *f; /* truth table for this node */ 00091 int polarity; /* f is the onset (0) or the offset (1) */ 00092 int active; /* node has variable associated to it (1) or not (0) */ 00093 int var; /* DD variable index associated to this node */ 00094 DdNode *dd; /* decision diagram for the function of this node */ 00095 int exdc_flag; /* whether an exdc node or not */ 00096 struct BnetNode *exdc; /* pointer to exdc of dd node */ 00097 int count; /* auxiliary field for DD dropping */ 00098 int level; /* maximum distance from the inputs */ 00099 int visited; /* flag for search */ 00100 struct BnetNode *next; /* pointer to implement the linked list of nodes */ 00101 } BnetNode; 00102 00103 /* Very simple boolean network data structure. */ 00104 typedef struct BnetNetwork { 00105 char *name; /* network name: from the .model directive */ 00106 int npis; /* number of primary inputs */ 00107 int ninputs; /* number of inputs */ 00108 char **inputs; /* primary input names: from the .inputs directive */ 00109 int npos; /* number of primary outputs */ 00110 int noutputs; /* number of outputs */ 00111 char **outputs; /* primary output names: from the .outputs directive */ 00112 int nlatches; /* number of latches */ 00113 char ***latches; /* next state names: from the .latch directives */ 00114 BnetNode *nodes; /* linked list of the nodes */ 00115 st_table *hash; /* symbol table to access nodes by name */ 00116 char *slope; /* wire_load_slope */ 00117 } BnetNetwork; 00118 00119 /*---------------------------------------------------------------------------*/ 00120 /* Variable declarations */ 00121 /*---------------------------------------------------------------------------*/ 00122 00123 /*---------------------------------------------------------------------------*/ 00124 /* Macro declarations */ 00125 /*---------------------------------------------------------------------------*/ 00126 00127 /* These are potential duplicates. */ 00128 #ifndef EXTERN 00129 # ifdef __cplusplus 00130 # define EXTERN extern "C" 00131 # else 00132 # define EXTERN extern 00133 # endif 00134 #endif 00135 #ifndef ARGS 00136 # if defined(__STDC__) || defined(__cplusplus) 00137 # define ARGS(protos) protos /* ANSI C */ 00138 # else /* !(__STDC__ || __cplusplus) */ 00139 # define ARGS(protos) () /* K&R C */ 00140 # endif /* !(__STDC__ || __cplusplus) */ 00141 #endif 00142 00143 #ifndef TRUE 00144 # define TRUE 1 00145 #endif 00146 #ifndef FALSE 00147 # define FALSE 0 00148 #endif 00149 00152 /*---------------------------------------------------------------------------*/ 00153 /* Function prototypes */ 00154 /*---------------------------------------------------------------------------*/ 00155 00156 EXTERN BnetNetwork * Bnet_ReadNetwork ARGS((FILE *fp, int pr)); 00157 EXTERN void Bnet_PrintNetwork ARGS((BnetNetwork *net)); 00158 EXTERN void Bnet_FreeNetwork ARGS((BnetNetwork *net)); 00159 EXTERN int Bnet_BuildNodeBDD ARGS((DdManager *dd, BnetNode *nd, st_table *hash, int params, int nodrop)); 00160 EXTERN int Bnet_DfsVariableOrder ARGS((DdManager *dd, BnetNetwork *net)); 00161 EXTERN int Bnet_bddDump ARGS((DdManager *dd, BnetNetwork *network, char *dfile, int dumpFmt, int reencoded)); 00162 EXTERN int Bnet_bddArrayDump ARGS((DdManager *dd, BnetNetwork *network, char *dfile, DdNode **outputs, char **onames, int noutputs, int dumpFmt)); 00163 EXTERN int Bnet_ReadOrder ARGS((DdManager *dd, char *ordFile, BnetNetwork *net, int locGlob, int nodrop)); 00164 EXTERN int Bnet_PrintOrder ARGS((BnetNetwork * net, DdManager *dd)); 00165 00168 #endif /* _BNET */
1.2.18