ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
NewTt::Man Class Reference

#include <giaNewTt.h>

Public Member Functions

lit Bvar2Lit (bvar a) const
 
bvar Lit2Bvar (lit x) const
 
lit IthVar (int v) const
 
lit LitNot (lit x) const
 
lit LitNotCond (lit x, bool c) const
 
bool LitIsCompl (lit x) const
 
ref Ref (lit x) const
 
lit Const0 () const
 
lit Const1 () const
 
bool IsConst0 (lit x) const
 
bool IsConst1 (lit x) const
 
bool LitIsEq (lit x, lit y) const
 
size OneCount (lit x) const
 
void IncRef (lit x)
 
void DecRef (lit x)
 
bool Resize ()
 
bool Gbc ()
 
 Man (int nVars, Param p)
 
lit And (lit x, lit y)
 
lit Or (lit x, lit y)
 
void Reorder ()
 
void SetRef (std::vector< lit > const &vLits)
 
void RemoveRefIfUnused ()
 
void TurnOffReo ()
 
int GetNumVars () const
 
void PrintNode (lit x) const
 

Detailed Description

Definition at line 68 of file giaNewTt.h.

Constructor & Destructor Documentation

◆ Man()

NewTt::Man::Man ( int nVars,
Param p )
inline

Definition at line 189 of file giaNewTt.h.

189 : nVars(nVars) {
190 if(p.nObjsMaxLog < p.nObjsAllocLog)
191 fatal_error("nObjsMax must not be smaller than nObjsAlloc");
192 if(nVars >= lww())
193 nSize = 1ull << (nVars - lww());
194 else
195 nSize = 1;
196 if(!nSize)
197 fatal_error("Memout (nVars) in init");
198 if(!(nSize << p.nObjsMaxLog))
199 fatal_error("Memout (nObjsMax) in init");
200 lit nObjsMaxLit = (lit)1 << p.nObjsMaxLog;
201 if(!nObjsMaxLit)
202 fatal_error("Memout (nObjsMax) in init");
203 if(nObjsMaxLit > (lit)BvarMax())
204 nObjsMax = BvarMax();
205 else
206 nObjsMax = (bvar)nObjsMaxLit;
207 lit nObjsAllocLit = (lit)1 << p.nObjsAllocLog;
208 if(!nObjsAllocLit)
209 fatal_error("Memout (nObjsAlloc) in init");
210 if(nObjsAllocLit > (lit)BvarMax())
211 nObjsAlloc = BvarMax();
212 else
213 nObjsAlloc = (bvar)nObjsAllocLit;
214 if(nObjsAlloc <= (bvar)nVars)
215 fatal_error("nObjsAlloc must be larger than nVars");
216 nTotalSize = nSize << p.nObjsAllocLog;
217 vVals.resize(nTotalSize);
218 if(p.fCountOnes && nVars > 63)
219 fatal_error("nVars must be less than 64 to count ones");
220 nObjs = 1;
221 for(int i = 0; i < 6 && i < nVars; i++) {
222 for(size j = 0; j < nSize; j++)
223 vVals[nSize * nObjs + j] = vars(i);
224 nObjs++;
225 }
226 for(int i = 0; i < nVars - 6; i++) {
227 for(size j = 0; j < nSize; j += (2ull << i))
228 for(size k = 0; k < (1ull << i); k++)
229 vVals[nSize * nObjs + j + k] = one();
230 nObjs++;
231 }
232 nVerbose = p.nVerbose;
233 nGbc = p.nGbc;
234 if(nGbc || p.nReo != BvarMax())
235 vRefs.resize(nObjsAlloc);
236 }
Cube * p
Definition exorList.c:222
int bvar
Definition giaNewTt.h:35
unsigned lit
Definition giaNewTt.h:36
unsigned long long size
Definition giaNewTt.h:38

Member Function Documentation

◆ And()

lit NewTt::Man::And ( lit x,
lit y )
inline

Definition at line 237 of file giaNewTt.h.

