source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Component_vhdl_instance.cpp @ 81

Last change on this file since 81 was 81, checked in by rosiere, 16 years ago
  • Finish Environment (and test)
  • Continue predictor_unit
  • Add external tools
  • svn keyword "Id" set
  • Property svn:keywords set to Id
File size: 5.3 KB
Line 
1#ifdef VHDL
2/*
3 * $Id: Component_vhdl_instance.cpp 81 2008-04-15 18:40:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/include/Component.h"
10
11namespace morpheo              {
12namespace behavioural          {
13
14#undef  FUNCTION
15#define FUNCTION "Component::vhdl_instance"
16  void Component::vhdl_instance (Vhdl * & vhdl)
17  {
18    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
19
20    uint32_t             cpt = 0;
21    std::map<Signal *,std::string> tab;
22
23    // buffer all output
24   
25    {
26      // for each interface
27      std::list<Interface_fifo *>         * list_interface = (_entity)->get_interfaces_list()->get_interface_list();
28      std::list<Interface_fifo *>::iterator j              = list_interface->begin();
29      if (not list_interface->empty())
30        {
31          vhdl->set_body ("------------------------------------------------------");
32          vhdl->set_body ("-- Output's Buffer");
33          vhdl->set_body ("------------------------------------------------------");
34         
35          while (j != list_interface->end())
36            {
37              // for each signal
38              std::list<Signal *>         * list_signal = (*j)->get_signal_list();
39              std::list<Signal *>::iterator k           = list_signal->begin();
40              if (not list_signal->empty())
41                {
42                  while (k != list_signal->end())
43                    {
44                      Signal * signal = (*k);
45
46                      // test if is connect with external interface or with an another component AND if this port is mapped.
47                      if ( (signal->get_direction() == OUT) and
48                           (signal->get_connect_from_signal () != NULL) )
49                        {
50                          // Create name
51                          std::string signal_name = "signal_"+toString(cpt++);
52                         
53                          tab [signal                           ] = signal_name;
54                          tab [signal->get_connect_from_signal()] = signal_name;
55                         
56                          // Add a new signal and the affectation
57                          vhdl->set_signal (signal_name, signal->get_size());
58                          vhdl->set_body   (signal->get_name()+" <= "+signal_name+";");
59                        }
60                      else
61                        {
62                          tab [signal                   ] = signal->get_name();
63                        }
64                      ++k;
65                    }
66                }
67              ++j;
68            }
69          vhdl->set_body ("");
70          vhdl->set_body ("------------------------------------------------------");
71          vhdl->set_body ("");
72        }
73    }
74
75    vhdl->set_library_work (_entity->get_name() + "_Pack");
76
77    // for each entity
78    std::list<Tcomponent_t *>         * list_component = _list_component;
79    std::list<Tcomponent_t *>::iterator i              = list_component->begin();
80    if (not list_component->empty())
81      {
82        while (i != list_component->end())
83          {
84            Entity *    entity   = (*i)->_entity;
85            Tinstance_t instance = (*i)->_instance;
86           
87            if (instance & INSTANCE_LIBRARY)
88              vhdl->set_library_work (entity->get_name() + "_Pack");
89
90            if (instance & INSTANCE_COMPONENT)
91            {
92              std::list<std::string> list_port_map;
93             
94              // for each interface
95              std::list<Interface_fifo *>         * list_interface = entity->get_interfaces_list()->get_interface_list();
96              std::list<Interface_fifo *>::iterator j              = list_interface->begin();
97              if (not list_interface->empty())
98                {
99                  while (j != list_interface->end())
100                    {
101                      // for each signal
102                      std::list<Signal *>         * list_signal = (*j)->get_signal_list();
103                      std::list<Signal *>::iterator k           = list_signal->begin();
104                      if (not list_signal->empty())
105                        {
106                          while (k != list_signal->end())
107                            {
108                              // test if is connect with external interface or with an another component.
109                              Signal * signal_src  = (*k);
110                             
111                              if (signal_src->presence_vhdl () == true)
112                                {
113                                  Signal * signal_dest = signal_src->get_connect_to_signal();
114                                  std::string   name_src    = signal_src->get_name();
115                                  std::string   name_dest;
116                                 
117//                              // Test if destination signal is a interface port ?
118//                              if (_entity->find_signal(signal_dest) == false)
119//                                {
120                                  // find if signal is already link
121                                  std::map<Signal *,std::string>::iterator it = tab.find(signal_dest); 
122                                  if (tab.find(signal_dest) == tab.end())
123                                    {
124                                      // Create name
125                                      name_dest = "signal_"+toString(cpt++);
126                                     
127                                      tab [signal_src ] = name_dest;
128                                      tab [signal_dest] = name_dest;
129                                     
130                                      // Add a new signal
131                                      vhdl->set_signal (name_dest, signal_src->get_size());
132                                    }
133                                  else
134                                    {
135                                      // find !!!!
136                                      name_dest = (*it).second;
137                                      tab [signal_src ] = name_dest;
138                                    }
139//                                }
140//                              else
141//                                {
142//                                  // Test if output
143//                                  if (signal_dest->get_direction() == OUT)
144//                                    {
145//                                      // Take buffer's signal
146//                                      map<Signal *,std::string>::iterator it = tab.find(signal_dest);
147//                                      name_dest        = (*it).second;
148
149//                                      cout << " * OUT - name : " << name_dest << endl;
150//                                    }
151//                                  else
152//                                    {
153//                                      name_dest = signal_dest->get_name();
154//                                      cout << " * IN  - name : " << name_dest << endl;
155//                                    }                             
156//                                }
157                                 
158                                  vhdl->set_body_component_port_map (list_port_map,
159                                                                     name_src , signal_src ->get_size(),
160                                                                     name_dest, signal_dest->get_size() );
161                                }
162                              ++k;
163                            }
164                        }
165                      ++j;
166                    }
167                }
168              vhdl->set_body_component ("instance_"+entity->get_name(),entity->get_name(),list_port_map);
169             
170            }
171            ++i;
172          }
173      }
174    log_printf(FUNC,Behavioural,FUNCTION,"End");
175  };
176 
177}; // end namespace behavioural
178}; // end namespace morpheo
179#endif
Note: See TracBrowser for help on using the repository browser.