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

Last change on this file since 65 was 65, checked in by rosiere, 17 years ago

register_unit : systemc et VHDL ok

File size: 2.8 KB
Line 
1/*
2 * $Id$
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    log_printf(FUNC,Behavioural,FUNCTION,"Begin");
20
21    Signal * signal_src = this;
22
23    // Test
24    if (signal_src ->_is_allocate == false)
25      throw (ErrorMorpheo ("<Signal::link> Signal \""+_name+"\", can't map with signal \""+        get_name()+"\", because the first signal is not already allocate."));
26    if (signal_dest->_is_allocate == false)
27      throw (ErrorMorpheo ("<Signal::link> Signal \""+_name+"\", can't map with signal \""+signal_dest->get_name()+"\", because the second signal is not already allocate."));
28    if (signal_src ->_is_map_as_src  == true)
29      throw (ErrorMorpheo ("<Signal::mapping> Can't mapping signal \""+_name+"\" with \""+signal_dest->get_name()+"\", because the first signal is already mapped."));
30
31    // List of all case
32    //
33    //            src         dest
34    // COMPONENT {IN } ----- {SIG} SIGNAL
35    // COMPONENT {OUT} ----- {SIG} SIGNAL
36    //
37    // COMPONENT {IN } ----- {IN } PORT
38    // COMPONENT {OUT} ----- {OUT} PORT
39
40    // list valid case
41    if (not (    signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == IN      )) or
42                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == OUT     )))) and
43        not (not signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == INTERNAL)) or
44                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == INTERNAL)))))
45      throw (ErrorMorpheo ("<Signal::link> Signal \""+_name+"\" can't been linked with signal \""+signal_dest->get_name()+"\" : illegal direction ("+toString(signal_src->_direction)+" with "+toString(signal_dest->_direction)+")."));
46
47    // update info source
48    signal_src ->_connect_to_signal   = signal_dest;
49    signal_src ->_is_map_as_src       = true;
50   
51    // update info destination
52    signal_dest->_connect_from_signal = signal_src;
53    signal_dest->_is_map_as_dest      = true;
54
55    // an internal signal and port can't be a source.
56    // also, to fill the connect_to_signal's field
57    if ((signal_src->_direction == OUT) and
58        (signal_dest->_direction == INTERNAL))
59      {
60        signal_dest->_connect_to_signal = signal_src;
61      }
62
63    // vhdl_testbench : to read an output producte by a internal component
64    // TODO : à vérifier !!!!!!!!!!!!
65    if ((signal_dest_is_port == true) and
66        (signal_src ->_direction == OUT))
67      signal_dest->_sc_signal_map = signal_src ->_sc_signal_map;
68   
69    connect (signal_dest);
70
71    log_printf(FUNC,Behavioural,FUNCTION,"End");
72  };
73
74}; // end namespace behavioural         
75}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.