source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Simulation_test_end.cpp

Last change on this file was 138, checked in by rosiere, 14 years ago

1) add counters_t type for interface
2) fix in check load in load_store_unit
3) add parameters (but not yet implemented)
4) change environment and add script (distcc_env.sh ...)
5) add warning if an unser change rename flag with l.mtspr instruction
6) ...

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Simulation_test_end.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/Systemc.h"
11#include "Common/include/ErrorMorpheo.h"
12
13namespace morpheo              {
14namespace behavioural          {
15
16  bool simulation_test_end (void)
17  {
18    msgInformation("##########[ cycle %.0f ]\n",static_cast<double>(simulation_cycle()));
19
20    // Test if a stop condition is activate
21    if ((_simulation_nb_cycle == 0) and
22        (_simulation_nb_instruction == 0)
23        )
24      return false;
25
26    bool end_cycle;
27    bool end_inst ;
28
29    if (_simulation_nb_cycle != 0)
30      end_cycle = (_simulation_nb_cycle <= simulation_cycle());
31    else
32      end_cycle = true;
33
34    if (_simulation_nb_instruction != 0)
35      {
36        end_inst = true;
37        std::vector<double>::iterator it=_simulation_nb_instruction_commited.begin();
38
39        switch (_simulation_stop_type)
40          {
41          case ALL_THREAD :
42            {
43              double sum_inst = 0;
44
45              // Scan all context and test if all can finish
46              while (it!=_simulation_nb_instruction_commited.end())
47                {
48                  sum_inst += *it;
49                  it ++;
50                }
51             
52              // Stop if sum of all instruction is higher of "simulation_nb_instruction"
53              end_inst &= (_simulation_nb_instruction <= sum_inst);
54
55              break;
56            }
57          case EACH_THREAD_AND_CONTINUE :
58          case EACH_THREAD_AND_STOP :
59            {
60              // Scan all context and test if all can finish
61              while (end_inst and it!=_simulation_nb_instruction_commited.end())
62                {
63
64                  // Stop if all thread have executed more that "simulation_nb_instruction" instructions.
65                  end_inst &= (_simulation_nb_instruction <= *it);
66                  it ++;
67                }
68              break;
69            }
70          }
71      }
72    else
73      end_inst = true;
74   
75    if (end_cycle and _simulation_stop_exception)
76      {
77        throw ErrorMorpheo(_("Maximal cycles Reached"));
78        return false;
79      }
80    else
81      return end_cycle and end_inst;
82  }
83
84}; // end namespace behavioural         
85}; // end namespace morpheo             
86
87#endif
Note: See TracBrowser for help on using the repository browser.