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

Last change on this file since 146 was 146, checked in by rosiere, 13 years ago

1) Integration of RegisterFile_Internal_Banked in RegisterFile?
2) Erase "read_write" interface in RegisterFile_Monolithic component
3) Add smith predictor parameters in Load_store_pointer_unit.
4) Fix not statistics flags

  • Property svn:keywords set to Id
File size: 9.0 KB
Line 
1#ifdef VHDL
2/*
3 * $Id: RegisterFile_Monolithic_vhdl_body.cpp 146 2011-02-01 20:57:54Z 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
32    vhdl->set_body   (0,"");
33    vhdl->set_comment(0,"---------------------------------------------------------------------------");
34    vhdl->set_comment(0," Read RegisterFile");
35    vhdl->set_comment(0,"---------------------------------------------------------------------------");
36    vhdl->set_body   (0,"");
37   
38    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
39      {
40        std::string str_address;
41        if (_param->_have_port_address)
42          str_address = "conv_integer(in_READ_"+toString(i)+"_ADDRESS)";
43        else
44          str_address = "0";
45
46        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)+";");
47      }
48
49    vhdl->set_body   (0,"");
50    vhdl->set_comment(0,"---------------------------------------------------------------------------");
51    vhdl->set_comment(0," Write RegisterFile");
52    vhdl->set_comment(0,"---------------------------------------------------------------------------");
53    vhdl->set_body   (0,"");
54
55    vhdl->set_body   (0,"RegisterFile_write: process (in_CLOCK)");
56    vhdl->set_body   (0,"begin  -- process RegisterFile_write");
57    vhdl->set_body   (1,"if in_CLOCK'event and in_CLOCK = '1' then");
58
59    if (_param->_have_init_value)
60      {
61        vhdl->set_body   (2,"if in_NRESET = '0' then");
62       
63        std::string init_value = ((_param->_size_word>1)?"\"":"'")+_param->_init_value+((_param->_size_word>1)?"\"":"'");
64       
65        for (uint32_t i=0; i<_param->_nb_word; ++i)
66          vhdl->set_body   (3,"reg_DATA("+toString(i)+") <= "+init_value+";");
67
68        vhdl->set_body   (2,"else");
69      }
70   
71    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
72      {
73        std::string str_address;
74        if (_param->_have_port_address)
75          str_address = "conv_integer(in_WRITE_"+toString(i)+"_ADDRESS)";
76        else
77          str_address = "0";
78
79        vhdl->set_body   (2,"if (in_WRITE_"+toString(i)+"_VAL = '1') then");
80        vhdl->set_body   (3,"reg_DATA("+str_address+") <= in_WRITE_"+toString(i)+"_DATA;");
81        vhdl->set_body   (2,"end if;");
82      }
83
84    vhdl->set_body   (1,"end if;");
85
86    if (_param->_have_init_value)
87      vhdl->set_body   (1,"end if;");
88    vhdl->set_body   (0,"end process RegisterFile_write;");
89
90#else
91    // vhdl->set_body   (0,"");
92    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
93    // vhdl->set_comment(0," Ackitement");
94    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
95    // vhdl->set_body   (0,"");
96
97    // for (uint32_t i = 0; i < _param->_nb_port_read; i++)
98    //   vhdl->set_body   (0,"out_READ_"+toString(i)+"_ACK  <= '1';");
99    // for (uint32_t i = 0; i < _param->_nb_port_write; i++)
100    //   vhdl->set_body   (0,"out_WRITE_"+toString(i)+"_ACK <= '1';");
101
102    // vhdl->set_body   (0,"");
103    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
104    // vhdl->set_comment(0," Read RegisterFile");
105    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
106    // vhdl->set_body   (0,"");
107
108    // for (uint32_t num_read=0; num_read<_param->_nb_port_read; ++num_read)
109    //   {
110    //     vhdl->set_body   (0,"with in_READ_"+toString(num_read)+"_ADDRESS select");
111    //       vhdl->set_body   (1,"out_READ_"+toString(num_read)+"_DATA <=");
112    //       for (uint32_t num_word=0; num_word<_param->_nb_word-1; ++num_word)
113    //         vhdl->set_body   (1,"reg_DATA_"+toString(num_word)+" when "+std_logic_cst(_param->_size_address,num_word)+",");
114    //       vhdl->set_body   (1,"reg_DATA_"+toString(_param->_nb_word-1)+" when others;");
115    //   }
116
117    // vhdl->set_body   (0,"");
118    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
119    // vhdl->set_comment(0," Write RegisterFile");
120    // vhdl->set_comment(0,"---------------------------------------------------------------------------");
121    // vhdl->set_body   (0,"");
122
123    // vhdl->set_body   (0,"RegisterFile_write: process (in_CLOCK)");
124    // vhdl->set_body   (0,"begin  -- process RegisterFile_write");
125    // vhdl->set_body   (1,"if in_CLOCK'event and in_CLOCK = '1' then");
126
127    // for (uint32_t num_write = 0; num_write < _param->_nb_port_write; num_write++)
128    //   {
129    //     vhdl->set_body   (2,"if (in_WRITE_"+toString(num_write)+"_VAL = '1') then");
130    //     for (uint32_t num_word=0; num_word<_param->_nb_word; ++num_word)
131    //       {
132    //         vhdl->set_body   (3,"if (in_WRITE_"+toString(num_write)+"_ADDRESS = "+std_logic_cst(_param->_size_address,num_word)+") then");
133    //         vhdl->set_body   (4,"reg_DATA_"+toString(num_word)+" <= in_WRITE_"+toString(num_write)+"_DATA;");
134    //         vhdl->set_body   (3,"end if;");
135    //       }
136    //     vhdl->set_body   (2,"end if;");
137    //   }
138   
139    // vhdl->set_body   (1,"end if;");
140    // vhdl->set_body   (0,"end process RegisterFile_write;");
141
142    vhdl->set_body   (0,"combinatory : process (");
143    for (uint32_t num_read=0; num_read<_param->_nb_port_read; ++num_read)
144      {
145        vhdl->set_body   (1,"in_READ_"+toString(num_read)+"_VAL,");
146        if (_param->_have_port_address)
147        vhdl->set_body   (1,"in_READ_"+toString(num_read)+"_ADDRESS,");
148      }
149    for (uint32_t num_write=0; num_write<_param->_nb_port_write; ++num_write)
150      {
151        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_VAL,");
152        if (_param->_have_port_address)
153        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_ADDRESS,");
154        vhdl->set_body   (1,"in_WRITE_"+toString(num_write)+"_DATA,");
155      }
156    for (uint32_t num_write = 0; num_write < _param->_nb_port_write; num_write++)
157    vhdl->set_body   (1,"in_NRESET,");
158    vhdl->set_body   (1,"reg_DATA)");
159    vhdl->set_body   (1,"variable sig_DATA : Treg;");
160    vhdl->set_body   (0,"begin");
161    vhdl->set_body   (1,"");
162    vhdl->set_body   (1,"sig_DATA := reg_DATA;");
163
164    vhdl->set_body   (1,"");
165    vhdl->set_body   (1," -- ack");
166    vhdl->set_body   (1,"");
167   
168    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
169      vhdl->set_body   (1,"out_READ_"+toString(i)+"_ACK  <= '1';");
170    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
171      vhdl->set_body   (1,"out_WRITE_"+toString(i)+"_ACK <= '1';");
172    vhdl->set_body   (1,"");
173    vhdl->set_body   (1," -- Read");
174    vhdl->set_body   (1,"");
175
176    for (uint32_t i = 0; i < _param->_nb_port_read; i++)
177      {
178        std::string str_address;
179        if (_param->_have_port_address)
180          str_address = "conv_integer(in_READ_"+toString(i)+"_ADDRESS)";
181        else
182          str_address = "0";
183
184        vhdl->set_body   (1,"if (in_READ_"+toString(i)+"_VAL = '1') then"),
185        vhdl->set_body   (2,"out_READ_"+toString(i)+"_DATA <= sig_DATA.reg ("+str_address+");");
186        vhdl->set_body   (1,"else"),
187        vhdl->set_body   (2,"out_READ_"+toString(i)+"_DATA <= "+std_logic_others(_param->_size_word,0)+";");
188        vhdl->set_body   (1,"end if;");
189      }
190    vhdl->set_body   (1,"");
191    vhdl->set_body   (1," -- write");
192    vhdl->set_body   (1,"");
193
194    for (uint32_t i = 0; i < _param->_nb_port_write; i++)
195      {
196        std::string str_address;
197        if (_param->_have_port_address)
198          str_address = "conv_integer(in_WRITE_"+toString(i)+"_ADDRESS)";
199        else
200          str_address = "0";
201
202        vhdl->set_body   (1,"if (in_WRITE_"+toString(i)+"_VAL = '1') then");
203        vhdl->set_body   (2,"sig_DATA.reg("+str_address+") := in_WRITE_"+toString(i)+"_DATA;");
204        vhdl->set_body   (1,"end if;");
205      }
206
207    vhdl->set_body   (1,"");
208    vhdl->set_body   (1,"reg_DATA_next <= sig_DATA;");
209    vhdl->set_body   (1,"");
210    vhdl->set_body   (0,"end process combinatory;");
211
212
213    vhdl->set_body   (0,"sequential: process (in_CLOCK)");
214    vhdl->set_body   (0,"begin");
215    vhdl->set_body   (1,"if rising_edge(in_CLOCK) then");
216    vhdl->set_body   (2,"reg_DATA <= reg_DATA_NEXT;");
217    vhdl->set_body   (1,"end if;");
218    vhdl->set_body   (0,"end process sequential;");
219
220#endif
221
222  };
223
224}; // end namespace registerfile_monolithic
225}; // end namespace registerfile
226}; // end namespace generic
227}; // end namespace behavioural         
228}; // end namespace morpheo             
229#endif
Note: See TracBrowser for help on using the repository browser.