1 | #ifdef VHDL |
---|
2 | /* |
---|
3 | * $Id: Component_vhdl_instance.cpp 95 2008-12-16 16:24:26Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/include/Component.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | |
---|
14 | #undef FUNCTION |
---|
15 | #define FUNCTION "Component::vhdl_instance" |
---|
16 | void Component::vhdl_instance (Vhdl * & vhdl) |
---|
17 | { |
---|
18 | log_printf(FUNC,Behavioural,FUNCTION,"Begin"); |
---|
19 | |
---|
20 | uint32_t cpt = 0; |
---|
21 | std::map<Signal *,std::string> tab; |
---|
22 | |
---|
23 | // buffer all output |
---|
24 | |
---|
25 | { |
---|
26 | // for each interface |
---|
27 | std::list<Interface_fifo *> * list_interface = (_entity)->get_interfaces_list()->get_interface_list(); |
---|
28 | std::list<Interface_fifo *>::iterator j = list_interface->begin(); |
---|
29 | bool print_comment = false; |
---|
30 | if (not list_interface->empty()) |
---|
31 | { |
---|
32 | while (j != list_interface->end()) |
---|
33 | { |
---|
34 | // for each signal |
---|
35 | std::list<Signal *> * list_signal = (*j)->get_signal_list(); |
---|
36 | std::list<Signal *>::iterator k = list_signal->begin(); |
---|
37 | if (not list_signal->empty()) |
---|
38 | { |
---|
39 | while (k != list_signal->end()) |
---|
40 | { |
---|
41 | Signal * signal = (*k); |
---|
42 | |
---|
43 | // test if is connect with external interface or with an another component AND if this port is mapped. |
---|
44 | if ( (signal->get_direction() == OUT) and |
---|
45 | (signal->get_connect_from_signal () != NULL) ) |
---|
46 | { |
---|
47 | if (not print_comment) |
---|
48 | { |
---|
49 | vhdl->set_body ("------------------------------------------------------"); |
---|
50 | vhdl->set_body ("-- Output's Buffer"); |
---|
51 | vhdl->set_body ("------------------------------------------------------"); |
---|
52 | |
---|
53 | print_comment = true; |
---|
54 | } |
---|
55 | |
---|
56 | // Create name |
---|
57 | std::string signal_name = "signal_"+toString(cpt++); |
---|
58 | |
---|
59 | tab [signal ] = signal_name; |
---|
60 | tab [signal->get_connect_from_signal()] = signal_name; |
---|
61 | |
---|
62 | // Add a new signal and the affectation |
---|
63 | vhdl->set_signal (signal_name, signal->get_size()); |
---|
64 | vhdl->set_body (signal->get_name()+" <= "+signal_name+";"); |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | tab [signal ] = signal->get_name(); |
---|
69 | } |
---|
70 | ++k; |
---|
71 | } |
---|
72 | } |
---|
73 | ++j; |
---|
74 | } |
---|
75 | |
---|
76 | if (print_comment) |
---|
77 | { |
---|
78 | vhdl->set_body (""); |
---|
79 | vhdl->set_body ("------------------------------------------------------"); |
---|
80 | vhdl->set_body (""); |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | vhdl->set_library_work (_entity->get_name() + "_Pack"); |
---|
86 | |
---|
87 | // for each entity |
---|
88 | std::list<Tcomponent_t *> * list_component = _list_component; |
---|
89 | std::list<Tcomponent_t *>::iterator i = list_component->begin(); |
---|
90 | if (not list_component->empty()) |
---|
91 | { |
---|
92 | while (i != list_component->end()) |
---|
93 | { |
---|
94 | Entity * entity = (*i)->_entity; |
---|
95 | Tinstance_t instance = (*i)->_instance; |
---|
96 | |
---|
97 | if (instance & INSTANCE_LIBRARY) |
---|
98 | vhdl->set_library_work (entity->get_name() + "_Pack"); |
---|
99 | |
---|
100 | if (instance & INSTANCE_COMPONENT) |
---|
101 | { |
---|
102 | std::list<std::string> list_port_map; |
---|
103 | |
---|
104 | // for each interface |
---|
105 | std::list<Interface_fifo *> * list_interface = entity->get_interfaces_list()->get_interface_list(); |
---|
106 | std::list<Interface_fifo *>::iterator j = list_interface->begin(); |
---|
107 | if (not list_interface->empty()) |
---|
108 | { |
---|
109 | while (j != list_interface->end()) |
---|
110 | { |
---|
111 | // for each signal |
---|
112 | std::list<Signal *> * list_signal = (*j)->get_signal_list(); |
---|
113 | std::list<Signal *>::iterator k = list_signal->begin(); |
---|
114 | if (not list_signal->empty()) |
---|
115 | { |
---|
116 | while (k != list_signal->end()) |
---|
117 | { |
---|
118 | // test if is connect with external interface or with an another component. |
---|
119 | Signal * signal_src = (*k); |
---|
120 | |
---|
121 | if (signal_src->presence_vhdl () == true) |
---|
122 | { |
---|
123 | Signal * signal_dest = signal_src->get_connect_to_signal(); |
---|
124 | std::string name_src = signal_src->get_name(); |
---|
125 | std::string name_dest; |
---|
126 | |
---|
127 | // // Test if destination signal is a interface port ? |
---|
128 | // if (_entity->find_signal(signal_dest) == false) |
---|
129 | // { |
---|
130 | // find if signal is already link |
---|
131 | std::map<Signal *,std::string>::iterator it = tab.find(signal_dest); |
---|
132 | if (tab.find(signal_dest) == tab.end()) |
---|
133 | { |
---|
134 | // Create name |
---|
135 | name_dest = "signal_"+toString(cpt++); |
---|
136 | |
---|
137 | tab [signal_src ] = name_dest; |
---|
138 | tab [signal_dest] = name_dest; |
---|
139 | |
---|
140 | // Add a new signal |
---|
141 | vhdl->set_signal (name_dest, signal_src->get_size()); |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | // find !!!! |
---|
146 | name_dest = (*it).second; |
---|
147 | tab [signal_src ] = name_dest; |
---|
148 | } |
---|
149 | // } |
---|
150 | // else |
---|
151 | // { |
---|
152 | // // Test if output |
---|
153 | // if (signal_dest->get_direction() == OUT) |
---|
154 | // { |
---|
155 | // // Take buffer's signal |
---|
156 | // map<Signal *,std::string>::iterator it = tab.find(signal_dest); |
---|
157 | // name_dest = (*it).second; |
---|
158 | |
---|
159 | // cout << " * OUT - name : " << name_dest << endl; |
---|
160 | // } |
---|
161 | // else |
---|
162 | // { |
---|
163 | // name_dest = signal_dest->get_name(); |
---|
164 | // cout << " * IN - name : " << name_dest << endl; |
---|
165 | // } |
---|
166 | // } |
---|
167 | |
---|
168 | vhdl->set_body_component_port_map (list_port_map, |
---|
169 | name_src , signal_src ->get_size(), |
---|
170 | name_dest, signal_dest->get_size() ); |
---|
171 | } |
---|
172 | ++k; |
---|
173 | } |
---|
174 | } |
---|
175 | ++j; |
---|
176 | } |
---|
177 | } |
---|
178 | vhdl->set_body_component ("instance_"+entity->get_name(),entity->get_name(),list_port_map); |
---|
179 | |
---|
180 | } |
---|
181 | ++i; |
---|
182 | } |
---|
183 | } |
---|
184 | log_printf(FUNC,Behavioural,FUNCTION,"End"); |
---|
185 | }; |
---|
186 | |
---|
187 | }; // end namespace behavioural |
---|
188 | }; // end namespace morpheo |
---|
189 | #endif |
---|