source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/src/RegisterFile_Monolithic_vhdl_body.cpp @ 145

Last change on this file since 145 was 145, checked in by rosiere, 14 years ago

1) add test with SPECINT2K
2) new config of Selftest
3) modif RAT to support multiple depth_save ... but not finish (need fix Update Prediction Table)
4) add Function_pointer but need fix

  • Property svn:keywords set to Id
File size: 10.4 KB
Line 
1#ifdef VHDL
2/*
3 * $Id: RegisterFile_Monolithic_vhdl_body.cpp 145 2010-10-13 18:15:51Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h"
10
11namespace morpheo                    {
12namespace behavioural                {
13namespace generic                    {
14namespace registerfile               {
15namespace registerfile_monolithic    {
16
17  void RegisterFile_Monolithic::vhdl_body (Vhdl * & vhdl)
18  {
19#ifndef VHDL_GAISLER
20
21    vhdl->set_body   (0,"");
22    vhdl->set_comment(0,"---------------------------------------------------------------------------");
23    vhdl->set_comment(0," Ackitement");
24    vhdl->set_comment(0,"---------------------------------------------------------------------------");
25    vhdl->set_body   (0,"");
26
27    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
28      vhdl->set_body   (0,"out_READ_"+toString(i)+"_ACK  <= '1';");
29    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
30      vhdl->set_body   (0,"out_WRITE_"+toString(i)+"_ACK <= '1';");
31    for (uint32_t i = 0; i < _param->_nb_port_read_write; i++)
32      vhdl->set_body   (0,"out_READ_WRITE_"+toString(i)+"_ACK  <= '1';");
33
34    vhdl->set_body   (0,"");
35    vhdl->set_comment(0,"---------------------------------------------------------------------------");
36    vhdl->set_comment(0," Read RegisterFile");
37    vhdl->set_comment(0,"---------------------------------------------------------------------------");
38    vhdl->set_body   (0,"");
39   
40    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
41      {
42        std::string str_address;
43        if (_param->_have_port_address)
44          str_address = "conv_integer(in_READ_"+toString(i)+"_ADDRESS)";
45        else
46          str_address = "0";
47
48        vhdl->set_body   (0,"out_READ_"+toString(i)+"_DATA <= reg_DATA ("+str_address+") when in_READ_"+toString(i)+"_VAL = '1' else "+std_logic_others(_param->_size_word,0)+";");
49      }
50    for (uint32_t i = 0; i < _param->_nb_port_read_write; i++)
51      {
52        std::string str_address;
53        if (_param->_have_port_address)
54          str_address = "conv_integer(in_READ_WRITE_"+toString(i)+"_ADDRESS)";
55        else
56          str_address = "0";
57        vhdl->set_body   (0,"out_READ_WRITE_"+toString(i)+"_RDATA <= reg_DATA ("+str_address+") when in_READ_WRITE_"+toString(i)+"_VAL = '1' and in_READ_WRITE_"+toString(i)+"_RW = '"+toString(RW_READ)+"' else "+std_logic_others(_param->_size_word,0)+";");
58      }
59
60    vhdl->set_body   (0,"");
61    vhdl->set_comment(0,"---------------------------------------------------------------------------");
62    vhdl->set_comment(0," Write RegisterFile");
63    vhdl->set_comment(0,"---------------------------------------------------------------------------");
64    vhdl->set_body   (0,"");
65
66    vhdl->set_body   (0,"RegisterFile_write: process (in_CLOCK)");
67    vhdl->set_body   (0,"begin  -- process RegisterFile_write");
68    vhdl->set_body   (1,"if in_CLOCK'event and in_CLOCK = '1' then");
69
70    if (_param->_have_init_value)
71      {
72        vhdl->set_body   (2,"if in_NRESET = '0' then");
73       
74        std::string init_value = ((_param->_size_word>1)?"\"":"'")+_param->_init_value+((_param->_size_word>1)?"\"":"'");
75       
76        for (uint32_t i=0; i<_param->_nb_word; ++i)
77          vhdl->set_body   (3,"reg_DATA("+toString(i)+") <= "+init_value+";");
78
79        vhdl->set_body   (2,"else");
80      }
81   
82    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
83      {
84        std::string str_address;
85        if (_param->_have_port_address)
86          str_address = "conv_integer(in_WRITE_"+toString(i)+"_ADDRESS)";
87        else
88          str_address = "0";
89
90        vhdl->set_body   (2,"if (in_WRITE_"+toString(i)+"_VAL = '1') then");
91        vhdl->set_body   (3,"reg_DATA("+str_address+") <= in_WRITE_"+toString(i)+"_DATA;");
92        vhdl->set_body   (2,"end if;");
93      }
94    for (uint32_t i = 0; i < _param->_nb_port_read_write; i++)
95      {
96        std::string str_address;
97        if (_param->_have_port_address)
98          str_address = "conv_integer(in_READ_WRITE_"+toString(i)+"_ADDRESS)";
99        else
100          str_address = "0";
101       
102        vhdl->set_body   (2,"if (in_READ_WRITE_"+toString(i)+"_VAL = '1' and in_READ_WRITE_"+toString(i)+"_RW = '"+toString(RW_WRITE)+"') then");
103        vhdl->set_body   (3,"reg_DATA("+str_address+") <= in_READ_WRITE_"+toString(i)+"_WDATA;");
104        vhdl->set_body   (2,"end if;");
105      }
106
107    vhdl->set_body   (1,"end if;");
108
109    if (_param->_have_init_value)
110      vhdl->set_body   (1,"end if;");
111    vhdl->set_body   (0,"end process RegisterFile_write;");
112
113#else
114    // vhdl->set_body   (0,"");
115    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
116    // vhdl->set_comment(0," Ackitement");
117    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
118    // vhdl->set_body   (0,"");
119
120    // for (uint32_t i = 0; i < _param->_nb_port_read; i++)
121    //   vhdl->set_body   (0,"out_READ_"+toString(i)+"_ACK  <= '1';");
122    // for (uint32_t i = 0; i < _param->_nb_port_write; i++)
123    //   vhdl->set_body   (0,"out_WRITE_"+toString(i)+"_ACK <= '1';");
124    // for (uint32_t i = 0; i < _param->_nb_port_read_write; i++)
125    //   vhdl->set_body   (0,"out_READ_WRITE_"+toString(i)+"_ACK  <= '1';");
126
127    // vhdl->set_body   (0,"");
128    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
129    // vhdl->set_comment(0," Read RegisterFile");
130    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
131    // vhdl->set_body   (0,"");
132
133    // for (uint32_t num_read=0; num_read<_param->_nb_port_read; ++num_read)
134    //   {
135    //     vhdl->set_body   (0,"with in_READ_"+toString(num_read)+"_ADDRESS select");
136    //       vhdl->set_body   (1,"out_READ_"+toString(num_read)+"_DATA <=");
137    //       for (uint32_t num_word=0; num_word<_param->_nb_word-1; ++num_word)
138    //         vhdl->set_body   (1,"reg_DATA_"+toString(num_word)+" when "+std_logic_cst(_param->_size_address,num_word)+",");
139    //       vhdl->set_body   (1,"reg_DATA_"+toString(_param->_nb_word-1)+" when others;");
140    //   }
141
142    // vhdl->set_body   (0,"");
143    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
144    // vhdl->set_comment(0," Write RegisterFile");
145    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
146    // vhdl->set_body   (0,"");
147
148    // vhdl->set_body   (0,"RegisterFile_write: process (in_CLOCK)");
149    // vhdl->set_body   (0,"begin  -- process RegisterFile_write");
150    // vhdl->set_body   (1,"if in_CLOCK'event and in_CLOCK = '1' then");
151
152    // for (uint32_t num_write = 0; num_write < _param->_nb_port_write; num_write++)
153    //   {
154    //     vhdl->set_body   (2,"if (in_WRITE_"+toString(num_write)+"_VAL = '1') then");
155    //     for (uint32_t num_word=0; num_word<_param->_nb_word; ++num_word)
156    //       {
157    //         vhdl->set_body   (3,"if (in_WRITE_"+toString(num_write)+"_ADDRESS = "+std_logic_cst(_param->_size_address,num_word)+") then");
158    //         vhdl->set_body   (4,"reg_DATA_"+toString(num_word)+" <= in_WRITE_"+toString(num_write)+"_DATA;");
159    //         vhdl->set_body   (3,"end if;");
160    //       }
161    //     vhdl->set_body   (2,"end if;");
162    //   }
163   
164    // vhdl->set_body   (1,"end if;");
165    // vhdl->set_body   (0,"end process RegisterFile_write;");
166
167    vhdl->set_body   (0,"combinatory : process (");
168    for (uint32_t num_read=0; num_read<_param->_nb_port_read; ++num_read)
169      {
170        vhdl->set_body   (1,"in_READ_"+toString(num_read)+"_VAL,");
171        if (_param->_have_port_address)
172        vhdl->set_body   (1,"in_READ_"+toString(num_read)+"_ADDRESS,");
173      }
174    for (uint32_t num_write=0; num_write<_param->_nb_port_write; ++num_write)
175      {
176        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_VAL,");
177        if (_param->_have_port_address)
178        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_ADDRESS,");
179        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_DATA,");
180      }
181    for (uint32_t num_write = 0; num_write < _param->_nb_port_write; num_write++)
182    vhdl->set_body   (1,"in_NRESET,");
183    vhdl->set_body   (1,"reg_DATA)");
184    vhdl->set_body   (1,"variable sig_DATA : Treg;");
185    vhdl->set_body   (0,"begin");
186    vhdl->set_body   (1,"");
187    vhdl->set_body   (1,"sig_DATA := reg_DATA;");
188
189    vhdl->set_body   (1,"");
190    vhdl->set_body   (1," -- ack");
191    vhdl->set_body   (1,"");
192   
193    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
194      vhdl->set_body   (1,"out_READ_"+toString(i)+"_ACK  <= '1';");
195    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
196      vhdl->set_body   (1,"out_WRITE_"+toString(i)+"_ACK <= '1';");
197    for (uint32_t i = 0; i < _param->_nb_port_read_write; i++)
198      vhdl->set_body   (1,"out_READ_WRITE_"+toString(i)+"_ACK  <= '1';");
199    vhdl->set_body   (1,"");
200    vhdl->set_body   (1," -- Read");
201    vhdl->set_body   (1,"");
202
203    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
204      {
205        std::string str_address;
206        if (_param->_have_port_address)
207          str_address = "conv_integer(in_READ_"+toString(i)+"_ADDRESS)";
208        else
209          str_address = "0";
210
211        vhdl->set_body   (1,"if (in_READ_"+toString(i)+"_VAL = '1') then"),
212        vhdl->set_body   (2,"out_READ_"+toString(i)+"_DATA <= sig_DATA.reg ("+str_address+");");
213        vhdl->set_body   (1,"else"),
214        vhdl->set_body   (2,"out_READ_"+toString(i)+"_DATA <= "+std_logic_others(_param->_size_word,0)+";");
215        vhdl->set_body   (1,"end if;");
216      }
217    vhdl->set_body   (1,"");
218    vhdl->set_body   (1," -- write");
219    vhdl->set_body   (1,"");
220
221    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
222      {
223        std::string str_address;
224        if (_param->_have_port_address)
225          str_address = "conv_integer(in_WRITE_"+toString(i)+"_ADDRESS)";
226        else
227          str_address = "0";
228
229        vhdl->set_body   (1,"if (in_WRITE_"+toString(i)+"_VAL = '1') then");
230        vhdl->set_body   (2,"sig_DATA.reg("+str_address+") := in_WRITE_"+toString(i)+"_DATA;");
231        vhdl->set_body   (1,"end if;");
232      }
233
234    vhdl->set_body   (1,"");
235    vhdl->set_body   (1,"reg_DATA_next <= sig_DATA;");
236    vhdl->set_body   (1,"");
237    vhdl->set_body   (0,"end process combinatory;");
238
239
240    vhdl->set_body   (0,"sequential: process (in_CLOCK)");
241    vhdl->set_body   (0,"begin");
242    vhdl->set_body   (1,"if rising_edge(in_CLOCK) then");
243    vhdl->set_body   (2,"reg_DATA <= reg_DATA_NEXT;");
244    vhdl->set_body   (1,"end if;");
245    vhdl->set_body   (0,"end process sequential;");
246
247#endif
248
249  };
250
251}; // end namespace registerfile_monolithic
252}; // end namespace registerfile
253}; // end namespace generic
254}; // end namespace behavioural         
255}; // end namespace morpheo             
256#endif
Note: See TracBrowser for help on using the repository browser.