[2] | 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 | * |
---|
[113] | 9 | * [ Description ] |
---|
[2] | 10 | * |
---|
| 11 | */ |
---|
| 12 | |
---|
| 13 | #include <stdint.h> |
---|
| 14 | #include <iostream> |
---|
| 15 | #include <list> |
---|
[113] | 16 | #include <map> |
---|
[88] | 17 | #include "Common/include/Environment.h" |
---|
[25] | 18 | #include "Behavioural/include/Direction.h" |
---|
[44] | 19 | #include "Common/include/ToString.h" |
---|
| 20 | #include "Common/include/Debug.h" |
---|
[65] | 21 | #include "Common/include/ErrorMorpheo.h" |
---|
[2] | 22 | |
---|
| 23 | namespace morpheo { |
---|
[71] | 24 | namespace behavioural { |
---|
[2] | 25 | |
---|
[113] | 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 | |
---|
[98] | 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); |
---|
[2] | 47 | |
---|
[71] | 48 | class Vhdl |
---|
| 49 | { |
---|
[113] | 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; |
---|
[2] | 58 | |
---|
[113] | 59 | // -----[ fields ]---------------------------------------------------- |
---|
| 60 | private : const std::string _name; |
---|
| 61 | private : const std::string _id; |
---|
[2] | 62 | |
---|
[113] | 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=""); |
---|
[71] | 75 | public : ~Vhdl (); |
---|
[2] | 76 | |
---|
[71] | 77 | public : void generate_file (void); |
---|
| 78 | public : void generate_file (bool generate_package, |
---|
| 79 | bool generate_model ); |
---|
[2] | 80 | |
---|
[71] | 81 | private : void generate_file_package (void); |
---|
| 82 | private : void generate_file_model (void); |
---|
[88] | 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 , |
---|
[113] | 90 | std::string entity_name ); |
---|
[88] | 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 ); |
---|
[113] | 95 | private : void test_architecture (void); |
---|
| 96 | private : std::string test_architecture (std::string name ); |
---|
| 97 | public : std::string set_architecture (std::string name ); |
---|
[88] | 98 | private : std::string get_architecture (uint32_t depth , |
---|
| 99 | std::string entity_name ); |
---|
[113] | 100 | private : std::string get_configuration (uint32_t depth , |
---|
| 101 | std::string entity_name , |
---|
| 102 | std::string configuration_name ); |
---|
[88] | 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 , |
---|
[71] | 108 | direction_t direction , |
---|
[88] | 109 | std::string type ); |
---|
| 110 | public : void set_port (std::string name , |
---|
[71] | 111 | direction_t direction , |
---|
| 112 | uint32_t size ); |
---|
[113] | 113 | // public : void set_port_clock (std::string name ); |
---|
[88] | 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 , |
---|
[93] | 118 | uint32_t size ); |
---|
[88] | 119 | public : void set_signal (std::string name , |
---|
| 120 | std::string type , |
---|
| 121 | std::string init ); |
---|
| 122 | public : void set_signal (std::string name , |
---|
[71] | 123 | uint32_t size , |
---|
[88] | 124 | std::string init ); |
---|
| 125 | public : void set_signal (std::string name , |
---|
[71] | 126 | uint32_t size , |
---|
| 127 | uint32_t init ); |
---|
[88] | 128 | public : void set_constant (std::string name , |
---|
| 129 | std::string type , |
---|
| 130 | std::string init ); |
---|
| 131 | public : void set_constant (std::string name , |
---|
[71] | 132 | uint32_t size , |
---|
[88] | 133 | std::string init ); |
---|
| 134 | public : void set_constant (std::string name , |
---|
[71] | 135 | uint32_t size , |
---|
| 136 | uint32_t init ); |
---|
[2] | 137 | |
---|
[88] | 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 , |
---|
[71] | 147 | uint32_t size1 , |
---|
[88] | 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 ); |
---|
[2] | 157 | |
---|
[88] | 158 | private : std::string get_body (uint32_t depth ); |
---|
| 159 | public : void set_body (std::string text ); |
---|
[94] | 160 | public : void set_body (uint32_t depth , |
---|
| 161 | std::string text ); |
---|
| 162 | |
---|
| 163 | public : void set_body (uint32_t depth , |
---|
| 164 | Vhdl * vhdl ); |
---|
[88] | 165 | public : void set_body_component (std::string name_instance , |
---|
| 166 | std::string name_component , |
---|
[113] | 167 | std::string name_architecture , |
---|
| 168 | std::string name_package , |
---|
[88] | 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 ); |
---|
[2] | 175 | |
---|
[94] | 176 | public : void set_comment (std::string text ); |
---|
| 177 | public : void set_comment (uint32_t depth , |
---|
| 178 | std::string text ); |
---|
| 179 | |
---|
[113] | 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"); |
---|
[88] | 191 | public : void set_library_work (std::string package_name ); |
---|
[2] | 192 | |
---|
[88] | 193 | private : std::string direction_toString (direction_t direction ); |
---|
[71] | 194 | }; |
---|
| 195 | |
---|
[113] | 196 | std::string vhdl_get_id (std::string model_name); |
---|
| 197 | |
---|
[71] | 198 | }; // end namespace behavioural |
---|
[113] | 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 | |
---|
[2] | 212 | }; // end namespace morpheo |
---|
| 213 | |
---|
| 214 | #endif |
---|
| 215 | #endif |
---|