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

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

1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test

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