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

Last change on this file since 57 was 57, checked in by rosiere, 17 years ago
  • VHDL - RegisterFile_Multi_Banked (only partial_crossbar)
  • SystemC - modif Component, interface and co -> ajout du type Tusage_T pour instancier un coposant mais ne demander que le VHDL ou le systemC.
  • Séminaire interne
File size: 5.2 KB
Line 
1#ifdef VHDL
2/*
3 * $Id$
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    map<Signal *,string> tab;
22
23    // buffer all output
24    {
25      vhdl->set_body ("------------------------------------------------------");
26      vhdl->set_body ("-- Output's Buffer");
27      vhdl->set_body ("------------------------------------------------------");
28
29      // for each interface
30      list<Interface_fifo *>         * list_interface = (_entity)->get_interfaces_list()->get_interface_list();
31      list<Interface_fifo *>::iterator j              = list_interface->begin();
32      if (not list_interface->empty())
33        {
34          while (j != list_interface->end())
35            {
36              // for each signal
37              list<Signal *>         * list_signal = (*j)->get_signal_list();
38              list<Signal *>::iterator k           = list_signal->begin();
39              if (not list_signal->empty())
40                {
41                  while (k != list_signal->end())
42                    {
43                      Signal * signal = (*k);
44
45                      // test if is connect with external interface or with an another component AND if this port is mapped.
46                      if ( (signal->get_direction() == OUT) and
47                           (signal->get_connect_from_signal () != NULL) )
48                        {
49                          // Create name
50                          string signal_name = "signal_"+toString(cpt++);
51                         
52                          tab [signal                           ] = signal_name;
53                          tab [signal->get_connect_from_signal()] = signal_name;
54                         
55                          // Add a new signal and the affectation
56                          vhdl->set_signal (signal_name, signal->get_size());
57                          vhdl->set_body   (signal->get_name()+" <= "+signal_name+";");
58                        }
59                      else
60                        {
61                          tab [signal                   ] = signal->get_name();
62                        }
63                      ++k;
64                    }
65                }
66              ++j;
67            }
68        }
69      vhdl->set_body ("");
70      vhdl->set_body ("------------------------------------------------------");
71      vhdl->set_body ("");
72    }
73
74    vhdl->set_library_work (_entity->get_name() + "_Pack");
75
76    // for each entity
77    list<Tcomponent_t *>         * list_component = _list_component;
78    list<Tcomponent_t *>::iterator i              = list_component->begin();
79    if (not list_component->empty())
80      {
81        while (i != list_component->end())
82          {
83            Entity *    entity   = (*i)->_entity;
84            Tinstance_t instance = (*i)->_instance;
85           
86            if (instance & INSTANCE_LIBRARY)
87              vhdl->set_library_work (entity->get_name() + "_Pack");
88
89            if (instance & INSTANCE_COMPONENT)
90            {
91              list<string> list_port_map;
92             
93              // for each interface
94              list<Interface_fifo *>         * list_interface = entity->get_interfaces_list()->get_interface_list();
95              list<Interface_fifo *>::iterator j              = list_interface->begin();
96              if (not list_interface->empty())
97                {
98                  while (j != list_interface->end())
99                    {
100                      // for each signal
101                      list<Signal *>         * list_signal = (*j)->get_signal_list();
102                      list<Signal *>::iterator k           = list_signal->begin();
103                      if (not list_signal->empty())
104                        {
105                          while (k != list_signal->end())
106                            {
107                              // test if is connect with external interface or with an another component.
108                              Signal * signal_src  = (*k);
109                             
110                              if (signal_src->presence_vhdl () == true)
111                                {
112                                  Signal * signal_dest = signal_src->get_connect_to_signal();
113                                  string   name_src    = signal_src->get_name();
114                                  string   name_dest;
115                                 
116//                              // Test if destination signal is a interface port ?
117//                              if (_entity->find_signal(signal_dest) == false)
118//                                {
119                                  // find if signal is already link
120                                  map<Signal *,string>::iterator it = tab.find(signal_dest); 
121                                  if (tab.find(signal_dest) == tab.end())
122                                    {
123                                      // Create name
124                                      name_dest = "signal_"+toString(cpt++);
125                                     
126                                      tab [signal_src ] = name_dest;
127                                      tab [signal_dest] = name_dest;
128                                     
129                                      // Add a new signal
130                                      vhdl->set_signal (name_dest, signal_src->get_size());
131                                    }
132                                  else
133                                    {
134                                      // find !!!!
135                                      name_dest = (*it).second;
136                                      tab [signal_src ] = name_dest;
137                                    }
138//                                }
139//                              else
140//                                {
141//                                  cout << "Kane à dit : " << signal_dest->get_name() << endl;
142//                                  // Test if output
143//                                  if (signal_dest->get_direction() == OUT)
144//                                    {
145//                                      // Take buffer's signal
146//                                      map<Signal *,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, name_src, name_dest);
159                                }
160                              ++k;
161                            }
162                        }
163                      ++j;
164                    }
165                }
166              vhdl->set_body_component ("instance_"+entity->get_name(),entity->get_name(),list_port_map);
167             
168            }
169            ++i;
170          }
171      }
172    log_printf(FUNC,Behavioural,FUNCTION,"End");
173  };
174 
175}; // end namespace behavioural
176}; // end namespace morpheo
177#endif
Note: See TracBrowser for help on using the repository browser.