simulavr  1.1.0
traceval.cpp
Go to the documentation of this file.
1 /*
2  ****************************************************************************
3  *
4  * simulavr - A simulator for the Atmel AVR family of microcontrollers.
5  * Copyright (C) 2009 Onno Kortmann
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  ****************************************************************************
22  *
23  * $Id$
24  */
25 #include <algorithm>
26 #include <fstream>
27 #include <sstream>
28 #include <stdlib.h>
29 #include "helper.h"
30 #include "traceval.h"
31 #include "avrdevice.h"
32 #include "avrerror.h"
33 #include "systemclock.h"
34 
35 using namespace std;
36 
38  const std::string &__name,
39  const int __index,
40  const void *_shadow) :
41  _name(__name),
42  _index(__index),
43  b(bits),
44  shadow(_shadow),
45  v(0xaffeaffe),
46  f(0),
47  _written(false),
48  _enabled(false) {}
49 
50 size_t TraceValue::bits() const { return b; }
51 
52 std::string TraceValue::name() const {
53  if (index()>=0)
54  return _name+int2str(index());
55  else return _name;
56 }
57 
58 std::string TraceValue::barename() const { return _name; }
59 
60 int TraceValue::index() const { return _index; }
61 
62 unsigned TraceValue::value() const { return v; }
63 
64 bool TraceValue::enabled() const { return _enabled; }
65 
66 void TraceValue::enable() { _enabled=true; }
67 
68 void TraceValue::change(unsigned val) {
69  // this is mostly the same as write, but dosn't set WRITE nor _written flag!
70  if ((v != val) || !_written) {
71  f |= CHANGE;
72  v = val;
73  }
74 }
75 
76 void TraceValue::change(unsigned val, unsigned mask) {
77  // this is mostly the same as write, but dosn't set WRITE nor _written flag!
78  if (((v & mask) != (val & mask)) || !_written) {
79  f |= CHANGE;
80  v = (v & ~mask) | (val & mask);
81  }
82 }
83 
84 void TraceValue::write(unsigned val) {
85  if ((v != val) || !_written) {
86  f |= CHANGE;
87  v = val;
88  }
89  f |= WRITE;
90  _written = true;
91 }
92 
94  f |= READ;
95 }
96 
97 bool TraceValue::written() const { return _written; }
98 
100  _written=true;
101 }
102 
103 void TraceValue::set_written(unsigned val) {
104  _written=true;
105  v = val;
106 }
107 
109 
111  if (shadow) {
112  unsigned nv;
113  switch (b) {
114  case 1:
115  nv = *(const bool*) shadow; break;
116  case 8:
117  nv = *(const uint8_t*) shadow; break;
118  case 16:
119  nv = *(const uint16_t*) shadow; break;
120  case 32:
121  nv = *(const uint32_t*) shadow; break;
122  default:
123  avr_error("Internal error: Unsupported number of bits in TraceValue::cycle().");
124  break;
125  }
126  if (v!=nv) {
127  f|=CHANGE;
128  _written=true; // FIXME: This detection can fail!
129  v=nv;
130  }
131  }
132 }
133 
135  if (f&READ) {
136  d.markRead(this);
137  if (!_written)
138  d.markReadUnknown(this);
139  }
140  if (f&WRITE) {
141  d.markWrite(this);
142  }
143  if (f&CHANGE) {
144  d.markChange(this);
145  }
146  f=0;
147 }
148 
149 char TraceValue::VcdBit(int bitNo) const {
150  if (_written)
151  return (v & (1 << bitNo)) ? '1' : '0';
152  else
153  return 'x';
154 }
155 
156 char TraceValueOutput::VcdBit(int bitNo) const {
157  unsigned val = value();
158  if(written()) {
159  if(val == Pin::TRISTATE)
160  return 'z';
161  if((val == Pin::HIGH) || (val == Pin::PULLUP))
162  return '1';
163  if(val == Pin::LOW)
164  return '0';
165  }
166  return 'x';
167 }
168 
170  for (valmap_t::iterator i = _tvr_values.begin(); i != _tvr_values.end(); i++) {
171  delete i->first;
172  delete i->second;
173  }
174  _tvr_values.clear();
175  for (regmap_t::iterator i = _tvr_registers.begin(); i != _tvr_registers.end(); i++)
176  delete i->first;
177  _tvr_registers.clear();
178  if(_tvr_parent != NULL)
179  _tvr_parent->_tvr_unregisterTraceValues(this);
180 }
181 
183  string n = r->GetScopeName();
184  if(GetScopeGroupByName(n) == NULL) {
185  string *s = new string(n);
186  pair<string*, TraceValueRegister*> v(s, r);
187  _tvr_registers.insert(v);
188  } else
189  avr_error("duplicate name '%s', another TraceValueRegister child is already registered", n.c_str());
190 }
191 
193  string n = r->GetScopeName();
194  for (regmap_t::iterator i = _tvr_registers.begin(); i != _tvr_registers.end(); i++) {
195  if(n == *(i->first)) {
196  delete i->first;
197  _tvr_registers.erase(i);
198  break;
199  }
200  }
201 }
202 
204  size_t cnt = _tvr_values.size();
205  for (regmap_t::iterator i = _tvr_registers.begin(); i != _tvr_registers.end(); i++)
206  cnt += (i->second)->_tvr_getValuesCount();
207  return cnt;
208 }
209 
211  for (valmap_t::iterator i = _tvr_values.begin(); i != _tvr_values.end(); i++)
212  t.push_back(i->second);
213  for (regmap_t::iterator i = _tvr_registers.begin(); i != _tvr_registers.end(); i++)
214  (i->second)->_tvr_insertTraceValuesToSet(t);
215 }
216 
218  // check for duplicate names and the right prefix
219  string p = t->name();
220  unsigned int idx = _tvr_scopeprefix.length();
221  if((p.length() <= idx) || (p.substr(0, idx) != _tvr_scopeprefix))
222  avr_error("add TraceValue denied: wrong prefix: '%s', scope is '%s'",
223  p.c_str(), _tvr_scopeprefix.c_str());
224  string n = p.substr(idx);
225  if(n.find('.') != string::npos)
226  avr_error("add TraceValue denied: wrong name: '%s', scope is '%s'",
227  n.c_str(), _tvr_scopeprefix.c_str());
228  // register this TraceValue
229  if(GetTraceValueByName(n) == NULL) {
230  string *s = new string(n);
231  pair<string*, TraceValue*> v(s, t);
232  _tvr_values.insert(v);
233  } else
234  avr_error("add TraceValue denied: name found: '%s'", n.c_str());
235 }
236 
238  int idx = _tvr_scopeprefix.length();
239  string n = t->name().substr(idx);
240  for (valmap_t::iterator i = _tvr_values.begin(); i != _tvr_values.end(); i++) {
241  if(n == *(i->first)) {
242  delete i->first;
243  delete i->second;
244  _tvr_values.erase(i);
245  break;
246  }
247  }
248 }
249 
251  for (regmap_t::iterator i = _tvr_registers.begin(); i != _tvr_registers.end(); i++) {
252  if(name == *(i->first))
253  return i->second;
254  }
255  return NULL;
256 }
257 
259  for (valmap_t::iterator i = _tvr_values.begin(); i != _tvr_values.end(); i++) {
260  if(name == *(i->first))
261  return i->second;
262  }
263  return NULL;
264 }
265 
267  int idx = name.find('.');
268  if(idx > 0) {
269  TraceValueRegister *r = GetScopeGroupByName(name.substr(0, idx));
270  if(r == NULL)
271  return NULL;
272  else
273  return r->FindScopeGroupByName(name.substr(idx + 1));
274  } else
275  return GetScopeGroupByName(name);
276 }
277 
279  int idx = name.find('.');
280  if(idx > 0) {
281  TraceValueRegister *r = GetScopeGroupByName(name.substr(0, idx));
282  if(r == NULL)
283  return NULL;
284  else
285  return r->FindTraceValueByName(name.substr(idx + 1));
286  } else
287  return GetTraceValueByName(name);
288 }
289 
291  TraceSet* result = new TraceSet;
292  result->reserve(_tvr_values.size());
293  for (valmap_t::iterator i = _tvr_values.begin(); i != _tvr_values.end(); i++)
294  result->push_back(i->second);
295  return result;
296 }
297 
299  TraceSet* result = new TraceSet;
300  result->reserve(_tvr_getValuesCount());
301  _tvr_insertTraceValuesToSet(*result);
302  return result;
303 }
304 
306  TraceValueRegister(parent, "CORE") {}
307 
308 void TraceValueCoreRegister::RegisterTraceSetValue(TraceValue *t, const std::string &name, const size_t size) {
309  // seek TraceSet
310  TraceSet *set = NULL;
311  for(setmap_t::iterator i = _tvr_valset.begin(); i != _tvr_valset.end(); i++) {
312  if(name == *(i->first)) {
313  set = i->second;
314  break;
315  }
316  }
317  // create TraceSet, if not found
318  if(set == NULL) {
319  set = new TraceSet(size, NULL);
320  string *s = new string(name);
321  pair<string*, TraceSet*> v(s, set);
322  _tvr_valset.insert(v);
323  }
324  // set TraceValue to set[idx]
325  (*set)[t->index()] = t;
326 }
327 
330  if(res == NULL) {
331  int idx = _tvr_numberindex(name);
332  if(idx != -1) {
333  // name + number found, check name and index value
334  string n = name.substr(0, idx);
335  int v = atoi(name.substr(idx).c_str());
336  for(setmap_t::iterator i = _tvr_valset.begin(); i != _tvr_valset.end(); i++) {
337  if(n == *(i->first)) {
338  TraceSet *set = i->second;
339  if(v < (int)set->size())
340  res = (*set)[v];
341  break;
342  }
343  }
344  }
345  }
346  return res;
347 }
348 
350  for(setmap_t::iterator i = _tvr_valset.begin(); i != _tvr_valset.end(); i++) {
351  TraceSet s = *(i->second);
352  for(int j = s.size() - 1; j >= 0; j--)
353  delete s[j];
354  delete i->first;
355  delete i->second;
356  }
357 }
358 
361  // now count too values in _tvr_valset
362  for(setmap_t::iterator i = _tvr_valset.begin(); i != _tvr_valset.end(); i++)
363  cnt += i->second->size();
364  return cnt;
365 }
366 
369  // now insert also all values from _tvr_valset
370  for(setmap_t::iterator i = _tvr_valset.begin(); i != _tvr_valset.end(); i++) {
371  TraceSet* s = i->second;
372  for(TraceSet::iterator j = s->begin(); j != s->end(); j++)
373  t.push_back(*j);
374  }
375 }
376 
377 int TraceValueCoreRegister::_tvr_numberindex(const std::string &str) {
378  int l = str.size();
379  int i = l - 1;
380  // start from end of string to the beginning ...
381  for(; i >= 0; i--) {
382  char c = str[i];
383  // check, if number sign
384  if(c < '0' || c > '9') {
385  i++;
386  break;
387  }
388  }
389  if(i == l)
390  i = -1;
391  return i;
392 }
393 
394 WarnUnknown::WarnUnknown(AvrDevice *_core) : core(_core) {}
395 
397  cerr << "READ-before-WRITE for value " << t->name()
398  << " at time " << SystemClock::Instance().GetCurrentTime()
399  << ", PC=0x" << hex << 2*core->PC << dec << endl;
400 }
401 bool WarnUnknown::enabled(const TraceValue *t) const {
402  return true;
403 }
404 
405 void DumpVCD::valout(const TraceValue *v) {
406  osbuffer << 'b';
407  for (int i = v->bits()-1; i >= 0; i--)
408  osbuffer << v->VcdBit(i);
409 
410 }
411 
413  if(changesWritten) {
414  *os << osbuffer.str();
415  changesWritten = false;
416  }
417  osbuffer.str("");
418 }
419 
420 DumpVCD::DumpVCD(ostream *_os,
421  const std::string &_tscale,
422  const bool rstrobes,
423  const bool wstrobes) :
424  tscale(_tscale),
425  rs(rstrobes),
426  ws(wstrobes),
427  changesWritten(false),
428  os(_os)
429 {}
430 
431 DumpVCD::DumpVCD(const std::string &_name,
432  const std::string &_tscale,
433  const bool rstrobes,
434  const bool wstrobes) :
435  tscale(_tscale),
436  rs(rstrobes),
437  ws(wstrobes),
438  changesWritten(false),
439  os(new ofstream(_name.c_str()))
440 {}
441 
443  tv=act;
444  unsigned n=0;
445  for (TraceSet::const_iterator i=act.begin();
446  i!=act.end(); i++) {
447  if (id2num.find(*i)!=id2num.end())
448  avr_error("Trace value would be twice in VCD list.");
449  id2num[*i]=n++;
450  }
451 }
452 
454  *os <<
455  "$version\n"
456  "\tSimulavr VCD dump file generator\n"
457  "$end\n";
458 
459  *os << "$timescale 1" << tscale << " $end\n";
460  typedef TraceSet::iterator iter;
461  unsigned n=0;
462  for (iter i=tv.begin();
463  i!=tv.end(); i++) {
464  string s=(*i)->name();
465 
466  /* find last dot in string as divider
467  between name of the variable and the module string. */
468  int ld;
469  for (ld=s.size()-1; ld>0; ld--)
470  if (s[ld]=='.') break;
471 
472  *os << "$scope module " << s.substr(0, ld) << " $end\n";
473  *os << "$var wire " << (*i)->bits() << ' ' << n*(1+rs+ws) << ' ' << s.substr(ld+1, s.size()-1) << " $end\n";
474  if (rs)
475  *os << "$var wire 1 " << n*(1+rs+ws)+1 << ' ' << s.substr(ld+1, s.size()-1)+"_R" << " $end\n";
476  if (ws)
477  *os << "$var wire 1 " << n*(1+rs+ws)+1+rs << ' ' << s.substr(ld+1, s.size()-1)+"_W" << " $end\n";
478  *os << "$upscope $end\n";
479  n++;
480  }
481  *os << "$enddefinitions $end\n";
482 
483  // mark initial state
484  changesWritten = true;
485  osbuffer << "#0\n$dumpvars\n";
486  n=0;
487  for (iter i=tv.begin();
488  i!=tv.end(); i++) {
489  valout(*i);
490  osbuffer << ' ' << n*(1+rs+ws) << '\n';
491  // reset RS, WS
492  if (rs) {
493  osbuffer << "0" << n*(1+rs+ws)+1 << "\n";
494  }
495  if (ws) {
496  if (rs)
497  osbuffer << "0" << n*(1+rs+ws)+2 << "\n";
498  else
499  osbuffer << "0" << n*(1+rs+ws)+1 << "\n";
500  }
501  n++;
502  }
503  osbuffer << "$end\n";
504  flushbuffer();
505 }
506 
508  // flush the buffer
509  flushbuffer();
510 
511  // write new time marker to buffer
513  osbuffer << "#" << clock << '\n';
514 
515  // reset RS, WS states
516  for (size_t i=0; i<marked.size(); i++)
517  osbuffer << "0" << marked[i] << "\n";
518  if(marked.size())
519  changesWritten = true;
520  marked.clear();
521 }
522 
524  // flush the buffer
525  flushbuffer();
526 
527  // write a last time marker to report end of dump
529  *os << "#" << clock << '\n';
530 
531  os->flush(); // flush stream
532 }
533 
535  if (rs) {
536  // mark read cycle
537  osbuffer << "1" << id2num[t]*(1+rs+ws)+1 << "\n";
538  changesWritten = true;
539  // mark to disable @ next cycle
540  marked.push_back(id2num[t]*(1+rs+ws)+1);
541  }
542 }
543 
545  if (ws) {
546  osbuffer << "1" << id2num[t]*(1+rs+ws)+1+rs << "\n";
547  changesWritten = true;
548  marked.push_back(id2num[t]*(1+rs+ws)+1+rs);
549  }
550 }
551 
553  valout(t);
554  osbuffer << " " << id2num[t]*(1+rs+ws) << "\n";
555  changesWritten = true;
556 }
557 
558 bool DumpVCD::enabled(const TraceValue *t) const {
559  return id2num.find(t)!=id2num.end();
560 }
561 
562 DumpVCD::~DumpVCD() { delete os; }
563 
564 int DumpManager::_devidx = 0;
566 
568  if(_instance == NULL)
569  _instance = new DumpManager();
570  return _instance;
571 }
572 
573 void DumpManager::Reset(void) {
574  if(_instance) {
575  _instance->detachAvrDevices();
576  delete _instance;
577  }
578  _instance = NULL;
579  _devidx = 0;
580 }
581 
583  singleDeviceApp = false;
584 }
585 
586 void DumpManager::appendDeviceName(std::string &s) {
587  _devidx++;
588  if(singleDeviceApp && _devidx > 1)
589  avr_error("Can't create device name twice, because it's a single device application");
590  if(!singleDeviceApp)
591  s += "Dev" + int2str(_devidx);
592 }
593 
595  devices.push_back(dev);
596 }
597 
599  vector<AvrDevice*> dl;
600  for(vector<AvrDevice*>::iterator i = devices.begin(); i != devices.end(); i++) {
601  AvrDevice* d = *i;
602  if(d != dev)
603  dl.push_back(d);
604  }
605  devices.swap(dl);
606 }
607 
609  vector<AvrDevice*> dl;
610 
611  for(vector<AvrDevice*>::iterator i = devices.begin(); i != devices.end(); i++) {
612  AvrDevice* d = *i;
613  d->detachDumpManager();
614  }
615 }
616 
617 TraceValue* DumpManager::seekValueByName(const std::string &name) {
618  if(singleDeviceApp) {
619  if(devices.size() == 0)
620  return NULL;
621  return devices[0]->FindTraceValueByName(name);
622  } else {
623  int idx = name.find('.');
624  if(idx <= 0)
625  return NULL;
626  for(vector<AvrDevice*>::iterator i = devices.begin(); i != devices.end(); i++) {
627  if((*i)->GetScopeName() == name.substr(0, idx)) {
628  return (*i)->FindTraceValueByName(name.substr(idx + 1));
629  }
630  }
631  return NULL;
632  }
633 }
634 
636  if(devices.size() > 0)
637  avr_error("method SetSingleDeviceApp must be called before devices are added to DumpManager");
638  singleDeviceApp = true;
639 }
640 
641 void DumpManager::addDumper(Dumper *dump, const TraceSet &vals) {
642  // enable values and insert into active list, if not there
643  for(TraceSet::const_iterator i = vals.begin(); i != vals.end(); i++) {
644  (*i)->enable();
645  if(find(active.begin(), active.end(), *i) == active.end())
646  active.push_back(*i);
647  }
648 
649  // check, if dumper exists in dumps list
650  if(find(dumps.begin(), dumps.end(), dump) != dumps.end())
651  avr_error("Internal error: Dumper already registered.");
652  // set active signals for dumper
653  dump->setActiveSignals(vals);
654  // and insert dumper in dumps list
655  dumps.push_back(dump);
656 }
657 
659  TraceSet* s;
660 
661  // clear list
662  _all.clear();
663 
664  // over all registered devices
665  for(vector<AvrDevice*>::const_iterator d = devices.begin(); d != devices.end(); d++) {
666  // all values from device
667  s = (*d)->GetAllTraceValuesRecursive();
668  // change allocated vector size
669  _all.reserve(_all.size() + s->size());
670  // append all values from device list to result list
671  for(TraceSet::const_iterator i = s->begin(); i != s->end(); i++)
672  _all.push_back(*i);
673  delete s;
674  }
675 
676  // return resulting list
677  return _all;
678 }
679 
681  for (size_t i=0; i< dumps.size(); i++)
682  dumps[i]->start();
683 
684 }
685 
687  // First, call the Dumpers
688  for (size_t i=0; i<dumps.size(); i++)
689  dumps[i]->cycle();
690 
691  // And then, update the TraceValues and dump them
692  for (TraceSet::iterator i=active.begin();
693  i!=active.end(); i++) {
694  (*i)->cycle();
695  for (size_t j=0; j<dumps.size(); j++)
696  if (dumps[j]->enabled(*i))
697  (*i)->dump(*dumps[j]);
698  }
699 }
700 
702  for(size_t i = 0; i < dumps.size(); i++) {
703  dumps[i]->stop(); // inform dumper to stop output
704  delete dumps[i];
705  }
706  dumps.clear();
707 }
708 
709 void DumpManager::save(ostream &os) const {
710  TraceSet* s;
711  for(vector<AvrDevice*>::const_iterator d = devices.begin(); d != devices.end(); d++) {
712  s = (*d)->GetAllTraceValuesRecursive();
713  for(TraceSet::const_iterator i = s->begin(); i != s->end(); i++) {
714  TraceValue& tv = *(*i);
715  if (tv.index() >= 0) {
716  int c = tv.index();
717 
718  while(((*i)->barename() == tv.barename()) &&
719  (c == (*i)->index())) {
720  i++;
721  c++;
722  }
723  i--; c--;
724 
725  if(c) {
726  os << "| " << tv.barename() << ' '
727  << tv.index() << " .. "
728  << (*i)->index() << '\n';
729  } else {
730  os << "+ " << (*i)->name() << '\n';
731  }
732  } else
733  os << "+ " << (*i)->name() << '\n';
734  }
735  delete s;
736  }
737 }
738 
740  TraceSet res;
741 
742  while(!is.eof()) {
743  // read line from stream and split it up
744  string l = readline(is);
745  vector<string> ls = split(l);
746 
747  // empty line or to short?
748  if(ls.size() < 2) continue;
749 
750  if(ls[0] == "+") {
751  // single value, get name
752  string n = ls[1];
753  // seek value
754  TraceValue *t = seekValueByName(n);
755  if(t == NULL)
756  avr_error("TraceValue '%s' is not known.", n.c_str());
757  // insert to list
758  res.push_back(t);
759  } else if(ls[0] == "|") {
760  // value range?
761  if(ls[3] != "..")
762  avr_error("'..' expected between range limits.");
763  // get name and range values
764  string bn = ls[1];
765  size_t min = atoi(ls[2].c_str());
766  size_t max = atoi(ls[4].c_str());
767  // seek for all values in range
768  for(size_t i = min; i <= max; i++) {
769  string n = ls[1] + int2str(i);
770  TraceValue *t = seekValueByName(n);
771  if(t == NULL)
772  avr_error("While constructing range with '%s', TraceValue is not known.", n.c_str());
773  // insert to list
774  res.push_back(t);
775  }
776  } else if(ls[0][0] != '#')
777  // not a comment, then it's an error
778  avr_error("Invalid trace value specifier '%s'.", ls[0].c_str());
779  }
780  return res;
781 }
782 
783 TraceSet DumpManager::load(const string &istr) {
784  istringstream is(istr.c_str());
785  return load(is);
786 }
787 
788 TraceValue* trace_direct(TraceValueRegister *t, const std::string &name, const bool *val) {
789  TraceValue *tv=new TraceValue(1, t->GetTraceValuePrefix() + name,
790  -1, val);
791  t->RegisterTraceValue(tv);
792  return tv;
793 }
794 
795 TraceValue* trace_direct(TraceValueRegister *t, const std::string &name, const uint8_t*val) {
796  TraceValue* tv=new TraceValue(8, t->GetTraceValuePrefix() + name,
797  -1, val);
798  t->RegisterTraceValue(tv);
799  return tv;
800 }
801 
802 TraceValue* trace_direct(TraceValueRegister *t, const std::string &name, const uint16_t*val) {
803  TraceValue* tv=new TraceValue(16, t->GetTraceValuePrefix() + name,
804  -1, val);
805  t->RegisterTraceValue(tv);
806  return tv;
807 }
808 
809 TraceValue* trace_direct(TraceValueRegister *t, const std::string &name, const uint32_t*val) {
810  TraceValue* tv=new TraceValue(32, t->GetTraceValuePrefix() + name,
811  -1, val);
812  t->RegisterTraceValue(tv);
813  return tv;
814 }
815 
void start()
Definition: traceval.cpp:680
static std::vector< AvrDevice * > devices
Definition: vpi.cpp:41
virtual char VcdBit(int bitNo) const
Definition: traceval.cpp:149
Basic AVR device, contains the core functionality.
Definition: avrdevice.h:66
void read()
Log a read access.
Definition: traceval.cpp:93
setmap_t _tvr_valset
the registered TraceValue&#39;s
Definition: traceval.h:514
void markWrite(const TraceValue *t)
Definition: traceval.cpp:544
void flushbuffer(void)
writes content of osbuffer to os and empty osbuffer afterwards
Definition: traceval.cpp:412
bool changesWritten
Definition: traceval.h:326
SystemClockOffset GetCurrentTime() const
Returns the current simulation time.
Definition: systemclock.h:95
WarnUnknown(AvrDevice *core)
Definition: traceval.cpp:394
TraceSet * GetAllTraceValuesRecursive(void)
Get all here registered TraceValue&#39;s with descending values.
Definition: traceval.cpp:298
TraceSet * GetAllTraceValues(void)
Get all here registered TraceValue&#39;s only (not with descending values)
Definition: traceval.cpp:290
int index() const
Gives the index of this member in a memory field (or -1)
Definition: traceval.cpp:60
std::ostream * os
Definition: traceval.h:330
void unregisterAvrDevice(AvrDevice *dev)
Remove a device from devicelist.
Definition: traceval.cpp:598
void registerAvrDevice(AvrDevice *dev)
Add a device to devicelist.
Definition: traceval.cpp:594
void valout(const TraceValue *v)
Definition: traceval.cpp:405
const TraceSet & all()
Definition: traceval.cpp:658
unsigned value() const
Gives the saved shadow value for this trace value.
Definition: traceval.cpp:62
STL namespace.
std::string readline(istream &is)
Reads one line from a stream.
Definition: helper.cpp:71
virtual TraceValue * GetTraceValueByName(const std::string &name)
Get a here registered TraceValue by it&#39;s name.
Definition: traceval.cpp:258
void markReadUnknown(const TraceValue *t)
Definition: traceval.cpp:396
TraceValue * FindTraceValueByName(const std::string &name)
Seek for a TraceValue by it&#39;s name.
Definition: traceval.cpp:278
std::string barename() const
Gives the name without the index.
Definition: traceval.cpp:58
vector< std::string > split(const std::string &inp, std::string splitc)
Splits a string into a vector of strings at delimiters splitc.
Definition: helper.cpp:82
void setActiveSignals(const TraceSet &act)
Definition: traceval.cpp:442
virtual char VcdBit(int bitNo) const
Definition: traceval.cpp:156
virtual void _tvr_insertTraceValuesToSet(TraceSet &t)
Insert all TraceValues into TraceSet, that registered here and descending.
Definition: traceval.cpp:367
DumpManager()
Private instance constructor.
Definition: traceval.cpp:582
TraceSet load(std::istream &is)
Definition: traceval.cpp:739
int _index
Definition: traceval.h:192
std::stringstream osbuffer
Definition: traceval.h:333
virtual void markRead(const TraceValue *t)
Definition: traceval.h:248
void save(std::ostream &os) const
Definition: traceval.cpp:709
Definition: pin.h:116
static DumpManager * _instance
Definition: traceval.h:437
int _tvr_numberindex(const std::string &str)
helper function to split up into name an number tail
Definition: traceval.cpp:377
Atype flags() const
Gives the current set of flag readings.
Definition: traceval.cpp:108
void stopApplication(void)
Stop processing on all dumpers and removes it from dumpers list.
Definition: traceval.cpp:701
virtual ~TraceValueRegister()
Definition: traceval.cpp:169
void set_written()
Definition: traceval.cpp:99
#define avr_error(...)
Definition: avrerror.h:135
static int _devidx
Definition: traceval.h:436
static void Reset(void)
Reset DumpManager instance (e.g. delete available instance)
Definition: traceval.cpp:573
size_t bits() const
Give number of bits for this value. Max 32.
Definition: traceval.cpp:50
const unsigned b
number of bits
Definition: traceval.h:195
Build a register for TraceValue&#39;s.
Definition: traceval.h:442
virtual size_t _tvr_getValuesCount(void)
Get the count of all TraceValues, that are registered here and descending.
Definition: traceval.cpp:203
~DumpVCD()
Definition: traceval.cpp:562
std::map< const TraceValue *, size_t > id2num
Definition: traceval.h:323
void RegisterTraceSetValue(TraceValue *t, const std::string &name, const size_t size)
Registers a TraceValue for this register.
Definition: traceval.cpp:308
void RegisterTraceValue(TraceValue *t)
Registers a TraceValue for this register.
Definition: traceval.cpp:217
static SystemClock & Instance()
Returns the central SystemClock instance for the application.
virtual void markWrite(const TraceValue *t)
Definition: traceval.h:254
TraceValue(size_t bits, const std::string &_name, const int __index=-1, const void *shadow=NULL)
Generate a new unitialized trace value of width bits.
Definition: traceval.cpp:37
std::string name() const
Give name (fully qualified), including the index appended if it is >=0.
Definition: traceval.cpp:52
bool written() const
Definition: traceval.cpp:97
TraceValueRegister * FindScopeGroupByName(const std::string &name)
Seek for a TraceValueRegister by it&#39;s name.
Definition: traceval.cpp:266
void write(unsigned val)
Log a write access on this value.
Definition: traceval.cpp:84
bool enabled() const
Definition: traceval.cpp:64
TraceValueRegister * GetScopeGroupByName(const std::string &name)
Get a here registered TraceValueRegister by it&#39;s name.
Definition: traceval.cpp:250
long long SystemClockOffset
std::string int2str(int i)
Convert an int into a string.
Definition: helper.cpp:59
const void * shadow
shadow reg, if used
Definition: traceval.h:198
virtual void setActiveSignals(const TraceSet &act)
Definition: traceval.h:236
void detachDumpManager()
Definition: avrdevice.h:79
void SetSingleDeviceApp(void)
Tell DumpManager, that we have only one device.
Definition: traceval.cpp:635
void cycle()
Writes next clock cycle and resets all RS and WS states.
Definition: traceval.cpp:507
void _tvr_unregisterTraceValues(TraceValueRegister *r)
Definition: traceval.cpp:192
virtual size_t _tvr_getValuesCount(void)
Get the count of all TraceValues, that are registered here and descending.
Definition: traceval.cpp:359
TraceValueCoreRegister(TraceValueRegister *parent)
Create a TraceValueCoreRegister instance.
Definition: traceval.cpp:305
virtual TraceValue * GetTraceValueByName(const std::string &name)
Get a here registered TraceValue by it&#39;s name.
Definition: traceval.cpp:328
DumpVCD(std::ostream *os, const std::string &tscale="ns", const bool rstrobes=false, const bool wstrobes=false)
Create tracer with time scale tscale and output os.
Definition: traceval.cpp:420
void markRead(const TraceValue *t)
Definition: traceval.cpp:534
unsigned v
The value itself.
Definition: traceval.h:201
void detachAvrDevices()
detach all devices
Definition: traceval.cpp:608
const std::string GetTraceValuePrefix(void)
Returns the scope prefix.
Definition: traceval.h:487
void UnregisterTraceValue(TraceValue *t)
Unregisters a TraceValue, remove it from register.
Definition: traceval.cpp:237
void start()
Writes header stuff and the initial state.
Definition: traceval.cpp:453
void markChange(const TraceValue *t)
Definition: traceval.cpp:552
virtual void markChange(const TraceValue *t)
Definition: traceval.h:258
bool _written
Definition: traceval.h:206
TraceSet tv
Definition: traceval.h:322
bool _enabled
Tracing of this value enabled at all?
Definition: traceval.h:211
void stop()
Writes a last time marker.
Definition: traceval.cpp:523
void _tvr_registerTraceValues(TraceValueRegister *r)
Definition: traceval.cpp:182
std::vector< int > marked
Definition: traceval.h:329
void enable()
Enable tracing.
Definition: traceval.cpp:66
static DumpManager * Instance(void)
Singleton class access.
Definition: traceval.cpp:567
unsigned int PC
Definition: avrdevice.h:93
Definition: pin.h:117
void change(unsigned val)
Log a change on this value.
Definition: traceval.cpp:68
bool enabled(const TraceValue *t) const
Returns true iff tracing a particular value is enabled.
Definition: traceval.cpp:558
std::vector< TraceValue * > TraceSet
Definition: traceval.h:226
const std::string tscale
Definition: traceval.h:324
const bool ws
Definition: traceval.h:325
virtual void _tvr_insertTraceValuesToSet(TraceSet &t)
Insert all TraceValues into TraceSet, that registered here and descending.
Definition: traceval.cpp:210
void cycle()
Definition: traceval.cpp:686
void appendDeviceName(std::string &s)
append a unique device name to a string
Definition: traceval.cpp:586
TraceValue * seekValueByName(const std::string &name)
Seek value by name in all devices.
Definition: traceval.cpp:617
AvrDevice * core
Definition: traceval.h:281
virtual void markReadUnknown(const TraceValue *t)
Definition: traceval.h:250
TraceValue * trace_direct(TraceValueRegister *t, const std::string &name, const bool *val)
Register a directly traced bool value.
Definition: traceval.cpp:788
const bool rs
Definition: traceval.h:325
const std::string GetScopeName(void)
Returns the scope name.
Definition: traceval.h:489
bool enabled(const TraceValue *t) const
Returns true iff tracing a particular value is enabled.
Definition: traceval.cpp:401
int f
accesses since last dump/clearflagsd
Definition: traceval.h:203
virtual void cycle()
Called at least once for each cycle if this trace value is activated.
Definition: traceval.cpp:110
virtual void dump(Dumper &d)
Definition: traceval.cpp:134
std::string _name
Definition: traceval.h:190
void addDumper(Dumper *dump, const TraceSet &vals)
Definition: traceval.cpp:641
Atype
Possible access types for a trace value.
Definition: traceval.h:131