| 1 | /***************************************************************************** |
| 2 | |
| 3 | The following code is derived, directly or indirectly, from the SystemC |
| 4 | source code Copyright (c) 1996-2004 by all Contributors. |
| 5 | All Rights reserved. |
| 6 | |
| 7 | The contents of this file are subject to the restrictions and limitations |
| 8 | set forth in the SystemC Open Source License Version 2.4 (the "License"); |
| 9 | You may not use this file except in compliance with such restrictions and |
| 10 | limitations. You may obtain instructions on how to receive a copy of the |
| 11 | License at http://www.systemc.org/. Software distributed by Contributors |
| 12 | under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF |
| 13 | ANY KIND, either express or implied. See the License for the specific |
| 14 | language governing rights and limitations under the License. |
| 15 | |
| 16 | *****************************************************************************/ |
| 17 | |
| 18 | |
| 19 | #ifndef _TLM_TYPE_H_ |
| 20 | #define _TLM_TYPE_H_ |
| 21 | |
| 22 | /*------------------------------------------------------------------------------ |
| 23 | * Includes |
| 24 | *----------------------------------------------------------------------------*/ |
| 25 | #include "systemc.h" |
| 26 | |
| 27 | /** \defgroup byte_length_function Helper function: returns the number of byte represented by a datatype |
| 28 | * @{ |
| 29 | */ |
| 30 | |
| 31 | //------------------------------------------------- |
| 32 | /// Computes the number of byte of DATA type |
| 33 | template<typename DATA> |
| 34 | inline unsigned int get_nb_byte() { |
| 35 | return(sizeof(DATA)); |
| 36 | } |
| 37 | |
| 38 | // Computes the number of byte of DATA type inlined specializations |
| 39 | template<> |
| 40 | inline unsigned int get_nb_byte<sc_lv<32> >() { |
| 41 | return(4); |
| 42 | } |
| 43 | |
| 44 | template<> |
| 45 | inline unsigned int get_nb_byte<sc_lv<64> >() { |
| 46 | return(8); |
| 47 | } |
| 48 | |
| 49 | template<> |
| 50 | inline unsigned int get_nb_byte<sc_lv<128> >() { |
| 51 | return(16); |
| 52 | } |
| 53 | |
| 54 | template<> |
| 55 | inline unsigned int get_nb_byte<sc_uint<32> >() { |
| 56 | return(4); |
| 57 | } |
| 58 | |
| 59 | template<> |
| 60 | inline unsigned int get_nb_byte<sc_uint<64> >() { |
| 61 | return(8); |
| 62 | } |
| 63 | |
| 64 | template<> |
| 65 | inline unsigned int get_nb_byte<sc_biguint<32> >() { |
| 66 | return(4); |
| 67 | } |
| 68 | template<> |
| 69 | inline unsigned int get_nb_byte<sc_biguint<64> >() { |
| 70 | return(8); |
| 71 | } |
| 72 | |
| 73 | template<> |
| 74 | inline unsigned int get_nb_byte<sc_biguint<128> >() { |
| 75 | return(16); |
| 76 | } |
| 77 | |
| 78 | /* @} */ |
| 79 | |
| 80 | /** |
| 81 | * \defgroup tlm_endianness TLM endianness type |
| 82 | * Defines the two endianness. |
| 83 | * @{ |
| 84 | **/ |
| 85 | enum tlm_endianness { |
| 86 | TLM_LITTLE_ENDIAN, |
| 87 | TLM_BIG_ENDIAN |
| 88 | }; |
| 89 | /* @} */ |
| 90 | |
| 91 | |
| 92 | /** \defgroup data_mode tlm_bus_request and tlm_bus_reponse mode |
| 93 | * request and response data (and byte_enable array) management |
| 94 | * |
| 95 | * |
| 96 | * @{ |
| 97 | **/ |
| 98 | enum tlm_data_mode { |
| 99 | TLM_PASS_BY_COPY, ///< The data (and byte_enable array ) are passed by effective copy. |
| 100 | TLM_PASS_BY_POINTER ///< The data (and byte_enable array ) are passed using the pointer member copy only |
| 101 | }; |
| 102 | |
| 103 | /* @} */ |
| 104 | |
| 105 | |
| 106 | /** Host arch. identification and associated typedef and define. |
| 107 | **/ |
| 108 | |
| 109 | #if defined(__sparc) || defined(macintosh) || defined(__hppa) |
| 110 | |
| 111 | /* Workstation endianness */ |
| 112 | #define HOST_ENDIAN_BIG |
| 113 | |
| 114 | /* SOC Endianness default value = host endianness */ |
| 115 | #define TLM_HOST_ENDIAN tlm_bus::TLM_BIG_ENDIAN |
| 116 | |
| 117 | #elif defined(__acorn) || defined(__mvs) || defined(_WIN32) || \ |
| 118 | (defined(__alpha) && defined(__osf__)) || defined(__i386) |
| 119 | |
| 120 | /* Workstation endianness */ |
| 121 | #define HOST_ENDIAN_LITTLE |
| 122 | |
| 123 | /* SOC Endianness default value = host endianness */ |
| 124 | #define TLM_HOST_ENDIAN tlm_bus::TLM_LITTLE_ENDIAN |
| 125 | |
| 126 | #else |
| 127 | /* Workstation endianness */ |
| 128 | #define HOST_ENDIAN_UNKNOWN |
| 129 | |
| 130 | #endif |
| 131 | |
| 132 | |
| 133 | |
| 134 | /** |
| 135 | * \defgroup tlm_type common type definition |
| 136 | * @{ |
| 137 | **/ |
| 138 | #if defined(_WIN32) && defined(_MSC_VER) |
| 139 | |
| 140 | typedef unsigned __int64 tlm_uint64_t; |
| 141 | typedef unsigned __int32 tlm_uint32_t; |
| 142 | typedef unsigned __int16 tlm_uint16_t; |
| 143 | typedef unsigned __int8 tlm_uint8_t; |
| 144 | |
| 145 | typedef __int64 tlm_sint64_t; |
| 146 | typedef __int32 tlm_sint32_t; |
| 147 | typedef __int16 tlm_sint16_t; |
| 148 | typedef __int8 tlm_sint8_t; |
| 149 | |
| 150 | #else |
| 151 | |
| 152 | typedef unsigned long long tlm_uint64_t; |
| 153 | typedef unsigned long tlm_uint32_t; |
| 154 | typedef unsigned short tlm_uint16_t; |
| 155 | typedef unsigned char tlm_uint8_t; |
| 156 | |
| 157 | typedef long long tlm_sint64_t; |
| 158 | typedef long tlm_sint32_t; |
| 159 | typedef short tlm_sint16_t; |
| 160 | typedef char tlm_sint8_t; |
| 161 | |
| 162 | #endif |
| 163 | |
| 164 | /* @} */ |
| 165 | |
| 166 | #endif /* _TLM_TYPE_H_ */ |
| 167 | |
| 168 | |