source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Model.h @ 131

Last change on this file since 131 was 131, checked in by rosiere, 15 years ago

1) add constant method
2) test with systemc 2.2.0

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef morpheo_behavioural_Model_h
2#define morpheo_behavioural_Model_h
3
4/*
5 * $Id: Model.h 131 2009-07-08 18:40:08Z rosiere $
6 *
7 * [ Description ]
8 *
9 */
10
11#include "Common/include/ToString.h"
12#include "Common/include/FromString.h"
13#include "Common/include/ErrorMorpheo.h"
14#include <map>
15
16namespace morpheo              {
17namespace behavioural          {
18
19  typedef enum
20    {
21      MODEL_SYSTEMC,
22      MODEL_VHDL
23    } model_type_t;
24
25  typedef struct
26  {
27    model_type_t type ;
28    bool         debug;
29  } model_t;
30   
31  class Model
32  {
33  private : model_type_t default_type ;
34  private : bool         default_debug;
35
36  private : std::map<std::string,model_t> models;
37
38  public  :               Model (void);
39  public  :              ~Model (void);
40  public  : void         set_model (                       model_type_t type, bool debug);
41  public  : void         set_model (std::string component, model_type_t type, bool debug);
42  public  : model_type_t get_type  (std::string component);
43  public  : bool         get_debug (std::string component);
44  public  : void         print     (void);
45  };
46 
47}; // end namespace behavioural         
48
49  template<> inline std::string toString<morpheo::behavioural::model_type_t>(const morpheo::behavioural::model_type_t& x)
50  {
51    switch (x)
52      {
53      case morpheo::behavioural::MODEL_SYSTEMC : return "systemc" ; break;
54      case morpheo::behavioural::MODEL_VHDL    : return "vhdl"    ; break;
55      default : return ""; break;
56      }
57  };
58
59  template<> inline morpheo::behavioural::model_type_t fromString<morpheo::behavioural::model_type_t>(const std::string& x)
60  {
61    if ( (x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::MODEL_SYSTEMC))) == 0) or
62         (x.compare("model_systemc") == 0) or
63         (x.compare("systemc") == 0)
64         )
65      return morpheo::behavioural::MODEL_SYSTEMC;
66    if ( (x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::MODEL_VHDL))) == 0) or
67         (x.compare("model_vhdl") == 0) or
68         (x.compare("vhdl") == 0))
69      return morpheo::behavioural::MODEL_VHDL;
70    throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"\n"));
71  };
72
73}; // end namespace morpheo             
74
75#endif
76
Note: See TracBrowser for help on using the repository browser.