source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Signal_link.cpp @ 129

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

1) Debug_Signal

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1/*
2 * $Id: Signal_link.cpp 129 2009-06-29 16:38:40Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/include/Signal.h"
9
10
11namespace morpheo              {
12namespace behavioural          {
13
14#undef  FUNCTION
15#define FUNCTION "Signal::link"
16  void Signal::link (Signal * signal_dest,
17                     bool     signal_dest_is_port)
18  {
19    // signal_dest_is_port == 1 when the signal dest is in a top level interface. (else, signal_dest is type "INTERNAL")
20   
21    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
22
23    Signal * signal_src = this;
24
25    // Test
26    if (signal_src ->_is_allocate == false)
27      throw (ERRORMORPHEO (FUNCTION,"Signal \""+_name+"\", can't map with signal \""+        get_name()+"\", because the first signal is not already allocate."));
28    if (signal_dest->_is_allocate == false)
29      throw (ERRORMORPHEO (FUNCTION,"Signal \""+_name+"\", can't map with signal \""+signal_dest->get_name()+"\", because the second signal is not already allocate.\n"));
30
31    // Test if type is compatible
32    if (_type_info != signal_dest->_type_info)
33      throw (ERRORMORPHEO (FUNCTION,toString(_("Signal \"%s\" can't been linked with signal \"%s\" : incompatible type (%s != %s).\n"),
34                                             _name.c_str(),
35                                             signal_dest->get_name().c_str(),
36                                             toString(_type_info).c_str(),
37                                             toString(signal_dest->_type_info).c_str())));
38
39    // List of all case
40    //
41    //            src         dest
42    // COMPONENT {IN } ----- {SIG} SIGNAL
43    // COMPONENT {OUT} ----- {SIG} SIGNAL
44    //
45    // COMPONENT {IN } ----- {IN } PORT
46    // COMPONENT {OUT} ----- {OUT} PORT
47
48    // list valid case
49
50    if (not (    signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == IN      )) or
51                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == OUT     )))) and
52        not (not signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == INTERNAL)) or
53                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == INTERNAL)))))
54      throw (ERRORMORPHEO (FUNCTION,"Signal \""+_name+"\" can't been linked with signal \""+signal_dest->get_name()+"\" : illegal direction ("+toString(signal_src->_direction)+" with "+toString(signal_dest->_direction)+")."));
55
56
57    if (_size != signal_dest->get_size())
58      msgWarning(_("The size of the signal \"%s\" (%d) is different with the signal \"%s\" (%d).\n"),
59                 _name.c_str(),
60                 _size,
61                 signal_dest->get_name().c_str(),
62                 signal_dest->get_size());
63
64    // Multi consumer is authorized , no to multi producer!
65    bool source_have_multi_consumer      = (signal_src ->_connect_to_signal != NULL);
66//     bool destination_have_multi_producer = (signal_dest->_connect_from_signal != NULL) and (signal_dest_is_port == false);
67//     if (destination_have_multi_producer)
68// //       throw (ERRORMORPHEO (FUNCTION,"Signal \""+_name+"\" can't been linked with signal \""+signal_dest->get_name()+"\" : destination have multi producer."));
69//       log_printf(INFO,Behavioural,FUNCTION,"Signal \"%s\" can't been linked with signal \"%s\" : destination have multi producer.",_name.c_str(),signal_dest->get_name().c_str());
70
71    // update info source
72    signal_src ->_connect_to_signal       = signal_dest;
73    signal_src ->_is_map_as_component_src = true;
74
75    // update info destination
76    if (signal_dest_is_port == true)
77      signal_dest->_is_map_as_toplevel_dest = true; // because toplevel port can't be a source
78    else
79      // signal_dest is a internal signal
80      if (signal_src->_direction == OUT)
81        signal_dest->_is_map_as_component_dest = true;
82      else
83        signal_dest->_is_map_as_component_src  = true;
84   
85    // an internal signal and port can't be a source.
86    // also, to fill the connect_to_signal's field
87    if (signal_dest->_direction == INTERNAL)
88      if (signal_src->_direction == OUT)
89        signal_dest->_connect_from_signal = signal_src;
90      else
91        signal_dest->_connect_to_signal   = signal_src;
92    else
93      signal_dest->_connect_from_signal   = signal_src;
94   
95    // vhdl_testbench : to read an output producte by a internal component
96    // TODO : à vérifier !!!!!!!!!!!!
97    if ((signal_dest_is_port == true) and
98        (signal_src ->_direction == OUT))
99      signal_dest->_sc_signal_map = signal_src ->_sc_signal_map;
100
101    // A signal can be connect once
102    if (not source_have_multi_consumer)
103      connect (signal_dest);
104
105    log_printf(FUNC,Behavioural,FUNCTION,"End");
106  };
107
108}; // end namespace behavioural         
109}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.