Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/sc_signal.h

    r27 r17  
    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"
    27 
    28 #ifdef CONFIG_CHECK_FSM_RULES
     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"
    2927#include "fsm_rules.h"
    30 #endif
    3128
    3229namespace sc_core {
     
    4542        ///////////////////// DEPRECATED
    4643// C ANSI-only since it is needed to link with extern "C"
    47 // this declaration is not in casc.h since the CONFIG_CHECK_FSM_RULES macro
     44// this declaration is not in casc.h since the CHECK_FSM_RULES macro
    4845// is not defined.
    4946
     
    8279        size_t size = (sizeof (T)-1) / sizeof (base_type);
    8380        size_t i = 0;
    84         const base_type *pvalue = (const base_type*)(void*)(&value_);
     81        const base_type *pvalue = (const base_type*)(&value_);
    8582        do {
    8683#if 0
     
    9491                        const T          value_)
    9592{
    96   if (sizeof (T) > sizeof (base_type)) {
     93        if (sizeof (T) > sizeof (base_type)) {
    9794#if 0
    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_;
     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_;
    113110//      pending_write_vector[pending_write_vector_nb++].value = *(reinterpret_cast<const base_type*const>(&value_)); => bug !
    114     pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
     111  pending_write_vector[pending_write_vector_nb++].value = value_; // => bug avec blues !
    115112
    116113        // -> fix to use user-defined struct in sc_signal/sc_in/sc_out/sc_inout
     
    124121                return;
    125122#endif
    126   };
     123        };
    127124}
    128125
    129126inline bool is_posted_write ()
    130127{
    131   return pending_write_vector_nb > 0;
     128                return pending_write_vector_nb > 0;
    132129}
    133130
     
    142139class sc_signal_base : public sc_object, public sc_interface
    143140{
    144   //////
    145   // Internal
     141        //////
     142        // Internal
    146143  friend class sc_clock;
    147144  friend class sc_port_base;
    148145  void init ();
    149   //////                                 
     146        //////                           
    150147 
    151148
     
    161158  sc_signal_base(const char* name_);
    162159  sc_signal_base(const char* name_, void*);
    163   ~sc_signal_base();
     160        ~sc_signal_base();
    164161};
    165162
     
    168165{
    169166private:
    170   T val;
    171   typedef T                data_type;
     167        T val;
     168  typedef T  data_type;
    172169  typedef sc_signal < T >  this_type;
    173 
    174   ///////////
    175   // Internal
    176 public: void init ();
    177   ///////////
    178 
    179   //  virtual void update ();
     170        ///////////
     171        // Internal
     172        public: void init ();
     173        ///////////
     174//  virtual void update ();
    180175  void check_writer ();
    181176public:
    182177  // constructors, destructor
    183178  sc_signal ()
    184   { init (); }
     179        { init (); }
    185180  explicit sc_signal (const char *name_): sc_signal_base(name_)
    186   { init (); }
     181        { init (); }
    187182  /*virtual */~ sc_signal ()
    188183  {}
     
    232227sc_signal<T>::init()
    233228{
    234         set_pointer ((tab_t*)(void*)&val);
     229  set_pointer ((tab_t*)&val);
    235230  set_kind    (kind_string);
    236   sc_interface::init (sizeof (data_type));
     231        sc_interface::init (sizeof (data_type));
    237232  val = 0; /* The simulator initializes the signal/register to 0.    */
    238233           /* However, hardware initialization still has to be done. */
     
    250245                << " on signal " << name () << "\n";
    251246#endif
    252 #ifdef CONFIG_CHECK_FSM_RULES
     247#ifdef CHECK_FSM_RULES
    253248        // we can read value from sc_signal type (used like a register) at any time
    254249#endif 
     
    262257sc_signal<T>::write( const data_type& value_ )
    263258{
    264 #ifdef CONFIG_CHECK_FSM_RULES
     259#ifdef CHECK_FSM_RULES
    265260        if ((casc_fsm_step != TRANSITION)
    266261                        && ( casc_fsm_step != STIMULI)) {
     
    271266        }               
    272267#endif
    273 #ifdef CONFIG_DEBUG
     268#ifdef DEBUG
    274269  if (get_pointer() == NULL)
    275270  {
     
    278273  }
    279274#endif
    280 #ifdef CONFIG_CHECK_MULTIWRITING2REGISTER
     275#ifdef CHECK_MULTIWRITING2REGISTER
    281276  pending_writing2register_record_and_check (get_pointer ());
    282277#endif
Note: See TracChangeset for help on using the changeset viewer.