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

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

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

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