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

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

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