237 {
238 bvar xvar = Lit2Bvar(x);
239 bvar yvar = Lit2Bvar(y);
240 word xcompl = LitIsCompl(x)? one(): 0;
241 word ycompl = LitIsCompl(y)? one(): 0;
242 unsigned j;
243 if(nObjs >= nObjsAlloc && vDeads.empty()) {
244 bool fRemoved = false;
245 if(nGbc > 1)
246 fRemoved = Gbc();
247 if(!Resize() && !fRemoved && (nGbc != 1 || !Gbc()))
248 fatal_error("Memout (node)");
249 }
250 bvar zvar;
251 if(nObjs < nObjsAlloc)
252 zvar = nObjs++;
253 else
254 zvar = vDeads.back(), vDeads.resize(vDeads.size() - 1);
255 for(j = 0; j < nSize; j++)
256 vVals[nSize * zvar + j] = (vVals[nSize * xvar + j] ^ xcompl) & (vVals[nSize * yvar + j] ^ ycompl);
257 return zvar << 1;
258 }
bvar Lit2Bvar(lit x) const
Definition giaNewTt.h:110
bool Gbc()
Definition giaNewTt.h:179
bool LitIsCompl(lit x) const
Definition giaNewTt.h:114
bool Resize()
Definition giaNewTt.h:163
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bvar2Lit()

lit NewTt::Man::Bvar2Lit ( bvar a) const
inline

Definition at line 109 of file giaNewTt.h.

109{ return (lit)a << 1; }

◆ Const0()

lit NewTt::Man::Const0 ( ) const
inline

Definition at line 116 of file giaNewTt.h.

116{ return (lit)0; }

◆ Const1()

lit NewTt::Man::Const1 ( ) const
inline

Definition at line 117 of file giaNewTt.h.

117{ return (lit)1; }

◆ DecRef()

void NewTt::Man::DecRef ( lit x)
inline

Definition at line 160 of file giaNewTt.h.

160{ if(!vRefs.empty() && Ref(x) != RefMax()) vRefs[Lit2Bvar(x)]--; }
ref Ref(lit x) const
Definition giaNewTt.h:115
Here is the call graph for this function:

◆ Gbc()

bool NewTt::Man::Gbc ( )
inline

Definition at line 179 of file giaNewTt.h.

179 {
180 if(nVerbose >= 2)
181 std::cout << "Garbage collect" << std::endl;
182 for(bvar a = nVars + 1; a < nObjs; a++)
183 if(!vRefs[a])
184 vDeads.push_back(a);
185 return vDeads.size();
186 }
Here is the caller graph for this function:

◆ GetNumVars()

int NewTt::Man::GetNumVars ( ) const
inline

Definition at line 276 of file giaNewTt.h.

276 {
277 return nVars;
278 }

◆ IncRef()

void NewTt::Man::IncRef ( lit x)
inline

Definition at line 159 of file giaNewTt.h.

