source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/src/Queue_vhdl_body.cpp @ 101

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

1) Add soc test
2) fix bug (Pc management, Decod and execute, Update prediction ...)

  • Property svn:keywords set to Id
File size: 9.6 KB
Line 
1#ifdef VHDL
2/*
3 * $Id: Queue_vhdl_body.cpp 101 2009-01-15 17:19:08Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Generic/Queue/include/Queue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace generic {
14namespace 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    for (uint32_t i=0; i<_param->_nb_port_slot; ++i)
51      {
52        if (_param->_nb_port_slot > 1)
53          vhdl->set_body   (0,"out_SLOT_"+toString(i)+"_VAL        <= '1' when reg_NB_ELT > "+std_logic_cst(log2(_param->_size_queue+1),i)+" else '0';");
54        else
55          vhdl->set_body   (0,"out_SLOT_"+toString(i)+"_VAL        <= not signal_EMPTY;");
56       
57        if (_param->_nb_port_slot > 1)
58          vhdl->set_body   (0,"out_SLOT_"+toString(i)+"_DATA       <= reg_DATA(conv_integer(signal_SLOT_"+toString(i)+"));");
59        else
60          if (_param->_size_queue > 1)
61            vhdl->set_body   (0,"out_SLOT_"+toString(i)+"_DATA       <= reg_DATA(conv_integer(signal_PTR_READ));");
62          else
63            vhdl->set_body   (0,"out_SLOT_"+toString(i)+"_DATA       <= reg_DATA(conv_integer(0));");
64      }
65
66    if (_param->_have_port_ptr)
67      {
68    vhdl->set_body   (0,"");
69    vhdl->set_comment(0,"---------------------------------------------------------------------------");
70    vhdl->set_comment(0," Slot");
71    vhdl->set_comment(0,"---------------------------------------------------------------------------");
72    vhdl->set_body   (0,"");
73    if (_param->_have_port_ptr_write)
74    vhdl->set_body   (0,"out_PTR_WRITE         <= signal_PTR_WRITE;");
75    if (_param->_have_port_ptr_read)
76    vhdl->set_body   (0,"out_PTR_READ          <= signal_PTR_READ;");
77      }
78
79    vhdl->set_body   (0,"");
80    vhdl->set_comment(0,"---------------------------------------------------------------------------");
81    vhdl->set_comment(0," Signal");
82    vhdl->set_comment(0,"---------------------------------------------------------------------------");
83    vhdl->set_body   (0,"");
84    vhdl->set_body   (0,"signal_READ           <= (not signal_EMPTY) and in_RETIRE_ACK;");
85    vhdl->set_body   (0,"signal_WRITE          <= (not signal_FULL ) and in_INSERT_VAL;");
86    vhdl->set_body   (0,"");
87    if (_param->_nb_port_slot>1)
88      {
89        vhdl->set_body   (0,"signal_EMPTY          <= '1' when reg_NB_ELT = "+std_logic_cst(log2(_param->_size_queue+1),0)+" else '0';");
90    if (is_power2(_param->_size_queue))
91    vhdl->set_body   (0,"signal_FULL           <= reg_NB_ELT "+std_logic_range(log2(_param->_size_queue),log2(_param->_size_queue))+";");
92    else
93      vhdl->set_body   (0,"signal_FULL           <= '1' when reg_NB_ELT = "+std_logic_cst(log2(_param->_size_queue+1),_param->_size_queue)+" else '0';");
94      }
95    else
96      {
97    vhdl->set_body   (0,"signal_EMPTY          <= reg_EMPTY;");
98    vhdl->set_body   (0,"signal_FULL           <= reg_FULL ;");
99      }
100    vhdl->set_body   (0,"");
101    if (_param->_size_queue > 1)
102      {
103    vhdl->set_body   (0,"signal_PTR_READ       <= reg_PTR_READ;");
104    if (_param->_nb_port_slot>1)
105      {
106        if (is_power2(_param->_size_queue))
107          vhdl->set_body   (0,"signal_PTR_WRITE      <= reg_PTR_READ + reg_NB_ELT"+std_logic_range(log2(_param->_size_queue))+";");
108        else
109          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';");
110      }
111    else
112    vhdl->set_body   (0,"signal_PTR_WRITE      <= reg_PTR_WRITE;");
113      }
114    vhdl->set_body   (0,"");
115
116    if (_param->_nb_port_slot>1)
117      {
118    vhdl->set_body   (0,"");
119    vhdl->set_comment(0," nb_elt");
120    if (_param->_size_queue > 1)
121      { 
122    vhdl->set_body   (0,"signal_NEXT_NB_ELT  <= ");
123    vhdl->set_body   (1,"reg_NB_ELT   when (signal_READ xor signal_WRITE) = '0' else");
124    if (_param->_size_queue > 2)
125      {
126    vhdl->set_body   (1,"reg_NB_ELT +'1' when signal_WRITE='1' else");
127    vhdl->set_body   (1,"reg_NB_ELT -'1';");
128      }
129    else
130    vhdl->set_body   (1,"not reg_NB_ELT;");
131      }
132      }
133    else
134      {
135    vhdl->set_body   (0,"signal_PTR_EQUAL      <=");
136    if (_param->_size_queue > 1)
137      {
138    vhdl->set_body   (1,"'1' when signal_NEXT_PTR_READ = signal_NEXT_PTR_WRITE else");
139    vhdl->set_body   (1,"'0';");
140      }
141    else
142    vhdl->set_body   (1,"'1';");
143    vhdl->set_body   (0,"signal_NEXT_FULL      <=");
144    vhdl->set_body   (1,"'1' when signal_WRITE='1' and signal_PTR_EQUAL='1' else");
145    vhdl->set_body   (1,"'0' when signal_READ ='1'                          else");
146    vhdl->set_body   (1,"reg_FULL ;");
147    vhdl->set_body   (0,"signal_NEXT_EMPTY     <=");
148    vhdl->set_body   (1,"'1' when signal_READ ='1' and signal_PTR_EQUAL='1' else");
149    vhdl->set_body   (1,"'0' when signal_WRITE='1'                          else");
150    vhdl->set_body   (1,"reg_EMPTY;");
151    vhdl->set_body   (0,"");
152
153    vhdl->set_comment(0," write");
154    if (_param->_size_queue > 1)
155      {
156    vhdl->set_body   (0,"signal_NEXT_PTR_WRITE <= ");
157    vhdl->set_body   (1,"reg_PTR_WRITE  when signal_WRITE='0' else");
158    if (is_log2(_param->_size_queue) == false)
159    vhdl->set_body   (1,"const_PTR_INIT when reg_PTR_WRITE = const_PTR_MAX else");
160    if (_param->_size_queue > 2)
161    vhdl->set_body   (1,"reg_PTR_WRITE+'1';");
162    else
163    vhdl->set_body   (1,"not reg_PTR_WRITE;");
164      }
165      }
166
167    vhdl->set_body   (0,"");
168    vhdl->set_comment(0," read");
169    if (_param->_size_queue > 1)
170      { 
171    vhdl->set_body   (0,"signal_NEXT_PTR_READ  <= ");
172    vhdl->set_body   (1,"reg_PTR_READ   when signal_READ='0' else");
173    if (is_log2(_param->_size_queue) == false)
174    vhdl->set_body   (1,"const_PTR_INIT when reg_PTR_READ  = const_PTR_MAX else");
175
176    if (_param->_size_queue > 2)
177    vhdl->set_body   (1,"reg_PTR_READ +'1';");
178    else
179    vhdl->set_body   (1,"not reg_PTR_READ;");
180      }
181    vhdl->set_body   (0,"");
182
183    vhdl->set_comment(0,"---------------------------------------------------------------------------");
184    vhdl->set_comment(0," Registers");
185    vhdl->set_comment(0,"---------------------------------------------------------------------------");
186    vhdl->set_body   (0,"");
187    vhdl->set_body   (0,"queue_write: process (in_CLOCK)");
188    vhdl->set_body   (0,"begin  -- process queue_write");
189    vhdl->set_body   (1,"if in_CLOCK'event and in_CLOCK = '1' then");
190    vhdl->set_body   (0,"");
191    vhdl->set_body   (2,"if (in_NRESET = '0') then");   
192    if (_param->_size_queue > 1)
193      {
194        vhdl->set_body   (3,"reg_PTR_READ  <= const_PTR_INIT;");
195        if (_param->_nb_port_slot>1)
196        vhdl->set_body   (3,"reg_NB_ELT    <= "+std_logic_cst(log2(_param->_size_queue+1),0)+";");
197        else
198        vhdl->set_body   (3,"reg_PTR_WRITE <= const_PTR_INIT;");
199      }
200    if (_param->_nb_port_slot<=1)
201      {
202    vhdl->set_body   (3,"reg_FULL      <= '0';");
203    vhdl->set_body   (3,"reg_EMPTY     <= '1';");
204      }
205    vhdl->set_body   (2,"else");
206    if (_param->_size_queue > 1)
207      {
208        vhdl->set_body   (3,"reg_PTR_READ  <= signal_NEXT_PTR_READ ;");
209        if (_param->_nb_port_slot>1)
210        vhdl->set_body   (3,"reg_NB_ELT    <= signal_NEXT_NB_ELT   ;");
211        else
212        vhdl->set_body   (3,"reg_PTR_WRITE <= signal_NEXT_PTR_WRITE;");
213      }
214    if (_param->_nb_port_slot<=1)
215      {
216    vhdl->set_body   (3,"reg_FULL      <= signal_NEXT_FULL ;");
217    vhdl->set_body   (3,"reg_EMPTY     <= signal_NEXT_EMPTY;");
218      }
219    vhdl->set_body   (0,"");
220    vhdl->set_body   (3,"if (signal_WRITE = '1') then");   
221    if (_param->_size_queue > 1)
222      vhdl->set_body   (3,"\treg_DATA(conv_integer(signal_PTR_WRITE)) <= in_INSERT_DATA;");
223    else
224      vhdl->set_body   (3,"\treg_DATA(0) <= in_INSERT_DATA;");
225    vhdl->set_body   (3,"end if;");
226    vhdl->set_body   (2,"end if;");
227    vhdl->set_body   (0,"");
228    vhdl->set_body   (1,"end if;");
229    vhdl->set_body   (0,"end process queue_write;");
230
231    log_printf(FUNC,Queue,FUNCTION,"End");
232  };
233
234}; // end namespace queue
235}; // end namespace generic
236
237}; // end namespace behavioural
238}; // end namespace morpheo             
239#endif
Note: See TracBrowser for help on using the repository browser.