[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 | |
---|
| 31 | enum sc_logic_value_t |
---|
| 32 | { |
---|
| 33 | Log_0 = 0, |
---|
| 34 | Log_1, |
---|
| 35 | Log_Z, |
---|
| 36 | Log_X |
---|
| 37 | }; |
---|
| 38 | |
---|
| 39 | class sc_logic |
---|
| 40 | { |
---|
| 41 | public: |
---|
| 42 | // constructors & destructor |
---|
| 43 | sc_logic (); |
---|
| 44 | sc_logic (const sc_logic & a); |
---|
| 45 | sc_logic (sc_logic_value_t v); |
---|
| 46 | explicit sc_logic (bool a); |
---|
| 47 | explicit sc_logic (char a); |
---|
| 48 | explicit sc_logic (int a); |
---|
| 49 | explicit sc_logic (const sc_bit & a); |
---|
| 50 | ~sc_logic (); |
---|
| 51 | // assignment operators |
---|
| 52 | sc_logic & operator = (const sc_logic & a); |
---|
| 53 | sc_logic & operator = (sc_logic_value_t v); |
---|
| 54 | sc_logic & operator = (bool a); |
---|
| 55 | sc_logic & operator = (char a); |
---|
| 56 | sc_logic & operator = (int a); |
---|
| 57 | sc_logic & operator = (const sc_bit & a); |
---|
| 58 | // bitwise assignment operators |
---|
| 59 | sc_logic & operator &= (const sc_logic & b); |
---|
| 60 | sc_logic & operator &= (sc_logic_value_t v); |
---|
| 61 | sc_logic & operator &= (bool b); |
---|
| 62 | sc_logic & operator &= (char b); |
---|
| 63 | sc_logic & operator &= (int b); |
---|
| 64 | sc_logic & operator |= (const sc_logic & b); |
---|
| 65 | sc_logic & operator |= (sc_logic_value_t v); |
---|
| 66 | sc_logic & operator |= (bool b); |
---|
| 67 | sc_logic & operator |= (char b); |
---|
| 68 | sc_logic & operator |= (int b); |
---|
| 69 | sc_logic & operator ^= (const sc_logic & b); |
---|
| 70 | sc_logic & operator ^= (sc_logic_value_t v); |
---|
| 71 | sc_logic & operator ^= (bool b); |
---|
| 72 | sc_logic & operator ^= (char b); |
---|
| 73 | sc_logic & operator ^= (int b); |
---|
| 74 | // bitwise complement |
---|
| 75 | const sc_logic operator ~ () const; |
---|
| 76 | sc_logic & b_not (); |
---|
| 77 | // bitwise and |
---|
| 78 | friend const sc_logic operator & (const sc_logic & a, const sc_logic & b); |
---|
| 79 | friend const sc_logic operator & (const sc_logic & a, sc_logic_value_t b); |
---|
| 80 | friend const sc_logic operator & (const sc_logic & a, bool b); |
---|
| 81 | friend const sc_logic operator & (const sc_logic & a, char b); |
---|
| 82 | friend const sc_logic operator & (const sc_logic & a, int b); |
---|
| 83 | friend const sc_logic operator & (sc_logic_value_t a, const sc_logic & b); |
---|
| 84 | friend const sc_logic operator & (bool a, const sc_logic & b); |
---|
| 85 | friend const sc_logic operator & (char a, const sc_logic & b); |
---|
| 86 | friend const sc_logic operator & (int a, const sc_logic & b); |
---|
| 87 | // bitwise or |
---|
| 88 | friend const sc_logic operator | (const sc_logic & a, const sc_logic & b); |
---|
| 89 | friend const sc_logic operator | (const sc_logic & a, sc_logic_value_t b); |
---|
| 90 | friend const sc_logic operator | (const sc_logic & a, bool b); |
---|
| 91 | friend const sc_logic operator | (const sc_logic & a, char b); |
---|
| 92 | friend const sc_logic operator | (const sc_logic & a, int b); |
---|
| 93 | friend const sc_logic operator | (sc_logic_value_t a, const sc_logic & b); |
---|
| 94 | friend const sc_logic operator | (bool a, const sc_logic & b); |
---|
| 95 | friend const sc_logic operator | (char a, const sc_logic & b); |
---|
| 96 | friend const sc_logic operator | (int a, const sc_logic & b); |
---|
| 97 | // bitwise xor |
---|
| 98 | friend const sc_logic operator ^ (const sc_logic & a, const sc_logic & b); |
---|
| 99 | friend const sc_logic operator ^ (const sc_logic & a, sc_logic_value_t b); |
---|
| 100 | friend const sc_logic operator ^ (const sc_logic & a, bool b); |
---|
| 101 | friend const sc_logic operator ^ (const sc_logic & a, char b); |
---|
| 102 | friend const sc_logic operator ^ (const sc_logic & a, int b); |
---|
| 103 | friend const sc_logic operator ^ (sc_logic_value_t a, const sc_logic & b); |
---|
| 104 | friend const sc_logic operator ^ (bool a, const sc_logic & b); |
---|
| 105 | friend const sc_logic operator ^ (char a, const sc_logic & b); |
---|
| 106 | friend const sc_logic operator ^ (int a, const sc_logic & b); |
---|
| 107 | // relational operators and functions |
---|
| 108 | friend bool operator == (const sc_logic & a, const sc_logic & b); |
---|
| 109 | friend bool operator == (const sc_logic & a, |
---|
| 110 | sc_logic_value_t b); |
---|
| 111 | friend bool operator == (const sc_logic & a, bool b); |
---|
| 112 | friend bool operator == (const sc_logic & a, char b); |
---|
| 113 | friend bool operator == (const sc_logic & a, int b); |
---|
| 114 | friend bool operator == (sc_logic_value_t a, const sc_logic & b); |
---|
| 115 | friend bool operator == (bool a, const sc_logic & b); |
---|
| 116 | friend bool operator == (char a, const sc_logic & b); |
---|
| 117 | friend bool operator == (int a, const sc_logic & b); |
---|
| 118 | friend bool operator != (const sc_logic & a, const sc_logic & b); |
---|
| 119 | friend bool operator != (const sc_logic & a, sc_logic_value_t b); |
---|
| 120 | friend bool operator != (const sc_logic & a, bool b); |
---|
| 121 | friend bool operator != (const sc_logic & a, char b); |
---|
| 122 | friend bool operator != (const sc_logic & a, int b); |
---|
| 123 | friend bool operator != (sc_logic_value_t a, const sc_logic & b); |
---|
| 124 | friend bool operator != (bool a, const sc_logic & b); |
---|
| 125 | friend bool operator != (char a, const sc_logic & b); |
---|
| 126 | friend bool operator != (int a, const sc_logic & b); |
---|
| 127 | // explicit conversions |
---|
| 128 | sc_logic_value_t value () const; |
---|
| 129 | bool is_01 () const; |
---|
| 130 | bool to_bool () const; |
---|
| 131 | char to_char () const; |
---|
| 132 | /* |
---|
| 133 | // other methods |
---|
| 134 | void print (std::ostream & os = std::cout) const; |
---|
| 135 | void scan (std::istream & is = std::cin); |
---|
| 136 | */ |
---|
| 137 | // memory (de);allocation |
---|
| 138 | static void *operator new (size_t, void *p); // placement new |
---|
| 139 | static void *operator new (size_t sz); |
---|
| 140 | static void operator delete (void *p, size_t sz); |
---|
| 141 | static void *operator new[] (size_t sz); |
---|
| 142 | static void operator delete[] (void *p, size_t sz); |
---|
| 143 | private: |
---|
| 144 | // disabled |
---|
| 145 | explicit sc_logic (const char *); |
---|
| 146 | sc_logic & operator = (const char *); |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | extern const sc_logic SC_LOGIC_0; |
---|
| 150 | extern const sc_logic SC_LOGIC_1; |
---|
| 151 | extern const sc_logic SC_LOGIC_Z; |
---|
| 152 | extern const sc_logic SC_LOGIC_X; |
---|
| 153 | |
---|
| 154 | } /* end of sc_dt namespace */ |
---|
| 155 | |
---|
| 156 | #endif /* __SC_LOGIC_H__ */ |
---|