112027Sjungma@eit.uni-kl.de/*****************************************************************************
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412027Sjungma@eit.uni-kl.de  more contributor license agreements.  See the NOTICE file distributed
512027Sjungma@eit.uni-kl.de  with this work for additional information regarding copyright ownership.
612027Sjungma@eit.uni-kl.de  Accellera licenses this file to you under the Apache License, Version 2.0
712027Sjungma@eit.uni-kl.de  (the "License"); you may not use this file except in compliance with the
812027Sjungma@eit.uni-kl.de  License.  You may obtain a copy of the License at
912027Sjungma@eit.uni-kl.de
1012027Sjungma@eit.uni-kl.de    http://www.apache.org/licenses/LICENSE-2.0
1112027Sjungma@eit.uni-kl.de
1212027Sjungma@eit.uni-kl.de  Unless required by applicable law or agreed to in writing, software
1312027Sjungma@eit.uni-kl.de  distributed under the License is distributed on an "AS IS" BASIS,
1412027Sjungma@eit.uni-kl.de  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512027Sjungma@eit.uni-kl.de  implied.  See the License for the specific language governing
1612027Sjungma@eit.uni-kl.de  permissions and limitations under the License.
1712027Sjungma@eit.uni-kl.de
1812027Sjungma@eit.uni-kl.de *****************************************************************************/
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.de/*****************************************************************************
2112027Sjungma@eit.uni-kl.de
2212027Sjungma@eit.uni-kl.de  sc_wif_trace.h - Implementation of WIF tracing.
2312027Sjungma@eit.uni-kl.de
2412027Sjungma@eit.uni-kl.de  Original Author - Abhijit Ghosh, Synopsys, Inc.
2512027Sjungma@eit.uni-kl.de
2612027Sjungma@eit.uni-kl.de *****************************************************************************/
2712027Sjungma@eit.uni-kl.de
2812027Sjungma@eit.uni-kl.de/*****************************************************************************
2912027Sjungma@eit.uni-kl.de
3012027Sjungma@eit.uni-kl.de  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
3112027Sjungma@eit.uni-kl.de  changes you are making here.
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.de      Name, Affiliation, Date:
3412027Sjungma@eit.uni-kl.de  Description of Modification:
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.de *****************************************************************************/
3712027Sjungma@eit.uni-kl.de
3812027Sjungma@eit.uni-kl.de/*****************************************************************************
3912027Sjungma@eit.uni-kl.de
4012027Sjungma@eit.uni-kl.de   Acknowledgement: The tracing mechanism is based on the tracing
4112027Sjungma@eit.uni-kl.de   mechanism developed at Infineon (formerly Siemens HL). Though this
4212027Sjungma@eit.uni-kl.de   code is somewhat different, and significantly enhanced, the basics
4312027Sjungma@eit.uni-kl.de   are identical to what was originally contributed by Infineon.
4412027Sjungma@eit.uni-kl.de   The contribution of Infineon in the development of this tracing
4512027Sjungma@eit.uni-kl.de   technology is hereby acknowledged.
4612027Sjungma@eit.uni-kl.de
4712027Sjungma@eit.uni-kl.de *****************************************************************************/
4812027Sjungma@eit.uni-kl.de
4912027Sjungma@eit.uni-kl.de/*****************************************************************************
5012027Sjungma@eit.uni-kl.de
5112027Sjungma@eit.uni-kl.de   Instead of creating the binary WIF format, we create the ASCII
5212027Sjungma@eit.uni-kl.de   WIF format which can be converted to the binary format using
5312027Sjungma@eit.uni-kl.de   a2wif (utility that comes with VSS from Synopsys). This way,
5412027Sjungma@eit.uni-kl.de   a user who does not have Synopsys VSS can still create WIF
5512027Sjungma@eit.uni-kl.de   files, but the files can only be viewed by users who have VSS.
5612027Sjungma@eit.uni-kl.de
5712027Sjungma@eit.uni-kl.de *****************************************************************************/
5812027Sjungma@eit.uni-kl.de
5912027Sjungma@eit.uni-kl.de#ifndef SC_WIF_TRACE_H
6012027Sjungma@eit.uni-kl.de#define SC_WIF_TRACE_H
6112027Sjungma@eit.uni-kl.de
6212027Sjungma@eit.uni-kl.de#include <cstdio>
6312027Sjungma@eit.uni-kl.de#include "sysc/datatypes/int/sc_nbdefs.h"
6412027Sjungma@eit.uni-kl.de#include "sysc/tracing/sc_trace_file_base.h"
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.denamespace sc_core {
6712027Sjungma@eit.uni-kl.de
6812027Sjungma@eit.uni-kl.declass wif_trace;  // defined in wif_trace.cc
6912027Sjungma@eit.uni-kl.detemplate<class T> class wif_T_trace;
7012027Sjungma@eit.uni-kl.de
7112027Sjungma@eit.uni-kl.declass wif_trace_file
7212027Sjungma@eit.uni-kl.de  : public sc_trace_file_base
7312027Sjungma@eit.uni-kl.de{
7412027Sjungma@eit.uni-kl.depublic:
7512027Sjungma@eit.uni-kl.de    enum wif_enum {WIF_BIT=0, WIF_MVL=1, WIF_REAL=2, WIF_LAST};
7612027Sjungma@eit.uni-kl.de
7712027Sjungma@eit.uni-kl.de    // Create a wif trace file.
7812027Sjungma@eit.uni-kl.de    // `Name' forms the base of the name to which `.awif' is added.
7912027Sjungma@eit.uni-kl.de    explicit wif_trace_file(const char *name);
8012027Sjungma@eit.uni-kl.de
8112027Sjungma@eit.uni-kl.de    ~wif_trace_file();
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.deprotected:
8412027Sjungma@eit.uni-kl.de    // These are all virtual functions in sc_trace_file and
8512027Sjungma@eit.uni-kl.de    // they need to be defined here.
8612027Sjungma@eit.uni-kl.de
8712027Sjungma@eit.uni-kl.de    // Trace a boolean object (single bit)
8812027Sjungma@eit.uni-kl.de     void trace(const bool& object, const std::string& name);
8912027Sjungma@eit.uni-kl.de
9012027Sjungma@eit.uni-kl.de    // Trace a sc_bit object (single bit)
9112027Sjungma@eit.uni-kl.de     void trace(const sc_dt::sc_bit& object, const std::string& name);
9212027Sjungma@eit.uni-kl.de
9312027Sjungma@eit.uni-kl.de    // Trace a sc_logic object (single bit)
9412027Sjungma@eit.uni-kl.de     void trace(const sc_dt::sc_logic& object, const std::string& name);
9512027Sjungma@eit.uni-kl.de
9612027Sjungma@eit.uni-kl.de    // Trace an unsigned char with the given width
9712027Sjungma@eit.uni-kl.de     void trace(const unsigned char& object, const std::string& name,
9812027Sjungma@eit.uni-kl.de	int width);
9912027Sjungma@eit.uni-kl.de
10012027Sjungma@eit.uni-kl.de    // Trace an unsigned short with the given width
10112027Sjungma@eit.uni-kl.de     void trace(const unsigned short& object, const std::string& name,
10212027Sjungma@eit.uni-kl.de         int width);
10312027Sjungma@eit.uni-kl.de
10412027Sjungma@eit.uni-kl.de    // Trace an unsigned int with the given width
10512027Sjungma@eit.uni-kl.de     void trace(const unsigned int& object, const std::string& name,
10612027Sjungma@eit.uni-kl.de         int width);
10712027Sjungma@eit.uni-kl.de
10812027Sjungma@eit.uni-kl.de    // Trace an unsigned long with the given width
10912027Sjungma@eit.uni-kl.de     void trace(const unsigned long& object, const std::string& name,
11012027Sjungma@eit.uni-kl.de         int width);
11112027Sjungma@eit.uni-kl.de
11212027Sjungma@eit.uni-kl.de    // Trace a signed char with the given width
11312027Sjungma@eit.uni-kl.de     void trace(const char& object, const std::string& name, int width);
11412027Sjungma@eit.uni-kl.de
11512027Sjungma@eit.uni-kl.de    // Trace a signed short with the given width
11612027Sjungma@eit.uni-kl.de     void trace(const short& object, const std::string& name, int width);
11712027Sjungma@eit.uni-kl.de
11812027Sjungma@eit.uni-kl.de    // Trace a signed int with the given width
11912027Sjungma@eit.uni-kl.de     void trace(const int& object, const std::string& name, int width);
12012027Sjungma@eit.uni-kl.de
12112027Sjungma@eit.uni-kl.de    // Trace a signed long with the given width
12212027Sjungma@eit.uni-kl.de     void trace(const long& object, const std::string& name, int width);
12312027Sjungma@eit.uni-kl.de
12412027Sjungma@eit.uni-kl.de    // Trace a signed long long with the given width
12512027Sjungma@eit.uni-kl.de     void trace(const sc_dt::int64& object, const std::string& name,
12612027Sjungma@eit.uni-kl.de         int width);
12712027Sjungma@eit.uni-kl.de
12812027Sjungma@eit.uni-kl.de    // Trace an usigned long long with the given width
12912027Sjungma@eit.uni-kl.de     void trace(const sc_dt::uint64& object, const std::string& name,
13012027Sjungma@eit.uni-kl.de         int width);
13112027Sjungma@eit.uni-kl.de
13212027Sjungma@eit.uni-kl.de    // Trace a float
13312027Sjungma@eit.uni-kl.de     void trace(const float& object, const std::string& name);
13412027Sjungma@eit.uni-kl.de
13512027Sjungma@eit.uni-kl.de    // Trace a double
13612027Sjungma@eit.uni-kl.de     void trace(const double& object, const std::string& name);
13712027Sjungma@eit.uni-kl.de
13812027Sjungma@eit.uni-kl.de    // Trace sc_unsigned
13912027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_unsigned& object,
14012027Sjungma@eit.uni-kl.de	 const std::string& name);
14112027Sjungma@eit.uni-kl.de
14212027Sjungma@eit.uni-kl.de    // Trace sc_signed
14312027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_signed& object,
14412027Sjungma@eit.uni-kl.de	 const std::string& name);
14512027Sjungma@eit.uni-kl.de
14612027Sjungma@eit.uni-kl.de    // Trace sc_uint_base
14712027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_uint_base& object,
14812027Sjungma@eit.uni-kl.de         const std::string& name);
14912027Sjungma@eit.uni-kl.de
15012027Sjungma@eit.uni-kl.de    // Trace sc_int_base
15112027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_int_base& object, const std::string& name);
15212027Sjungma@eit.uni-kl.de
15312027Sjungma@eit.uni-kl.de    // Trace sc_fxval
15412027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxval& object, const std::string& name );
15512027Sjungma@eit.uni-kl.de
15612027Sjungma@eit.uni-kl.de    // Trace sc_fxval_fast
15712027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxval_fast& object,
15812027Sjungma@eit.uni-kl.de    	const std::string& name );
15912027Sjungma@eit.uni-kl.de
16012027Sjungma@eit.uni-kl.de    // Trace sc_fxnum
16112027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxnum& object, const std::string& name );
16212027Sjungma@eit.uni-kl.de
16312027Sjungma@eit.uni-kl.de    // Trace sc_fxnum_fast
16412027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxnum_fast& object,
16512027Sjungma@eit.uni-kl.de    	const std::string& name );
16612027Sjungma@eit.uni-kl.de
16712027Sjungma@eit.uni-kl.de    template<class T>
16812027Sjungma@eit.uni-kl.de    void traceT(const T& object, const std::string& name, wif_enum type)
16912027Sjungma@eit.uni-kl.de    {
17012027Sjungma@eit.uni-kl.de        if( add_trace_check(name) )
17112027Sjungma@eit.uni-kl.de            traces.push_back( new wif_T_trace<T>( object, name
17212027Sjungma@eit.uni-kl.de                                                , obtain_name(),type ) );
17312027Sjungma@eit.uni-kl.de    }
17412027Sjungma@eit.uni-kl.de
17512027Sjungma@eit.uni-kl.de    // Trace sc_bv_base (sc_bv)
17612027Sjungma@eit.uni-kl.de    virtual void trace( const sc_dt::sc_bv_base& object,
17712027Sjungma@eit.uni-kl.de    	const std::string& name );
17812027Sjungma@eit.uni-kl.de
17912027Sjungma@eit.uni-kl.de    // Trace sc_lv_base (sc_lv)
18012027Sjungma@eit.uni-kl.de    virtual void trace( const sc_dt::sc_lv_base& object,
18112027Sjungma@eit.uni-kl.de    	const std::string& name );
18212027Sjungma@eit.uni-kl.de
18312027Sjungma@eit.uni-kl.de    // Trace an enumerated object - where possible output the enumeration literals
18412027Sjungma@eit.uni-kl.de    // in the trace file. Enum literals is a null terminated array of null
18512027Sjungma@eit.uni-kl.de    // terminated char* literal strings.
18612027Sjungma@eit.uni-kl.de     void trace(const unsigned& object, const std::string& name,
18712027Sjungma@eit.uni-kl.de         const char** enum_literals);
18812027Sjungma@eit.uni-kl.de
18912027Sjungma@eit.uni-kl.de    // Output a comment to the trace file
19012027Sjungma@eit.uni-kl.de     void write_comment(const std::string& comment);
19112027Sjungma@eit.uni-kl.de
19212027Sjungma@eit.uni-kl.de    // Write trace info for cycle.
19312027Sjungma@eit.uni-kl.de     void cycle(bool delta_cycle);
19412027Sjungma@eit.uni-kl.de
19512027Sjungma@eit.uni-kl.deprivate:
19612027Sjungma@eit.uni-kl.de
19712027Sjungma@eit.uni-kl.de#if SC_TRACING_PHASE_CALLBACKS_
19812027Sjungma@eit.uni-kl.de    // avoid hidden overload warnings
19912027Sjungma@eit.uni-kl.de    virtual void trace( sc_trace_file* ) const { sc_assert(false); }
20012027Sjungma@eit.uni-kl.de#endif // SC_TRACING_PHASE_CALLBACKS_
20112027Sjungma@eit.uni-kl.de
20212027Sjungma@eit.uni-kl.de    // Initialize the tracing mechanism
20312027Sjungma@eit.uni-kl.de    virtual void do_initialize();
20412027Sjungma@eit.uni-kl.de
20512027Sjungma@eit.uni-kl.de    unsigned wif_name_index;           // Number of variables traced
20612027Sjungma@eit.uni-kl.de
20712027Sjungma@eit.uni-kl.de    unsigned previous_time_units_low;  // Previous time as 64 bit integer
20812027Sjungma@eit.uni-kl.de    unsigned previous_time_units_high;
20912027Sjungma@eit.uni-kl.de    double   previous_time;            // Previous time as a double
21012027Sjungma@eit.uni-kl.de
21112027Sjungma@eit.uni-kl.depublic:
21212027Sjungma@eit.uni-kl.de    // Create wif names for each variable
21312027Sjungma@eit.uni-kl.de    std::string obtain_name();
21412027Sjungma@eit.uni-kl.de
21512027Sjungma@eit.uni-kl.de    // Array to store the variables traced
21612027Sjungma@eit.uni-kl.de    std::vector<wif_trace*> traces;
21712027Sjungma@eit.uni-kl.de};
21812027Sjungma@eit.uni-kl.de
21912027Sjungma@eit.uni-kl.de} //  namespace sc_core
22012027Sjungma@eit.uni-kl.de
22112027Sjungma@eit.uni-kl.de#endif // SC_WIF_TRACE_H
22212027Sjungma@eit.uni-kl.de// Taf!
223