ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
exor.h
Go to the documentation of this file.
1
20
40
41#ifndef __EXORMAIN_H__
42#define __EXORMAIN_H__
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <assert.h>
47#include <time.h>
48#include "misc/vec/vec.h"
49#include "misc/vec/vecWec.h"
50
52
56
57enum {
58 // the number of bits per integer
59 BPI = 32,
60 BPIMASK = 31,
61 LOGBPI = 5,
62
63 // the maximum number of input variables
64 MAXVARS = 1000,
65
66 // the number of cubes that are allocated additionally
68
69 // the factor showing how many cube pairs will be allocated
71 // the following number of cube pairs are allocated:
72 // nCubesAlloc/CUBE_PAIR_FACTOR
73
74 DIFFERENT = 0x55555555,
75};
76
77extern unsigned char BitCount[];
78
79static inline int BIT_COUNT(int w) { return BitCount[(w)&0xffff] + BitCount[(w)>>16]; }
80
81static inline int VarWord(int element) { return element>>LOGBPI; }
82static inline int VarBit(int element) { return element&BPIMASK; }
83
84static inline float TICKS_TO_SECONDS(abctime time) { return (float)time/(float)CLOCKS_PER_SEC; }
85
89
90typedef enum { MULTI_OUTPUT = 1, SINGLE_NODE, MULTI_NODE } type;
91
92// infomation about the cover
93typedef struct cinfo_tag
94{
95 int nVarsIn; // number of input binary variables in the cubes
96 int nVarsOut; // number of output binary variables in the cubes
97 int nWordsIn; // number of input words used to represent the cover
98 int nWordsOut; // number of output words used to represent the cover
99 int nCubesAlloc; // the number of allocated cubes
100 int nCubesBefore; // number of cubes before simplification
101 int nCubesInUse; // number of cubes after simplification
102 int nCubesFree; // number of free cubes
103 int nLiteralsBefore;// number of literals before
104 int nLiteralsAfter; // number of literals after
105 int QCostBefore; // q-cost before
106 int QCostAfter; // q-cost after
107 int cIDs; // the counter of cube IDs
108
109 int Verbosity; // verbosity level
110 int Quality; // quality
111 int nCubesMax; // maximum number of cubes in starting cover
112 int fUseQCost; // use q-cost instead of literal count
113
114 abctime TimeRead; // reading time
115 abctime TimeStart; // starting cover computation time
116 abctime TimeMin; // pure minimization time
118
119// representation of one cube (24 bytes + bit info)
120typedef unsigned int drow;
121typedef unsigned char byte;
122typedef struct cube
123{
124 byte fMark; // the flag which is TRUE if the cubes is enabled
125 byte ID; // (almost) unique ID of the cube
126 short a; // the number of literals
127 short z; // the number of 1's in the output part
128 short q; // user cost
129 drow* pCubeDataIn; // a pointer to the bit string representing literals
130 drow* pCubeDataOut; // a pointer to the bit string representing literals
131 struct cube* Prev; // pointers to the previous/next cubes in the list/ring
132 struct cube* Next;
134
135
136// preparation
137extern void PrepareBitSetModule();
138extern int WriteResultIntoFile( char * pFileName );
139
140// iterative ExorLink
141extern int IterativelyApplyExorLink2( char fDistEnable );
142extern int IterativelyApplyExorLink3( char fDistEnable );
143extern int IterativelyApplyExorLink4( char fDistEnable );
144
145// cube storage allocation/delocation
146extern int AllocateCubeSets( int nVarsIn, int nVarsOut );
147extern void DelocateCubeSets();
148
149// adjacency queque allocation/delocation procedures
150extern int AllocateQueques( int nPlaces );
151extern void DelocateQueques();
152
153extern int AllocateCover( int nCubes, int nWordsIn, int nWordsOut );
154extern void DelocateCover();
155
156extern void AddToFreeCubes( Cube* pC );
157extern Cube* GetFreeCube();
158// getting and returning free cubes to the heap
159
160extern void InsertVarsWithoutClearing( Cube * pC, int * pVars, int nVarsIn, int * pVarValues, int Output );
161extern int CheckForCloseCubes( Cube* p, int fAddCube );
162
163extern int FindDiffVars( int *pDiffVars, Cube* pC1, Cube* pC2 );
164// determines the variables that are different in cubes pC1 and pC2
165// returns the number of variables
166
167extern int ComputeQCost( Vec_Int_t * vCube );
168extern int ComputeQCostBits( Cube * p );
169
170extern int CountLiterals();
171extern int CountQCost();
172
176
177// literal values
178typedef enum { VAR_NEG = 1, VAR_POS, VAR_ABS } varvalue;
179
180// the flag in some function calls can take one of the follwing values
181typedef enum { DIST2, DIST3, DIST4 } cubedist;
182
184
185#endif
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define LOGBPI
Definition espresso.h:69
Cube * p
Definition exorList.c:222
int FindDiffVars(int *pDiffVars, Cube *pC1, Cube *pC2)
Definition exorBits.c:304
int AllocateCover(int nCubes, int nWordsIn, int nWordsOut)
CUBE COVER MEMORY MANAGEMENT //.
Definition exorCubes.c:90
void DelocateQueques()
Definition exorList.c:1139
unsigned char byte
Definition exor.h:121
void PrepareBitSetModule()
FUNCTION DEFINITIONS ///.
Definition exorBits.c:144
int CountLiterals()
FUNCTION DECLARATIONS ///.
Definition exorUtil.c:77
unsigned char BitCount[]
Definition exorBits.c:138
int CountQCost()
Definition exorUtil.c:119
int IterativelyApplyExorLink4(char fDistEnable)
Definition exorList.c:524
unsigned int drow
Definition exor.h:120
int AllocateCubeSets(int nVarsIn, int nVarsOut)
CUBE SET MANIPULATION PROCEDURES ///.
Definition exorList.c:792
int AllocateQueques(int nPlaces)
Definition exorList.c:1112
int ComputeQCostBits(Cube *p)
Definition exor.c:139
void DelocateCubeSets()
Definition exorList.c:816
int ComputeQCost(Vec_Int_t *vCube)
Definition exor.c:132
type
CUBE COVER and CUBE typedefs ///.
Definition exor.h:90
@ SINGLE_NODE
Definition exor.h:90
@ MULTI_OUTPUT
Definition exor.h:90
@ MULTI_NODE
Definition exor.h:90
void InsertVarsWithoutClearing(Cube *pC, int *pVars, int nVarsIn, int *pVarValues, int Output)
Definition exorBits.c:388
int WriteResultIntoFile(char *pFileName)
Definition exorUtil.c:182
struct cube Cube
@ BPI
Definition exor.h:59
@ ADDITIONAL_CUBES
Definition exor.h:67
@ CUBE_PAIR_FACTOR
Definition exor.h:70
@ DIFFERENT
Definition exor.h:74
@ BPIMASK
Definition exor.h:60
int IterativelyApplyExorLink3(char fDistEnable)
Definition exorList.c:405
int IterativelyApplyExorLink2(char fDistEnable)
FUNCTIONS OF THIS MODULE ///.
Definition exorList.c:277
cubedist
Definition exor.h:181
@ DIST4
Definition exor.h:181
@ DIST2
Definition exor.h:181
@ DIST3
Definition exor.h:181
Cube * GetFreeCube()
Definition exorCubes.c:174
void DelocateCover()
Definition exorCubes.c:147
struct cinfo_tag cinfo
int CheckForCloseCubes(Cube *p, int fAddCube)
Definition exorList.c:643
varvalue
VARVALUE and CUBEDIST enum typedefs ///.
Definition exor.h:178
@ VAR_POS
Definition exor.h:178
@ VAR_NEG
Definition exor.h:178
@ VAR_ABS
Definition exor.h:178
void AddToFreeCubes(Cube *pC)
FREE CUBE LIST MANIPULATION FUNCTIONS ///.
Definition exorCubes.c:157
#define MAXVARS
abctime TimeRead
Definition exor.h:114
int nLiteralsBefore
Definition exor.h:103
int cIDs
Definition exor.h:107
int nWordsIn
Definition exor.h:97
abctime TimeMin
Definition exor.h:116
int nLiteralsAfter
Definition exor.h:104
int nCubesFree
Definition exor.h:102
int nVarsIn
Definition exor.h:95
int QCostAfter
Definition exor.h:106
abctime TimeStart
Definition exor.h:115
int nVarsOut
Definition exor.h:96
int Quality
Definition exor.h:110
int QCostBefore
Definition exor.h:105
int fUseQCost
Definition exor.h:112
int nCubesInUse
Definition exor.h:101
int nWordsOut
Definition exor.h:98
int nCubesAlloc
Definition exor.h:99
int nCubesBefore
Definition exor.h:100
int Verbosity
Definition exor.h:109
int nCubesMax
Definition exor.h:111
Definition exor.h:123
struct cube * Prev
Definition exor.h:131
short a
Definition exor.h:126
short z
Definition exor.h:127
short q
Definition exor.h:128
byte ID
Definition exor.h:125
drow * pCubeDataOut
Definition exor.h:130
drow * pCubeDataIn
Definition exor.h:129
struct cube * Next
Definition exor.h:132
byte fMark
Definition exor.h:124