source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Stat.h @ 139

Last change on this file since 139 was 139, checked in by rosiere, 14 years ago
  • Add test for all configuration
  • RAT : add rat scheme (depth_save)
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1#ifdef STATISTICS
2#ifndef morpheo_behavioural_Stat_h
3#define morpheo_behavioural_Stat_h
4
5#include "Behavioural/include/Parameters_Statistics.h"
6#include "Behavioural/include/Stat_type.h"
7#include "Behavioural/include/Stat_binary_tree.h"
8#include "Behavioural/include/XML.h"
9#include "Common/include/ErrorMorpheo.h"
10#include "Common/include/Message.h"
11
12#ifdef SYSTEMC
13#include "systemc.h"
14#endif
15
16#include <stdint.h>
17#include <string>
18#include <map>
19#include <list>
20#include <iostream>
21
22namespace morpheo {
23  namespace behavioural {
24
25    typedef double cycle_t;
26 
27    typedef struct 
28    {
29      counter_type_t type;
30      counter_t *    counter;
31      std::string    name;
32      std::string    unit;
33      std::string    description;
34      std::list<counter_t> save_counter;
35    } var_t;
36 
37    typedef struct 
38    {
39//    bool               each_cycle;
40      counter_t        * variable;
41      Stat_binary_tree * expression;
42    } expr_t;
43
44    class Stat
45    {
46    private: const std::string              _name_instance;
47    private: const std::string              _name_component;
48    private: const cycle_t                  _nb_cycle_before_begin;
49    private: const cycle_t                  _period;
50    private: const bool                     _save_periodic;
51    private: bool                           _generate_file;
52
53      // Tableau des variables
54    private: std::map<std::string, var_t> * _list_operand;
55      // Liste chaîné des expressions
56    private: std::list<expr_t>            * _list_expr_per_cycle;
57    private: std::list<expr_t>            * _list_expr_per_period;
58      // List chaîné des "counters" (seulement pour la désallocation)
59    private: std::list<counters_t*>       * _list_counters;
60
61    private: counter_t                    * _cycle;
62
63    private: std::list<Stat *>            * _list_stat;
64
65    public :                     Stat                         (std::string name_instance,
66                                                               std::string name_component,
67                                                               Parameters_Statistics * param);
68    public :                     Stat                         (std::string name_instance,
69                                                               std::string name_component,
70                                                               cycle_t nb_cycle_before_begin=0,
71                                                               cycle_t period=0);
72    public :                    ~Stat                         (void);
73
74    public  : counter_t *        create_variable              (std::string varname);
75    public  : counter_t *        create_counter               (std::string varname,
76                                                               std::string unit,
77                                                               std::string description);
78    public  : counters_t *       create_counters              (std::string varname,
79                                                               uint32_t    nb_counter,
80                                                               std::string unit,
81                                                               std::string description_counter, // need one %d
82                                                               std::string description_percent, // need one %d
83                                                               std::string description_average);
84    private : counter_t *        alloc_operand                (counter_type_t type,
85                                                               std::string varname,
86                                                               std::string unit,
87                                                               std::string description);
88
89    public  : void               create_expr                  (std::string varname,
90                                                               std::string expr,
91                                                               bool each_cycle=false);
92
93    public  : void               create_expr                  (std::string    varname,
94                                                               std::string    expr,
95                                                               counter_type_t type,
96                                                               std::string    unit,
97                                                               std::string    description,
98                                                               bool each_cycle=false);
99
100    public  : void               create_expr_average          (std::string varname,
101                                                               std::string expr_sum,
102                                                               std::string expr_deps,
103                                                               std::string unit,
104                                                               std::string description);
105
106    public  : void               create_expr_average_by_cycle (std::string varname,
107                                                               std::string expr_sum,
108                                                               std::string unit,
109                                                               std::string description);
110
111    public  : void               create_expr_percent          (std::string varname,
112                                                               std::string expr_sum,
113                                                               std::string expr_max,
114                                                               std::string description);
115
116    private : Stat_binary_tree * string2tree                  (std::string expr);
117
118    public  : void               end_cycle                    (void);
119    private : void               end_simulation               (void);
120
121    private : void               test_and_save                (bool force_save=false);
122    private : void               reset                        (bool save);
123
124    private : void               eval_exprs                   (bool only_each_cycle=true);
125    private : void               eval_expr                    (expr_t expr);
126
127    private : bool               is_valid_var                 (std::string expr);
128
129    private : void               generate_file                (void);
130
131    private : bool               have_counter                 (void);
132
133    public  : void               add_stat                     (Stat * stat);
134
135    public  : std::string        print                        (uint32_t depth=0);
136    };
137
138  };
139};
140#endif
141#endif
Note: See TracBrowser for help on using the repository browser.