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

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