Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/sc_signal.h

    r17 r27  
    1515
    1616// Define registers writing method
    17 #include<iostream>
    18 #include<cstdlib>
    19 #include"sc_fwd.h"
    20 #include"sc_nbdefs.h"
    21 //#include"sc_event_finder.h"
    22 //#include"sc_event.h"
    23 #include"sc_time.h" // SC_ZERO_TIME
    24 #include"sc_object.h"
    25 #include"sc_interface.h"
    26 #include"internal_ext.h"
     17#include <iostream>
     18#include <cstdlib>
     19#include "sc_fwd.h"
     20#include "sc_nbdefs.h"
     21//#include "sc_event_finder.h"
     22//#include "sc_event.h"
     23#include "sc_time.h" // SC_ZERO_TIME
     24#include "sc_object.h"
     25#include "sc_interface.h"
     26#include "internal_ext.h"
     27
     28#ifdef CONFIG_CHECK_FSM_RULES
    2729#include "fsm_rules.h"
     30#endif
    2831
    2932namespace sc_core {
     
    4245        ///////////////////// DEPRECATED
    4346// C ANSI-only since it is needed to link with extern "C"
    44 // this declaration is not in casc.h since the CHECK_FSM_RULES macro
     47// this declaration is not in casc.h since the CONFIG_CHECK_FSM_RULES macro
    4548// is not defined.
    4649
     
    7982        size_t size = (sizeof (T)-1) / sizeof (base_type);
    8083        size_t i = 0;
    81         const base_type *pvalue = (const base_type*)(&value_);
     84        const base_type *pvalue = (const base_type*)(void*)(&value_);
    8285        do {
    8386#if 0
     
    9194                        const T          value_)
    9295{
    93         if (sizeof (T) > sizeof (base_type)) {
     96  if (sizeof (T) > sizeof (base_type)) {
    9497#if 0
    95     cout << "sizeof (T) = " << sizeof (T) << " (base_type = " << sizeof
    96 (base_type) << "\n";
    97 #endif
    98                 post_multiwrite (pointer_,value_);
    99         } else {
    100 #if defined(DEBUG)
    101         if (pending_write_vector_nb >= pending_write_vector_capacity) {
    102         //if (pending_write_vector_nb >= pending_write_vector_capacity * sizeof(pending_write)) {
    103                 std::cerr << "Error : The array for posted writing on register is too small.\n";
    104                 std::cerr << "Up to 1 writing per register is allowed during a cycle.\n";
    105                 std::cerr << "Please check the hardware description.\n";
    106                 exit (-1);
    107         }
    108 #endif // DEBUG
    109   pending_write_vector[pending_write_vector_nb].pointer = pointer_;
     98  std::cout << "sizeof (T) = " << sizeof (T)
     99            << " (base_type = " << sizeof (base_type) << "\n";
     100#endif
     101  post_multiwrite (pointer_,value_);
     102  } else {
     103#if defined(CONFIG_DEBUG)
     104    if (pending_write_vector_nb >= pending_write_vector_capacity) {
     105      //if (pending_write_vector_nb >= pending_write_vector_capacity * sizeof(pending_write)) {
     106      std::cerr << "Error : The array for posted writing on register is too small.\n";
     107      std::cerr << "Up to 1 writing per register is allowed during a cycle.\n";
     108      std::cerr << "Please check the hardware description.\n";
     109      exit (-1);
     110    }
     111#endif // CONFIG_DEBUG
     112    pending_write_vector[pending_write_vector_nb].pointer = pointer_;
    110113//      pending_write_vector[pending_write_vector_nb++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
    111   pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
     114    pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
    112115
    113116        // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout
     
    121124                return;
    122125#endif
    123         };
     126  };
    124127}
    125128
    126129inline bool is_posted_write ()
    127130{
    128                 return pending_write_vector_nb > 0;
     131  return pending_write_vector_nb > 0;
    129132}
    130133
     
    139142class sc_signal_base : public sc_object, public sc_interface
    140143{
    141         //////
    142         // Internal
     144  //////
     145  // Internal
    143146  friend class sc_clock;
    144147  friend class sc_port_base;
    145148  void init ();
    146         //////                           
     149  //////                                 
    147150 
    148151
     
    158161  sc_signal_base(const char* name_);
    159162  sc_signal_base(const char* name_, void*);
    160         ~sc_signal_base();
     163  ~sc_signal_base();
    161164};
    162165
     
    165168{
    166169private:
    167         T val;
    168   typedef T  data_type;
     170  T val;
     171  typedef T                data_type;
    169172  typedef sc_signal < T >  this_type;
    170         ///////////
    171         // Internal
    172         public: void init ();
    173         ///////////
    174 //  virtual void update ();
     173
     174  ///////////
     175  // Internal
     176public: void init ();
     177  ///////////
     178
     179  //  virtual void update ();
    175180  void check_writer ();
    176181public:
    177182  // constructors, destructor
    178183  sc_signal ()
    179         { init (); }
     184  { init (); }
    180185  explicit sc_signal (const char *name_): sc_signal_base(name_)
    181         { init (); }
     186  { init (); }
    182187  /*virtual */~ sc_signal ()
    183188  {}
     
    227232sc_signal<T>::init()
    228233{
    229   set_pointer ((tab_t*)&val);
     234        set_pointer ((tab_t*)(void*)&val);
    230235  set_kind    (kind_string);
    231         sc_interface::init (sizeof (data_type));
     236  sc_interface::init (sizeof (data_type));
    232237  val = 0; /* The simulator initializes the signal/register to 0.    */
    233238           /* However, hardware initialization still has to be done. */
     
    245250                << " on signal " << name () << "\n";
    246251#endif
    247 #ifdef CHECK_FSM_RULES
     252#ifdef CONFIG_CHECK_FSM_RULES
    248253        // we can read value from sc_signal type (used like a register) at any time
    249254#endif 
     
    257262sc_signal<T>::write( const data_type& value_ )
    258263{
    259 #ifdef CHECK_FSM_RULES
     264#ifdef CONFIG_CHECK_FSM_RULES
    260265        if ((casc_fsm_step != TRANSITION)
    261266                        && ( casc_fsm_step != STIMULI)) {
     
    266271        }               
    267272#endif
    268 #ifdef DEBUG
     273#ifdef CONFIG_DEBUG
    269274  if (get_pointer() == NULL)
    270275  {
     
    273278  }
    274279#endif
    275 #ifdef CHECK_MULTIWRITING2REGISTER
     280#ifdef CONFIG_CHECK_MULTIWRITING2REGISTER
    276281  pending_writing2register_record_and_check (get_pointer ());
    277282#endif
Note: See TracChangeset for help on using the changeset viewer.