source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Signal.h @ 78

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

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 8.5 KB
Line 
1#ifndef morpheo_behavioural_Signal_h
2#define morpheo_behavioural_Signal_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
18#ifdef VHDL
19#include "Behavioural/include/Vhdl.h"
20#endif
21
22#include "Behavioural/include/Direction.h"
23#include "Behavioural/include/XML.h"
24#include "Common/include/ErrorMorpheo.h"
25#include "Common/include/ToBase2.h"
26#include "Common/include/ToString.h"
27#include "Common/include/Debug.h"
28
29namespace morpheo              {
30namespace behavioural          {
31
32  typedef enum {UNKNOW                     ,
33                BOOL                       ,
34                UINT8_T                    ,
35                UINT16_T                   ,
36                UINT32_T                   ,
37                UINT64_T                   } type_info_t;
38
39  typedef enum {PORT_VHDL_YES_TESTBENCH_YES,
40                PORT_VHDL_YES_TESTBENCH_NO ,
41                PORT_VHDL_NO_TESTBENCH_YES ,
42                PORT_VHDL_NO_TESTBENCH_NO  ,
43                CLOCK_VHDL_YES             ,
44                CLOCK_VHDL_NO              ,
45                RESET_VHDL_YES             ,
46                RESET_VHDL_NO              } presence_port_t;
47
48  class Signal
49  {
50    friend class Interface;
51
52    // -----[ fields ]----------------------------------------------------
53  private   : const std::string     _name          ;
54  private   : const direction_t     _direction     ;
55  private   : const presence_port_t _presence_port ;
56  private   :       uint32_t        _size          ;
57
58  private   : Signal *              _connect_to_signal       ;   // the actual implementaion, this signal link with one signal (but if signal is an output, it can be connect with many signal ...)
59  private   : Signal *              _connect_from_signal     ; // producter of signal. If NULL, then producteur is the current entity
60  private   : bool                  _is_allocate             ; // Have allocate a sc_in or sc_out port
61  private   : void *                _sc_signal               ; // sc_in or sc_out associated at this signal
62  private   : void *                _sc_signal_map           ; // sc_out generated this signal
63  private   : bool                  _is_map_as_toplevel_dest ; 
64  private   : bool                  _is_map_as_component_src ; 
65  private   : bool                  _is_map_as_component_dest;
66  private   : type_info_t           _type_info               ;
67
68#ifdef VHDL_TESTBENCH
69  private   : std::list<std::string> * _list_value    ;
70#endif
71
72    // -----[ methods ]---------------------------------------------------
73  public    :                   Signal          (std::string          name          ,
74                                                 direction_t     direction     ,
75                                                 uint32_t        size          ,
76                                                 presence_port_t presence_port = PORT_VHDL_YES_TESTBENCH_YES);
77  public    :                   Signal          (const Signal &);
78  public    :                   ~Signal         ();
79
80  public    : std::string            get_name                (void);
81  public    : uint32_t          get_size                (void);
82  public    : void              set_size                (uint32_t size);
83  public    : void              set_size_max            (uint32_t size);
84
85  public    : Signal *          get_connect_to_signal   (void);
86  public    : Signal *          get_connect_from_signal (void);
87  public    : direction_t       get_direction           (void);
88  public    : type_info_t       get_type_info           (void);
89
90  public    : bool              presence_vhdl           (void);
91  public    : bool              presence_testbench      (void);
92
93  public    : bool              test_map                (uint32_t depth, bool top_level);
94
95  public    : void              link                    (Signal * signal_dest,
96                                                         bool     signal_dest_is_port);
97
98  public    : void              connect                 (Signal * signal_dest);
99
100#ifdef SYSTEMC         
101  public    :template <typename T>
102             T                  read (void)
103    {
104      switch (_direction)
105        {
106        case IN  : {return read_in  <T>();}
107        case OUT : {return read_out <T>();}
108        default  : throw (ErrorMorpheo ("Signal \""+_name+"\" : direction unknow."));
109        }
110    }
111
112  public    :template <typename T>
113             T                  read_in (void)
114    {
115      switch (_type_info)
116        {
117        case BOOL     : return (static_cast<sc_in  <bool    > *>(_sc_signal_map)->read()); 
118        case UINT8_T  : return (static_cast<sc_in  <uint8_t > *>(_sc_signal_map)->read()); 
119        case UINT16_T : return (static_cast<sc_in  <uint16_t> *>(_sc_signal_map)->read());
120        case UINT32_T : return (static_cast<sc_in  <uint32_t> *>(_sc_signal_map)->read()); 
121        case UINT64_T : return (static_cast<sc_in  <uint64_t> *>(_sc_signal_map)->read()); 
122        default       : throw (ErrorMorpheo ("Signal \""+_name+"\" : type unknow."));
123        }
124    }
125
126  public    :template <typename T>
127             T                  read_out(void)
128    {
129      switch (_type_info)
130        {
131        case BOOL     : return (static_cast<sc_out <bool    > *>(_sc_signal_map)->read()); 
132        case UINT8_T  : return (static_cast<sc_out <uint8_t > *>(_sc_signal_map)->read()); 
133        case UINT16_T : return (static_cast<sc_out <uint16_t> *>(_sc_signal_map)->read());
134        case UINT32_T : return (static_cast<sc_out <uint32_t> *>(_sc_signal_map)->read()); 
135        case UINT64_T : return (static_cast<sc_out <uint64_t> *>(_sc_signal_map)->read()); 
136        default       : throw (ErrorMorpheo ("Signal \""+_name+"\" : type unknow."));
137        }
138    }
139
140#undef  FUNCTION
141#define FUNCTION "Signal::alloc"
142  public    : template <typename T>
143  void              alloc           (void * sc_signal)
144    {
145      log_printf(FUNC,Behavioural,FUNCTION,"Begin");
146
147      if (_type_info != UNKNOW)
148        throw (ErrorMorpheo ("Signal \""+_name+"\" : already allocate."));
149
150      _is_allocate    = true;
151      _sc_signal      = sc_signal;
152      _sc_signal_map  = sc_signal;
153
154      log_printf(TRACE,Behavioural,FUNCTION, "Allocation of %s - %.8x", _name.c_str(), (uint32_t)(_sc_signal_map));
155
156      if (typeid(T) == typeid(bool    ))
157        _type_info = BOOL;
158      else
159      if (typeid(T) == typeid(uint8_t ))
160        _type_info = UINT8_T;
161      else
162      if (typeid(T) == typeid(uint16_t))
163        _type_info = UINT16_T;
164      else
165      if (typeid(T) == typeid(uint32_t))
166        _type_info = UINT32_T;
167      else
168      if (typeid(T) == typeid(uint64_t))
169        _type_info = UINT64_T;
170      else
171        _type_info = UNKNOW;
172
173      log_printf(FUNC,Behavioural,FUNCTION,"End");
174    }
175#endif
176
177#ifdef VHDL
178  public    : void              set_port        (Vhdl * & vhdl);
179#  ifdef VHDL_TESTBENCH
180  public    : Signal *          get_clock       (void);
181  public    : Signal *          get_reset       (void);
182  public    : uint32_t          get_reset_cycle (bool active_low);
183
184  public    : void              set_signal      (Vhdl * & vhdl);
185  public    : void              get_name_vhdl   (std::list<std::string> * & list_signal);
186
187  public    : void              testbench        (void);
188  public    : void              testbench_body   (Vhdl           * & vhdl          ,
189                                                  std::string             counter_name  ,
190                                                  std::string             reset_name    );
191  public    : void              testbench_test_ok(Vhdl           * & vhdl          );
192#  endif
193#endif
194  public    : XML               toXML           (void);
195
196  public    : friend std::ostream&   operator<<      (std::ostream& output_stream,
197                                                      morpheo::behavioural::Signal & x);
198
199  };
200}; // end namespace behavioural         
201
202  template<>           inline std::string toString<morpheo::behavioural::presence_port_t>(const morpheo::behavioural::presence_port_t& x)
203  {
204    switch (x)
205      {
206      case morpheo::behavioural::PORT_VHDL_YES_TESTBENCH_YES : return "Port  is in VHDL's model and TestBench's model" ; break;
207      case morpheo::behavioural::PORT_VHDL_YES_TESTBENCH_NO  : return "Port  is in VHDL's model                      " ; break;
208      case morpheo::behavioural::PORT_VHDL_NO_TESTBENCH_YES  : return "Port  is in                  TestBench's model" ; break;
209      case morpheo::behavioural::PORT_VHDL_NO_TESTBENCH_NO   : return "Port  is in none model                        " ; break;
210      case morpheo::behavioural::CLOCK_VHDL_YES              : return "Clock is in VHDL's model                     " ; break;
211      case morpheo::behavioural::CLOCK_VHDL_NO               : return "Clock is not in VHDL's model                 " ; break;
212      case morpheo::behavioural::RESET_VHDL_YES              : return "Reset is in VHDL's model                     " ; break;
213      case morpheo::behavioural::RESET_VHDL_NO               : return "Reset is not in VHDL's model                 " ; break;
214      default                                                : return "";                                               break;
215      }
216  }
217
218}; // end namespace morpheo             
219
220#endif
Note: See TracBrowser for help on using the repository browser.