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

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

Modification en profondeur de Component-port_map.
Compilation ok pour Register_unit ... a tester (systemC et vhdl)

File size: 2.9 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    //     log_printf(TRACE,Behavioural,FUNCTION, " * sc_signal (before) %.8x - %.8x", (uint32_t)(_sc_signal_map), (uint32_t)(signal_dest->_sc_signal_map));
32
33    // List of all case
34    //
35    //            src         dest
36    // COMPONENT {IN } ----- {SIG} SIGNAL
37    // COMPONENT {OUT} ----- {SIG} SIGNAL
38    //
39    // COMPONENT {IN } ----- {IN } PORT
40    // COMPONENT {OUT} ----- {OUT} PORT
41
42    // list valid case
43    if (not (    signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == IN      )) or
44                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == OUT     )))) and
45        not (not signal_dest_is_port and (((signal_src->_direction == IN ) and (signal_dest->_direction == INTERNAL)) or
46                                          ((signal_src->_direction == OUT) and (signal_dest->_direction == INTERNAL)))))
47      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)+")."));
48
49    // update info source
50    signal_src ->_connect_to_signal   = signal_dest;
51    signal_src ->_is_map_as_src       = true;
52   
53    // update info destination
54    signal_dest->_connect_from_signal = signal_src;
55    signal_dest->_is_map_as_dest      = true;
56
57    // vhdl_testbench : to read an output producte by a internal component
58    // TODO : à vérifier !!!!!!!!!!!!
59    if ((signal_dest_is_port == true) and
60        (signal_src ->_direction == OUT))
61      signal_dest->_sc_signal_map = signal_src ->_sc_signal_map;
62   
63    connect (signal_dest);
64
65    //  log_printf(TRACE,Behavioural,FUNCTION, " * sc_signal (after ) %.8x - %.8x", (uint32_t)(_sc_signal_map), (uint32_t)(signal_dest->_sc_signal_map));
66   
67    log_printf(FUNC,Behavioural,FUNCTION,"End");
68  };
69
70}; // end namespace behavioural         
71}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.