scc 2025.09
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 <sysc/datatypes/fx/fx.h>
21#include <sysc/tracing/sc_tracing_ids.h>
22#include <systemc>
23#include <type_traits>
24
25namespace scc {
26namespace trace {
27
28enum trace_type { WIRE, REAL };
29/*******************************************************************************************************
30 *
31 *******************************************************************************************************/
32template <typename T> struct traits {
33 static inline trace_type get_type() { return std::is_floating_point<T>::value ? REAL : WIRE; }
34 static inline unsigned get_bits(T const&) { return std::is_floating_point<T>::value ? 1 : sizeof(T) * 8; }
35};
36
37template <> inline trace_type traits<sc_dt::sc_fxval>::get_type() { return REAL; }
38template <> inline trace_type traits<sc_dt::sc_fxval_fast>::get_type() { return REAL; }
39template <> inline trace_type traits<sc_dt::sc_fxnum>::get_type() { return REAL; }
40template <> inline trace_type traits<sc_dt::sc_fxnum_fast>::get_type() { return REAL; }
41
42template <> inline unsigned traits<bool>::get_bits(bool const&) { return 1; }
43template <> inline unsigned traits<sc_dt::sc_bit>::get_bits(sc_dt::sc_bit const&) { return 1; }
44template <> inline unsigned traits<sc_dt::sc_logic>::get_bits(sc_dt::sc_logic const&) { return 1; }
45template <> inline unsigned traits<sc_dt::sc_bv_base>::get_bits(sc_dt::sc_bv_base const& o) { return o.length(); }
46template <> inline unsigned traits<sc_dt::sc_lv_base>::get_bits(sc_dt::sc_lv_base const& o) { return o.length(); }
47template <> inline unsigned traits<sc_dt::sc_int_base>::get_bits(sc_dt::sc_int_base const& o) { return o.length(); }
48template <> inline unsigned traits<sc_dt::sc_uint_base>::get_bits(sc_dt::sc_uint_base const& o) { return o.length(); }
49template <> inline unsigned traits<sc_dt::sc_signed>::get_bits(sc_dt::sc_signed const& o) { return o.length(); }
50template <> inline unsigned traits<sc_dt::sc_unsigned>::get_bits(sc_dt::sc_unsigned const& o) { return o.length(); }
51template <> inline unsigned traits<sc_dt::sc_fxval>::get_bits(sc_dt::sc_fxval const&) { return 1; }
52template <> inline unsigned traits<sc_dt::sc_fxval_fast>::get_bits(sc_dt::sc_fxval_fast const&) { return 1; }
53// FIXME: printing fxnum/fxnum_fast as real is just a workaround
54// should return act_val.wl();
55template <> inline unsigned traits<sc_dt::sc_fxnum>::get_bits(sc_dt::sc_fxnum const&) { return 1; }
56template <> inline unsigned traits<sc_dt::sc_fxnum_fast>::get_bits(sc_dt::sc_fxnum_fast const& o) { return 1; }
57} // namespace trace
58} // namespace scc
59
60#endif /* _SCC_TRACE_TYPES_HH_ */
SCC SystemC tracing utilities.
Definition fst_trace.cpp:33
SCC TLM utilities.