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

Last change on this file since 88 was 88, checked in by rosiere, 15 years ago

Almost complete design
with Test and test platform

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