159{ if(!vRefs.empty() && Ref(x) != RefMax()) vRefs[Lit2Bvar(x)]++; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsConst0()

bool NewTt::Man::IsConst0 ( lit x) const
inline

Definition at line 118 of file giaNewTt.h.

118 {
119 bvar a = Lit2Bvar(x);
120 word c = LitIsCompl(x)? one(): 0;
121 for(size j = 0; j < nSize; j++)
122 if(vVals[nSize * a + j] ^ c)
123 return false;
124 return true;
125 }
Here is the call graph for this function:

◆ IsConst1()

bool NewTt::Man::IsConst1 ( lit x) const
inline

Definition at line 126 of file giaNewTt.h.

126 {
127 bvar a = Lit2Bvar(x);
128 word c = LitIsCompl(x)? one(): 0;
129 for(size j = 0; j < nSize; j++)
130 if(~(vVals[nSize * a + j] ^ c))
131 return false;
132 return true;
133 }
Here is the call graph for this function:

◆ IthVar()

lit NewTt::Man::IthVar ( int v) const
inline

Definition at line 111 of file giaNewTt.h.

111{ return ((lit)v + 1) << 1; }

◆ Lit2Bvar()

bvar NewTt::Man::Lit2Bvar ( lit x) const
inline

Definition at line 110 of file giaNewTt.h.

110{ return (bvar)(x >> 1); }
Here is the caller graph for this function:

◆ LitIsCompl()

bool NewTt::Man::LitIsCompl ( lit x) const
inline

Definition at line 114 of file giaNewTt.h.

114{ return x & (lit)1; }
Here is the caller graph for this function:

◆ LitIsEq()

bool NewTt::Man::LitIsEq ( lit x,
lit y ) const
inline

Definition at line 134 of file giaNewTt.h.

134 {
135 if(x == y)
136 return true;
137 if(x == LitMax() || y == LitMax())
138 return false;
139 bvar xvar = Lit2Bvar(x);
140 bvar yvar = Lit2Bvar(y);
141 word c = LitIsCompl(x) ^ LitIsCompl(y)? one(): 0;
142 for(size j = 0; j < nSize; j++)
143 if(vVals[nSize * xvar + j] ^ vVals[nSize * yvar + j] ^ c)
144 return false;
145 return true;
146 }
Here is the call graph for this function:

◆ LitNot()

lit NewTt::Man::LitNot ( lit x) const
inline

Definition at line 112 of file giaNewTt.h.

112{ return x ^ (lit)1; }
Here is the caller graph for this function:

◆ LitNotCond()

lit NewTt::Man::LitNotCond ( lit x,
bool c ) const
inline

Definition at line 113 of file giaNewTt.h.

113{ return x ^ (lit)c; }

◆ OneCount()

size NewTt::Man::OneCount ( lit x) const
inline

Definition at line 147 of file giaNewTt.h.

147 {
148 bvar a = Lit2Bvar(x);
149 size count = 0;
150 if(nVars > 6) {
151 for(size j = 0; j < nSize; j++)
152 count += bsw(vVals[nSize * a + j]).count();
153 } else
154 count = bsw(vVals[nSize * a] & ones(nVars)).count();
155 return LitIsCompl(x)? ((size)1 << nVars) - count: count;
156 }
Here is the call graph for this function:

◆ Or()

lit NewTt::Man::Or ( lit x,
lit y )
inline

Definition at line 259 of file giaNewTt.h.

259 {
260 return LitNot(And(LitNot(x), LitNot(y)));
261 }
lit LitNot(lit x) const
Definition giaNewTt.h:112
lit And(lit x, lit y)
Definition giaNewTt.h:237
Here is the call graph for this function:

◆ PrintNode()

void NewTt::Man::PrintNode ( lit x) const
inline

Definition at line 279 of file giaNewTt.h.

279 {
280 bvar a = Lit2Bvar(x);
281 word c = LitIsCompl(x)? one(): 0;
282 for(size j = 0; j < nSize; j++)
283 std::cout << bsw(vVals[nSize * a + j] ^ c);
284 std::cout << std::endl;
285 }
Here is the call graph for this function:

◆ Ref()

ref NewTt::Man::Ref ( lit x) const
inline

Definition at line 115 of file giaNewTt.h.

115{ return vRefs[Lit2Bvar(x)]; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveRefIfUnused()

void NewTt::Man::RemoveRefIfUnused ( )
inline

Definition at line 271 of file giaNewTt.h.

271 {
272 if(!nGbc)
273 vRefs.clear();
274 }

◆ Reorder()

void NewTt::Man::Reorder ( )
inline

Definition at line 262 of file giaNewTt.h.

262{} // dummy

◆ Resize()

bool NewTt::Man::Resize ( )
inline

Definition at line 163 of file giaNewTt.h.

163 {
164 if(nObjsAlloc == nObjsMax)
165 return false;
166 lit nObjsAllocLit = (lit)nObjsAlloc << 1;
167 if(nObjsAllocLit > (lit)BvarMax())
168 nObjsAlloc = BvarMax();
169 else
170 nObjsAlloc = (bvar)nObjsAllocLit;
171 nTotalSize = nTotalSize << 1;
172 if(nVerbose >= 2)
173 std::cout << "Reallocating " << nObjsAlloc << " nodes" << std::endl;
174 vVals.resize(nTotalSize);
175 if(!vRefs.empty())
176 vRefs.resize(nObjsAlloc);
177 return true;
178 }
Here is the caller graph for this function:

◆ SetRef()

void NewTt::Man::SetRef ( std::vector< lit > const & vLits)
inline

Definition at line 265 of file giaNewTt.h.

265 {
266 vRefs.clear();
267 vRefs.resize(nObjsAlloc);
268 for(size_t i = 0; i < vLits.size(); i++)
269 IncRef(vLits[i]);
270 }
void IncRef(lit x)
Definition giaNewTt.h:159
Here is the call graph for this function:

◆ TurnOffReo()

void NewTt::Man::TurnOffReo ( )
inline

Definition at line 275 of file giaNewTt.h.

275{}

The documentation for this class was generated from the following file: