source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Vhdl.h @ 113

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

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

  • Property svn:keywords set to Id
File size: 12.3 KB
Line 
1#ifdef VHDL
2
3#ifndef morpheo_behavioural_Vhdl_h
4#define morpheo_behavioural_Vhdl_h
5
6/*
7 * $Id: Vhdl.h 113 2009-04-14 18:39:12Z rosiere $
8 *
9 * [ Description ]
10 *
11 */
12
13#include <stdint.h>
14#include <iostream>
15#include <list>
16#include <map>
17#include "Common/include/Environment.h"
18#include "Behavioural/include/Direction.h"
19#include "Common/include/ToString.h"
20#include "Common/include/Debug.h"
21#include "Common/include/ErrorMorpheo.h"
22
23namespace morpheo              {
24  namespace behavioural          {
25
26#define VHDL_EXTENSION ".vhdl"
27
28    typedef enum 
29      {
30        VHDL_SEVERITY_NOTE   ,
31        VHDL_SEVERITY_WARNING,
32        VHDL_SEVERITY_ERROR  ,
33        VHDL_SEVERITY_FAILURE
34      } vhdl_severity_t;
35   
36    std::string  std_logic        (uint32_t size);
37    std::string  std_logic_conv   (uint32_t size, std::string   value);
38    std::string  std_logic_conv   (uint32_t size, uint32_t value);
39    std::string  std_logic_cst    (uint32_t size, uint32_t value);
40    std::string  std_logic_range  (uint32_t size, uint32_t max , uint32_t min );
41    std::string  std_logic_range  (               uint32_t max , uint32_t min );
42    std::string  std_logic_range  (uint32_t size                              );
43    std::string _std_logic_range  (uint32_t size, uint32_t max , uint32_t min );
44    std::string _std_logic_range  (               uint32_t max , uint32_t min );
45    std::string _std_logic_range  (uint32_t size                              );
46    std::string  std_logic_others (uint32_t size, bool cst);
47
48    class Vhdl
49    {
50      typedef struct
51      {
52        std::list<std::string> _list_signal;
53        std::list<std::string> _list_type  ;
54        std::list<std::string> _list_alias ;
55        std::list<std::string> _list_body  ;
56        std::list<std::string> _list_debug ;
57      } vhdl_architecture_t;
58
59      // -----[ fields ]----------------------------------------------------
60    private   : const std::string                         _name;
61    private   : const std::string                         _id;
62
63    private   : std::list<std::string>                    _list_library;
64      // Entity
65//  private   : std::string                               _port_clock;
66    private   : std::list<std::string>                    _list_port;
67      // Architecture
68    public    : const std::string                         _name_architecture_default;
69    private   :       std::string                         _name_architecture;
70    private   : std::map<std::string,vhdl_architecture_t> _architecture;
71
72      // -----[ methods ]---------------------------------------------------
73    public    :                  Vhdl                        (std::string name,
74                                                              std::string id="");
75    public    :                  ~Vhdl                       ();
76
77    public    : void             generate_file               (void);
78    public    : void             generate_file               (bool generate_package,
79                                                              bool generate_model  );
80
81    private   : void             generate_file_package       (void);
82    private   : void             generate_file_model         (void);
83     
84    private   : std::string      get_package                 (uint32_t    depth                 ,
85                                                              std::string filename              ,
86                                                              std::string package_name          ,
87                                                              std::string entity_name           );
88    private   : std::string      get_model                   (uint32_t    depth                 ,
89                                                              std::string filename              ,
90                                                              std::string entity_name           );
91    private   : std::string      get_header                  (uint32_t    depth                 ,
92                                                              std::string filename              );
93    private   : std::string      get_entity                  (uint32_t    depth                 ,
94                                                              std::string name                  );
95    private   : void             test_architecture           (void);
96    private   : std::string      test_architecture           (std::string name                  );
97    public    : std::string      set_architecture            (std::string name                  );
98    private   : std::string      get_architecture            (uint32_t    depth                 , 
99                                                              std::string entity_name           );
100    private   : std::string      get_configuration           (uint32_t    depth                 ,
101                                                              std::string entity_name           ,
102                                                              std::string configuration_name    );
103    private   : std::string      get_component               (uint32_t    depth                 ,
104                                                              std::string name                  );
105     
106    private   : std::string      get_port                    (uint32_t    depth                 );
107    public    : void             set_port                    (std::string name                  ,
108                                                              direction_t direction             ,
109                                                              std::string type                  );
110    public    : void             set_port                    (std::string name                  ,
111                                                              direction_t direction             ,
112                                                              uint32_t    size                  );
113//  public    : void             set_port_clock              (std::string name                  );
114    private   : std::string      get_signal                  (uint32_t    depth                 );
115    public    : void             set_signal                  (std::string name                  ,
116                                                              std::string type                  );
117    public    : void             set_signal                  (std::string name                  ,
118                                                              uint32_t    size                  );
119    public    : void             set_signal                  (std::string name                  ,
120                                                              std::string type                  ,
121                                                              std::string init                  );
122    public    : void             set_signal                  (std::string name                  ,
123                                                              uint32_t    size                  ,
124                                                              std::string init                  );
125    public    : void             set_signal                  (std::string name                  ,
126                                                              uint32_t    size                  ,
127                                                              uint32_t    init                  );
128    public    : void             set_constant                (std::string name                  ,
129                                                              std::string type                  ,
130                                                              std::string init                  );
131    public    : void             set_constant                (std::string name                  ,
132                                                              uint32_t    size                  ,
133                                                              std::string init                  );
134    public    : void             set_constant                (std::string name                  ,
135                                                              uint32_t    size                  ,
136                                                              uint32_t    init                  );
137
138    private   : std::string      get_type                    (uint32_t    depth                 );
139    public    : void             set_type                    (std::string name                  ,
140                                                              std::string type                  );
141    private   : std::string      get_alias                   (uint32_t    depth                 );
142    public    : void             set_alias                   (std::string name1                 ,
143                                                              std::string type1                 ,
144                                                              std::string name2                 ,
145                                                              std::string range2                );
146    public    : void             set_alias                   (std::string name1                 ,
147                                                              uint32_t    size1                 ,
148                                                              std::string name2                 ,
149                                                              std::string range2                );
150     
151    public    : std::string      get_list                    (std::list<std::string> liste      ,
152                                                              uint32_t     depth                ,
153                                                              std::string  separator            ,
154                                                              bool         last_separator       );
155    public    : void             set_list                    (std::list<std::string> & liste    ,
156                                                              std::string  text                 );
157
158    private   : std::string      get_body                    (uint32_t     depth                );
159    public    : void             set_body                    (std::string  text                 );
160    public    : void             set_body                    (uint32_t     depth                ,
161                                                              std::string  text                 );
162                                                                                   
163    public    : void             set_body                    (uint32_t     depth                ,
164                                                              Vhdl *       vhdl                 );
165    public    : void             set_body_component          (std::string  name_instance        ,
166                                                              std::string  name_component       ,
167                                                              std::string  name_architecture    ,
168                                                              std::string  name_package         ,
169                                                              std::list<std::string>   list_port_map);
170    public    : void             set_body_component_port_map (std::list<std::string> & list_port_map,
171                                                              std::string  name_port            ,
172                                                              uint32_t     size_port            ,
173                                                              std::string  name_signal          ,
174                                                              uint32_t     size_signal          );
175
176    public    : void             set_comment                 (std::string  text                 );
177    public    : void             set_comment                 (uint32_t     depth                ,
178                                                              std::string  text                 );
179
180    public    : void             set_debug                   (std::string  condition            ,
181                                                              std::string  text                 ,
182                                                              vhdl_severity_t severity = VHDL_SEVERITY_NOTE);
183    private   : std::string      get_debug                   (uint32_t     depth                );
184
185    private   : std::string      get_library                 (uint32_t     depth                );
186    private   : std::string      get_library_default         (uint32_t     depth                );
187    private   : void             set_library_default         (void                              );
188    public    : void             set_library                 (std::string  library_name         ,
189                                                              std::string  package_name         ,
190                                                              std::string  declarative_unit="all");
191    public    : void             set_library_work            (std::string  package_name         );
192
193    private   : std::string      direction_toString          (direction_t  direction            );
194    };
195
196    std::string vhdl_get_id (std::string model_name);
197
198  }; // end namespace behavioural         
199
200  template<> inline std::string toString<morpheo::behavioural::vhdl_severity_t>(const morpheo::behavioural::vhdl_severity_t& x)
201  {
202    switch (x)
203      {
204      case morpheo::behavioural::VHDL_SEVERITY_NOTE    : return "note"   ; break;
205      case morpheo::behavioural::VHDL_SEVERITY_WARNING : return "warning"; break;
206      case morpheo::behavioural::VHDL_SEVERITY_ERROR   : return "error"  ; break;
207      case morpheo::behavioural::VHDL_SEVERITY_FAILURE : return "failure"; break;
208      default : return ""; break;
209      }
210  };
211
212}; // end namespace morpheo             
213
214#endif
215#endif
Note: See TracBrowser for help on using the repository browser.