source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Victim/Victim_Pseudo_LRU/src/Victim_Pseudo_LRU_vhdl_body.cpp @ 57

Last change on this file since 57 was 42, checked in by rosiere, 17 years ago

Modification des classes d'encapsulation des interfaces :

  • gère les signaux à écrire dans le vhdl
  • les traces pour le testbench
  • la génération des vhdl structurelles

-> test sur la Pattern History Table

File size: 7.4 KB
RevLine 
[10]1#ifdef VHDL
2/*
3 * $Id$
4 *
5 * [ Description ]
6 *
7 */
8
[15]9#include "Behavioural/Generic/Victim/Victim_Pseudo_LRU/include/Victim_Pseudo_LRU.h"
[10]10
11namespace morpheo {
12namespace behavioural {
13namespace generic {
14namespace victim {
[15]15namespace victim_pseudo_lru {
[10]16
[42]17  void Victim_Pseudo_LRU::vhdl_body (Vhdl * & vhdl)
[10]18  {
[42]19    vhdl->set_body ("");
20    vhdl->set_body ("-----------------------------------------------------------------------------");
21    vhdl->set_body ("-- Access");
22    vhdl->set_body ("-----------------------------------------------------------------------------");
23    vhdl->set_body ("");
24    vhdl->set_body ("-- Tree of Pseudo-LRU - example to 8 entity");
25    vhdl->set_body ("--");
26    vhdl->set_body ("--                4-5-6-7?              ");
27    vhdl->set_body ("--           0_______|_______1         ");
28    vhdl->set_body ("--           |               |         ");
29    vhdl->set_body ("--          2-3?            6-7?        ");
30    vhdl->set_body ("--       0___|___1       0___|___1      ");
31    vhdl->set_body ("--       |       |       |       |      ");
32    vhdl->set_body ("--       1?      3?      5?      7?     ");
33    vhdl->set_body ("--     0_|_1   0_|_1   0_|_1   0_|_1    ");
34    vhdl->set_body ("--     |   |   |   |   |   |   |   |    ");
35    vhdl->set_body ("--    Way Way Way Way Way Way Way Way   ");
36    vhdl->set_body ("--     0   1   2   3   4   5   6   7    ");
[10]37    for (uint32_t i=0; i<_param._nb_access; i++)
38      {
[42]39        vhdl->set_body ("");
[10]40        // Read the table
41       
42        string access_address;
43
44        if (_param._size_table>1)
[42]45          access_address = "conv_integer(in_ACCESS_"+toString(i)+"_ADDRESS)";
[10]46        else
47          access_address = "0";
48
[42]49        vhdl->set_body ("access_entry_"+toString(i)+" <= reg_TABLE ("+access_address+");");
50        vhdl->set_body ("");
[10]51
52        for (int32_t j=static_cast<uint32_t>(log2(_param._nb_entity)-1); j>=0; j--)
53          {
[42]54            vhdl->set_body ("access_entity_"+toString(i)+"("+toString(j)+") <= ");
[10]55
56            uint32_t cpt=0;
57
58            for (int32_t k=(1<<j)-1; k<static_cast<int32_t>(_param._nb_entity-1); k+=(1<<(j+1)))
59              {
60                string cond = "";
61               
62                // Create the condition
63                for (uint32_t l=j+1; l<static_cast<uint32_t>(log2(_param._nb_entity));l++)
64                  {
65                    if (l==static_cast<uint32_t>(j+1))
66                      cond += "when";
67                    else
68                      cond += " and";
69                    cond += " access_entity_"+toString(i)+"("+toString(l)+") = '"+toString((cpt>>(l-(j+1)))&1)+"'";
70                  }
71               
72                string print_else = (k==(1<<j)-1)?"     ":"else ";
73
[42]74                vhdl->set_body ("\t"+print_else+"access_entry_"+toString(i)+"("+toString(k)+") "+cond);
[10]75                cpt ++;
76              }
[42]77            vhdl->set_body ("\t;");
[10]78          }
79      }
80
[42]81    vhdl->set_body ("");
82    vhdl->set_body ("-----------------------------------------------------------------------------");
83    vhdl->set_body ("-- Update");
84    vhdl->set_body ("-----------------------------------------------------------------------------");
85    vhdl->set_body ("");
86    vhdl->set_body ("-- port access");
[10]87    for (uint32_t i=0; i<_param._nb_access; i++)
88      for (int32_t j=static_cast<uint32_t>(log2(_param._nb_entity)-1); j>=0; j--)
89        {
90          uint32_t cpt=0;
91         
92          for (int32_t k=(1<<j)-1; k<static_cast<int32_t>(_param._nb_entity-1); k+=(1<<(j+1)))
93            {
94              bool   have_cond = false;
95              string cond      = "";
96             
97              // condition to change the bit
98              for (uint32_t l=j+1; l<static_cast<uint32_t>(log2(_param._nb_entity));l++)
99                {
100                  have_cond = true;
101
102                  if (l==static_cast<uint32_t>(j+1))
103                    cond += "when";
104                  else
105                    cond += " and";
106                  cond += " access_entity_"+toString(i)+"("+toString(l)+")='"+toString((cpt>>(l-(j+1)))&1)+"'";
107                }
108             
[42]109              vhdl->set_body ("access_next_entry_"+toString(i)+"("+toString(k)+") <=");
110              vhdl->set_body ("\tnot access_entity_"+toString(i)+"("+toString(j)+") "+cond);
[10]111              if (have_cond == true)
[42]112                vhdl->set_body ("\telse access_entry_"+toString(i)+"("+toString(k)+")");
113              vhdl->set_body ("\t;");         
[10]114              cpt ++;
115            }
116        }
117
[42]118    vhdl->set_body ("");
119    vhdl->set_body ("-- port update");
[10]120    for (uint32_t i=0; i<_param._nb_update; i++)
121      for (int32_t j=static_cast<uint32_t>(log2(_param._nb_entity)-1); j>=0; j--)
122        {
123          uint32_t cpt=0;
124         
125          for (int32_t k=(1<<j)-1; k<static_cast<int32_t>(_param._nb_entity-1); k+=(1<<(j+1)))
126            {
127              bool   have_cond = false;
128              string cond      = "";
129             
130              // condition to change the bit
131              for (uint32_t l=j+1; l<static_cast<uint32_t>(log2(_param._nb_entity));l++)
132                {
133                  have_cond = true;
134
135                  if (l==static_cast<uint32_t>(j+1))
136                    cond += "when";
137                  else
138                    cond += " and";
[42]139                  cond += " in_UPDATE_"+toString(i)+"_ENTITY("+toString(l)+")='"+toString((cpt>>(l-(j+1)))&1)+"'";
[10]140                }
141             
[42]142              vhdl->set_body ("update_next_entry_"+toString(i)+"("+toString(k)+") <=");
143              vhdl->set_body ("\tnot in_UPDATE_"+toString(i)+"_ENTITY("+toString(j)+") "+cond);
[10]144              if (have_cond == true)
145                {
146                  string update_address;
147
148                  if (_param._size_table>1)
[42]149                    update_address = "conv_integer(in_UPDATE_"+toString(i)+"_ADDRESS)";
[10]150                  else
151                    update_address = "0";
152                 
[42]153                  vhdl->set_body ("\telse reg_TABLE ("+update_address+")("+toString(k)+")");
[10]154                }
[42]155              vhdl->set_body ("\t;");         
[10]156              cpt ++;
157            }
158        }
159
[42]160    vhdl->set_body ("");
161    vhdl->set_body ("-----------------------------------------------------------------------------");
162    vhdl->set_body ("-- Transition");
163    vhdl->set_body ("-----------------------------------------------------------------------------");
164    vhdl->set_body ("");
[10]165
[42]166    vhdl->set_body ("reg_TABLE_write: process (in_CLOCK)");
167    vhdl->set_body ("begin");
168    vhdl->set_body ("\tif in_CLOCK'event and in_CLOCK = '1' then");
169    vhdl->set_body ("\t\t-- Access port");
[10]170    for (uint32_t i=0; i<_param._nb_access; i++)
171      {
172        string access_address;
173
174        if (_param._size_table>1)
[42]175          access_address = "conv_integer(in_ACCESS_"+toString(i)+"_ADDRESS)";
[10]176        else
177          access_address = "0";
178
[42]179        vhdl->set_body ("\t\tif (in_ACCESS_"+toString(i)+"_VAL = '1') then");
180        vhdl->set_body ("\t\t\treg_TABLE ("+access_address+") <= access_next_entry_"+toString(i)+";");
181        vhdl->set_body ("\t\tend if;");
[10]182      }
183
[42]184    vhdl->set_body ("\t\t-- Update port");
[10]185    for (uint32_t i=0; i<_param._nb_update; i++)
186      {
187        string update_address;
188
189        if (_param._size_table>1)
[42]190          update_address = "conv_integer(in_UPDATE_"+toString(i)+"_ADDRESS)";
[10]191        else
192          update_address = "0";
193                 
[42]194        vhdl->set_body ("\t\tif (in_UPDATE_"+toString(i)+"_VAL = '1') then");
195        vhdl->set_body ("\t\t\treg_TABLE ("+update_address+") <= update_next_entry_"+toString(i)+";");
196        vhdl->set_body ("\t\tend if;");
[10]197      }
198
[42]199    vhdl->set_body ("\tend if;");
200    vhdl->set_body ("end process reg_TABLE_write;");
[10]201
[42]202    vhdl->set_body ("");
203    vhdl->set_body ("-----------------------------------------------------------------------------");
204    vhdl->set_body ("-- Output");
205    vhdl->set_body ("-----------------------------------------------------------------------------");
206    vhdl->set_body ("");
207    vhdl->set_body ("-- Ack is always ");
208    vhdl->set_body ("");
[10]209    for (uint32_t i=0; i<_param._nb_access; i++)
210      {
[42]211        vhdl->set_body ("out_ACCESS_"+toString(i)+"_ACK    <= '1';");
212        vhdl->set_body ("out_ACCESS_"+toString(i)+"_ENTITY <= access_entity_"+toString(i)+" when in_ACCESS_"+toString(i)+"_VAL = '1' else (others => '0');");
[10]213      }
[42]214    vhdl->set_body ("");
[10]215    for (uint32_t i=0; i<_param._nb_update; i++)
216      {
[42]217        vhdl->set_body ("out_UPDATE_"+toString(i)+"_ACK    <= '1';");
[10]218      }
219  };
220
[15]221}; // end namespace victim_pseudo_lru
[10]222}; // end namespace victim
223}; // end namespace generic
224
225}; // end namespace behavioural
226}; // end namespace morpheo             
227#endif
Note: See TracBrowser for help on using the repository browser.