scc  2022.4.0
SystemC components library
types.hh
1 /*******************************************************************************
2  * Copyright 2021 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef _SCC_TRACE_TYPES_HH_
18 #define _SCC_TRACE_TYPES_HH_
19 
20 #include <type_traits>
21 #include <systemc>
22 #include <sysc/datatypes/fx/fx.h>
23 #ifndef NCSC
24 #include <sysc/tracing/sc_tracing_ids.h>
25 #else
26 namespace sc_core {
27 static const char* SC_ID_TRACING_OBJECT_IGNORED_="object cannot not be traced";
28 static const char* SC_ID_TRACING_OBJECT_NAME_FILTERED_="traced object name filtered";
29 }
30 #endif
31 
32 namespace scc {
33 namespace trace {
34 
35 enum trace_type {WIRE, REAL};
36 /*******************************************************************************************************
37  *
38  *******************************************************************************************************/
39 template<typename T> struct traits {
40  static inline trace_type get_type() { return std::is_floating_point<T>::value?REAL:WIRE;}
41  static inline unsigned get_bits(T const&) { return std::is_floating_point<T>::value?1:sizeof(T)*8;}
42 };
43 
44 template<> inline trace_type traits<sc_dt::sc_fxval>::get_type(){ return REAL;}
45 template<> inline trace_type traits<sc_dt::sc_fxval_fast>::get_type(){ return REAL;}
46 template<> inline trace_type traits<sc_dt::sc_fxnum>::get_type(){ return REAL;}
47 template<> inline trace_type traits<sc_dt::sc_fxnum_fast>::get_type(){ return REAL;}
48 
49 template<> inline unsigned traits<bool>::get_bits(bool const&){ return 1; }
50 template<> inline unsigned traits<sc_dt::sc_bit>::get_bits(sc_dt::sc_bit const&){ return 1; }
51 template<> inline unsigned traits<sc_dt::sc_logic>::get_bits(sc_dt::sc_logic const&){ return 1; }
52 template<> inline unsigned traits<sc_dt::sc_bv_base>::get_bits(sc_dt::sc_bv_base const& o){ return o.length(); }
53 template<> inline unsigned traits<sc_dt::sc_lv_base>::get_bits(sc_dt::sc_lv_base const& o){ return o.length(); }
54 template<> inline unsigned traits<sc_dt::sc_int_base>::get_bits(sc_dt::sc_int_base const& o){ return o.length(); }
55 template<> inline unsigned traits<sc_dt::sc_uint_base>::get_bits(sc_dt::sc_uint_base const& o){ return o.length(); }
56 template<> inline unsigned traits<sc_dt::sc_signed>::get_bits(sc_dt::sc_signed const& o){ return o.length(); }
57 template<> inline unsigned traits<sc_dt::sc_unsigned>::get_bits(sc_dt::sc_unsigned const& o){ return o.length(); }
58 template<> inline unsigned traits<sc_dt::sc_fxval>::get_bits(sc_dt::sc_fxval const&){ return 1; }
59 template<> inline unsigned traits<sc_dt::sc_fxval_fast>::get_bits(sc_dt::sc_fxval_fast const&){ return 1; }
60 //FIXME: printing fxnum/fxnum_fast as real is just a workaround
61 // should return act_val.wl();
62 template<> inline unsigned traits<sc_dt::sc_fxnum>::get_bits(sc_dt::sc_fxnum const&){return 1; }
63 template<> inline unsigned traits<sc_dt::sc_fxnum_fast>::get_bits(sc_dt::sc_fxnum_fast const& o){ return 1; }
64 }
65 }
66 
67 
68 #endif /* _SCC_TRACE_TYPES_HH_ */
SCC SystemC utilities.