Changeset 22 for sources/src/sc_int.h


Ignore:
Timestamp:
Apr 16, 2009, 2:46:01 PM (15 years ago)
Author:
buchmann
Message:

Fix:

  • add missing system header include
  • add a namespace path to atoi

And... code cleanup:

  • bunch of various operators that share the same implementation now are using the same #define.
  • indent and tab/space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/sc_int.h

    r1 r22  
    1818#include <sc_logic.h>
    1919#include <sc_bv.h>
     20#include <cstdlib>
    2021
    2122// ----------------------------------------------------------------------------
     
    135136  sc_int()                 { val = 0; }
    136137//  sc_int(data_type val_)  { val = 0; write (val_); }
    137   sc_int (const char *a)   { val = 0; write (atoi (a)); }
     138  sc_int (const char *a)   { val = 0; write (std::atoi (a)); }
    138139  sc_int (unsigned short a){ val = 0; write (a); }
    139140  sc_int (short a)         { val = 0; write (a); }
     
    197198
    198199  // arithmetic
    199   template <typename T>
    200   inline sc_int& operator <<= (T v)
    201   { vf.valW <<= v; return *this; }
    202   template <typename T>
    203   inline sc_int& operator >>= (T v)
    204   { vf.valW >>= v; return *this; }
    205   template <typename T>
    206   inline sc_int& operator += (T v)
    207   { vf.valW += v; return *this; }
    208   template <typename T>
    209   inline sc_int& operator -= (T v)
    210   { vf.valW -= v; return *this; }
    211   template <typename T>
    212   inline sc_int& operator *= (T v)
    213   { vf.valW *= v; return *this; }
    214   template <typename T>
    215   inline sc_int& operator /= (T v)
    216   { vf.valW /= v; return *this; }
    217   template <typename T>
    218   inline sc_int& operator %= (T v)
    219   { vf.valW %= v; return *this; }
    220   template <typename T>
    221   inline sc_int& operator &= (T v)
    222   { vf.valW &= v; return *this; }
    223   template <typename T>
    224   inline sc_int& operator |= (T v)
    225   { vf.valW |= v; return *this; }
    226   template <typename T>
    227   inline sc_int& operator ^= (T v)
    228   { vf.valW ^= v; return *this; }
     200#define DEFINE_OPERATOR(OPER)        \
     201  template <typename T>              \
     202  inline sc_int& operator OPER (T v) \
     203  { vf.valW OPER v; return *this; }
     204
     205  DEFINE_OPERATOR(<<=)
     206  DEFINE_OPERATOR(>>=)
     207  DEFINE_OPERATOR(+=)
     208  DEFINE_OPERATOR(-=)
     209  DEFINE_OPERATOR(*=)
     210  DEFINE_OPERATOR(/=)
     211  DEFINE_OPERATOR(%=)
     212  DEFINE_OPERATOR(&=)
     213  DEFINE_OPERATOR(|=)
     214  DEFINE_OPERATOR(^=)
     215#undef DEFINE_OPERATOR
     216
    229217  inline sc_int_bit_ref& operator [] (int v)
    230218  { return (vf.valW >> v) & 1; }
Note: See TracChangeset for help on using the changeset viewer.