source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Component_port_map.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: 4.4 KB
Line 
1/*
2 * $Id: Component_port_map.cpp 113 2009-04-14 18:39:12Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/include/Component.h"
9
10namespace morpheo              {
11namespace behavioural          {
12
13#undef  FUNCTION
14#define FUNCTION "Component::port_map"
15  void Component::port_map (std::string component_src ,
16                            std::string port_src      ,
17                            std::string component_dest,
18                            std::string port_dest     )
19  {
20    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
21
22//     log_printf(INFO,Behavioural,FUNCTION,"Map %s.%s with %s.%s",
23//             component_src.c_str(),
24//             port_src.c_str(),
25//             component_dest.c_str(),
26//             port_dest.c_str());
27
28    std::string name_entity = _entity->get_name();
29
30    // First entity
31    Entity * entity_dest = find_entity(component_dest);
32
33    if (entity_dest == NULL)
34      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but the component \""+component_dest+"\" is unknow.\n"));
35
36    Signal * signal_dest = entity_dest->find_signal (port_dest);
37
38    if (signal_dest == NULL)
39      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\",try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but the component \""+component_dest+"\" have not the signal \""+port_dest+"\".\n"));
40
41    // Second entity
42    Entity * entity_src = find_entity(component_src);
43
44    if (entity_src == NULL)
45      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but the component \""+component_src+"\" is unknow.\n"));
46
47    Signal * signal_src = entity_src->find_signal (port_src);
48
49    if (signal_src == NULL)
50      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but the component \""+component_src+"\" have not the signal \""+port_src+"\".\n"));
51
52    // If all is ok, mapping
53    log_printf(TRACE,Behavioural,FUNCTION, _("Signal \"%s.%s\"\tlink with \"%s.%s\"")
54               ,entity_src ->get_name().c_str()
55               ,signal_src ->get_name().c_str()
56               ,entity_dest->get_name().c_str()
57               ,signal_dest->get_name().c_str());
58
59    // need an internal signal ?
60    bool src_is_port  = (entity_src  == _entity);
61    bool dest_is_port = (entity_dest == _entity);
62
63    if (src_is_port == true)
64      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but the component \""+component_src+" is the Top_level, and we can't be use interface's port of the top level as a source.\n"));
65   
66    // 2 cases :
67    //  a) dest is a top level port -> direct connection
68    //  b) dest is a component port -> need internal signal
69    if (dest_is_port == false)
70      {
71        // 1) find productor of signal
72        //       
73        // Interface      Component
74        //    |              |     
75        //  ----> (IN)     --X-> (IN)
76        //    |              |     
77        //  <-X-- (OUT)    <---- (OUT)
78        //    |              |       
79       
80        Signal * signal_productor;
81        Entity * entity_productor;
82        Signal * signal_consumer ;
83        Entity * entity_consumer ;
84
85        bool     src_is_productor = (signal_src->get_direction() == OUT);
86
87        if (src_is_productor == true)
88          {
89            signal_productor = signal_src ;
90            entity_productor = entity_src ;
91            signal_consumer  = signal_dest;
92            entity_consumer  = entity_dest;
93          }
94        else
95          {
96            signal_productor = signal_dest;
97            entity_productor = entity_dest;
98            signal_consumer  = signal_src ;
99            entity_consumer  = entity_src ;
100          }
101
102        // Create internal signal
103        signal_dest= signal_internal (entity_productor,
104                                      signal_productor,
105                                      entity_consumer ,
106                                      signal_consumer );
107        signal_dest->set_size_max(signal_src->get_size());
108      }
109   
110    try
111      {
112        signal_src->link(signal_dest,
113                         dest_is_port);
114      }
115    catch (morpheo::ErrorMorpheo & error)
116      {
117      throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", try map \""+component_src+"."+port_src+"\" with \""+component_dest+"."+port_dest+"\" but "+error.what ()));
118      }
119    //catch (...)
120    //  {
121    //  }
122
123    log_printf(FUNC,Behavioural,FUNCTION,"End");
124  };
125
126}; // end namespace behavioural         
127}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.