source: trunk/IPs/systemC/processor/Morpheo/Common/src/Environment.cpp @ 97

Last change on this file since 97 was 97, checked in by rosiere, 16 years ago

1) Update Prediction Table : statistics
2) Size instruction address on 30 bits
3) Change Log File
4) Add debug_level in simulation configuration file

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/*
2 * $Id: Environment.cpp 97 2008-12-19 15:34:00Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Common/include/Environment.h"
9#include "Common/include/ErrorMorpheo.h"
10#include "Common/include/Debug.h"
11#include "Common/include/Message.h"
12#include <sys/stat.h>
13
14namespace morpheo {
15
16static bool environment_initialized;
17std::string MORPHEO_HOME;
18std::string MORPHEO_TOPLEVEL;
19
20#undef  FUNCTION
21#define FUNCTION "environment"
22void environment (void)
23{
24  if (not environment_initialized)
25    {
26      {
27        char * toplevel = getenv("MORPHEO_TOPLEVEL");
28       
29        if (toplevel == NULL)
30          throw ERRORMORPHEO(FUNCTION,_("Error morpheo environment is not positioned.\n"));
31
32        MORPHEO_TOPLEVEL = toplevel;
33      }
34
35      {
36        char * home = getenv("MORPHEO_HOME");
37       
38        if (home == NULL)
39          throw ERRORMORPHEO(FUNCTION,_("Error morpheo environment is not positioned.\n"));
40
41        MORPHEO_HOME = home;
42      }
43
44      environment_initialized = true;
45    }
46}
47
48static bool directory_initialized;
49std::string MORPHEO_STATISTICS;
50std::string MORPHEO_VHDL;
51std::string MORPHEO_POSITION;
52std::string MORPHEO_LOG;
53
54#undef  FUNCTION
55#define FUNCTION "exist_directory"
56void exist_directory (std::string dir)
57{
58//   struct stat *buf;
59//   int res = stat(dir.c_str(), buf);
60//   if ((res != 0) or not S_ISDIR(buf->st_mode))
61//     throw ERRORMORPHEO(FUNCTION,toString(_("Error in opening directory \"%s\".\n"),dir.c_str()));
62
63
64  char * pwd = getenv("PWD");
65  if (chdir(dir.c_str())!=0)
66    throw ERRORMORPHEO(FUNCTION,toString(_("Error in opening directory \"%s\".\n"),dir.c_str()));
67  chdir(pwd);
68}
69
70#undef  FUNCTION
71#define FUNCTION "directory_init"
72void directory_init (std::string morpheo_statistics,
73                     std::string morpheo_vhdl      ,
74                     std::string morpheo_position  ,
75                     std::string morpheo_log       )
76{
77  if (not directory_initialized)
78    {
79      exist_directory(morpheo_statistics);
80      exist_directory(morpheo_vhdl      );
81      exist_directory(morpheo_position  );
82      exist_directory(morpheo_log       );
83
84      MORPHEO_STATISTICS = morpheo_statistics;
85      MORPHEO_VHDL       = morpheo_vhdl      ;
86      MORPHEO_POSITION   = morpheo_position  ;
87      MORPHEO_LOG        = morpheo_log       ;
88
89      directory_initialized = true;
90    }
91//   else
92//     {
93//       msg_printf(WARNING,_("Multi instance of Morpheo : directory, keep actual directory."));
94//     }
95}
96
97#undef  FUNCTION
98#define FUNCTION "directory"
99void directory (void)
100{
101  // with default value
102  directory_init();
103};
104
105}; //end namespace morpheo
Note: See TracBrowser for help on using the repository browser.