[71] | 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 | |
---|
| 22 | namespace 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 | { |
---|
[88] | 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; |
---|
[71] | 51 | // Tableau des variables |
---|
[88] | 52 | private: std::map<std::string, var_t> * _list_operand; |
---|
[71] | 53 | // Liste chaîné des expressions |
---|
[88] | 54 | private: std::list<expr_t> * _list_expr; |
---|
[71] | 55 | |
---|
[88] | 56 | private: counter_t * _cycle; |
---|
[71] | 57 | |
---|
[88] | 58 | private: std::list<Stat *> * _list_stat; |
---|
[74] | 59 | |
---|
[88] | 60 | private: bool _generate_file; |
---|
[74] | 61 | |
---|
[78] | 62 | public : Stat (std::string name_instance, |
---|
| 63 | std::string name_component, |
---|
| 64 | Parameters_Statistics * param); |
---|
| 65 | public : Stat (std::string name_instance, |
---|
| 66 | std::string name_component, |
---|
| 67 | cycle_t nb_cycle_before_begin=0, |
---|
| 68 | cycle_t period=0); |
---|
| 69 | public : ~Stat (void); |
---|
[71] | 70 | |
---|
[78] | 71 | public : counter_t * create_variable (std::string varname); |
---|
| 72 | public : counter_t * create_counter (std::string varname, |
---|
| 73 | std::string unit, |
---|
| 74 | std::string description); |
---|
| 75 | private : counter_t * alloc_operand (counter_type_t type, |
---|
| 76 | std::string varname, |
---|
| 77 | std::string unit, |
---|
| 78 | std::string description); |
---|
[71] | 79 | |
---|
[78] | 80 | public : void create_expr (std::string varname, |
---|
| 81 | std::string expr, |
---|
| 82 | bool each_cycle=false); |
---|
[84] | 83 | |
---|
| 84 | public : void create_expr (std::string varname, |
---|
| 85 | std::string expr, |
---|
| 86 | counter_type_t type, |
---|
| 87 | std::string unit, |
---|
| 88 | std::string description, |
---|
| 89 | bool each_cycle=false); |
---|
| 90 | |
---|
[78] | 91 | public : void create_expr_average (std::string varname, |
---|
| 92 | std::string expr_sum, |
---|
| 93 | std::string expr_deps, |
---|
| 94 | std::string unit, |
---|
| 95 | std::string description); |
---|
[71] | 96 | |
---|
[78] | 97 | public : void create_expr_average_by_cycle (std::string varname, |
---|
| 98 | std::string expr_sum, |
---|
| 99 | std::string unit, |
---|
| 100 | std::string description); |
---|
[71] | 101 | |
---|
[78] | 102 | public : void create_expr_percent (std::string varname, |
---|
| 103 | std::string expr_sum, |
---|
| 104 | std::string expr_max, |
---|
| 105 | std::string description); |
---|
[71] | 106 | |
---|
[78] | 107 | private : Stat_binary_tree * string2tree (std::string expr); |
---|
[75] | 108 | |
---|
[78] | 109 | public : void end_cycle (void); |
---|
| 110 | private : void end_simulation (void); |
---|
[74] | 111 | |
---|
[78] | 112 | private : void test_and_save (bool force_save=false); |
---|
| 113 | |
---|
| 114 | private : void eval_exprs (bool only_each_cycle=true); |
---|
| 115 | private : void eval_expr (expr_t expr); |
---|
| 116 | |
---|
| 117 | private : bool is_valid_var (std::string expr); |
---|
| 118 | |
---|
| 119 | private : void generate_file (void); |
---|
| 120 | |
---|
| 121 | private : bool have_counter (void); |
---|
| 122 | |
---|
| 123 | public : void add_stat (Stat * stat); |
---|
| 124 | |
---|
| 125 | public : std::string print (uint32_t depth=0); |
---|
[71] | 126 | }; |
---|
| 127 | |
---|
| 128 | }; |
---|
| 129 | }; |
---|
| 130 | #endif |
---|
| 131 | #endif |
---|