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

Last change on this file since 113 was 113, checked in by rosiere, 15 years ago

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1#ifdef VHDL
2/*
3 * $Id: Component_vhdl_instance.cpp 113 2009-04-14 18:39:12Z 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      bool print_comment = false;
30      if (not list_interface->empty())
31        {
32          while (j != list_interface->end())
33            {
34              // for each signal
35              std::list<Signal *>         * list_signal = (*j)->get_signal_list();
36              std::list<Signal *>::iterator k           = list_signal->begin();
37              if (not list_signal->empty())
38                {
39                  while (k != list_signal->end())
40                    {
41                      Signal * signal = (*k);
42
43                      // test if is connect with external interface or with an another component AND if this port is mapped.
44                      if ( (signal->get_direction() == OUT) and
45                           (signal->get_connect_from_signal () != NULL) )
46                        {
47                          if (not print_comment)
48                            {
49                              vhdl->set_body ("------------------------------------------------------");
50                              vhdl->set_body ("-- Output's Buffer");
51                              vhdl->set_body ("------------------------------------------------------");
52                             
53                              print_comment = true;
54                            }
55
56                          // Create name
57                          std::string signal_name = "signal_"+toString(cpt++);
58                         
59                          tab [signal                           ] = signal_name;
60                          tab [signal->get_connect_from_signal()] = signal_name;
61                         
62                          // Add a new signal and the affectation
63                          vhdl->set_signal (signal_name, signal->get_size());
64                          vhdl->set_body   (signal->get_name()+" <= "+signal_name+";");
65                        }
66                      else
67                        {
68                          tab [signal                   ] = signal->get_name();
69                        }
70                      ++k;
71                    }
72                }
73              ++j;
74            }
75
76          if (print_comment)
77            {
78              vhdl->set_body ("");
79              vhdl->set_body ("------------------------------------------------------");
80              vhdl->set_body ("");
81            }
82        }
83    }
84
85    vhdl->set_library_work (_entity->get_name() + "_Pack");
86
87    // for each entity
88    std::list<Tcomponent_t *>         * list_component = _list_component;
89    std::list<Tcomponent_t *>::iterator i              = list_component->begin();
90    if (not list_component->empty())
91      {
92        while (i != list_component->end())
93          {
94            Entity *    entity       = (*i)->_entity;
95            Tinstance_t instance     = (*i)->_instance;
96            std::string architecture = (*i)->_architecture;
97            std::string package      = "work";
98           
99            if (instance & INSTANCE_LIBRARY)
100              vhdl->set_library_work (entity->get_name() + "_Pack");
101
102            if (instance & INSTANCE_COMPONENT)
103            {
104              std::list<std::string> list_port_map;
105             
106              // for each interface
107              std::list<Interface_fifo *>         * list_interface = entity->get_interfaces_list()->get_interface_list();
108              std::list<Interface_fifo *>::iterator j              = list_interface->begin();
109              if (not list_interface->empty())
110                {
111                  while (j != list_interface->end())
112                    {
113                      // for each signal
114                      std::list<Signal *>         * list_signal = (*j)->get_signal_list();
115                      std::list<Signal *>::iterator k           = list_signal->begin();
116                      if (not list_signal->empty())
117                        {
118                          while (k != list_signal->end())
119                            {
120                              // test if is connect with external interface or with an another component.
121                              Signal * signal_src  = (*k);
122                             
123                              if (signal_src->presence_vhdl () == true)
124                                {
125                                  Signal * signal_dest = signal_src->get_connect_to_signal();
126                                  std::string   name_src    = signal_src->get_name();
127                                  std::string   name_dest;
128                                 
129//                              // Test if destination signal is a interface port ?
130//                              if (_entity->find_signal(signal_dest) == false)
131//                                {
132                                  // find if signal is already link
133                                  std::map<Signal *,std::string>::iterator it = tab.find(signal_dest); 
134                                  if (tab.find(signal_dest) == tab.end())
135                                    {
136                                      // Create name
137                                      name_dest = "signal_"+toString(cpt++);
138                                     
139                                      tab [signal_src ] = name_dest;
140                                      tab [signal_dest] = name_dest;
141                                     
142                                      // Add a new signal
143                                      vhdl->set_signal (name_dest, signal_src->get_size());
144                                    }
145                                  else
146                                    {
147                                      // find !!!!
148                                      name_dest = (*it).second;
149                                      tab [signal_src ] = name_dest;
150                                    }
151//                                }
152//                              else
153//                                {
154//                                  // Test if output
155//                                  if (signal_dest->get_direction() == OUT)
156//                                    {
157//                                      // Take buffer's signal
158//                                      map<Signal *,std::string>::iterator it = tab.find(signal_dest);
159//                                      name_dest        = (*it).second;
160
161//                                      cout << " * OUT - name : " << name_dest << endl;
162//                                    }
163//                                  else
164//                                    {
165//                                      name_dest = signal_dest->get_name();
166//                                      cout << " * IN  - name : " << name_dest << endl;
167//                                    }                             
168//                                }
169                                 
170                                  vhdl->set_body_component_port_map (list_port_map,
171                                                                     name_src , signal_src ->get_size(),
172                                                                     name_dest, signal_dest->get_size() );
173                                }
174                              ++k;
175                            }
176                        }
177                      ++j;
178                    }
179                }
180              vhdl->set_body_component ("instance_"+entity->get_name(),
181                                        entity->get_name(),
182                                        architecture,
183                                        package,
184                                        list_port_map);
185             
186            }
187            ++i;
188          }
189      }
190    log_printf(FUNC,Behavioural,FUNCTION,"End");
191  };
192 
193}; // end namespace behavioural
194}; // end namespace morpheo
195#endif
Note: See TracBrowser for help on using the repository browser.