13#include "trg/trg/Utilities.h"
14#include "trg/trg/State.h"
51 for (
unsigned i = 0; i < bitSize; i++) {
52 const unsigned wp = i /
_bsu;
53 const unsigned bp = i %
_bsu;
69 for (
unsigned i = 0; i <
_size; i++) {
70 const unsigned wp = i /
_bsu;
71 const unsigned bp = i %
_bsu;
85 _size = states.size();
90 for (
unsigned i = 0; i <
_size; i++) {
91 const unsigned wp = i /
_bsu;
92 const unsigned bp = i %
_bsu;
114 for (
unsigned i = 0; i <
_n; i++) {
116 if (order == 0)
_state[i] = states[i];
117 else _state[
_n - 1 - i] = states[i];
131 _size = strlen(inChar);
133 for (
unsigned iBit = 0; iBit <
_size; iBit++) {
134 if (!(inChar[iBit] ==
'0' || inChar[iBit] ==
'1')) {
136 cout <<
"TRGState::TRGState !!! invalid char found : aborted"
138 cout <<
" invalid char = [" << inChar[iBit]
144 }
else if (inType == 1) {
145 _size = strlen(inChar) * 4;
147 for (
unsigned iChar = 0; iChar <
_size / 4; iChar++) {
148 if (!isxdigit(inChar[iChar])) {
150 cout <<
"TRGState::TRGState !!! invalid char found : aborted"
152 cout <<
" invalid char = ["
153 << inChar[iChar] <<
"]" << endl;
160 cout <<
"TRGState::TRGState !!! invalid type : aborted"
162 cout <<
" invalid type = " << inType
172 for (
unsigned iBit = 0; iBit <
_size; iBit++) {
173 const unsigned wp = iBit /
_bsu;
174 const unsigned bp = iBit %
_bsu;
175 if (inChar[
_size - 1 - iBit] ==
'1')
180 }
else if (inType == 1) {
181 for (
unsigned iChar = 0; iChar <
_size / 4; iChar++) {
182 if (iChar % 8 == 0)
_state[iChar / 8] = 0;
183 short unsigned t_int;
184 unsigned charP =
_size / 4 - 1 - iChar;
185 if (inChar[charP] > 47 && inChar[charP] < 58) t_int = inChar[charP] - 48;
186 else t_int = inChar[charP] - 97 + 10;
187 _state[iChar / 8] += t_int << ((iChar % 8) * 4);
200 const string& pre)
const
204 bool large = (
_size > 60) || msg.find(
"large") != string::npos;
207 cout << pre <<
"size=" <<
_size <<
",";
208 for (
unsigned i = 0; i <
_size; i++) {
209 const unsigned j =
_size - i - 1;
219 cout << pre <<
"size=" <<
_size << endl;
221 const unsigned nPerLines = 64;
222 const unsigned lines =
_size / nPerLines + 1;
223 const unsigned rem =
_size % nPerLines;
225 cout <<
"TRGState" <<
226 " +56 +48 +40 +32 +24 +16 +8"
229 bool skipLast =
false;
230 for (
unsigned i = 0; i < lines; i++) {
231 const unsigned n0 = (i == 0) ? rem - 1 : nPerLines - 1;
233 const int os = (lines - i - 1) * nPerLines;
247 cout <<
"... (all zero)" << endl;
261 unsigned n = nPerLines - rem + (nPerLines - rem) / 8;
263 for (
unsigned j = 0; j < n; j++)
267 for (
int j = n0; j >= n1; --j) {
268 const unsigned v = (* this)[j + os];
319 const unsigned sizeNew =
_size + a.size();
320 const unsigned sizeMax =
_n *
_bsu;
321 const unsigned oldSize =
_size;
324 if (sizeNew > sizeMax) {
325 unsigned nNew = sizeNew /
_bsu;
326 if (sizeNew %
_bsu) ++nNew;
327 unsigned* tmp = (
unsigned*) calloc(nNew,
_su);
328 for (
unsigned i = 0; i <
_n; i++) {
338 for (
unsigned i = 0; i < a.size(); i++) {
339 unsigned j = i + oldSize;
340 const unsigned wp = j /
_bsu;
341 const unsigned bp = j %
_bsu;
359 for (
unsigned i = s; i < s + n; i++) {
361 stack.push_back(
true);
363 stack.push_back(
false);
376 for (
unsigned i = 0; i <
_n; i++) {
386 const unsigned long long n0(*
this);
387 const unsigned long long n1(a);
401 for (
unsigned i = 0; i < s.size(); i++) {
402 const unsigned j = s.size() - i - 1;
A class to represent a state of multi bits.
unsigned _n
bit storage size.
unsigned * _state
bit state.
virtual ~TRGState()
Destructor.
TRGState(unsigned bitSize=0)
Default constructor.
TRGState subset(unsigned i, unsigned n) const
returns subset from i with n bits.
static const unsigned _bsu
bit size of unsigned.
bool operator<(const TRGState &) const
Copy operator.
static const unsigned _su
size of unsigned.
static std::string itostring(int i)
converts int to string. (Use boost::lexical_cast)
TRGState & operator+=(const TRGState &)
appends TRGState (as MSB).
TRGState & operator=(const TRGState &)
Copy operator.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Abstract base class for different kinds of events.