1 | #ifdef VHDL |
---|
2 | /* |
---|
3 | * $Id: Queue_vhdl_body.cpp 103 2009-01-16 16:55:32Z moulu $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Generic/Queue/include/Queue.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace generic { |
---|
14 | namespace queue { |
---|
15 | |
---|
16 | |
---|
17 | #undef FUNCTION |
---|
18 | #define FUNCTION "Queue::vhdl_body" |
---|
19 | void Queue::vhdl_body (Vhdl * & vhdl) |
---|
20 | { |
---|
21 | log_printf(FUNC,Queue,FUNCTION,"Begin"); |
---|
22 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
23 | vhdl->set_comment(0," Output"); |
---|
24 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
25 | vhdl->set_body (0,"out_INSERT_ACK <= not signal_FULL;"); |
---|
26 | vhdl->set_body (0,"out_RETIRE_VAL <= not signal_EMPTY;"); |
---|
27 | |
---|
28 | if (_param->_size_queue > 1) |
---|
29 | vhdl->set_body (0,"out_RETIRE_DATA <= reg_DATA(conv_integer(signal_PTR_READ));"); |
---|
30 | else |
---|
31 | vhdl->set_body (0,"out_RETIRE_DATA <= reg_DATA(0);"); |
---|
32 | |
---|
33 | vhdl->set_body (0,""); |
---|
34 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
35 | vhdl->set_comment(0," Slot"); |
---|
36 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
37 | vhdl->set_body (0,""); |
---|
38 | if (_param->_nb_port_slot > 1) |
---|
39 | for (uint32_t i=0; i<_param->_nb_port_slot; ++i) |
---|
40 | if (i==0) |
---|
41 | vhdl->set_body (0,"signal_SLOT_0 <= signal_PTR_READ;"); |
---|
42 | else |
---|
43 | { |
---|
44 | if (is_power2(_param->_size_queue)) |
---|
45 | vhdl->set_body (0,"signal_SLOT_"+toString(i)+" <= signal_PTR_READ+"+std_logic_cst(log2(_param->_size_queue),i)+";"); |
---|
46 | else |
---|
47 | vhdl->set_body (0,"signal_SLOT_"+toString(i)+" <= const_PTR_INIT when signal_SLOT_"+toString(i-1)+" = const_PTR_MAX else signal_SLOT_"+toString(i-1)+"+'1';"); |
---|
48 | |
---|
49 | } |
---|
50 | |
---|
51 | for (uint32_t i=0; i<_param->_nb_port_slot; ++i) |
---|
52 | { |
---|
53 | if (_param->_nb_port_slot > 1) |
---|
54 | vhdl->set_body (0,"signal_SLOT_"+toString(i)+"_VAL <= '1' when reg_NB_ELT > "+std_logic_cst(log2(_param->_size_queue+1),i)+" else '0';"); |
---|
55 | else |
---|
56 | vhdl->set_body (0,"signal_SLOT_"+toString(i)+"_VAL <= not signal_EMPTY;"); |
---|
57 | |
---|
58 | vhdl->set_body (0,"out_SLOT_"+toString(i)+"_VAL <= signal_SLOT_"+toString(i)+"_VAL;"); |
---|
59 | |
---|
60 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
61 | std::string str_val_disable=std_logic_cst(_param->_size_data,0)+" when signal_SLOT_"+toString(i)+"_VAL='0' else"; |
---|
62 | #endif |
---|
63 | if (_param->_nb_port_slot > 1) |
---|
64 | { |
---|
65 | vhdl->set_body (0,"out_SLOT_"+toString(i)+"_DATA <= "); |
---|
66 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
67 | vhdl->set_body (1,str_val_disable); |
---|
68 | #endif |
---|
69 | vhdl->set_body (1,"reg_DATA(conv_integer(signal_SLOT_"+toString(i)+"));"); |
---|
70 | } |
---|
71 | else |
---|
72 | if (_param->_size_queue > 1) |
---|
73 | { |
---|
74 | vhdl->set_body (0,"out_SLOT_"+toString(i)+"_DATA <="); |
---|
75 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
76 | vhdl->set_body (1,str_val_disable); |
---|
77 | #endif |
---|
78 | vhdl->set_body (1,"reg_DATA(conv_integer(signal_PTR_READ));"); |
---|
79 | } |
---|
80 | else |
---|
81 | { |
---|
82 | vhdl->set_body (0,"out_SLOT_"+toString(i)+"_DATA <="); |
---|
83 | #ifdef SYSTEMC_VHDL_COMPATIBILITY |
---|
84 | vhdl->set_body (1,str_val_disable); |
---|
85 | #endif |
---|
86 | vhdl->set_body (1,"reg_DATA(conv_integer(0));"); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | if (_param->_have_port_ptr) |
---|
91 | { |
---|
92 | vhdl->set_body (0,""); |
---|
93 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
94 | vhdl->set_comment(0," Slot"); |
---|
95 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
96 | vhdl->set_body (0,""); |
---|
97 | if (_param->_have_port_ptr_write) |
---|
98 | vhdl->set_body (0,"out_PTR_WRITE <= signal_PTR_WRITE;"); |
---|
99 | if (_param->_have_port_ptr_read) |
---|
100 | vhdl->set_body (0,"out_PTR_READ <= signal_PTR_READ;"); |
---|
101 | } |
---|
102 | |
---|
103 | vhdl->set_body (0,""); |
---|
104 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
105 | vhdl->set_comment(0," Signal"); |
---|
106 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
107 | vhdl->set_body (0,""); |
---|
108 | vhdl->set_body (0,"signal_READ <= (not signal_EMPTY) and in_RETIRE_ACK;"); |
---|
109 | vhdl->set_body (0,"signal_WRITE <= (not signal_FULL ) and in_INSERT_VAL;"); |
---|
110 | vhdl->set_body (0,""); |
---|
111 | if (_param->_nb_port_slot>1) |
---|
112 | { |
---|
113 | vhdl->set_body (0,"signal_EMPTY <= '1' when reg_NB_ELT = "+std_logic_cst(log2(_param->_size_queue+1),0)+" else '0';"); |
---|
114 | if (is_power2(_param->_size_queue)) |
---|
115 | vhdl->set_body (0,"signal_FULL <= reg_NB_ELT "+std_logic_range(log2(_param->_size_queue),log2(_param->_size_queue))+";"); |
---|
116 | else |
---|
117 | vhdl->set_body (0,"signal_FULL <= '1' when reg_NB_ELT = "+std_logic_cst(log2(_param->_size_queue+1),_param->_size_queue)+" else '0';"); |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | vhdl->set_body (0,"signal_EMPTY <= reg_EMPTY;"); |
---|
122 | vhdl->set_body (0,"signal_FULL <= reg_FULL ;"); |
---|
123 | } |
---|
124 | vhdl->set_body (0,""); |
---|
125 | if (_param->_size_queue > 1) |
---|
126 | { |
---|
127 | vhdl->set_body (0,"signal_PTR_READ <= reg_PTR_READ;"); |
---|
128 | if (_param->_nb_port_slot>1) |
---|
129 | { |
---|
130 | if (is_power2(_param->_size_queue)) |
---|
131 | vhdl->set_body (0,"signal_PTR_WRITE <= reg_PTR_READ + reg_NB_ELT"+std_logic_range(log2(_param->_size_queue))+";"); |
---|
132 | else |
---|
133 | vhdl->set_body (0,"signal_PTR_WRITE <= reg_PTR_READ + reg_NB_ELT"+std_logic_range(log2(_param->_size_queue))+" when reg_PTR_READ + reg_NB_ELT"+std_logic_range(log2(_param->_size_queue)) +" <= const_PTR_MAX else reg_PTR_READ + reg_NB_ELT"+std_logic_range(log2(_param->_size_queue))+" - const_PTR_MAX-'1';"); |
---|
134 | } |
---|
135 | else |
---|
136 | vhdl->set_body (0,"signal_PTR_WRITE <= reg_PTR_WRITE;"); |
---|
137 | } |
---|
138 | vhdl->set_body (0,""); |
---|
139 | |
---|
140 | if (_param->_nb_port_slot>1) |
---|
141 | { |
---|
142 | vhdl->set_body (0,""); |
---|
143 | vhdl->set_comment(0," nb_elt"); |
---|
144 | if (_param->_size_queue > 1) |
---|
145 | { |
---|
146 | vhdl->set_body (0,"signal_NEXT_NB_ELT <= "); |
---|
147 | vhdl->set_body (1,"reg_NB_ELT when (signal_READ xor signal_WRITE) = '0' else"); |
---|
148 | if (_param->_size_queue > 2) |
---|
149 | { |
---|
150 | vhdl->set_body (1,"reg_NB_ELT +'1' when signal_WRITE='1' else"); |
---|
151 | vhdl->set_body (1,"reg_NB_ELT -'1';"); |
---|
152 | } |
---|
153 | else |
---|
154 | vhdl->set_body (1,"not reg_NB_ELT;"); |
---|
155 | } |
---|
156 | } |
---|
157 | else |
---|
158 | { |
---|
159 | vhdl->set_body (0,"signal_PTR_EQUAL <="); |
---|
160 | if (_param->_size_queue > 1) |
---|
161 | { |
---|
162 | vhdl->set_body (1,"'1' when signal_NEXT_PTR_READ = signal_NEXT_PTR_WRITE else"); |
---|
163 | vhdl->set_body (1,"'0';"); |
---|
164 | } |
---|
165 | else |
---|
166 | vhdl->set_body (1,"'1';"); |
---|
167 | vhdl->set_body (0,"signal_NEXT_FULL <="); |
---|
168 | vhdl->set_body (1,"'1' when signal_WRITE='1' and signal_PTR_EQUAL='1' else"); |
---|
169 | vhdl->set_body (1,"'0' when signal_READ ='1' else"); |
---|
170 | vhdl->set_body (1,"reg_FULL ;"); |
---|
171 | vhdl->set_body (0,"signal_NEXT_EMPTY <="); |
---|
172 | vhdl->set_body (1,"'1' when signal_READ ='1' and signal_PTR_EQUAL='1' else"); |
---|
173 | vhdl->set_body (1,"'0' when signal_WRITE='1' else"); |
---|
174 | vhdl->set_body (1,"reg_EMPTY;"); |
---|
175 | vhdl->set_body (0,""); |
---|
176 | |
---|
177 | vhdl->set_comment(0," write"); |
---|
178 | if (_param->_size_queue > 1) |
---|
179 | { |
---|
180 | vhdl->set_body (0,"signal_NEXT_PTR_WRITE <= "); |
---|
181 | vhdl->set_body (1,"reg_PTR_WRITE when signal_WRITE='0' else"); |
---|
182 | if (is_log2(_param->_size_queue) == false) |
---|
183 | vhdl->set_body (1,"const_PTR_INIT when reg_PTR_WRITE = const_PTR_MAX else"); |
---|
184 | if (_param->_size_queue > 2) |
---|
185 | vhdl->set_body (1,"reg_PTR_WRITE+'1';"); |
---|
186 | else |
---|
187 | vhdl->set_body (1,"not reg_PTR_WRITE;"); |
---|
188 | } |
---|
189 | } |
---|
190 | |
---|
191 | vhdl->set_body (0,""); |
---|
192 | vhdl->set_comment(0," read"); |
---|
193 | if (_param->_size_queue > 1) |
---|
194 | { |
---|
195 | vhdl->set_body (0,"signal_NEXT_PTR_READ <= "); |
---|
196 | vhdl->set_body (1,"reg_PTR_READ when signal_READ='0' else"); |
---|
197 | if (is_log2(_param->_size_queue) == false) |
---|
198 | vhdl->set_body (1,"const_PTR_INIT when reg_PTR_READ = const_PTR_MAX else"); |
---|
199 | |
---|
200 | if (_param->_size_queue > 2) |
---|
201 | vhdl->set_body (1,"reg_PTR_READ +'1';"); |
---|
202 | else |
---|
203 | vhdl->set_body (1,"not reg_PTR_READ;"); |
---|
204 | } |
---|
205 | vhdl->set_body (0,""); |
---|
206 | |
---|
207 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
208 | vhdl->set_comment(0," Registers"); |
---|
209 | vhdl->set_comment(0,"---------------------------------------------------------------------------"); |
---|
210 | vhdl->set_body (0,""); |
---|
211 | vhdl->set_body (0,"queue_write: process (in_CLOCK)"); |
---|
212 | vhdl->set_body (0,"begin -- process queue_write"); |
---|
213 | vhdl->set_body (1,"if in_CLOCK'event and in_CLOCK = '1' then"); |
---|
214 | vhdl->set_body (0,""); |
---|
215 | vhdl->set_body (2,"if (in_NRESET = '0') then"); |
---|
216 | if (_param->_size_queue > 1) |
---|
217 | { |
---|
218 | vhdl->set_body (3,"reg_PTR_READ <= const_PTR_INIT;"); |
---|
219 | if (_param->_nb_port_slot>1) |
---|
220 | vhdl->set_body (3,"reg_NB_ELT <= "+std_logic_cst(log2(_param->_size_queue+1),0)+";"); |
---|
221 | else |
---|
222 | vhdl->set_body (3,"reg_PTR_WRITE <= const_PTR_INIT;"); |
---|
223 | } |
---|
224 | if (_param->_nb_port_slot<=1) |
---|
225 | { |
---|
226 | vhdl->set_body (3,"reg_FULL <= '0';"); |
---|
227 | vhdl->set_body (3,"reg_EMPTY <= '1';"); |
---|
228 | } |
---|
229 | vhdl->set_body (2,"else"); |
---|
230 | if (_param->_size_queue > 1) |
---|
231 | { |
---|
232 | vhdl->set_body (3,"reg_PTR_READ <= signal_NEXT_PTR_READ ;"); |
---|
233 | if (_param->_nb_port_slot>1) |
---|
234 | vhdl->set_body (3,"reg_NB_ELT <= signal_NEXT_NB_ELT ;"); |
---|
235 | else |
---|
236 | vhdl->set_body (3,"reg_PTR_WRITE <= signal_NEXT_PTR_WRITE;"); |
---|
237 | } |
---|
238 | if (_param->_nb_port_slot<=1) |
---|
239 | { |
---|
240 | vhdl->set_body (3,"reg_FULL <= signal_NEXT_FULL ;"); |
---|
241 | vhdl->set_body (3,"reg_EMPTY <= signal_NEXT_EMPTY;"); |
---|
242 | } |
---|
243 | vhdl->set_body (0,""); |
---|
244 | vhdl->set_body (3,"if (signal_WRITE = '1') then"); |
---|
245 | if (_param->_size_queue > 1) |
---|
246 | vhdl->set_body (3,"\treg_DATA(conv_integer(signal_PTR_WRITE)) <= in_INSERT_DATA;"); |
---|
247 | else |
---|
248 | vhdl->set_body (3,"\treg_DATA(0) <= in_INSERT_DATA;"); |
---|
249 | vhdl->set_body (3,"end if;"); |
---|
250 | vhdl->set_body (2,"end if;"); |
---|
251 | vhdl->set_body (0,""); |
---|
252 | vhdl->set_body (1,"end if;"); |
---|
253 | vhdl->set_body (0,"end process queue_write;"); |
---|
254 | |
---|
255 | log_printf(FUNC,Queue,FUNCTION,"End"); |
---|
256 | }; |
---|
257 | |
---|
258 | }; // end namespace queue |
---|
259 | }; // end namespace generic |
---|
260 | |
---|
261 | }; // end namespace behavioural |
---|
262 | }; // end namespace morpheo |
---|
263 | #endif |
---|