source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Interface.h @ 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: 7.5 KB
Line 
1#ifndef morpheo_behavioural_Interface_h
2#define morpheo_behavioural_Interface_h
3
4/*
5 * $Id$
6 *
7 * [ Description ]
8 *
9 */
10
11#ifdef SYSTEMC
12#include "systemc.h"
13#endif
14
15#include <stdint.h>
16#include <iostream>
17#include <list>
18#include "Behavioural/include/Signal.h"
19#include "Behavioural/include/Direction.h"
20#include "Behavioural/include/Localisation.h"
21#ifdef VHDL
22#include "Behavioural/include/Vhdl.h"
23#endif
24#include "Common/include/ChangeCase.h"
25#include "Common/include/ToString.h"
26#include "Common/include/ErrorMorpheo.h"
27#include "Common/include/Debug.h"
28#include "Behavioural/include/Usage.h"
29
30using namespace std;
31
32namespace morpheo              {
33namespace behavioural          {
34
35  class Interface
36  {
37    // -----[ fields ]----------------------------------------------------
38  protected : const string          _name         ;
39#ifdef POSITION
40  protected : const direction_t     _direction    ;
41  protected : const localisation_t  _localisation ;
42#endif
43  protected : const Tusage_t        _usage;
44
45#ifdef POSITION
46  protected :       string          _comment      ;
47#endif
48
49  protected : list<Signal *>      * _list_signal  ;
50
51#ifdef POSITION
52  protected :       bool            _is_map       ;
53  protected :       void          * _entity_map   ; // Entity -> erreur cyclique
54  protected :       void          * _interface_map; // pour être homogène avec _entity_map
55#endif
56
57#ifdef VHDL_TESTBENCH
58  private   : uint32_t              _nb_cycle     ;
59#endif
60   
61    // -----[ methods ]---------------------------------------------------
62  public    :                       Interface            (string         name       
63#ifdef POSITION
64                                                          ,direction_t    direction   
65                                                          ,localisation_t localisation
66#endif
67                                                          ,Tusage_t       usage=USE_ALL
68                                                          );
69
70  public    :                       Interface            (const Interface    & interface);
71  public    :                       ~Interface           ();
72
73  public    : string                get_name             ();
74
75#ifdef POSITION
76  public    : void                  set_comment          (string comment);
77  protected : string                get_comment          (void          );
78#endif
79
80  protected : string                signal_name          (string      name_interface,
81                                                          string      name_signal   ,
82                                                          direction_t direction     );
83
84  public    : Signal *              find_signal          (string name);
85  public    : bool                  find_signal          (Signal * signal);
86
87  protected : string                get_signal           (void);
88  public    : Signal *              set_signal           (string          name     ,
89                                                          direction_t     direction,
90                                                          uint32_t        size     ,
91                                                          presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES);
92  public    : list<Signal *>      * get_signal_list      (void);
93
94#ifdef SYSTEMC
95  public    : sc_in_clk *           set_signal_clk       (string          name     ,
96                                                          uint32_t        size     ,
97                                                          presence_port_t presence_port=CLOCK_VHDL_YES)
98    {
99      log_printf(FUNC,Behavioural,"set_signal_clk","Begin");
100
101      if ((presence_port != CLOCK_VHDL_YES) and
102          (presence_port != CLOCK_VHDL_NO ))
103        throw ErrorMorpheo ("Signal \""+name+"\" is a clock, bad presence_port.");
104
105      Signal    * sig  = set_signal (name, IN , size, presence_port);
106      sc_in_clk * port;
107
108      if (_usage & USE_SYSTEMC)
109        {
110          port = new sc_in_clk (sig->_name.c_str());
111          sig->alloc<bool> (static_cast<void *>(port));
112        }
113      else
114        {
115          port = NULL;
116        }
117
118      log_printf(FUNC,Behavioural,"set_signal_clk","End");
119
120      return port;
121    };
122
123  public    : template <typename T>
124              sc_in <T> *           set_signal_in       (string          name     ,
125                                                         uint32_t        size     ,
126                                                         presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES)
127    {
128      log_printf(FUNC,Behavioural,"set_signal_in","Begin");
129
130      if ((presence_port == CLOCK_VHDL_YES) or
131          (presence_port == CLOCK_VHDL_NO ))
132        throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port.");
133
134      Signal    * sig  = set_signal (name, IN , size, presence_port);
135      sc_in <T> * port;
136
137      if (_usage & USE_SYSTEMC)
138        {
139          port = new sc_in <T> (sig->_name.c_str());
140          sig->alloc<T> (static_cast<void *>(port));
141        }
142      else
143        {
144          port = NULL;
145        }
146
147      log_printf(FUNC,Behavioural,"set_signal_in","End");
148
149      return port;
150    };
151
152  public    : template <typename T>
153              sc_out <T> *          set_signal_out      (string          name     ,
154                                                         uint32_t        size     ,
155                                                         presence_port_t presence_port=PORT_VHDL_YES_TESTBENCH_YES)
156    {
157      log_printf(FUNC,Behavioural,"set_signal_out","Begin");
158
159      if ((presence_port == CLOCK_VHDL_YES) or
160          (presence_port == CLOCK_VHDL_NO ))
161        throw ErrorMorpheo ("Signal \""+name+"\" is not a clock, bad presence_port.");
162
163      Signal * sig = set_signal (name, OUT , size, presence_port);
164      sc_out <T> * port;
165
166      if (_usage & USE_SYSTEMC)
167        {
168          port = new sc_out <T> (sig->_name.c_str());
169          sig->alloc<T> (static_cast<void *>(port));
170        }
171      else
172        {
173          port = NULL;
174        }
175
176      log_printf(FUNC,Behavioural,"set_signal_out","End");
177
178      return port;
179    };
180
181  public    : template <typename T>
182              sc_signal <T> *       set_signal_internal (string   name,
183                                                         uint32_t size)
184    {
185      log_printf(FUNC,Behavioural,"set_signal_internal","Begin");
186
187      Signal * sig = set_signal (name, INTERNAL , size, PORT_VHDL_NO_TESTBENCH_NO);
188      sc_signal <T> * port;
189
190      if (_usage & USE_SYSTEMC)
191        {
192          port = new sc_signal <T> (sig->_name.c_str());
193          sig->alloc<T> (static_cast<void *>(port));
194        }
195      else
196        {
197          port = NULL;
198        }
199
200      log_printf(FUNC,Behavioural,"set_signal_internal","End");
201
202      return port;
203    };
204
205#endif
206
207#ifdef VHDL
208  public    : void                  set_port             (Vhdl * & vhdl);
209#  ifdef VHDL_TESTBENCH
210  public    : void                  set_signal           (Vhdl * & vhdl);
211  public    : void                  get_signal           (list<string> * & list_signal);
212#  endif
213#endif
214#ifdef VHDL_TESTBENCH
215  public    : uint32_t              get_cycle            (void);
216  public    : Signal *              get_clock            (void);
217  public    : Signal *              get_reset            (void);
218
219  public    : void                  testbench            (void);
220  public    : void                  testbench_cycle      (void);
221  public    : void                  testbench_body       (Vhdl           * & vhdl          ,
222                                                          string             counter_name  ,
223                                                          string             reset_name    );
224  public    : string                testbench_test       (Vhdl           * & vhdl        ,
225                                                          string             counter_name,
226                                                          string             reset_name);
227  public    : string                testbench_test_ok    (Vhdl           * & vhdl        );
228  protected : string                testbench_test_name   (Vhdl           * & vhdl);
229  protected : string                testbench_test_ok_name(Vhdl           * & vhdl);
230  protected : string                testbench_test_transaction_name(Vhdl           * & vhdl);
231#endif
232
233  public    : bool                  test_map             (bool top_level);
234
235#ifdef POSITION
236  public    : void                  interface_map        (void * entity,
237                                                          void * interface);
238  public    : XML                   toXML                (void);
239  public    : XML                   toXML_mapping        (void);
240#endif
241  public    : friend ostream&       operator<<           (ostream& output_stream,
242                                                          morpheo::behavioural::Interface & x);
243
244  };
245
246}; // end namespace behavioural         
247}; // end namespace morpheo             
248
249#endif
Note: See TracBrowser for help on using the repository browser.