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

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

1) Add Vhdl component
2) Inhib VHDL Seltest interface

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