source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Stat_print.cpp @ 75

Last change on this file since 75 was 75, checked in by rosiere, 16 years ago

Update all component (except front_end) to :

  • new statistics model
  • no namespace std
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#ifdef STATISTICS
2#include "Behavioural/include/Stat.h"
3
4namespace morpheo {
5namespace behavioural { 
6
7  std::string Stat::print (uint32_t depth)
8  {
9    end_simulation(); 
10
11    cycle_t _cycle_sum = sc_simulation_time();
12
13    morpheo::behavioural::XML xml (_name_instance);
14
15    xml.balise_open_begin(_name_component);
16    xml.attribut("name",_name_instance);
17    xml.balise_open_end();
18
19    // Print component
20    for (std::list<Stat *>::iterator stat=_list_stat->begin();
21         stat != _list_stat->end();
22         stat ++)
23      xml.text((*stat)->print(1));
24   
25
26    // Test special case
27
28    if (have_counter())
29      {
30        if (_cycle_sum < _nb_cycle_before_begin)
31          {
32            xml.comment(_("Number of cycle is less than the number minimal"));
33          }
34        else
35          {
36            bool stop = false;
37            cycle_t nb_cycle_min;
38            cycle_t nb_cycle_max = _nb_cycle_before_begin-1;
39            for (cycle_t period=0; stop==false; period++)
40              {
41                std::map<std::string, var_t>::iterator operand=_list_operand->begin();
42               
43                if (operand->second.save_counter.size()==0)
44                  throw(ERRORMORPHEO("Stat::generate_file",_("Queue 'save_counter' is empty.")));
45               
46                bool last = operand->second.save_counter.size()==1;
47               
48                nb_cycle_min  = nb_cycle_max+1;
49               
50                if (last)
51                  nb_cycle_max = static_cast<cycle_t>(_cycle_sum);
52                else
53                  nb_cycle_max += _period;
54
55                xml.balise_open_begin("period");
56                xml.attribut("number",toString(period));
57                xml.attribut("nb_cycle_min",toString(nb_cycle_min));
58                xml.attribut("nb_cycle_max",toString(nb_cycle_max));
59                xml.balise_open_end();
60               
61                for (;
62                     operand!= _list_operand->end();
63                     ++operand)
64                  {
65                    if (operand->second.type == TYPE_COUNTER)
66                      {
67                        xml.singleton_begin(operand->second.name);
68                        xml.attribut("value",toString(operand->second.save_counter.front()));
69                        xml.attribut("unit",operand->second.unit);
70                        xml.attribut("description",operand->second.description);
71                        xml.singleton_end();
72                      }
73                    operand->second.save_counter.pop_front();
74                  }
75               
76                xml.balise_close();
77               
78                stop = last;
79              }
80          }
81      }
82    xml.balise_close();
83
84    return xml.get_body(depth);
85  }
86}; 
87};
88#endif
Note: See TracBrowser for help on using the repository browser.