source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Interface.h @ 57

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