1 | #ifdef VHDL |
---|
2 | |
---|
3 | #ifndef morpheo_behavioural_Vhdl_h |
---|
4 | #define morpheo_behavioural_Vhdl_h |
---|
5 | |
---|
6 | /* |
---|
7 | * $Id$ |
---|
8 | * |
---|
9 | * [ Description ] |
---|
10 | * |
---|
11 | */ |
---|
12 | |
---|
13 | #include <stdint.h> |
---|
14 | #include <iostream> |
---|
15 | #include <list> |
---|
16 | #include "Include/ToString.h" |
---|
17 | #include "Include/Debug.h" |
---|
18 | |
---|
19 | using namespace std; |
---|
20 | |
---|
21 | namespace morpheo { |
---|
22 | namespace behavioural { |
---|
23 | |
---|
24 | typedef enum { IN, OUT, INOUT } direction_t; |
---|
25 | |
---|
26 | string std_logic (uint32_t size); |
---|
27 | string std_logic_conv (uint32_t size, string value); |
---|
28 | string std_logic_conv (uint32_t size, uint32_t value); |
---|
29 | string std_logic_range (uint32_t max , uint32_t min ); |
---|
30 | string std_logic_range (uint32_t size); |
---|
31 | string std_logic_others (uint32_t size, uint32_t cst ); |
---|
32 | |
---|
33 | class Vhdl |
---|
34 | { |
---|
35 | // -----[ fields ]---------------------------------------------------- |
---|
36 | private : const string _name ; |
---|
37 | |
---|
38 | private : list<string> _list_library_work ; |
---|
39 | private : list<string> _list_signal ; |
---|
40 | private : list<string> _list_type ; |
---|
41 | private : list<string> _list_alias ; |
---|
42 | private : list<string> _list_port ; |
---|
43 | private : list<string> _list_body ; |
---|
44 | |
---|
45 | // -----[ methods ]--------------------------------------------------- |
---|
46 | public : Vhdl (string name); |
---|
47 | public : virtual ~Vhdl (); |
---|
48 | |
---|
49 | public : void generate_file (void); |
---|
50 | public : void generate_file (bool generate_package, |
---|
51 | bool generate_model ); |
---|
52 | |
---|
53 | private : void generate_file_package (void); |
---|
54 | private : void generate_file_model (void); |
---|
55 | |
---|
56 | private : string get_package (uint32_t depth , |
---|
57 | string filename , |
---|
58 | string package_name , |
---|
59 | string entity_name ); |
---|
60 | private : string get_model (uint32_t depth , |
---|
61 | string filename , |
---|
62 | string entity_name , |
---|
63 | string architecture_name ); |
---|
64 | private : string get_header (uint32_t depth , |
---|
65 | string filename ); |
---|
66 | private : string get_entity (uint32_t depth , |
---|
67 | string name ); |
---|
68 | private : string get_architecture (uint32_t depth , |
---|
69 | string name , |
---|
70 | string entity_name ); |
---|
71 | private : string get_component (uint32_t depth , |
---|
72 | string name ); |
---|
73 | |
---|
74 | private : string get_port (uint32_t depth ); |
---|
75 | public : void set_port (string name , |
---|
76 | direction_t direction , |
---|
77 | string type ); |
---|
78 | public : void set_port (string name , |
---|
79 | direction_t direction , |
---|
80 | uint32_t size ); |
---|
81 | private : string get_signal (uint32_t depth ); |
---|
82 | public : void set_signal (string name , |
---|
83 | string type ); |
---|
84 | public : void set_signal (string name , |
---|
85 | uint32_t signal ); |
---|
86 | public : void set_signal (string name , |
---|
87 | string type , |
---|
88 | string init ); |
---|
89 | public : void set_signal (string name , |
---|
90 | uint32_t size , |
---|
91 | string init ); |
---|
92 | public : void set_signal (string name , |
---|
93 | uint32_t size , |
---|
94 | uint32_t init ); |
---|
95 | public : void set_constant (string name , |
---|
96 | string type , |
---|
97 | string init ); |
---|
98 | public : void set_constant (string name , |
---|
99 | uint32_t size , |
---|
100 | string init ); |
---|
101 | public : void set_constant (string name , |
---|
102 | uint32_t size , |
---|
103 | uint32_t init ); |
---|
104 | |
---|
105 | private : string get_type (uint32_t depth ); |
---|
106 | public : void set_type (string name , |
---|
107 | string type ); |
---|
108 | private : string get_alias (uint32_t depth ); |
---|
109 | public : void set_alias (string name1 , |
---|
110 | string type1 , |
---|
111 | string name2 , |
---|
112 | string range2 ); |
---|
113 | |
---|
114 | public : string get_list (list<string> liste , |
---|
115 | uint32_t depth , |
---|
116 | string separator , |
---|
117 | bool last_separator ); |
---|
118 | public : void set_list (list<string> & liste , |
---|
119 | string text ); |
---|
120 | |
---|
121 | private : string get_body (uint32_t depth ); |
---|
122 | public : void set_body (string text ); |
---|
123 | |
---|
124 | public : void set_body_component (string name_instance , |
---|
125 | string name_component , |
---|
126 | list<string> list_port_map ); |
---|
127 | public : void set_body_component_port_map (list<string> & list_port_map , |
---|
128 | string name_port , |
---|
129 | string name_signal ); |
---|
130 | |
---|
131 | private : string get_library_ieee (uint32_t depth ); |
---|
132 | private : string get_library_work (uint32_t depth ); |
---|
133 | public : void set_library_work (string package_name ); |
---|
134 | |
---|
135 | private : string direction_toString (direction_t direction); |
---|
136 | }; |
---|
137 | |
---|
138 | }; // end namespace behavioural |
---|
139 | }; // end namespace morpheo |
---|
140 | |
---|
141 | #endif |
---|
142 | #endif |
---|