HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
wave_group_value.cpp
Go to the documentation of this file.
2 
3 namespace hal {
4  WaveGroupValue::WaveGroupValue(int nbits) : mHasTransition(0), mValue(0), mTooManyTransitions(0), mUndefined(0)
5  {
6  for (int i=0; i<nbits; i++)
7  {
8  u32 mask = 1<<(nbits-i-1);
9  mHasTransition |= mask;
10  mUndefined |= mask;
11  }
12  }
13 
14  void WaveGroupValue::setValue(u32 mask, int val)
15  {
16  mHasTransition |= mask;
17  if (val == sTooManyTransitions)
18  {
19  mTooManyTransitions |= mask;
20  mUndefined &= (~mask);
21  }
22  else if (val < 0)
23  {
24  mTooManyTransitions &= (~mask);
25  mUndefined |= mask;
26  }
27  else
28  {
29  mTooManyTransitions &= (~mask);
30  mUndefined &= (~mask);
31  if (val)
32  mValue |= mask;
33  else
34  mValue &= (~mask);
35  }
36  }
37 
39  {
40  WaveGroupValue retval(previous);
41  u32 mask = 1;
42  while (mask)
43  {
44  if (mHasTransition & mask)
45  {
46  if (mUndefined & mask)
47  retval.setValue(mask,-1);
48  else if (mTooManyTransitions & mask)
49  retval.setValue(mask,sTooManyTransitions);
50  else
51  retval.setValue(mask, (mValue&mask) ? 1 : 0);
52  }
53  mask <<= 1;
54  }
55  return retval;
56  }
57 
59  {
60  if (mUndefined > 0)
61  return -1;
62  if (mTooManyTransitions > 0)
63  return sTooManyTransitions;
64  return mValue;
65  }
66 
67 
68 }
static const int sTooManyTransitions
void setValue(u32 mask, int val)
WaveGroupValue mergePrevious(const WaveGroupValue &previous) const
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45