[1] | 1 | /*------------------------------------------------------------\ |
---|
| 2 | | | |
---|
| 3 | | Tool : systemcass | |
---|
| 4 | | | |
---|
| 5 | | File : sc_logic.h | |
---|
| 6 | | | |
---|
| 7 | | Author : Buchmann Richard | |
---|
| 8 | | | |
---|
| 9 | | Date : 14_04_2005 | |
---|
| 10 | | | |
---|
| 11 | \------------------------------------------------------------*/ |
---|
| 12 | #ifndef __SC_LOGIC_H__ |
---|
| 13 | #define __SC_LOGIC_H__ |
---|
| 14 | |
---|
| 15 | // ---------------------------------------------------------------------------- |
---|
| 16 | // CLASS : sc_logic |
---|
| 17 | // |
---|
| 18 | // ---------------------------------------------------------------------------- |
---|
| 19 | |
---|
[27] | 20 | #include "sc_nbdefs.h" |
---|
| 21 | #include "sc_fwd.h" |
---|
[1] | 22 | |
---|
| 23 | namespace sc_dt { |
---|
| 24 | |
---|
| 25 | // ---------------------------------------------------------------------------- |
---|
| 26 | // ENUM : sc_logic_value_t |
---|
| 27 | // |
---|
| 28 | // Enumeration of logic values. |
---|
| 29 | // ---------------------------------------------------------------------------- |
---|
| 30 | |
---|
[52] | 31 | enum sc_logic_value_t { |
---|
| 32 | Log_0 = 0, |
---|
| 33 | Log_1, |
---|
| 34 | Log_Z, |
---|
| 35 | Log_X |
---|
[1] | 36 | }; |
---|
| 37 | |
---|
[52] | 38 | |
---|
| 39 | class sc_logic { |
---|
| 40 | public: |
---|
| 41 | // constructors & destructor |
---|
| 42 | sc_logic(); |
---|
| 43 | sc_logic(const sc_logic & a); |
---|
| 44 | sc_logic(sc_logic_value_t v); |
---|
| 45 | explicit sc_logic(bool a); |
---|
| 46 | explicit sc_logic(char a); |
---|
| 47 | explicit sc_logic(int a); |
---|
| 48 | explicit sc_logic(const sc_bit & a); |
---|
| 49 | ~sc_logic(); |
---|
| 50 | // assignment operators |
---|
| 51 | sc_logic & operator = (const sc_logic & a); |
---|
| 52 | sc_logic & operator = (sc_logic_value_t v); |
---|
| 53 | sc_logic & operator = (bool a); |
---|
| 54 | sc_logic & operator = (char a); |
---|
| 55 | sc_logic & operator = (int a); |
---|
| 56 | sc_logic & operator = (const sc_bit & a); |
---|
| 57 | // bitwise assignment operators |
---|
| 58 | sc_logic & operator &= (const sc_logic & b); |
---|
| 59 | sc_logic & operator &= (sc_logic_value_t v); |
---|
| 60 | sc_logic & operator &= (bool b); |
---|
| 61 | sc_logic & operator &= (char b); |
---|
| 62 | sc_logic & operator &= (int b); |
---|
| 63 | sc_logic & operator |= (const sc_logic & b); |
---|
| 64 | sc_logic & operator |= (sc_logic_value_t v); |
---|
| 65 | sc_logic & operator |= (bool b); |
---|
| 66 | sc_logic & operator |= (char b); |
---|
| 67 | sc_logic & operator |= (int b); |
---|
| 68 | sc_logic & operator ^= (const sc_logic & b); |
---|
| 69 | sc_logic & operator ^= (sc_logic_value_t v); |
---|
| 70 | sc_logic & operator ^= (bool b); |
---|
| 71 | sc_logic & operator ^= (char b); |
---|
| 72 | sc_logic & operator ^= (int b); |
---|
| 73 | // bitwise complement |
---|
| 74 | const sc_logic operator ~ () const; |
---|
| 75 | sc_logic & b_not(); |
---|
| 76 | // bitwise and |
---|
| 77 | friend const sc_logic operator & (const sc_logic & a, const sc_logic & b); |
---|
| 78 | friend const sc_logic operator & (const sc_logic & a, sc_logic_value_t b); |
---|
| 79 | friend const sc_logic operator & (const sc_logic & a, bool b); |
---|
| 80 | friend const sc_logic operator & (const sc_logic & a, char b); |
---|
| 81 | friend const sc_logic operator & (const sc_logic & a, int b); |
---|
| 82 | friend const sc_logic operator & (sc_logic_value_t a, const sc_logic & b); |
---|
| 83 | friend const sc_logic operator & (bool a, const sc_logic & b); |
---|
| 84 | friend const sc_logic operator & (char a, const sc_logic & b); |
---|
| 85 | friend const sc_logic operator & (int a, const sc_logic & b); |
---|
| 86 | // bitwise or |
---|
| 87 | friend const sc_logic operator | (const sc_logic & a, const sc_logic & b); |
---|
| 88 | friend const sc_logic operator | (const sc_logic & a, sc_logic_value_t b); |
---|
| 89 | friend const sc_logic operator | (const sc_logic & a, bool b); |
---|
| 90 | friend const sc_logic operator | (const sc_logic & a, char b); |
---|
| 91 | friend const sc_logic operator | (const sc_logic & a, int b); |
---|
| 92 | friend const sc_logic operator | (sc_logic_value_t a, const sc_logic & b); |
---|
| 93 | friend const sc_logic operator | (bool a, const sc_logic & b); |
---|
| 94 | friend const sc_logic operator | (char a, const sc_logic & b); |
---|
| 95 | friend const sc_logic operator | (int a, const sc_logic & b); |
---|
| 96 | // bitwise xor |
---|
| 97 | friend const sc_logic operator ^ (const sc_logic & a, const sc_logic & b); |
---|
| 98 | friend const sc_logic operator ^ (const sc_logic & a, sc_logic_value_t b); |
---|
| 99 | friend const sc_logic operator ^ (const sc_logic & a, bool b); |
---|
| 100 | friend const sc_logic operator ^ (const sc_logic & a, char b); |
---|
| 101 | friend const sc_logic operator ^ (const sc_logic & a, int b); |
---|
| 102 | friend const sc_logic operator ^ (sc_logic_value_t a, const sc_logic & b); |
---|
| 103 | friend const sc_logic operator ^ (bool a, const sc_logic & b); |
---|
| 104 | friend const sc_logic operator ^ (char a, const sc_logic & b); |
---|
| 105 | friend const sc_logic operator ^ (int a, const sc_logic & b); |
---|
| 106 | // relational operators and functions |
---|
| 107 | friend bool operator == (const sc_logic & a, const sc_logic & b); |
---|
| 108 | friend bool operator == (const sc_logic & a, sc_logic_value_t b); |
---|
| 109 | friend bool operator == (const sc_logic & a, bool b); |
---|
| 110 | friend bool operator == (const sc_logic & a, char b); |
---|
| 111 | friend bool operator == (const sc_logic & a, int b); |
---|
| 112 | friend bool operator == (sc_logic_value_t a, const sc_logic & b); |
---|
| 113 | friend bool operator == (bool a, const sc_logic & b); |
---|
| 114 | friend bool operator == (char a, const sc_logic & b); |
---|
| 115 | friend bool operator == (int a, const sc_logic & b); |
---|
| 116 | friend bool operator != (const sc_logic & a, const sc_logic & b); |
---|
| 117 | friend bool operator != (const sc_logic & a, sc_logic_value_t b); |
---|
| 118 | friend bool operator != (const sc_logic & a, bool b); |
---|
| 119 | friend bool operator != (const sc_logic & a, char b); |
---|
| 120 | friend bool operator != (const sc_logic & a, int b); |
---|
| 121 | friend bool operator != (sc_logic_value_t a, const sc_logic & b); |
---|
| 122 | friend bool operator != (bool a, const sc_logic & b); |
---|
| 123 | friend bool operator != (char a, const sc_logic & b); |
---|
| 124 | friend bool operator != (int a, const sc_logic & b); |
---|
| 125 | |
---|
| 126 | // explicit conversions |
---|
| 127 | sc_logic_value_t value() const; |
---|
| 128 | bool is_01() const; |
---|
| 129 | bool to_bool() const; |
---|
| 130 | char to_char() const; |
---|
| 131 | |
---|
| 132 | // memory (de);allocation |
---|
| 133 | static void * operator new (size_t, void * p); // placement new |
---|
| 134 | static void * operator new (size_t sz); |
---|
| 135 | static void operator delete (void * p, size_t sz); |
---|
| 136 | static void * operator new [] (size_t sz); |
---|
| 137 | static void operator delete [] (void * p, size_t sz); |
---|
| 138 | |
---|
| 139 | private: |
---|
| 140 | // disabled |
---|
[1] | 141 | explicit sc_logic (const char *); |
---|
| 142 | sc_logic & operator = (const char *); |
---|
| 143 | }; |
---|
| 144 | |
---|
| 145 | extern const sc_logic SC_LOGIC_0; |
---|
| 146 | extern const sc_logic SC_LOGIC_1; |
---|
| 147 | extern const sc_logic SC_LOGIC_Z; |
---|
| 148 | extern const sc_logic SC_LOGIC_X; |
---|
| 149 | |
---|
| 150 | } /* end of sc_dt namespace */ |
---|
| 151 | |
---|
| 152 | #endif /* __SC_LOGIC_H__ */ |
---|
[52] | 153 | |
---|
| 154 | /* |
---|
| 155 | # Local Variables: |
---|
| 156 | # tab-width: 4; |
---|
| 157 | # c-basic-offset: 4; |
---|
| 158 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 159 | # indent-tabs-mode: nil; |
---|
| 160 | # End: |
---|
| 161 | # |
---|
| 162 | # vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 163 | */ |
---|
| 164 | |
---|