1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Simulation.cpp 138 2010-05-12 17:34:01Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/include/Simulation.h" |
---|
10 | #include "Common/include/ErrorMorpheo.h" |
---|
11 | |
---|
12 | namespace morpheo { |
---|
13 | namespace behavioural { |
---|
14 | |
---|
15 | static bool simulation_initialized; |
---|
16 | bool _simulation_stop_exception; |
---|
17 | double _simulation_nb_cycle; |
---|
18 | double _simulation_nb_instruction; |
---|
19 | std::vector<double> _simulation_nb_instruction_commited; |
---|
20 | stop_type_t _simulation_stop_type; |
---|
21 | bool _simulation_file_with_date; |
---|
22 | bool _simulation_file_with_pid ; |
---|
23 | |
---|
24 | Model _model; |
---|
25 | |
---|
26 | void simulation_init (double nb_cycle, |
---|
27 | double debug_nb_cycle, |
---|
28 | double nb_instruction, |
---|
29 | stop_type_t stop_type, |
---|
30 | bool file_with_date, |
---|
31 | bool file_with_pid ) |
---|
32 | { |
---|
33 | if (not simulation_initialized) |
---|
34 | { |
---|
35 | if (debug_nb_cycle == 0) |
---|
36 | { |
---|
37 | _simulation_nb_cycle = nb_cycle; |
---|
38 | _simulation_stop_exception = false; |
---|
39 | } |
---|
40 | else |
---|
41 | { |
---|
42 | _simulation_nb_cycle = (debug_nb_cycle<nb_cycle)?debug_nb_cycle:nb_cycle; |
---|
43 | _simulation_stop_exception = (debug_nb_cycle<nb_cycle); |
---|
44 | } |
---|
45 | |
---|
46 | _simulation_nb_instruction = nb_instruction; |
---|
47 | // _simulation_nb_instruction_commited = new std::vector<double>; |
---|
48 | _simulation_stop_type = stop_type; |
---|
49 | _simulation_file_with_date = file_with_date; |
---|
50 | _simulation_file_with_pid = file_with_pid ; |
---|
51 | |
---|
52 | simulation_initialized = true; |
---|
53 | } |
---|
54 | else |
---|
55 | { |
---|
56 | msg_printf(WARNING,_("Multi instance of Morpheo : stop condition, take the highest.")); |
---|
57 | |
---|
58 | if (//(_simulation_nb_cycle == 0) or |
---|
59 | (_simulation_nb_cycle < debug_nb_cycle)) |
---|
60 | { |
---|
61 | _simulation_nb_cycle = debug_nb_cycle; |
---|
62 | _simulation_stop_exception = true; |
---|
63 | } |
---|
64 | |
---|
65 | if (//(_simulation_nb_cycle == 0) or |
---|
66 | (_simulation_nb_cycle < nb_cycle)) |
---|
67 | { |
---|
68 | _simulation_nb_cycle = nb_cycle; |
---|
69 | _simulation_stop_exception = false; |
---|
70 | } |
---|
71 | |
---|
72 | if (//(_simulation_nb_instruction == 0) or |
---|
73 | (_simulation_nb_instruction < nb_instruction)) |
---|
74 | _simulation_nb_instruction = nb_instruction; |
---|
75 | |
---|
76 | _simulation_file_with_date |= file_with_date; |
---|
77 | _simulation_file_with_pid |= file_with_pid ; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | }; // end namespace behavioural |
---|
82 | }; // end namespace morpheo |
---|
83 | |
---|
84 | #endif |
---|