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_vcd_trace.h - Implementation of VCD 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.  The
4412027Sjungma@eit.uni-kl.de   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#ifndef SC_VCD_TRACE_H
5012027Sjungma@eit.uni-kl.de#define SC_VCD_TRACE_H
5112027Sjungma@eit.uni-kl.de
5212027Sjungma@eit.uni-kl.de#include "sysc/tracing/sc_trace_file_base.h"
5312027Sjungma@eit.uni-kl.de
5412027Sjungma@eit.uni-kl.denamespace sc_core {
5512027Sjungma@eit.uni-kl.de
5612027Sjungma@eit.uni-kl.declass vcd_trace;  // defined in vcd_trace.cpp
5712027Sjungma@eit.uni-kl.detemplate<class T> class vcd_T_trace;
5812027Sjungma@eit.uni-kl.de
5912027Sjungma@eit.uni-kl.de
6012027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
6112027Sjungma@eit.uni-kl.de//  CLASS : vcd_trace_file
6212027Sjungma@eit.uni-kl.de//
6312027Sjungma@eit.uni-kl.de//  ...
6412027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.declass vcd_trace_file
6712027Sjungma@eit.uni-kl.de  : public sc_trace_file_base
6812027Sjungma@eit.uni-kl.de{
6912027Sjungma@eit.uni-kl.depublic:
7012027Sjungma@eit.uni-kl.de
7112027Sjungma@eit.uni-kl.de    enum vcd_enum {VCD_WIRE=0, VCD_REAL=1, VCD_LAST};
7212027Sjungma@eit.uni-kl.de
7312027Sjungma@eit.uni-kl.de	// sc_set_vcd_time_unit is deprecated.
7412027Sjungma@eit.uni-kl.de#if 0 // deprecated
7512027Sjungma@eit.uni-kl.de    inline void sc_set_vcd_time_unit(int exponent10_seconds)
7612027Sjungma@eit.uni-kl.de    	{ set_time_unit(exponent10_seconds); }
7712027Sjungma@eit.uni-kl.de#endif
7812027Sjungma@eit.uni-kl.de
7912027Sjungma@eit.uni-kl.de    // Create a Vcd trace file.
8012027Sjungma@eit.uni-kl.de    // `Name' forms the base of the name to which `.vcd' is added.
8112027Sjungma@eit.uni-kl.de    vcd_trace_file(const char *name);
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.de    // Flush results and close file.
8412027Sjungma@eit.uni-kl.de    ~vcd_trace_file();
8512027Sjungma@eit.uni-kl.de
8612027Sjungma@eit.uni-kl.deprotected:
8712027Sjungma@eit.uni-kl.de
8812027Sjungma@eit.uni-kl.de    // These are all virtual functions in sc_trace_file and
8912027Sjungma@eit.uni-kl.de    // they need to be defined here.
9012027Sjungma@eit.uni-kl.de
9112027Sjungma@eit.uni-kl.de    // Trace a boolean object (single bit)
9212027Sjungma@eit.uni-kl.de     void trace(const bool& object, const std::string& name);
9312027Sjungma@eit.uni-kl.de
9412027Sjungma@eit.uni-kl.de    // Trace a sc_bit object (single bit)
9512027Sjungma@eit.uni-kl.de    virtual void trace( const sc_dt::sc_bit& object,
9612027Sjungma@eit.uni-kl.de	    const std::string& name);
9712027Sjungma@eit.uni-kl.de
9812027Sjungma@eit.uni-kl.de    // Trace a sc_logic object (single bit)
9912027Sjungma@eit.uni-kl.de     void trace(const sc_dt::sc_logic& object, const std::string& name);
10012027Sjungma@eit.uni-kl.de
10112027Sjungma@eit.uni-kl.de    // Trace an unsigned char with the given width
10212027Sjungma@eit.uni-kl.de     void trace(const unsigned char& object, const std::string& name,
10312027Sjungma@eit.uni-kl.de     	int width);
10412027Sjungma@eit.uni-kl.de
10512027Sjungma@eit.uni-kl.de    // Trace an unsigned short with the given width
10612027Sjungma@eit.uni-kl.de     void trace(const unsigned short& object, const std::string& name,
10712027Sjungma@eit.uni-kl.de     	int width);
10812027Sjungma@eit.uni-kl.de
10912027Sjungma@eit.uni-kl.de    // Trace an unsigned int with the given width
11012027Sjungma@eit.uni-kl.de     void trace(const unsigned int& object, const std::string& name,
11112027Sjungma@eit.uni-kl.de     	int width);
11212027Sjungma@eit.uni-kl.de
11312027Sjungma@eit.uni-kl.de    // Trace an unsigned long with the given width
11412027Sjungma@eit.uni-kl.de     void trace(const unsigned long& object, const std::string& name,
11512027Sjungma@eit.uni-kl.de     	int width);
11612027Sjungma@eit.uni-kl.de
11712027Sjungma@eit.uni-kl.de    // Trace a signed char with the given width
11812027Sjungma@eit.uni-kl.de     void trace(const char& object, const std::string& name, int width);
11912027Sjungma@eit.uni-kl.de
12012027Sjungma@eit.uni-kl.de    // Trace a signed short with the given width
12112027Sjungma@eit.uni-kl.de     void trace(const short& object, const std::string& name, int width);
12212027Sjungma@eit.uni-kl.de
12312027Sjungma@eit.uni-kl.de    // Trace a signed int with the given width
12412027Sjungma@eit.uni-kl.de     void trace(const int& object, const std::string& name, int width);
12512027Sjungma@eit.uni-kl.de
12612027Sjungma@eit.uni-kl.de    // Trace a signed long with the given width
12712027Sjungma@eit.uni-kl.de     void trace(const long& object, const std::string& name, int width);
12812027Sjungma@eit.uni-kl.de
12912027Sjungma@eit.uni-kl.de    // Trace an int64 with a given width
13012027Sjungma@eit.uni-kl.de     void trace(const sc_dt::int64& object, const std::string& name,
13112027Sjungma@eit.uni-kl.de         int width);
13212027Sjungma@eit.uni-kl.de
13312027Sjungma@eit.uni-kl.de    // Trace a uint64 with a given width
13412027Sjungma@eit.uni-kl.de     void trace(const sc_dt::uint64& object, const std::string& name,
13512027Sjungma@eit.uni-kl.de         int width);
13612027Sjungma@eit.uni-kl.de
13712027Sjungma@eit.uni-kl.de    // Trace a float
13812027Sjungma@eit.uni-kl.de     void trace(const float& object, const std::string& name);
13912027Sjungma@eit.uni-kl.de
14012027Sjungma@eit.uni-kl.de    // Trace a double
14112027Sjungma@eit.uni-kl.de     void trace(const double& object, const std::string& name);
14212027Sjungma@eit.uni-kl.de
14312027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_uint_base
14412027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_uint_base& object,
14512027Sjungma@eit.uni-kl.de	 	const std::string& name);
14612027Sjungma@eit.uni-kl.de
14712027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_int_base
14812027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_int_base& object,
14912027Sjungma@eit.uni-kl.de	 	const std::string& name);
15012027Sjungma@eit.uni-kl.de
15112027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_unsigned
15212027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_unsigned& object,
15312027Sjungma@eit.uni-kl.de	 	const std::string& name);
15412027Sjungma@eit.uni-kl.de
15512027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_signed
15612027Sjungma@eit.uni-kl.de     void trace (const sc_dt::sc_signed& object, const std::string& name);
15712027Sjungma@eit.uni-kl.de
15812027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_fxval
15912027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxval& object, const std::string& name );
16012027Sjungma@eit.uni-kl.de
16112027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_fxval_fast
16212027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxval_fast& object,
16312027Sjungma@eit.uni-kl.de		const std::string& name );
16412027Sjungma@eit.uni-kl.de
16512027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_fxnum
16612027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxnum& object, const std::string& name );
16712027Sjungma@eit.uni-kl.de
16812027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_fxnum_fast
16912027Sjungma@eit.uni-kl.de    void trace( const sc_dt::sc_fxnum_fast& object,
17012027Sjungma@eit.uni-kl.de		const std::string& name );
17112027Sjungma@eit.uni-kl.de
17212027Sjungma@eit.uni-kl.de    template<class T>
17312027Sjungma@eit.uni-kl.de    void traceT(const T& object, const std::string& name,
17412027Sjungma@eit.uni-kl.de    	vcd_enum type=VCD_WIRE)
17512027Sjungma@eit.uni-kl.de    {
17612027Sjungma@eit.uni-kl.de        if( add_trace_check(name) )
17712027Sjungma@eit.uni-kl.de            traces.push_back(new vcd_T_trace<T>( object, name
17812027Sjungma@eit.uni-kl.de                                               , obtain_name(),type) );
17912027Sjungma@eit.uni-kl.de    }
18012027Sjungma@eit.uni-kl.de
18112027Sjungma@eit.uni-kl.de   // Trace sc_dt::sc_bv_base (sc_dt::sc_bv)
18212027Sjungma@eit.uni-kl.de    virtual void trace(const sc_dt::sc_bv_base& object,
18312027Sjungma@eit.uni-kl.de		const std::string& name);
18412027Sjungma@eit.uni-kl.de
18512027Sjungma@eit.uni-kl.de    // Trace sc_dt::sc_lv_base (sc_dt::sc_lv)
18612027Sjungma@eit.uni-kl.de    virtual void trace(const sc_dt::sc_lv_base& object,
18712027Sjungma@eit.uni-kl.de	    const std::string& name);
18812027Sjungma@eit.uni-kl.de    // Trace an enumerated object - where possible output the enumeration literals
18912027Sjungma@eit.uni-kl.de    // in the trace file. Enum literals is a null terminated array of null
19012027Sjungma@eit.uni-kl.de    // terminated char* literal strings.
19112027Sjungma@eit.uni-kl.de     void trace(const unsigned& object, const std::string& name,
19212027Sjungma@eit.uni-kl.de     	const char** enum_literals);
19312027Sjungma@eit.uni-kl.de
19412027Sjungma@eit.uni-kl.de    // Output a comment to the trace file
19512027Sjungma@eit.uni-kl.de     void write_comment(const std::string& comment);
19612027Sjungma@eit.uni-kl.de
19712027Sjungma@eit.uni-kl.de    // Write trace info for cycle.
19812027Sjungma@eit.uni-kl.de     void cycle(bool delta_cycle);
19912027Sjungma@eit.uni-kl.de
20012027Sjungma@eit.uni-kl.deprivate:
20112027Sjungma@eit.uni-kl.de
20212027Sjungma@eit.uni-kl.de#if SC_TRACING_PHASE_CALLBACKS_
20312027Sjungma@eit.uni-kl.de    // avoid hidden overload warnings
20412027Sjungma@eit.uni-kl.de    virtual void trace( sc_trace_file* ) const { sc_assert(false); }
20512027Sjungma@eit.uni-kl.de#endif // SC_TRACING_PHASE_CALLBACKS_
20612027Sjungma@eit.uni-kl.de
20712027Sjungma@eit.uni-kl.de    // Initialize the VCD tracing
20812027Sjungma@eit.uni-kl.de    virtual void do_initialize();
20912027Sjungma@eit.uni-kl.de
21012027Sjungma@eit.uni-kl.de    unsigned vcd_name_index;           // Number of variables traced
21112027Sjungma@eit.uni-kl.de
21212027Sjungma@eit.uni-kl.de    unsigned previous_time_units_low;  // Previous time unit as 64-bit integer
21312027Sjungma@eit.uni-kl.de    unsigned previous_time_units_high;
21412027Sjungma@eit.uni-kl.de
21512027Sjungma@eit.uni-kl.depublic:
21612027Sjungma@eit.uni-kl.de
21712027Sjungma@eit.uni-kl.de    // Array to store the variables traced
21812027Sjungma@eit.uni-kl.de    std::vector<vcd_trace*> traces;
21912027Sjungma@eit.uni-kl.de
22012027Sjungma@eit.uni-kl.de    // Create VCD names for each variable
22112027Sjungma@eit.uni-kl.de    std::string obtain_name();
22212027Sjungma@eit.uni-kl.de
22312027Sjungma@eit.uni-kl.de};
22412027Sjungma@eit.uni-kl.de
22512027Sjungma@eit.uni-kl.de} // namespace sc_core
22612027Sjungma@eit.uni-kl.de
22712027Sjungma@eit.uni-kl.de#endif // SC_VCD_TRACE_H
22812027Sjungma@eit.uni-kl.de// Taf!
229