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_signal_ports.h -- The sc_signal<T> port classes.
2312027Sjungma@eit.uni-kl.de
2412027Sjungma@eit.uni-kl.de  Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
2512027Sjungma@eit.uni-kl.de
2612027Sjungma@eit.uni-kl.de  CHANGE LOG APPEARS AT THE END OF THE FILE
2712027Sjungma@eit.uni-kl.de *****************************************************************************/
2812027Sjungma@eit.uni-kl.de
2912027Sjungma@eit.uni-kl.de#ifndef SC_SIGNAL_PORTS_H
3012027Sjungma@eit.uni-kl.de#define SC_SIGNAL_PORTS_H
3112027Sjungma@eit.uni-kl.de
3212027Sjungma@eit.uni-kl.de
3312027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_event_finder.h"
3412027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_port.h"
3512027Sjungma@eit.uni-kl.de#include "sysc/communication/sc_signal_ifs.h"
3612027Sjungma@eit.uni-kl.de#include "sysc/datatypes/bit/sc_logic.h"
3712027Sjungma@eit.uni-kl.de#include "sysc/tracing/sc_trace.h"
3812027Sjungma@eit.uni-kl.de
3912027Sjungma@eit.uni-kl.de#if ! defined( SC_DISABLE_VIRTUAL_BIND )
4012027Sjungma@eit.uni-kl.de#  define SC_VIRTUAL_ virtual
4112027Sjungma@eit.uni-kl.de#else
4212027Sjungma@eit.uni-kl.de#  define SC_VIRTUAL_ /* non-virtual */
4312027Sjungma@eit.uni-kl.de#endif
4412027Sjungma@eit.uni-kl.de
4512027Sjungma@eit.uni-kl.denamespace sc_core {
4612027Sjungma@eit.uni-kl.de
4712027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
4812027Sjungma@eit.uni-kl.de//  STRUCT : sc_trace_params
4912027Sjungma@eit.uni-kl.de//
5012027Sjungma@eit.uni-kl.de//  Struct for storing the trace file and object name of an sc_trace call.
5112027Sjungma@eit.uni-kl.de//  FOR INTERNAL USE ONLY!
5212027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
5312027Sjungma@eit.uni-kl.de
5412027Sjungma@eit.uni-kl.deextern void sc_deprecated_add_trace();
5512027Sjungma@eit.uni-kl.de
5612027Sjungma@eit.uni-kl.destruct sc_trace_params
5712027Sjungma@eit.uni-kl.de{
5812027Sjungma@eit.uni-kl.de    sc_trace_file*        tf;
5912027Sjungma@eit.uni-kl.de    std::string      name;
6012027Sjungma@eit.uni-kl.de
6112027Sjungma@eit.uni-kl.de    sc_trace_params( sc_trace_file* tf_, const std::string& name_ )
6212027Sjungma@eit.uni-kl.de	: tf( tf_ ), name( name_ )
6312027Sjungma@eit.uni-kl.de	{}
6412027Sjungma@eit.uni-kl.de};
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.de
6712027Sjungma@eit.uni-kl.detypedef std::vector<sc_trace_params*> sc_trace_params_vec;
6812027Sjungma@eit.uni-kl.de
6912027Sjungma@eit.uni-kl.de
7012027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
7112027Sjungma@eit.uni-kl.de//  CLASS : sc_in<T>
7212027Sjungma@eit.uni-kl.de//
7312027Sjungma@eit.uni-kl.de//  The sc_signal<T> input port class.
7412027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
7512027Sjungma@eit.uni-kl.de
7612027Sjungma@eit.uni-kl.detemplate <class T>
7712027Sjungma@eit.uni-kl.declass sc_in
7812027Sjungma@eit.uni-kl.de: public sc_port<sc_signal_in_if<T>,1,SC_ONE_OR_MORE_BOUND>
7912027Sjungma@eit.uni-kl.de{
8012027Sjungma@eit.uni-kl.depublic:
8112027Sjungma@eit.uni-kl.de
8212027Sjungma@eit.uni-kl.de    // typedefs
8312027Sjungma@eit.uni-kl.de
8412027Sjungma@eit.uni-kl.de    typedef T                                             data_type;
8512027Sjungma@eit.uni-kl.de
8612027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                    if_type;
8712027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>       base_type;
8812027Sjungma@eit.uni-kl.de    typedef sc_in<data_type>                              this_type;
8912027Sjungma@eit.uni-kl.de    typedef typename base_type::port_type                 base_port_type;
9012027Sjungma@eit.uni-kl.de
9112027Sjungma@eit.uni-kl.de    typedef if_type                                       in_if_type;
9212027Sjungma@eit.uni-kl.de    typedef base_type                                     in_port_type;
9312027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>                 inout_if_type;
9412027Sjungma@eit.uni-kl.de    typedef sc_port<inout_if_type,1,SC_ONE_OR_MORE_BOUND> inout_port_type;
9512027Sjungma@eit.uni-kl.de
9612027Sjungma@eit.uni-kl.depublic:
9712027Sjungma@eit.uni-kl.de
9812027Sjungma@eit.uni-kl.de    // constructors
9912027Sjungma@eit.uni-kl.de
10012027Sjungma@eit.uni-kl.de    sc_in()
10112027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ),
10212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
10312027Sjungma@eit.uni-kl.de	{}
10412027Sjungma@eit.uni-kl.de
10512027Sjungma@eit.uni-kl.de    explicit sc_in( const char* name_ )
10612027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ),
10712027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
10812027Sjungma@eit.uni-kl.de	{}
10912027Sjungma@eit.uni-kl.de
11012027Sjungma@eit.uni-kl.de    explicit sc_in( const in_if_type& interface_ )
11112027Sjungma@eit.uni-kl.de        : base_type( CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
11212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
11312027Sjungma@eit.uni-kl.de        {}
11412027Sjungma@eit.uni-kl.de
11512027Sjungma@eit.uni-kl.de    sc_in( const char* name_, const in_if_type& interface_ )
11612027Sjungma@eit.uni-kl.de	: base_type( name_, CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
11712027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
11812027Sjungma@eit.uni-kl.de	{}
11912027Sjungma@eit.uni-kl.de
12012027Sjungma@eit.uni-kl.de    explicit sc_in( in_port_type& parent_ )
12112027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
12212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
12312027Sjungma@eit.uni-kl.de	{}
12412027Sjungma@eit.uni-kl.de
12512027Sjungma@eit.uni-kl.de    sc_in( const char* name_, in_port_type& parent_ )
12612027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
12712027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
12812027Sjungma@eit.uni-kl.de	{}
12912027Sjungma@eit.uni-kl.de
13012027Sjungma@eit.uni-kl.de    explicit sc_in( inout_port_type& parent_ )
13112027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ),
13212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
13312027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
13412027Sjungma@eit.uni-kl.de
13512027Sjungma@eit.uni-kl.de    sc_in( const char* name_, inout_port_type& parent_ )
13612027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ),
13712027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
13812027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
13912027Sjungma@eit.uni-kl.de
14012027Sjungma@eit.uni-kl.de    sc_in( this_type& parent_ )
14112027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
14212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
14312027Sjungma@eit.uni-kl.de	{}
14412027Sjungma@eit.uni-kl.de
14512027Sjungma@eit.uni-kl.de    sc_in( const char* name_, this_type& parent_ )
14612027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
14712027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
14812027Sjungma@eit.uni-kl.de	{}
14912027Sjungma@eit.uni-kl.de
15012027Sjungma@eit.uni-kl.de
15112027Sjungma@eit.uni-kl.de    // destructor
15212027Sjungma@eit.uni-kl.de
15312027Sjungma@eit.uni-kl.de    virtual ~sc_in()
15412027Sjungma@eit.uni-kl.de	{
15512027Sjungma@eit.uni-kl.de	    remove_traces();
15612027Sjungma@eit.uni-kl.de	    delete m_change_finder_p;
15712027Sjungma@eit.uni-kl.de	}
15812027Sjungma@eit.uni-kl.de
15912027Sjungma@eit.uni-kl.de
16012027Sjungma@eit.uni-kl.de    // bind to in interface
16112027Sjungma@eit.uni-kl.de
16212027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( const in_if_type& interface_ )
16312027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( CCAST<in_if_type&>( interface_ ) ); }
16412027Sjungma@eit.uni-kl.de
16512027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_if_type& interface_ )
16612027Sjungma@eit.uni-kl.de	{ this->bind( CCAST<const in_if_type&>( interface_ ) ); }
16712027Sjungma@eit.uni-kl.de
16812027Sjungma@eit.uni-kl.de    void operator () ( const in_if_type& interface_ )
16912027Sjungma@eit.uni-kl.de	{ this->bind( interface_ ); }
17012027Sjungma@eit.uni-kl.de
17112027Sjungma@eit.uni-kl.de
17212027Sjungma@eit.uni-kl.de    // bind to parent in port
17312027Sjungma@eit.uni-kl.de
17412027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_port_type& parent_ )
17512027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
17612027Sjungma@eit.uni-kl.de
17712027Sjungma@eit.uni-kl.de    void operator () ( in_port_type& parent_ )
17812027Sjungma@eit.uni-kl.de        { this->bind( parent_ ); }
17912027Sjungma@eit.uni-kl.de
18012027Sjungma@eit.uni-kl.de
18112027Sjungma@eit.uni-kl.de    // bind to parent inout port
18212027Sjungma@eit.uni-kl.de
18312027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( inout_port_type& parent_ )
18412027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
18512027Sjungma@eit.uni-kl.de
18612027Sjungma@eit.uni-kl.de    void operator () ( inout_port_type& parent_ )
18712027Sjungma@eit.uni-kl.de	{ this->bind( parent_ ); }
18812027Sjungma@eit.uni-kl.de
18912027Sjungma@eit.uni-kl.de
19012027Sjungma@eit.uni-kl.de    // interface access shortcut methods
19112027Sjungma@eit.uni-kl.de
19212027Sjungma@eit.uni-kl.de    // get the default event
19312027Sjungma@eit.uni-kl.de
19412027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
19512027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
19612027Sjungma@eit.uni-kl.de
19712027Sjungma@eit.uni-kl.de
19812027Sjungma@eit.uni-kl.de    // get the value changed event
19912027Sjungma@eit.uni-kl.de
20012027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
20112027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
20212027Sjungma@eit.uni-kl.de
20312027Sjungma@eit.uni-kl.de
20412027Sjungma@eit.uni-kl.de    // read the current value
20512027Sjungma@eit.uni-kl.de
20612027Sjungma@eit.uni-kl.de    const data_type& read() const
20712027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
20812027Sjungma@eit.uni-kl.de
20912027Sjungma@eit.uni-kl.de    operator const data_type& () const
21012027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
21112027Sjungma@eit.uni-kl.de
21212027Sjungma@eit.uni-kl.de
21312027Sjungma@eit.uni-kl.de    // was there a value changed event?
21412027Sjungma@eit.uni-kl.de
21512027Sjungma@eit.uni-kl.de    bool event() const
21612027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
21712027Sjungma@eit.uni-kl.de
21812027Sjungma@eit.uni-kl.de
21912027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
22012027Sjungma@eit.uni-kl.de
22112027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
22212027Sjungma@eit.uni-kl.de    {
22312027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
22412027Sjungma@eit.uni-kl.de	{
22512027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
22612027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
22712027Sjungma@eit.uni-kl.de	}
22812027Sjungma@eit.uni-kl.de	return *m_change_finder_p;
22912027Sjungma@eit.uni-kl.de    }
23012027Sjungma@eit.uni-kl.de
23112027Sjungma@eit.uni-kl.de
23212027Sjungma@eit.uni-kl.de    // called when elaboration is done
23312027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
23412027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
23512027Sjungma@eit.uni-kl.de
23612027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
23712027Sjungma@eit.uni-kl.de
23812027Sjungma@eit.uni-kl.de    virtual const char* kind() const
23912027Sjungma@eit.uni-kl.de        { return "sc_in"; }
24012027Sjungma@eit.uni-kl.de
24112027Sjungma@eit.uni-kl.de
24212027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
24312027Sjungma@eit.uni-kl.de
24412027Sjungma@eit.uni-kl.de    // called by sc_trace
24512027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
24612027Sjungma@eit.uni-kl.de
24712027Sjungma@eit.uni-kl.deprotected:
24812027Sjungma@eit.uni-kl.de
24912027Sjungma@eit.uni-kl.de    void remove_traces() const;
25012027Sjungma@eit.uni-kl.de
25112027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
25212027Sjungma@eit.uni-kl.de
25312027Sjungma@eit.uni-kl.deprotected:
25412027Sjungma@eit.uni-kl.de
25512027Sjungma@eit.uni-kl.de    // called by pbind (for internal use only)
25612027Sjungma@eit.uni-kl.de    virtual int vbind( sc_interface& );
25712027Sjungma@eit.uni-kl.de    virtual int vbind( sc_port_base& );
25812027Sjungma@eit.uni-kl.de
25912027Sjungma@eit.uni-kl.de    // implement virtual base_type port-binding function
26012027Sjungma@eit.uni-kl.de    //  - avoids warnings on some compilers
26112027Sjungma@eit.uni-kl.de    //  - should only be called, when using sc_port_b explicitly
26212027Sjungma@eit.uni-kl.de    //  - errors are detected during elaboration
26312027Sjungma@eit.uni-kl.de
26412027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( base_port_type& parent_ )
26512027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
26612027Sjungma@eit.uni-kl.de
26712027Sjungma@eit.uni-kl.de
26812027Sjungma@eit.uni-kl.deprivate:
26912027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
27012027Sjungma@eit.uni-kl.de
27112027Sjungma@eit.uni-kl.deprivate:
27212027Sjungma@eit.uni-kl.de
27312027Sjungma@eit.uni-kl.de    // disabled
27412027Sjungma@eit.uni-kl.de    sc_in( const this_type& );
27512027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& );
27612027Sjungma@eit.uni-kl.de
27712027Sjungma@eit.uni-kl.de#ifdef __GNUC__
27812027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
27912027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
28012027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
28112027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
28212027Sjungma@eit.uni-kl.de    static data_type dummy;
28312027Sjungma@eit.uni-kl.de#endif
28412027Sjungma@eit.uni-kl.de};
28512027Sjungma@eit.uni-kl.de
28612027Sjungma@eit.uni-kl.detemplate<typename T>
28712027Sjungma@eit.uni-kl.de::std::ostream& operator << ( ::std::ostream& os, const sc_in<T>& a )
28812027Sjungma@eit.uni-kl.de{
28912027Sjungma@eit.uni-kl.de    return os << a->read();
29012027Sjungma@eit.uni-kl.de}
29112027Sjungma@eit.uni-kl.de
29212027Sjungma@eit.uni-kl.de// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
29312027Sjungma@eit.uni-kl.de
29412027Sjungma@eit.uni-kl.de
29512027Sjungma@eit.uni-kl.de// called when elaboration is done
29612027Sjungma@eit.uni-kl.de
29712027Sjungma@eit.uni-kl.detemplate <class T>
29812027Sjungma@eit.uni-kl.deinline
29912027Sjungma@eit.uni-kl.devoid
30012027Sjungma@eit.uni-kl.desc_in<T>::end_of_elaboration()
30112027Sjungma@eit.uni-kl.de{
30212027Sjungma@eit.uni-kl.de    if( m_traces != 0 ) {
30312027Sjungma@eit.uni-kl.de	for( int i = 0; i < (int)m_traces->size(); ++ i ) {
30412027Sjungma@eit.uni-kl.de	    sc_trace_params* p = (*m_traces)[i];
30512027Sjungma@eit.uni-kl.de	    in_if_type* iface = DCAST<in_if_type*>( this->get_interface() );
30612027Sjungma@eit.uni-kl.de	    sc_trace( p->tf, iface->read(), p->name );
30712027Sjungma@eit.uni-kl.de	}
30812027Sjungma@eit.uni-kl.de	remove_traces();
30912027Sjungma@eit.uni-kl.de    }
31012027Sjungma@eit.uni-kl.de}
31112027Sjungma@eit.uni-kl.de
31212027Sjungma@eit.uni-kl.de
31312027Sjungma@eit.uni-kl.de// called by sc_trace
31412027Sjungma@eit.uni-kl.de
31512027Sjungma@eit.uni-kl.detemplate <class T>
31612027Sjungma@eit.uni-kl.deinline
31712027Sjungma@eit.uni-kl.devoid
31812027Sjungma@eit.uni-kl.desc_in<T>::add_trace_internal( sc_trace_file* tf_, const std::string& name_ )
31912027Sjungma@eit.uni-kl.deconst
32012027Sjungma@eit.uni-kl.de{
32112027Sjungma@eit.uni-kl.de    if( tf_ != 0 ) {
32212027Sjungma@eit.uni-kl.de	if( m_traces == 0 ) {
32312027Sjungma@eit.uni-kl.de	    m_traces = new sc_trace_params_vec;
32412027Sjungma@eit.uni-kl.de	}
32512027Sjungma@eit.uni-kl.de	m_traces->push_back( new sc_trace_params( tf_, name_ ) );
32612027Sjungma@eit.uni-kl.de    }
32712027Sjungma@eit.uni-kl.de}
32812027Sjungma@eit.uni-kl.de
32912027Sjungma@eit.uni-kl.detemplate <class T>
33012027Sjungma@eit.uni-kl.deinline
33112027Sjungma@eit.uni-kl.devoid
33212027Sjungma@eit.uni-kl.desc_in<T>::add_trace( sc_trace_file* tf_, const std::string& name_ )
33312027Sjungma@eit.uni-kl.deconst
33412027Sjungma@eit.uni-kl.de{
33512027Sjungma@eit.uni-kl.de    sc_deprecated_add_trace();
33612027Sjungma@eit.uni-kl.de    add_trace_internal(tf_, name_);
33712027Sjungma@eit.uni-kl.de}
33812027Sjungma@eit.uni-kl.de
33912027Sjungma@eit.uni-kl.detemplate <class T>
34012027Sjungma@eit.uni-kl.deinline
34112027Sjungma@eit.uni-kl.devoid
34212027Sjungma@eit.uni-kl.desc_in<T>::remove_traces() const
34312027Sjungma@eit.uni-kl.de{
34412027Sjungma@eit.uni-kl.de    if( m_traces != 0 ) {
34512027Sjungma@eit.uni-kl.de	for( int i = (int)m_traces->size() - 1; i >= 0; -- i ) {
34612027Sjungma@eit.uni-kl.de	    delete (*m_traces)[i];
34712027Sjungma@eit.uni-kl.de	}
34812027Sjungma@eit.uni-kl.de	delete m_traces;
34912027Sjungma@eit.uni-kl.de	m_traces = 0;
35012027Sjungma@eit.uni-kl.de    }
35112027Sjungma@eit.uni-kl.de}
35212027Sjungma@eit.uni-kl.de
35312027Sjungma@eit.uni-kl.de
35412027Sjungma@eit.uni-kl.de// called by pbind (for internal use only)
35512027Sjungma@eit.uni-kl.de
35612027Sjungma@eit.uni-kl.detemplate <class T>
35712027Sjungma@eit.uni-kl.deinline
35812027Sjungma@eit.uni-kl.deint
35912027Sjungma@eit.uni-kl.desc_in<T>::vbind( sc_interface& interface_ )
36012027Sjungma@eit.uni-kl.de{
36112027Sjungma@eit.uni-kl.de    return sc_port_b<if_type>::vbind( interface_ );
36212027Sjungma@eit.uni-kl.de}
36312027Sjungma@eit.uni-kl.de
36412027Sjungma@eit.uni-kl.detemplate <class T>
36512027Sjungma@eit.uni-kl.deinline
36612027Sjungma@eit.uni-kl.deint
36712027Sjungma@eit.uni-kl.desc_in<T>::vbind( sc_port_base& parent_ )
36812027Sjungma@eit.uni-kl.de{
36912027Sjungma@eit.uni-kl.de    in_port_type* in_parent = DCAST<in_port_type*>( &parent_ );
37012027Sjungma@eit.uni-kl.de    if( in_parent != 0 ) {
37112027Sjungma@eit.uni-kl.de	sc_port_base::bind( *in_parent );
37212027Sjungma@eit.uni-kl.de	return 0;
37312027Sjungma@eit.uni-kl.de    }
37412027Sjungma@eit.uni-kl.de    inout_port_type* inout_parent = DCAST<inout_port_type*>( &parent_ );
37512027Sjungma@eit.uni-kl.de    if( inout_parent != 0 ) {
37612027Sjungma@eit.uni-kl.de	sc_port_base::bind( *inout_parent );
37712027Sjungma@eit.uni-kl.de	return 0;
37812027Sjungma@eit.uni-kl.de    }
37912027Sjungma@eit.uni-kl.de    // type mismatch
38012027Sjungma@eit.uni-kl.de    return 2;
38112027Sjungma@eit.uni-kl.de}
38212027Sjungma@eit.uni-kl.de
38312027Sjungma@eit.uni-kl.de
38412027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
38512027Sjungma@eit.uni-kl.de//  CLASS : sc_in<bool>
38612027Sjungma@eit.uni-kl.de//
38712027Sjungma@eit.uni-kl.de//  Specialization of sc_in<T> for type bool.
38812027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
38912027Sjungma@eit.uni-kl.de
39012027Sjungma@eit.uni-kl.detemplate <>
39112027Sjungma@eit.uni-kl.declass sc_in<bool> :
39212027Sjungma@eit.uni-kl.de    public sc_port<sc_signal_in_if<bool>,1,SC_ONE_OR_MORE_BOUND>
39312027Sjungma@eit.uni-kl.de{
39412027Sjungma@eit.uni-kl.depublic:
39512027Sjungma@eit.uni-kl.de
39612027Sjungma@eit.uni-kl.de    // typedefs
39712027Sjungma@eit.uni-kl.de
39812027Sjungma@eit.uni-kl.de    typedef bool                                           data_type;
39912027Sjungma@eit.uni-kl.de
40012027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                     if_type;
40112027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>        base_type;
40212027Sjungma@eit.uni-kl.de    typedef sc_in<data_type>                               this_type;
40312027Sjungma@eit.uni-kl.de    typedef /* typename */ base_type::port_type            base_port_type;
40412027Sjungma@eit.uni-kl.de
40512027Sjungma@eit.uni-kl.de    typedef if_type                                        in_if_type;
40612027Sjungma@eit.uni-kl.de    typedef base_type                                      in_port_type;
40712027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>                  inout_if_type;
40812027Sjungma@eit.uni-kl.de    typedef sc_port<inout_if_type,1,SC_ONE_OR_MORE_BOUND>  inout_port_type;
40912027Sjungma@eit.uni-kl.de
41012027Sjungma@eit.uni-kl.depublic:
41112027Sjungma@eit.uni-kl.de
41212027Sjungma@eit.uni-kl.de    // constructors
41312027Sjungma@eit.uni-kl.de
41412027Sjungma@eit.uni-kl.de    sc_in()
41512027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ), m_change_finder_p(0),
41612027Sjungma@eit.uni-kl.de	  m_neg_finder_p(0), m_pos_finder_p(0)
41712027Sjungma@eit.uni-kl.de	{}
41812027Sjungma@eit.uni-kl.de
41912027Sjungma@eit.uni-kl.de    explicit sc_in( const char* name_ )
42012027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ), m_change_finder_p(0),
42112027Sjungma@eit.uni-kl.de	  m_neg_finder_p(0), m_pos_finder_p(0)
42212027Sjungma@eit.uni-kl.de	{}
42312027Sjungma@eit.uni-kl.de
42412027Sjungma@eit.uni-kl.de    explicit sc_in( const in_if_type& interface_ )
42512027Sjungma@eit.uni-kl.de	: base_type( CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
42612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
42712027Sjungma@eit.uni-kl.de	{}
42812027Sjungma@eit.uni-kl.de
42912027Sjungma@eit.uni-kl.de    sc_in( const char* name_, const in_if_type& interface_ )
43012027Sjungma@eit.uni-kl.de	: base_type( name_, CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
43112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
43212027Sjungma@eit.uni-kl.de	{}
43312027Sjungma@eit.uni-kl.de
43412027Sjungma@eit.uni-kl.de    explicit sc_in( in_port_type& parent_ )
43512027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
43612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
43712027Sjungma@eit.uni-kl.de	{}
43812027Sjungma@eit.uni-kl.de
43912027Sjungma@eit.uni-kl.de    sc_in( const char* name_, in_port_type& parent_ )
44012027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
44112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
44212027Sjungma@eit.uni-kl.de	{}
44312027Sjungma@eit.uni-kl.de
44412027Sjungma@eit.uni-kl.de    explicit sc_in( inout_port_type& parent_ )
44512027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ),
44612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
44712027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
44812027Sjungma@eit.uni-kl.de
44912027Sjungma@eit.uni-kl.de    sc_in( const char* name_, inout_port_type& parent_ )
45012027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ),
45112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
45212027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
45312027Sjungma@eit.uni-kl.de
45412027Sjungma@eit.uni-kl.de    sc_in( this_type& parent_ )
45512027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
45612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
45712027Sjungma@eit.uni-kl.de	{}
45812027Sjungma@eit.uni-kl.de
45912027Sjungma@eit.uni-kl.de#if defined(TESTING)
46012027Sjungma@eit.uni-kl.de    sc_in( const this_type& parent_ )
46112027Sjungma@eit.uni-kl.de	: base_type( *(in_if_type*)parent_.get_interface() ) , m_traces( 0 ),
46212027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
46312027Sjungma@eit.uni-kl.de	{}
46412027Sjungma@eit.uni-kl.de#endif
46512027Sjungma@eit.uni-kl.de
46612027Sjungma@eit.uni-kl.de    sc_in( const char* name_, this_type& parent_ )
46712027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
46812027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
46912027Sjungma@eit.uni-kl.de	{}
47012027Sjungma@eit.uni-kl.de
47112027Sjungma@eit.uni-kl.de
47212027Sjungma@eit.uni-kl.de    // destructor
47312027Sjungma@eit.uni-kl.de
47412027Sjungma@eit.uni-kl.de    virtual ~sc_in()
47512027Sjungma@eit.uni-kl.de	{
47612027Sjungma@eit.uni-kl.de	    remove_traces();
47712027Sjungma@eit.uni-kl.de	    delete m_change_finder_p;
47812027Sjungma@eit.uni-kl.de	    delete m_neg_finder_p;
47912027Sjungma@eit.uni-kl.de	    delete m_pos_finder_p;
48012027Sjungma@eit.uni-kl.de	}
48112027Sjungma@eit.uni-kl.de
48212027Sjungma@eit.uni-kl.de
48312027Sjungma@eit.uni-kl.de    // bind to in interface
48412027Sjungma@eit.uni-kl.de
48512027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( const in_if_type& interface_ )
48612027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( CCAST<in_if_type&>( interface_ ) ); }
48712027Sjungma@eit.uni-kl.de
48812027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_if_type& interface_ )
48912027Sjungma@eit.uni-kl.de	{ this->bind( CCAST<const in_if_type&>( interface_ ) ); }
49012027Sjungma@eit.uni-kl.de
49112027Sjungma@eit.uni-kl.de    void operator () ( const in_if_type& interface_ )
49212027Sjungma@eit.uni-kl.de	{ this->bind( interface_ ); }
49312027Sjungma@eit.uni-kl.de
49412027Sjungma@eit.uni-kl.de
49512027Sjungma@eit.uni-kl.de    // bind to parent in port
49612027Sjungma@eit.uni-kl.de
49712027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_port_type& parent_ )
49812027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
49912027Sjungma@eit.uni-kl.de
50012027Sjungma@eit.uni-kl.de    void operator () ( in_port_type& parent_ )
50112027Sjungma@eit.uni-kl.de        { this->bind( parent_ ); }
50212027Sjungma@eit.uni-kl.de
50312027Sjungma@eit.uni-kl.de
50412027Sjungma@eit.uni-kl.de    // bind to parent inout port
50512027Sjungma@eit.uni-kl.de
50612027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( inout_port_type& parent_ )
50712027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
50812027Sjungma@eit.uni-kl.de
50912027Sjungma@eit.uni-kl.de    void operator () ( inout_port_type& parent_ )
51012027Sjungma@eit.uni-kl.de	{ this->bind( parent_ ); }
51112027Sjungma@eit.uni-kl.de
51212027Sjungma@eit.uni-kl.de
51312027Sjungma@eit.uni-kl.de    // interface access shortcut methods
51412027Sjungma@eit.uni-kl.de
51512027Sjungma@eit.uni-kl.de    // get the default event
51612027Sjungma@eit.uni-kl.de
51712027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
51812027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
51912027Sjungma@eit.uni-kl.de
52012027Sjungma@eit.uni-kl.de
52112027Sjungma@eit.uni-kl.de    // get the value changed event
52212027Sjungma@eit.uni-kl.de
52312027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
52412027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
52512027Sjungma@eit.uni-kl.de
52612027Sjungma@eit.uni-kl.de    // get the positive edge event
52712027Sjungma@eit.uni-kl.de
52812027Sjungma@eit.uni-kl.de    const sc_event& posedge_event() const
52912027Sjungma@eit.uni-kl.de	{ return (*this)->posedge_event(); }
53012027Sjungma@eit.uni-kl.de
53112027Sjungma@eit.uni-kl.de    // get the negative edge event
53212027Sjungma@eit.uni-kl.de
53312027Sjungma@eit.uni-kl.de    const sc_event& negedge_event() const
53412027Sjungma@eit.uni-kl.de	{ return (*this)->negedge_event(); }
53512027Sjungma@eit.uni-kl.de
53612027Sjungma@eit.uni-kl.de
53712027Sjungma@eit.uni-kl.de    // read the current value
53812027Sjungma@eit.uni-kl.de
53912027Sjungma@eit.uni-kl.de    const data_type& read() const
54012027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
54112027Sjungma@eit.uni-kl.de
54212027Sjungma@eit.uni-kl.de    operator const data_type& () const
54312027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
54412027Sjungma@eit.uni-kl.de
54512027Sjungma@eit.uni-kl.de
54612027Sjungma@eit.uni-kl.de    // use for positive edge sensitivity
54712027Sjungma@eit.uni-kl.de
54812027Sjungma@eit.uni-kl.de    sc_event_finder& pos() const
54912027Sjungma@eit.uni-kl.de    {
55012027Sjungma@eit.uni-kl.de        if ( !m_pos_finder_p )
55112027Sjungma@eit.uni-kl.de	{
55212027Sjungma@eit.uni-kl.de	    m_pos_finder_p = new sc_event_finder_t<in_if_type>(
55312027Sjungma@eit.uni-kl.de	        *this, &in_if_type::posedge_event );
55412027Sjungma@eit.uni-kl.de	}
55512027Sjungma@eit.uni-kl.de	return *m_pos_finder_p;
55612027Sjungma@eit.uni-kl.de    }
55712027Sjungma@eit.uni-kl.de
55812027Sjungma@eit.uni-kl.de    // use for negative edge sensitivity
55912027Sjungma@eit.uni-kl.de
56012027Sjungma@eit.uni-kl.de    sc_event_finder& neg() const
56112027Sjungma@eit.uni-kl.de    {
56212027Sjungma@eit.uni-kl.de        if ( !m_neg_finder_p )
56312027Sjungma@eit.uni-kl.de	{
56412027Sjungma@eit.uni-kl.de	    m_neg_finder_p = new sc_event_finder_t<in_if_type>(
56512027Sjungma@eit.uni-kl.de	        *this, &in_if_type::negedge_event );
56612027Sjungma@eit.uni-kl.de	}
56712027Sjungma@eit.uni-kl.de	return *m_neg_finder_p;
56812027Sjungma@eit.uni-kl.de    }
56912027Sjungma@eit.uni-kl.de
57012027Sjungma@eit.uni-kl.de
57112027Sjungma@eit.uni-kl.de    // was there a value changed event?
57212027Sjungma@eit.uni-kl.de
57312027Sjungma@eit.uni-kl.de    bool event() const
57412027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
57512027Sjungma@eit.uni-kl.de
57612027Sjungma@eit.uni-kl.de    // was there a positive edge event?
57712027Sjungma@eit.uni-kl.de
57812027Sjungma@eit.uni-kl.de    bool posedge() const
57912027Sjungma@eit.uni-kl.de        { return (*this)->posedge(); }
58012027Sjungma@eit.uni-kl.de
58112027Sjungma@eit.uni-kl.de    // was there a negative edge event?
58212027Sjungma@eit.uni-kl.de
58312027Sjungma@eit.uni-kl.de    bool negedge() const
58412027Sjungma@eit.uni-kl.de        { return (*this)->negedge(); }
58512027Sjungma@eit.uni-kl.de
58612027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
58712027Sjungma@eit.uni-kl.de
58812027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
58912027Sjungma@eit.uni-kl.de    {
59012027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
59112027Sjungma@eit.uni-kl.de	{
59212027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
59312027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
59412027Sjungma@eit.uni-kl.de	}
59512027Sjungma@eit.uni-kl.de	return *m_change_finder_p;
59612027Sjungma@eit.uni-kl.de    }
59712027Sjungma@eit.uni-kl.de
59812027Sjungma@eit.uni-kl.de
59912027Sjungma@eit.uni-kl.de    // called when elaboration is done
60012027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
60112027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
60212027Sjungma@eit.uni-kl.de
60312027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
60412027Sjungma@eit.uni-kl.de
60512027Sjungma@eit.uni-kl.de    virtual const char* kind() const
60612027Sjungma@eit.uni-kl.de        { return "sc_in"; }
60712027Sjungma@eit.uni-kl.de
60812027Sjungma@eit.uni-kl.de
60912027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
61012027Sjungma@eit.uni-kl.de
61112027Sjungma@eit.uni-kl.de    // called by sc_trace
61212027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
61312027Sjungma@eit.uni-kl.de
61412027Sjungma@eit.uni-kl.deprotected:
61512027Sjungma@eit.uni-kl.de
61612027Sjungma@eit.uni-kl.de    void remove_traces() const;
61712027Sjungma@eit.uni-kl.de
61812027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
61912027Sjungma@eit.uni-kl.de
62012027Sjungma@eit.uni-kl.deprotected:
62112027Sjungma@eit.uni-kl.de
62212027Sjungma@eit.uni-kl.de    // called by pbind (for internal use only)
62312027Sjungma@eit.uni-kl.de    virtual int vbind( sc_interface& );
62412027Sjungma@eit.uni-kl.de    virtual int vbind( sc_port_base& );
62512027Sjungma@eit.uni-kl.de
62612027Sjungma@eit.uni-kl.de    // implement virtual base_type port-binding function
62712027Sjungma@eit.uni-kl.de    //  - avoids warnings on some compilers
62812027Sjungma@eit.uni-kl.de    //  - should only be called, when using sc_port_b explicitly
62912027Sjungma@eit.uni-kl.de    //  - errors are detected during elaboration
63012027Sjungma@eit.uni-kl.de
63112027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( base_port_type& parent_ )
63212027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
63312027Sjungma@eit.uni-kl.de
63412027Sjungma@eit.uni-kl.deprivate:
63512027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
63612027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_neg_finder_p;
63712027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_pos_finder_p;
63812027Sjungma@eit.uni-kl.de
63912027Sjungma@eit.uni-kl.deprivate:
64012027Sjungma@eit.uni-kl.de
64112027Sjungma@eit.uni-kl.de    // disabled
64212027Sjungma@eit.uni-kl.de#if defined(TESTING)
64312027Sjungma@eit.uni-kl.de#else
64412027Sjungma@eit.uni-kl.de    sc_in( const this_type& );
64512027Sjungma@eit.uni-kl.de#endif
64612027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& );
64712027Sjungma@eit.uni-kl.de
64812027Sjungma@eit.uni-kl.de#ifdef __GNUC__
64912027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
65012027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
65112027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
65212027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
65312027Sjungma@eit.uni-kl.de    static data_type dummy;
65412027Sjungma@eit.uni-kl.de#endif
65512027Sjungma@eit.uni-kl.de};
65612027Sjungma@eit.uni-kl.de
65712027Sjungma@eit.uni-kl.de
65812027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
65912027Sjungma@eit.uni-kl.de//  CLASS : sc_in<sc_dt::sc_logic>
66012027Sjungma@eit.uni-kl.de//
66112027Sjungma@eit.uni-kl.de//  Specialization of sc_in<T> for type sc_dt::sc_logic.
66212027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
66312027Sjungma@eit.uni-kl.de
66412027Sjungma@eit.uni-kl.detemplate <>
66512027Sjungma@eit.uni-kl.declass sc_in<sc_dt::sc_logic>
66612027Sjungma@eit.uni-kl.de: public sc_port<sc_signal_in_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>
66712027Sjungma@eit.uni-kl.de{
66812027Sjungma@eit.uni-kl.depublic:
66912027Sjungma@eit.uni-kl.de
67012027Sjungma@eit.uni-kl.de    // typedefs
67112027Sjungma@eit.uni-kl.de
67212027Sjungma@eit.uni-kl.de    typedef sc_dt::sc_logic                               data_type;
67312027Sjungma@eit.uni-kl.de
67412027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                    if_type;
67512027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>       base_type;
67612027Sjungma@eit.uni-kl.de    typedef sc_in<data_type>                              this_type;
67712027Sjungma@eit.uni-kl.de    typedef /* typename */ base_type::port_type           base_port_type;
67812027Sjungma@eit.uni-kl.de
67912027Sjungma@eit.uni-kl.de    typedef if_type                                       in_if_type;
68012027Sjungma@eit.uni-kl.de    typedef base_type                                     in_port_type;
68112027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>                 inout_if_type;
68212027Sjungma@eit.uni-kl.de    typedef sc_port<inout_if_type,1,SC_ONE_OR_MORE_BOUND> inout_port_type;
68312027Sjungma@eit.uni-kl.de
68412027Sjungma@eit.uni-kl.depublic:
68512027Sjungma@eit.uni-kl.de
68612027Sjungma@eit.uni-kl.de    // constructors
68712027Sjungma@eit.uni-kl.de
68812027Sjungma@eit.uni-kl.de    sc_in()
68912027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ),
69012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
69112027Sjungma@eit.uni-kl.de	{}
69212027Sjungma@eit.uni-kl.de
69312027Sjungma@eit.uni-kl.de    explicit sc_in( const char* name_ )
69412027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ),
69512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
69612027Sjungma@eit.uni-kl.de	{}
69712027Sjungma@eit.uni-kl.de
69812027Sjungma@eit.uni-kl.de    explicit sc_in( const in_if_type& interface_ )
69912027Sjungma@eit.uni-kl.de	: base_type( CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
70012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
70112027Sjungma@eit.uni-kl.de	{}
70212027Sjungma@eit.uni-kl.de
70312027Sjungma@eit.uni-kl.de    sc_in( const char* name_, const in_if_type& interface_ )
70412027Sjungma@eit.uni-kl.de	: base_type( name_, CCAST<in_if_type&>( interface_ ) ), m_traces( 0 ),
70512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
70612027Sjungma@eit.uni-kl.de	{}
70712027Sjungma@eit.uni-kl.de
70812027Sjungma@eit.uni-kl.de    explicit sc_in( in_port_type& parent_ )
70912027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
71012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
71112027Sjungma@eit.uni-kl.de	{}
71212027Sjungma@eit.uni-kl.de
71312027Sjungma@eit.uni-kl.de    sc_in( const char* name_, in_port_type& parent_ )
71412027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
71512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
71612027Sjungma@eit.uni-kl.de	{}
71712027Sjungma@eit.uni-kl.de
71812027Sjungma@eit.uni-kl.de    explicit sc_in( inout_port_type& parent_ )
71912027Sjungma@eit.uni-kl.de	: base_type(), m_traces( 0 ),
72012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
72112027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
72212027Sjungma@eit.uni-kl.de
72312027Sjungma@eit.uni-kl.de    sc_in( const char* name_, inout_port_type& parent_ )
72412027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_traces( 0 ),
72512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
72612027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
72712027Sjungma@eit.uni-kl.de
72812027Sjungma@eit.uni-kl.de    sc_in( this_type& parent_ )
72912027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_traces( 0 ),
73012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
73112027Sjungma@eit.uni-kl.de	{}
73212027Sjungma@eit.uni-kl.de
73312027Sjungma@eit.uni-kl.de    sc_in( const char* name_, this_type& parent_ )
73412027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_traces( 0 ),
73512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
73612027Sjungma@eit.uni-kl.de	{}
73712027Sjungma@eit.uni-kl.de
73812027Sjungma@eit.uni-kl.de
73912027Sjungma@eit.uni-kl.de    // destructor
74012027Sjungma@eit.uni-kl.de
74112027Sjungma@eit.uni-kl.de    virtual ~sc_in()
74212027Sjungma@eit.uni-kl.de	{
74312027Sjungma@eit.uni-kl.de	    remove_traces();
74412027Sjungma@eit.uni-kl.de	    delete m_change_finder_p;
74512027Sjungma@eit.uni-kl.de	    delete m_neg_finder_p;
74612027Sjungma@eit.uni-kl.de	    delete m_pos_finder_p;
74712027Sjungma@eit.uni-kl.de	}
74812027Sjungma@eit.uni-kl.de
74912027Sjungma@eit.uni-kl.de
75012027Sjungma@eit.uni-kl.de    // bind to in interface
75112027Sjungma@eit.uni-kl.de
75212027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( const in_if_type& interface_ )
75312027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( CCAST<in_if_type&>( interface_ ) ); }
75412027Sjungma@eit.uni-kl.de
75512027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_if_type& interface_ )
75612027Sjungma@eit.uni-kl.de	{ this->bind( CCAST<const in_if_type&>( interface_ ) ); }
75712027Sjungma@eit.uni-kl.de
75812027Sjungma@eit.uni-kl.de    void operator () ( const in_if_type& interface_ )
75912027Sjungma@eit.uni-kl.de	{ this->bind( interface_ ); }
76012027Sjungma@eit.uni-kl.de
76112027Sjungma@eit.uni-kl.de
76212027Sjungma@eit.uni-kl.de    // bind to parent in port
76312027Sjungma@eit.uni-kl.de
76412027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( in_port_type& parent_ )
76512027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
76612027Sjungma@eit.uni-kl.de
76712027Sjungma@eit.uni-kl.de    void operator () ( in_port_type& parent_ )
76812027Sjungma@eit.uni-kl.de        { this->bind( parent_ ); }
76912027Sjungma@eit.uni-kl.de
77012027Sjungma@eit.uni-kl.de
77112027Sjungma@eit.uni-kl.de    // bind to parent inout port
77212027Sjungma@eit.uni-kl.de
77312027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( inout_port_type& parent_ )
77412027Sjungma@eit.uni-kl.de	{ sc_port_base::bind( parent_ ); }
77512027Sjungma@eit.uni-kl.de
77612027Sjungma@eit.uni-kl.de    void operator () ( inout_port_type& parent_ )
77712027Sjungma@eit.uni-kl.de	{ this->bind( parent_ ); }
77812027Sjungma@eit.uni-kl.de
77912027Sjungma@eit.uni-kl.de
78012027Sjungma@eit.uni-kl.de    // interface access shortcut methods
78112027Sjungma@eit.uni-kl.de
78212027Sjungma@eit.uni-kl.de    // get the default event
78312027Sjungma@eit.uni-kl.de
78412027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
78512027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
78612027Sjungma@eit.uni-kl.de
78712027Sjungma@eit.uni-kl.de
78812027Sjungma@eit.uni-kl.de    // get the value changed event
78912027Sjungma@eit.uni-kl.de
79012027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
79112027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
79212027Sjungma@eit.uni-kl.de
79312027Sjungma@eit.uni-kl.de    // get the positive edge event
79412027Sjungma@eit.uni-kl.de
79512027Sjungma@eit.uni-kl.de    const sc_event& posedge_event() const
79612027Sjungma@eit.uni-kl.de	{ return (*this)->posedge_event(); }
79712027Sjungma@eit.uni-kl.de
79812027Sjungma@eit.uni-kl.de    // get the negative edge event
79912027Sjungma@eit.uni-kl.de
80012027Sjungma@eit.uni-kl.de    const sc_event& negedge_event() const
80112027Sjungma@eit.uni-kl.de	{ return (*this)->negedge_event(); }
80212027Sjungma@eit.uni-kl.de
80312027Sjungma@eit.uni-kl.de
80412027Sjungma@eit.uni-kl.de    // read the current value
80512027Sjungma@eit.uni-kl.de
80612027Sjungma@eit.uni-kl.de    const data_type& read() const
80712027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
80812027Sjungma@eit.uni-kl.de
80912027Sjungma@eit.uni-kl.de    operator const data_type& () const
81012027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
81112027Sjungma@eit.uni-kl.de
81212027Sjungma@eit.uni-kl.de
81312027Sjungma@eit.uni-kl.de    // use for positive edge sensitivity
81412027Sjungma@eit.uni-kl.de
81512027Sjungma@eit.uni-kl.de    sc_event_finder& pos() const
81612027Sjungma@eit.uni-kl.de    {
81712027Sjungma@eit.uni-kl.de        if ( !m_pos_finder_p )
81812027Sjungma@eit.uni-kl.de	{
81912027Sjungma@eit.uni-kl.de	    m_pos_finder_p = new sc_event_finder_t<in_if_type>(
82012027Sjungma@eit.uni-kl.de	        *this, &in_if_type::posedge_event );
82112027Sjungma@eit.uni-kl.de	}
82212027Sjungma@eit.uni-kl.de	return *m_pos_finder_p;
82312027Sjungma@eit.uni-kl.de    }
82412027Sjungma@eit.uni-kl.de
82512027Sjungma@eit.uni-kl.de    // use for negative edge sensitivity
82612027Sjungma@eit.uni-kl.de
82712027Sjungma@eit.uni-kl.de    sc_event_finder& neg() const
82812027Sjungma@eit.uni-kl.de    {
82912027Sjungma@eit.uni-kl.de        if ( !m_neg_finder_p )
83012027Sjungma@eit.uni-kl.de	{
83112027Sjungma@eit.uni-kl.de	    m_neg_finder_p = new sc_event_finder_t<in_if_type>(
83212027Sjungma@eit.uni-kl.de	        *this, &in_if_type::negedge_event );
83312027Sjungma@eit.uni-kl.de	}
83412027Sjungma@eit.uni-kl.de	return *m_neg_finder_p;
83512027Sjungma@eit.uni-kl.de    }
83612027Sjungma@eit.uni-kl.de
83712027Sjungma@eit.uni-kl.de
83812027Sjungma@eit.uni-kl.de    // was there a value changed event?
83912027Sjungma@eit.uni-kl.de
84012027Sjungma@eit.uni-kl.de    bool event() const
84112027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
84212027Sjungma@eit.uni-kl.de
84312027Sjungma@eit.uni-kl.de    // was there a positive edge event?
84412027Sjungma@eit.uni-kl.de
84512027Sjungma@eit.uni-kl.de    bool posedge() const
84612027Sjungma@eit.uni-kl.de        { return (*this)->posedge(); }
84712027Sjungma@eit.uni-kl.de
84812027Sjungma@eit.uni-kl.de    // was there a negative edge event?
84912027Sjungma@eit.uni-kl.de
85012027Sjungma@eit.uni-kl.de    bool negedge() const
85112027Sjungma@eit.uni-kl.de        { return (*this)->negedge(); }
85212027Sjungma@eit.uni-kl.de
85312027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
85412027Sjungma@eit.uni-kl.de
85512027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
85612027Sjungma@eit.uni-kl.de    {
85712027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
85812027Sjungma@eit.uni-kl.de	{
85912027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
86012027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
86112027Sjungma@eit.uni-kl.de	}
86212027Sjungma@eit.uni-kl.de	return *m_change_finder_p;
86312027Sjungma@eit.uni-kl.de    }
86412027Sjungma@eit.uni-kl.de
86512027Sjungma@eit.uni-kl.de
86612027Sjungma@eit.uni-kl.de    // called when elaboration is done
86712027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
86812027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
86912027Sjungma@eit.uni-kl.de
87012027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
87112027Sjungma@eit.uni-kl.de
87212027Sjungma@eit.uni-kl.de    virtual const char* kind() const
87312027Sjungma@eit.uni-kl.de        { return "sc_in"; }
87412027Sjungma@eit.uni-kl.de
87512027Sjungma@eit.uni-kl.de
87612027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
87712027Sjungma@eit.uni-kl.de
87812027Sjungma@eit.uni-kl.de    // called by sc_trace
87912027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
88012027Sjungma@eit.uni-kl.de
88112027Sjungma@eit.uni-kl.deprotected:
88212027Sjungma@eit.uni-kl.de
88312027Sjungma@eit.uni-kl.de    void remove_traces() const;
88412027Sjungma@eit.uni-kl.de
88512027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
88612027Sjungma@eit.uni-kl.de
88712027Sjungma@eit.uni-kl.deprotected:
88812027Sjungma@eit.uni-kl.de
88912027Sjungma@eit.uni-kl.de    // called by pbind (for internal use only)
89012027Sjungma@eit.uni-kl.de    virtual int vbind( sc_interface& );
89112027Sjungma@eit.uni-kl.de    virtual int vbind( sc_port_base& );
89212027Sjungma@eit.uni-kl.de
89312027Sjungma@eit.uni-kl.de    // implement virtual base_type port-binding function
89412027Sjungma@eit.uni-kl.de    //  - avoids warnings on some compilers
89512027Sjungma@eit.uni-kl.de    //  - should only be called, when using sc_port_b explicitly
89612027Sjungma@eit.uni-kl.de    //  - errors are detected during elaboration
89712027Sjungma@eit.uni-kl.de
89812027Sjungma@eit.uni-kl.de    SC_VIRTUAL_ void bind( base_port_type& parent_ )
89912027Sjungma@eit.uni-kl.de        { sc_port_base::bind( parent_ ); }
90012027Sjungma@eit.uni-kl.de
90112027Sjungma@eit.uni-kl.deprivate:
90212027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
90312027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_neg_finder_p;
90412027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_pos_finder_p;
90512027Sjungma@eit.uni-kl.de
90612027Sjungma@eit.uni-kl.deprivate:
90712027Sjungma@eit.uni-kl.de
90812027Sjungma@eit.uni-kl.de    // disabled
90912027Sjungma@eit.uni-kl.de    sc_in( const this_type& );
91012027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& );
91112027Sjungma@eit.uni-kl.de
91212027Sjungma@eit.uni-kl.de#ifdef __GNUC__
91312027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
91412027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
91512027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
91612027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
91712027Sjungma@eit.uni-kl.de    static data_type dummy;
91812027Sjungma@eit.uni-kl.de#endif
91912027Sjungma@eit.uni-kl.de};
92012027Sjungma@eit.uni-kl.de
92112027Sjungma@eit.uni-kl.de
92212027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
92312027Sjungma@eit.uni-kl.de//  CLASS : sc_inout<T>
92412027Sjungma@eit.uni-kl.de//
92512027Sjungma@eit.uni-kl.de//  The sc_signal<T> input/output port class.
92612027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
92712027Sjungma@eit.uni-kl.de
92812027Sjungma@eit.uni-kl.detemplate <class T>
92912027Sjungma@eit.uni-kl.declass sc_inout
93012027Sjungma@eit.uni-kl.de: public sc_port<sc_signal_inout_if<T>,1,SC_ONE_OR_MORE_BOUND>
93112027Sjungma@eit.uni-kl.de{
93212027Sjungma@eit.uni-kl.depublic:
93312027Sjungma@eit.uni-kl.de
93412027Sjungma@eit.uni-kl.de    // typedefs
93512027Sjungma@eit.uni-kl.de
93612027Sjungma@eit.uni-kl.de    typedef T                                          data_type;
93712027Sjungma@eit.uni-kl.de
93812027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>              if_type;
93912027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>    base_type;
94012027Sjungma@eit.uni-kl.de    typedef sc_inout<data_type>                        this_type;
94112027Sjungma@eit.uni-kl.de
94212027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                 in_if_type;
94312027Sjungma@eit.uni-kl.de    typedef sc_port<in_if_type,1,SC_ONE_OR_MORE_BOUND> in_port_type;
94412027Sjungma@eit.uni-kl.de    typedef if_type                                    inout_if_type;
94512027Sjungma@eit.uni-kl.de    typedef base_type                                  inout_port_type;
94612027Sjungma@eit.uni-kl.de
94712027Sjungma@eit.uni-kl.depublic:
94812027Sjungma@eit.uni-kl.de
94912027Sjungma@eit.uni-kl.de    // constructors
95012027Sjungma@eit.uni-kl.de
95112027Sjungma@eit.uni-kl.de    sc_inout()
95212027Sjungma@eit.uni-kl.de	: base_type(), m_init_val( 0 ), m_traces( 0 ),
95312027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
95412027Sjungma@eit.uni-kl.de	{}
95512027Sjungma@eit.uni-kl.de
95612027Sjungma@eit.uni-kl.de    explicit sc_inout( const char* name_ )
95712027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
95812027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
95912027Sjungma@eit.uni-kl.de	{}
96012027Sjungma@eit.uni-kl.de
96112027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_if_type& interface_ )
96212027Sjungma@eit.uni-kl.de	: base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
96312027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
96412027Sjungma@eit.uni-kl.de	{}
96512027Sjungma@eit.uni-kl.de
96612027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_if_type& interface_ )
96712027Sjungma@eit.uni-kl.de	: base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
96812027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
96912027Sjungma@eit.uni-kl.de	{}
97012027Sjungma@eit.uni-kl.de
97112027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_port_type& parent_ )
97212027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
97312027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
97412027Sjungma@eit.uni-kl.de	{}
97512027Sjungma@eit.uni-kl.de
97612027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_port_type& parent_ )
97712027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
97812027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
97912027Sjungma@eit.uni-kl.de	{}
98012027Sjungma@eit.uni-kl.de
98112027Sjungma@eit.uni-kl.de    sc_inout( this_type& parent_ )
98212027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
98312027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
98412027Sjungma@eit.uni-kl.de	{}
98512027Sjungma@eit.uni-kl.de
98612027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, this_type& parent_ )
98712027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
98812027Sjungma@eit.uni-kl.de	  m_change_finder_p(0)
98912027Sjungma@eit.uni-kl.de	{}
99012027Sjungma@eit.uni-kl.de
99112027Sjungma@eit.uni-kl.de
99212027Sjungma@eit.uni-kl.de    // destructor
99312027Sjungma@eit.uni-kl.de
99412027Sjungma@eit.uni-kl.de    virtual ~sc_inout();
99512027Sjungma@eit.uni-kl.de
99612027Sjungma@eit.uni-kl.de
99712027Sjungma@eit.uni-kl.de    // interface access shortcut methods
99812027Sjungma@eit.uni-kl.de
99912027Sjungma@eit.uni-kl.de    // get the default event
100012027Sjungma@eit.uni-kl.de
100112027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
100212027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
100312027Sjungma@eit.uni-kl.de
100412027Sjungma@eit.uni-kl.de
100512027Sjungma@eit.uni-kl.de    // get the value changed event
100612027Sjungma@eit.uni-kl.de
100712027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
100812027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
100912027Sjungma@eit.uni-kl.de
101012027Sjungma@eit.uni-kl.de
101112027Sjungma@eit.uni-kl.de    // read the current value
101212027Sjungma@eit.uni-kl.de
101312027Sjungma@eit.uni-kl.de    const data_type& read() const
101412027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
101512027Sjungma@eit.uni-kl.de
101612027Sjungma@eit.uni-kl.de    operator const data_type& () const
101712027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
101812027Sjungma@eit.uni-kl.de
101912027Sjungma@eit.uni-kl.de
102012027Sjungma@eit.uni-kl.de    // was there a value changed event?
102112027Sjungma@eit.uni-kl.de
102212027Sjungma@eit.uni-kl.de    bool event() const
102312027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
102412027Sjungma@eit.uni-kl.de
102512027Sjungma@eit.uni-kl.de
102612027Sjungma@eit.uni-kl.de    // write the new value
102712027Sjungma@eit.uni-kl.de
102812027Sjungma@eit.uni-kl.de    void write( const data_type& value_ )
102912027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); }
103012027Sjungma@eit.uni-kl.de
103112027Sjungma@eit.uni-kl.de    this_type& operator = ( const data_type& value_ )
103212027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); return *this; }
103312027Sjungma@eit.uni-kl.de
103412027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_if_type& interface_ )
103512027Sjungma@eit.uni-kl.de	{ (*this)->write( interface_.read() ); return *this; }
103612027Sjungma@eit.uni-kl.de
103712027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_port_type& port_ )
103812027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
103912027Sjungma@eit.uni-kl.de
104012027Sjungma@eit.uni-kl.de    this_type& operator = ( const inout_port_type& port_ )
104112027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
104212027Sjungma@eit.uni-kl.de
104312027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& port_ )
104412027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
104512027Sjungma@eit.uni-kl.de
104612027Sjungma@eit.uni-kl.de
104712027Sjungma@eit.uni-kl.de    // set initial value (can also be called when port is not bound yet)
104812027Sjungma@eit.uni-kl.de
104912027Sjungma@eit.uni-kl.de    void initialize( const data_type& value_ );
105012027Sjungma@eit.uni-kl.de
105112027Sjungma@eit.uni-kl.de    void initialize( const in_if_type& interface_ )
105212027Sjungma@eit.uni-kl.de	{ initialize( interface_.read() ); }
105312027Sjungma@eit.uni-kl.de
105412027Sjungma@eit.uni-kl.de
105512027Sjungma@eit.uni-kl.de    // called when elaboration is done
105612027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
105712027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
105812027Sjungma@eit.uni-kl.de
105912027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
106012027Sjungma@eit.uni-kl.de
106112027Sjungma@eit.uni-kl.de
106212027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
106312027Sjungma@eit.uni-kl.de
106412027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
106512027Sjungma@eit.uni-kl.de    {
106612027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
106712027Sjungma@eit.uni-kl.de	{
106812027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
106912027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
107012027Sjungma@eit.uni-kl.de	}
107112027Sjungma@eit.uni-kl.de	return *m_change_finder_p;
107212027Sjungma@eit.uni-kl.de    }
107312027Sjungma@eit.uni-kl.de
107412027Sjungma@eit.uni-kl.de    virtual const char* kind() const
107512027Sjungma@eit.uni-kl.de        { return "sc_inout"; }
107612027Sjungma@eit.uni-kl.de
107712027Sjungma@eit.uni-kl.deprotected:
107812027Sjungma@eit.uni-kl.de
107912027Sjungma@eit.uni-kl.de    data_type* m_init_val;
108012027Sjungma@eit.uni-kl.de
108112027Sjungma@eit.uni-kl.depublic:
108212027Sjungma@eit.uni-kl.de
108312027Sjungma@eit.uni-kl.de    // called by sc_trace
108412027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
108512027Sjungma@eit.uni-kl.de
108612027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
108712027Sjungma@eit.uni-kl.de
108812027Sjungma@eit.uni-kl.deprotected:
108912027Sjungma@eit.uni-kl.de
109012027Sjungma@eit.uni-kl.de    void remove_traces() const;
109112027Sjungma@eit.uni-kl.de
109212027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
109312027Sjungma@eit.uni-kl.de
109412027Sjungma@eit.uni-kl.deprivate:
109512027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
109612027Sjungma@eit.uni-kl.de
109712027Sjungma@eit.uni-kl.deprivate:
109812027Sjungma@eit.uni-kl.de
109912027Sjungma@eit.uni-kl.de    // disabled
110012027Sjungma@eit.uni-kl.de    sc_inout( const this_type& );
110112027Sjungma@eit.uni-kl.de
110212027Sjungma@eit.uni-kl.de#ifdef __GNUC__
110312027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
110412027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
110512027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
110612027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
110712027Sjungma@eit.uni-kl.de    static data_type dummy;
110812027Sjungma@eit.uni-kl.de#endif
110912027Sjungma@eit.uni-kl.de};
111012027Sjungma@eit.uni-kl.de
111112027Sjungma@eit.uni-kl.detemplate<typename T>
111212027Sjungma@eit.uni-kl.de::std::ostream& operator << ( ::std::ostream& os, const sc_inout<T>& a )
111312027Sjungma@eit.uni-kl.de{
111412027Sjungma@eit.uni-kl.de    return os << a->read();
111512027Sjungma@eit.uni-kl.de}
111612027Sjungma@eit.uni-kl.de
111712027Sjungma@eit.uni-kl.de// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
111812027Sjungma@eit.uni-kl.de
111912027Sjungma@eit.uni-kl.de
112012027Sjungma@eit.uni-kl.de// destructor
112112027Sjungma@eit.uni-kl.de
112212027Sjungma@eit.uni-kl.detemplate <class T>
112312027Sjungma@eit.uni-kl.deinline
112412027Sjungma@eit.uni-kl.desc_inout<T>::~sc_inout()
112512027Sjungma@eit.uni-kl.de{
112612027Sjungma@eit.uni-kl.de    delete m_change_finder_p;
112712027Sjungma@eit.uni-kl.de    delete m_init_val;
112812027Sjungma@eit.uni-kl.de    remove_traces();
112912027Sjungma@eit.uni-kl.de}
113012027Sjungma@eit.uni-kl.de
113112027Sjungma@eit.uni-kl.de
113212027Sjungma@eit.uni-kl.de// set initial value (can also be called when port is not bound yet)
113312027Sjungma@eit.uni-kl.de
113412027Sjungma@eit.uni-kl.detemplate <class T>
113512027Sjungma@eit.uni-kl.deinline
113612027Sjungma@eit.uni-kl.devoid
113712027Sjungma@eit.uni-kl.desc_inout<T>::initialize( const data_type& value_ )
113812027Sjungma@eit.uni-kl.de{
113912027Sjungma@eit.uni-kl.de    inout_if_type* iface = DCAST<inout_if_type*>( this->get_interface() );
114012027Sjungma@eit.uni-kl.de    if( iface != 0 ) {
114112027Sjungma@eit.uni-kl.de	iface->write( value_ );
114212027Sjungma@eit.uni-kl.de    } else {
114312027Sjungma@eit.uni-kl.de	if( m_init_val == 0 ) {
114412027Sjungma@eit.uni-kl.de	    m_init_val = new data_type;
114512027Sjungma@eit.uni-kl.de	}
114612027Sjungma@eit.uni-kl.de	*m_init_val = value_;
114712027Sjungma@eit.uni-kl.de    }
114812027Sjungma@eit.uni-kl.de}
114912027Sjungma@eit.uni-kl.de
115012027Sjungma@eit.uni-kl.de
115112027Sjungma@eit.uni-kl.de// called when elaboration is done
115212027Sjungma@eit.uni-kl.de
115312027Sjungma@eit.uni-kl.detemplate <class T>
115412027Sjungma@eit.uni-kl.deinline
115512027Sjungma@eit.uni-kl.devoid
115612027Sjungma@eit.uni-kl.desc_inout<T>::end_of_elaboration()
115712027Sjungma@eit.uni-kl.de{
115812027Sjungma@eit.uni-kl.de    if( m_init_val != 0 ) {
115912027Sjungma@eit.uni-kl.de	write( *m_init_val );
116012027Sjungma@eit.uni-kl.de	delete m_init_val;
116112027Sjungma@eit.uni-kl.de	m_init_val = 0;
116212027Sjungma@eit.uni-kl.de    }
116312027Sjungma@eit.uni-kl.de    if( m_traces != 0 ) {
116412027Sjungma@eit.uni-kl.de	for( int i = 0; i < (int)m_traces->size(); ++ i ) {
116512027Sjungma@eit.uni-kl.de	    sc_trace_params* p = (*m_traces)[i];
116612027Sjungma@eit.uni-kl.de	    in_if_type* iface = DCAST<in_if_type*>( this->get_interface() );
116712027Sjungma@eit.uni-kl.de	    sc_trace( p->tf, iface->read(), p->name );
116812027Sjungma@eit.uni-kl.de	}
116912027Sjungma@eit.uni-kl.de	remove_traces();
117012027Sjungma@eit.uni-kl.de    }
117112027Sjungma@eit.uni-kl.de}
117212027Sjungma@eit.uni-kl.de
117312027Sjungma@eit.uni-kl.de
117412027Sjungma@eit.uni-kl.de// called by sc_trace
117512027Sjungma@eit.uni-kl.de
117612027Sjungma@eit.uni-kl.detemplate <class T>
117712027Sjungma@eit.uni-kl.deinline
117812027Sjungma@eit.uni-kl.devoid
117912027Sjungma@eit.uni-kl.desc_inout<T>::add_trace_internal( sc_trace_file* tf_, const std::string& name_)
118012027Sjungma@eit.uni-kl.deconst
118112027Sjungma@eit.uni-kl.de{
118212027Sjungma@eit.uni-kl.de    if( tf_ != 0 ) {
118312027Sjungma@eit.uni-kl.de	    if( m_traces == 0 ) {
118412027Sjungma@eit.uni-kl.de	        m_traces = new sc_trace_params_vec;
118512027Sjungma@eit.uni-kl.de	    }
118612027Sjungma@eit.uni-kl.de	    m_traces->push_back( new sc_trace_params( tf_, name_ ) );
118712027Sjungma@eit.uni-kl.de    }
118812027Sjungma@eit.uni-kl.de}
118912027Sjungma@eit.uni-kl.de
119012027Sjungma@eit.uni-kl.detemplate <class T>
119112027Sjungma@eit.uni-kl.deinline
119212027Sjungma@eit.uni-kl.devoid
119312027Sjungma@eit.uni-kl.desc_inout<T>::add_trace( sc_trace_file* tf_, const std::string& name_) const
119412027Sjungma@eit.uni-kl.de{
119512027Sjungma@eit.uni-kl.de    sc_deprecated_add_trace();
119612027Sjungma@eit.uni-kl.de    add_trace_internal(tf_, name_);
119712027Sjungma@eit.uni-kl.de}
119812027Sjungma@eit.uni-kl.de
119912027Sjungma@eit.uni-kl.detemplate <class T>
120012027Sjungma@eit.uni-kl.deinline
120112027Sjungma@eit.uni-kl.devoid
120212027Sjungma@eit.uni-kl.desc_inout<T>::remove_traces() const
120312027Sjungma@eit.uni-kl.de{
120412027Sjungma@eit.uni-kl.de    if( m_traces != 0 ) {
120512027Sjungma@eit.uni-kl.de		for( int i = m_traces->size() - 1; i >= 0; -- i ) {
120612027Sjungma@eit.uni-kl.de	        delete (*m_traces)[i];
120712027Sjungma@eit.uni-kl.de		}
120812027Sjungma@eit.uni-kl.de		delete m_traces;
120912027Sjungma@eit.uni-kl.de		m_traces = 0;
121012027Sjungma@eit.uni-kl.de    }
121112027Sjungma@eit.uni-kl.de}
121212027Sjungma@eit.uni-kl.de
121312027Sjungma@eit.uni-kl.de
121412027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
121512027Sjungma@eit.uni-kl.de//  CLASS : sc_inout<bool>
121612027Sjungma@eit.uni-kl.de//
121712027Sjungma@eit.uni-kl.de//  Specialization of sc_inout<T> for type bool.
121812027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
121912027Sjungma@eit.uni-kl.de
122012027Sjungma@eit.uni-kl.detemplate <>
122112027Sjungma@eit.uni-kl.declass sc_inout<bool> :
122212027Sjungma@eit.uni-kl.de    public sc_port<sc_signal_inout_if<bool>,1,SC_ONE_OR_MORE_BOUND>
122312027Sjungma@eit.uni-kl.de{
122412027Sjungma@eit.uni-kl.depublic:
122512027Sjungma@eit.uni-kl.de
122612027Sjungma@eit.uni-kl.de    // typedefs
122712027Sjungma@eit.uni-kl.de
122812027Sjungma@eit.uni-kl.de    typedef bool                                       data_type;
122912027Sjungma@eit.uni-kl.de
123012027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>              if_type;
123112027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>    base_type;
123212027Sjungma@eit.uni-kl.de    typedef sc_inout<data_type>                        this_type;
123312027Sjungma@eit.uni-kl.de
123412027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                 in_if_type;
123512027Sjungma@eit.uni-kl.de    typedef sc_port<in_if_type,1,SC_ONE_OR_MORE_BOUND> in_port_type;
123612027Sjungma@eit.uni-kl.de    typedef if_type                                    inout_if_type;
123712027Sjungma@eit.uni-kl.de    typedef base_type                                  inout_port_type;
123812027Sjungma@eit.uni-kl.de
123912027Sjungma@eit.uni-kl.depublic:
124012027Sjungma@eit.uni-kl.de
124112027Sjungma@eit.uni-kl.de    // constructors
124212027Sjungma@eit.uni-kl.de
124312027Sjungma@eit.uni-kl.de    sc_inout()
124412027Sjungma@eit.uni-kl.de	: base_type(), m_init_val( 0 ), m_traces( 0 ),
124512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
124612027Sjungma@eit.uni-kl.de	{}
124712027Sjungma@eit.uni-kl.de
124812027Sjungma@eit.uni-kl.de    explicit sc_inout( const char* name_ )
124912027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
125012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
125112027Sjungma@eit.uni-kl.de	{}
125212027Sjungma@eit.uni-kl.de
125312027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_if_type& interface_ )
125412027Sjungma@eit.uni-kl.de	: base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
125512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
125612027Sjungma@eit.uni-kl.de	{}
125712027Sjungma@eit.uni-kl.de
125812027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_if_type& interface_ )
125912027Sjungma@eit.uni-kl.de	: base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
126012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
126112027Sjungma@eit.uni-kl.de	{}
126212027Sjungma@eit.uni-kl.de
126312027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_port_type& parent_ )
126412027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
126512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
126612027Sjungma@eit.uni-kl.de	{}
126712027Sjungma@eit.uni-kl.de
126812027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_port_type& parent_ )
126912027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
127012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
127112027Sjungma@eit.uni-kl.de	{}
127212027Sjungma@eit.uni-kl.de
127312027Sjungma@eit.uni-kl.de    sc_inout( this_type& parent_ )
127412027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
127512027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
127612027Sjungma@eit.uni-kl.de	{}
127712027Sjungma@eit.uni-kl.de
127812027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, this_type& parent_ )
127912027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
128012027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
128112027Sjungma@eit.uni-kl.de	{}
128212027Sjungma@eit.uni-kl.de
128312027Sjungma@eit.uni-kl.de
128412027Sjungma@eit.uni-kl.de    // destructor
128512027Sjungma@eit.uni-kl.de
128612027Sjungma@eit.uni-kl.de    virtual ~sc_inout();
128712027Sjungma@eit.uni-kl.de
128812027Sjungma@eit.uni-kl.de
128912027Sjungma@eit.uni-kl.de    // interface access shortcut methods
129012027Sjungma@eit.uni-kl.de
129112027Sjungma@eit.uni-kl.de    // get the default event
129212027Sjungma@eit.uni-kl.de
129312027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
129412027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
129512027Sjungma@eit.uni-kl.de
129612027Sjungma@eit.uni-kl.de
129712027Sjungma@eit.uni-kl.de    // get the value changed event
129812027Sjungma@eit.uni-kl.de
129912027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
130012027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
130112027Sjungma@eit.uni-kl.de
130212027Sjungma@eit.uni-kl.de    // get the positive edge event
130312027Sjungma@eit.uni-kl.de
130412027Sjungma@eit.uni-kl.de    const sc_event& posedge_event() const
130512027Sjungma@eit.uni-kl.de	{ return (*this)->posedge_event(); }
130612027Sjungma@eit.uni-kl.de
130712027Sjungma@eit.uni-kl.de    // get the negative edge event
130812027Sjungma@eit.uni-kl.de
130912027Sjungma@eit.uni-kl.de    const sc_event& negedge_event() const
131012027Sjungma@eit.uni-kl.de	{ return (*this)->negedge_event(); }
131112027Sjungma@eit.uni-kl.de
131212027Sjungma@eit.uni-kl.de
131312027Sjungma@eit.uni-kl.de    // read the current value
131412027Sjungma@eit.uni-kl.de
131512027Sjungma@eit.uni-kl.de    const data_type& read() const
131612027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
131712027Sjungma@eit.uni-kl.de
131812027Sjungma@eit.uni-kl.de    operator const data_type& () const
131912027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
132012027Sjungma@eit.uni-kl.de
132112027Sjungma@eit.uni-kl.de
132212027Sjungma@eit.uni-kl.de    // use for positive edge sensitivity
132312027Sjungma@eit.uni-kl.de
132412027Sjungma@eit.uni-kl.de    sc_event_finder& pos() const
132512027Sjungma@eit.uni-kl.de    {
132612027Sjungma@eit.uni-kl.de        if ( !m_pos_finder_p )
132712027Sjungma@eit.uni-kl.de	{
132812027Sjungma@eit.uni-kl.de	    m_pos_finder_p = new sc_event_finder_t<in_if_type>(
132912027Sjungma@eit.uni-kl.de	        *this, &in_if_type::posedge_event );
133012027Sjungma@eit.uni-kl.de	}
133112027Sjungma@eit.uni-kl.de	return *m_pos_finder_p;
133212027Sjungma@eit.uni-kl.de    }
133312027Sjungma@eit.uni-kl.de
133412027Sjungma@eit.uni-kl.de    // use for negative edge sensitivity
133512027Sjungma@eit.uni-kl.de
133612027Sjungma@eit.uni-kl.de    sc_event_finder& neg() const
133712027Sjungma@eit.uni-kl.de    {
133812027Sjungma@eit.uni-kl.de        if ( !m_neg_finder_p )
133912027Sjungma@eit.uni-kl.de	{
134012027Sjungma@eit.uni-kl.de	    m_neg_finder_p = new sc_event_finder_t<in_if_type>(
134112027Sjungma@eit.uni-kl.de	        *this, &in_if_type::negedge_event );
134212027Sjungma@eit.uni-kl.de	}
134312027Sjungma@eit.uni-kl.de	return *m_neg_finder_p;
134412027Sjungma@eit.uni-kl.de    }
134512027Sjungma@eit.uni-kl.de
134612027Sjungma@eit.uni-kl.de
134712027Sjungma@eit.uni-kl.de    // was there a value changed event?
134812027Sjungma@eit.uni-kl.de
134912027Sjungma@eit.uni-kl.de    bool event() const
135012027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
135112027Sjungma@eit.uni-kl.de
135212027Sjungma@eit.uni-kl.de    // was there a positive edge event?
135312027Sjungma@eit.uni-kl.de
135412027Sjungma@eit.uni-kl.de    bool posedge() const
135512027Sjungma@eit.uni-kl.de        { return (*this)->posedge(); }
135612027Sjungma@eit.uni-kl.de
135712027Sjungma@eit.uni-kl.de    // was there a negative edge event?
135812027Sjungma@eit.uni-kl.de
135912027Sjungma@eit.uni-kl.de    bool negedge() const
136012027Sjungma@eit.uni-kl.de        { return (*this)->negedge(); }
136112027Sjungma@eit.uni-kl.de
136212027Sjungma@eit.uni-kl.de    // write the new value
136312027Sjungma@eit.uni-kl.de
136412027Sjungma@eit.uni-kl.de    void write( const data_type& value_ )
136512027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); }
136612027Sjungma@eit.uni-kl.de
136712027Sjungma@eit.uni-kl.de    this_type& operator = ( const data_type& value_ )
136812027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); return *this; }
136912027Sjungma@eit.uni-kl.de
137012027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_if_type& interface_ )
137112027Sjungma@eit.uni-kl.de	{ (*this)->write( interface_.read() ); return *this; }
137212027Sjungma@eit.uni-kl.de
137312027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_port_type& port_ )
137412027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
137512027Sjungma@eit.uni-kl.de
137612027Sjungma@eit.uni-kl.de    this_type& operator = ( const inout_port_type& port_ )
137712027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
137812027Sjungma@eit.uni-kl.de
137912027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& port_ )
138012027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
138112027Sjungma@eit.uni-kl.de
138212027Sjungma@eit.uni-kl.de
138312027Sjungma@eit.uni-kl.de    // set initial value (can also be called when port is not bound yet)
138412027Sjungma@eit.uni-kl.de
138512027Sjungma@eit.uni-kl.de    void initialize( const data_type& value_ );
138612027Sjungma@eit.uni-kl.de
138712027Sjungma@eit.uni-kl.de    void initialize( const in_if_type& interface_ )
138812027Sjungma@eit.uni-kl.de	{ initialize( interface_.read() ); }
138912027Sjungma@eit.uni-kl.de
139012027Sjungma@eit.uni-kl.de
139112027Sjungma@eit.uni-kl.de    // called when elaboration is done
139212027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
139312027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
139412027Sjungma@eit.uni-kl.de
139512027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
139612027Sjungma@eit.uni-kl.de
139712027Sjungma@eit.uni-kl.de
139812027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
139912027Sjungma@eit.uni-kl.de
140012027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
140112027Sjungma@eit.uni-kl.de    {
140212027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
140312027Sjungma@eit.uni-kl.de	{
140412027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
140512027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
140612027Sjungma@eit.uni-kl.de	}
140712027Sjungma@eit.uni-kl.de	return *m_change_finder_p;
140812027Sjungma@eit.uni-kl.de    }
140912027Sjungma@eit.uni-kl.de
141012027Sjungma@eit.uni-kl.de    virtual const char* kind() const
141112027Sjungma@eit.uni-kl.de        { return "sc_inout"; }
141212027Sjungma@eit.uni-kl.de
141312027Sjungma@eit.uni-kl.deprotected:
141412027Sjungma@eit.uni-kl.de
141512027Sjungma@eit.uni-kl.de    data_type* m_init_val;
141612027Sjungma@eit.uni-kl.de
141712027Sjungma@eit.uni-kl.depublic:
141812027Sjungma@eit.uni-kl.de
141912027Sjungma@eit.uni-kl.de    // called by sc_trace
142012027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
142112027Sjungma@eit.uni-kl.de
142212027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
142312027Sjungma@eit.uni-kl.de
142412027Sjungma@eit.uni-kl.deprotected:
142512027Sjungma@eit.uni-kl.de
142612027Sjungma@eit.uni-kl.de    void remove_traces() const;
142712027Sjungma@eit.uni-kl.de
142812027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
142912027Sjungma@eit.uni-kl.de
143012027Sjungma@eit.uni-kl.deprivate:
143112027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
143212027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_neg_finder_p;
143312027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_pos_finder_p;
143412027Sjungma@eit.uni-kl.de
143512027Sjungma@eit.uni-kl.deprivate:
143612027Sjungma@eit.uni-kl.de
143712027Sjungma@eit.uni-kl.de    // disabled
143812027Sjungma@eit.uni-kl.de    sc_inout( const this_type& );
143912027Sjungma@eit.uni-kl.de
144012027Sjungma@eit.uni-kl.de#ifdef __GNUC__
144112027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
144212027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
144312027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
144412027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
144512027Sjungma@eit.uni-kl.de    static data_type dummy;
144612027Sjungma@eit.uni-kl.de#endif
144712027Sjungma@eit.uni-kl.de};
144812027Sjungma@eit.uni-kl.de
144912027Sjungma@eit.uni-kl.de
145012027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
145112027Sjungma@eit.uni-kl.de//  CLASS : sc_inout<sc_dt::sc_logic>
145212027Sjungma@eit.uni-kl.de//
145312027Sjungma@eit.uni-kl.de//  Specialization of sc_inout<T> for type sc_dt::sc_logic.
145412027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
145512027Sjungma@eit.uni-kl.de
145612027Sjungma@eit.uni-kl.detemplate <>
145712027Sjungma@eit.uni-kl.declass sc_inout<sc_dt::sc_logic>
145812027Sjungma@eit.uni-kl.de: public sc_port<sc_signal_inout_if<sc_dt::sc_logic>,1,SC_ONE_OR_MORE_BOUND>
145912027Sjungma@eit.uni-kl.de{
146012027Sjungma@eit.uni-kl.depublic:
146112027Sjungma@eit.uni-kl.de
146212027Sjungma@eit.uni-kl.de    // typedefs
146312027Sjungma@eit.uni-kl.de
146412027Sjungma@eit.uni-kl.de    typedef sc_dt::sc_logic                            data_type;
146512027Sjungma@eit.uni-kl.de
146612027Sjungma@eit.uni-kl.de    typedef sc_signal_inout_if<data_type>              if_type;
146712027Sjungma@eit.uni-kl.de    typedef sc_port<if_type,1,SC_ONE_OR_MORE_BOUND>    base_type;
146812027Sjungma@eit.uni-kl.de    typedef sc_inout<data_type>                        this_type;
146912027Sjungma@eit.uni-kl.de
147012027Sjungma@eit.uni-kl.de    typedef sc_signal_in_if<data_type>                 in_if_type;
147112027Sjungma@eit.uni-kl.de    typedef sc_port<in_if_type,1,SC_ONE_OR_MORE_BOUND> in_port_type;
147212027Sjungma@eit.uni-kl.de    typedef if_type                                    inout_if_type;
147312027Sjungma@eit.uni-kl.de    typedef base_type                                  inout_port_type;
147412027Sjungma@eit.uni-kl.de
147512027Sjungma@eit.uni-kl.depublic:
147612027Sjungma@eit.uni-kl.de
147712027Sjungma@eit.uni-kl.de    // constructors
147812027Sjungma@eit.uni-kl.de
147912027Sjungma@eit.uni-kl.de    sc_inout()
148012027Sjungma@eit.uni-kl.de	: base_type(), m_init_val( 0 ), m_traces( 0 ),
148112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
148212027Sjungma@eit.uni-kl.de	{}
148312027Sjungma@eit.uni-kl.de
148412027Sjungma@eit.uni-kl.de    explicit sc_inout( const char* name_ )
148512027Sjungma@eit.uni-kl.de	: base_type( name_ ), m_init_val( 0 ), m_traces( 0 ),
148612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
148712027Sjungma@eit.uni-kl.de	{}
148812027Sjungma@eit.uni-kl.de
148912027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_if_type& interface_ )
149012027Sjungma@eit.uni-kl.de	: base_type( interface_ ), m_init_val( 0 ), m_traces( 0 ),
149112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
149212027Sjungma@eit.uni-kl.de	{}
149312027Sjungma@eit.uni-kl.de
149412027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_if_type& interface_ )
149512027Sjungma@eit.uni-kl.de	: base_type( name_, interface_ ), m_init_val( 0 ), m_traces( 0 ),
149612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
149712027Sjungma@eit.uni-kl.de	{}
149812027Sjungma@eit.uni-kl.de
149912027Sjungma@eit.uni-kl.de    explicit sc_inout( inout_port_type& parent_ )
150012027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
150112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
150212027Sjungma@eit.uni-kl.de	{}
150312027Sjungma@eit.uni-kl.de
150412027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, inout_port_type& parent_ )
150512027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
150612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
150712027Sjungma@eit.uni-kl.de	{}
150812027Sjungma@eit.uni-kl.de
150912027Sjungma@eit.uni-kl.de    sc_inout( this_type& parent_ )
151012027Sjungma@eit.uni-kl.de	: base_type( parent_ ), m_init_val( 0 ), m_traces( 0 ),
151112027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
151212027Sjungma@eit.uni-kl.de	{}
151312027Sjungma@eit.uni-kl.de
151412027Sjungma@eit.uni-kl.de    sc_inout( const char* name_, this_type& parent_ )
151512027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ ), m_init_val( 0 ), m_traces( 0 ),
151612027Sjungma@eit.uni-kl.de	  m_change_finder_p(0), m_neg_finder_p(0), m_pos_finder_p(0)
151712027Sjungma@eit.uni-kl.de	{}
151812027Sjungma@eit.uni-kl.de
151912027Sjungma@eit.uni-kl.de
152012027Sjungma@eit.uni-kl.de    // destructor
152112027Sjungma@eit.uni-kl.de
152212027Sjungma@eit.uni-kl.de    virtual ~sc_inout();
152312027Sjungma@eit.uni-kl.de
152412027Sjungma@eit.uni-kl.de
152512027Sjungma@eit.uni-kl.de    // interface access shortcut methods
152612027Sjungma@eit.uni-kl.de
152712027Sjungma@eit.uni-kl.de    // get the default event
152812027Sjungma@eit.uni-kl.de
152912027Sjungma@eit.uni-kl.de    const sc_event& default_event() const
153012027Sjungma@eit.uni-kl.de	{ return (*this)->default_event(); }
153112027Sjungma@eit.uni-kl.de
153212027Sjungma@eit.uni-kl.de
153312027Sjungma@eit.uni-kl.de    // get the value changed event
153412027Sjungma@eit.uni-kl.de
153512027Sjungma@eit.uni-kl.de    const sc_event& value_changed_event() const
153612027Sjungma@eit.uni-kl.de	{ return (*this)->value_changed_event(); }
153712027Sjungma@eit.uni-kl.de
153812027Sjungma@eit.uni-kl.de    // get the positive edge event
153912027Sjungma@eit.uni-kl.de
154012027Sjungma@eit.uni-kl.de    const sc_event& posedge_event() const
154112027Sjungma@eit.uni-kl.de	{ return (*this)->posedge_event(); }
154212027Sjungma@eit.uni-kl.de
154312027Sjungma@eit.uni-kl.de    // get the negative edge event
154412027Sjungma@eit.uni-kl.de
154512027Sjungma@eit.uni-kl.de    const sc_event& negedge_event() const
154612027Sjungma@eit.uni-kl.de	{ return (*this)->negedge_event(); }
154712027Sjungma@eit.uni-kl.de
154812027Sjungma@eit.uni-kl.de
154912027Sjungma@eit.uni-kl.de    // read the current value
155012027Sjungma@eit.uni-kl.de
155112027Sjungma@eit.uni-kl.de    const data_type& read() const
155212027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
155312027Sjungma@eit.uni-kl.de
155412027Sjungma@eit.uni-kl.de    operator const data_type& () const
155512027Sjungma@eit.uni-kl.de	{ return (*this)->read(); }
155612027Sjungma@eit.uni-kl.de
155712027Sjungma@eit.uni-kl.de
155812027Sjungma@eit.uni-kl.de    // use for positive edge sensitivity
155912027Sjungma@eit.uni-kl.de
156012027Sjungma@eit.uni-kl.de    sc_event_finder& pos() const
156112027Sjungma@eit.uni-kl.de    {
156212027Sjungma@eit.uni-kl.de        if ( !m_pos_finder_p )
156312027Sjungma@eit.uni-kl.de	{
156412027Sjungma@eit.uni-kl.de	    m_pos_finder_p = new sc_event_finder_t<in_if_type>(
156512027Sjungma@eit.uni-kl.de	        *this, &in_if_type::posedge_event );
156612027Sjungma@eit.uni-kl.de	}
156712027Sjungma@eit.uni-kl.de	return *m_pos_finder_p;
156812027Sjungma@eit.uni-kl.de    }
156912027Sjungma@eit.uni-kl.de
157012027Sjungma@eit.uni-kl.de    // use for negative edge sensitivity
157112027Sjungma@eit.uni-kl.de
157212027Sjungma@eit.uni-kl.de    sc_event_finder& neg() const
157312027Sjungma@eit.uni-kl.de    {
157412027Sjungma@eit.uni-kl.de        if ( !m_neg_finder_p )
157512027Sjungma@eit.uni-kl.de	{
157612027Sjungma@eit.uni-kl.de	    m_neg_finder_p = new sc_event_finder_t<in_if_type>(
157712027Sjungma@eit.uni-kl.de	        *this, &in_if_type::negedge_event );
157812027Sjungma@eit.uni-kl.de	}
157912027Sjungma@eit.uni-kl.de	return *m_neg_finder_p;
158012027Sjungma@eit.uni-kl.de    }
158112027Sjungma@eit.uni-kl.de
158212027Sjungma@eit.uni-kl.de
158312027Sjungma@eit.uni-kl.de    // was there a value changed event?
158412027Sjungma@eit.uni-kl.de
158512027Sjungma@eit.uni-kl.de    bool event() const
158612027Sjungma@eit.uni-kl.de	{ return (*this)->event(); }
158712027Sjungma@eit.uni-kl.de
158812027Sjungma@eit.uni-kl.de    // was there a positive edge event?
158912027Sjungma@eit.uni-kl.de
159012027Sjungma@eit.uni-kl.de    bool posedge() const
159112027Sjungma@eit.uni-kl.de        { return (*this)->posedge(); }
159212027Sjungma@eit.uni-kl.de
159312027Sjungma@eit.uni-kl.de    // was there a negative edge event?
159412027Sjungma@eit.uni-kl.de
159512027Sjungma@eit.uni-kl.de    bool negedge() const
159612027Sjungma@eit.uni-kl.de        { return (*this)->negedge(); }
159712027Sjungma@eit.uni-kl.de
159812027Sjungma@eit.uni-kl.de    // write the new value
159912027Sjungma@eit.uni-kl.de
160012027Sjungma@eit.uni-kl.de    void write( const data_type& value_ )
160112027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); }
160212027Sjungma@eit.uni-kl.de
160312027Sjungma@eit.uni-kl.de    this_type& operator = ( const data_type& value_ )
160412027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); return *this; }
160512027Sjungma@eit.uni-kl.de
160612027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_if_type& interface_ )
160712027Sjungma@eit.uni-kl.de	{ (*this)->write( interface_.read() ); return *this; }
160812027Sjungma@eit.uni-kl.de
160912027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_port_type& port_ )
161012027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
161112027Sjungma@eit.uni-kl.de
161212027Sjungma@eit.uni-kl.de    this_type& operator = ( const inout_port_type& port_ )
161312027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
161412027Sjungma@eit.uni-kl.de
161512027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& port_ )
161612027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
161712027Sjungma@eit.uni-kl.de
161812027Sjungma@eit.uni-kl.de
161912027Sjungma@eit.uni-kl.de    // set initial value (can also be called when port is not bound yet)
162012027Sjungma@eit.uni-kl.de
162112027Sjungma@eit.uni-kl.de    void initialize( const data_type& value_ );
162212027Sjungma@eit.uni-kl.de
162312027Sjungma@eit.uni-kl.de    void initialize( const in_if_type& interface_ )
162412027Sjungma@eit.uni-kl.de	{ initialize( interface_.read() ); }
162512027Sjungma@eit.uni-kl.de
162612027Sjungma@eit.uni-kl.de
162712027Sjungma@eit.uni-kl.de    // called when elaboration is done
162812027Sjungma@eit.uni-kl.de    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
162912027Sjungma@eit.uni-kl.de    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
163012027Sjungma@eit.uni-kl.de
163112027Sjungma@eit.uni-kl.de    virtual void end_of_elaboration();
163212027Sjungma@eit.uni-kl.de
163312027Sjungma@eit.uni-kl.de
163412027Sjungma@eit.uni-kl.de    // (other) event finder method(s)
163512027Sjungma@eit.uni-kl.de
163612027Sjungma@eit.uni-kl.de    sc_event_finder& value_changed() const
163712027Sjungma@eit.uni-kl.de    {
163812027Sjungma@eit.uni-kl.de        if ( !m_change_finder_p )
163912027Sjungma@eit.uni-kl.de	{
164012027Sjungma@eit.uni-kl.de	    m_change_finder_p = new sc_event_finder_t<in_if_type>(
164112027Sjungma@eit.uni-kl.de	        *this, &in_if_type::value_changed_event );
164212027Sjungma@eit.uni-kl.de	}
164312027Sjungma@eit.uni-kl.de        return *m_change_finder_p;
164412027Sjungma@eit.uni-kl.de    }
164512027Sjungma@eit.uni-kl.de
164612027Sjungma@eit.uni-kl.de    virtual const char* kind() const
164712027Sjungma@eit.uni-kl.de        { return "sc_inout"; }
164812027Sjungma@eit.uni-kl.de
164912027Sjungma@eit.uni-kl.deprotected:
165012027Sjungma@eit.uni-kl.de
165112027Sjungma@eit.uni-kl.de    data_type* m_init_val;
165212027Sjungma@eit.uni-kl.de
165312027Sjungma@eit.uni-kl.depublic:
165412027Sjungma@eit.uni-kl.de
165512027Sjungma@eit.uni-kl.de    // called by sc_trace
165612027Sjungma@eit.uni-kl.de    void add_trace_internal( sc_trace_file*, const std::string& ) const;
165712027Sjungma@eit.uni-kl.de
165812027Sjungma@eit.uni-kl.de    void add_trace( sc_trace_file*, const std::string& ) const;
165912027Sjungma@eit.uni-kl.de
166012027Sjungma@eit.uni-kl.deprotected:
166112027Sjungma@eit.uni-kl.de
166212027Sjungma@eit.uni-kl.de    void remove_traces() const;
166312027Sjungma@eit.uni-kl.de
166412027Sjungma@eit.uni-kl.de    mutable sc_trace_params_vec* m_traces;
166512027Sjungma@eit.uni-kl.de
166612027Sjungma@eit.uni-kl.deprivate:
166712027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_change_finder_p;
166812027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_neg_finder_p;
166912027Sjungma@eit.uni-kl.de  mutable sc_event_finder* m_pos_finder_p;
167012027Sjungma@eit.uni-kl.de
167112027Sjungma@eit.uni-kl.deprivate:
167212027Sjungma@eit.uni-kl.de
167312027Sjungma@eit.uni-kl.de    // disabled
167412027Sjungma@eit.uni-kl.de    sc_inout( const this_type& );
167512027Sjungma@eit.uni-kl.de
167612027Sjungma@eit.uni-kl.de#ifdef __GNUC__
167712027Sjungma@eit.uni-kl.de    // Needed to circumvent a problem in the g++-2.95.2 compiler:
167812027Sjungma@eit.uni-kl.de    // This unused variable forces the compiler to instantiate
167912027Sjungma@eit.uni-kl.de    // an object of T template so an implicit conversion from
168012027Sjungma@eit.uni-kl.de    // read() to a C++ intrinsic data type will work.
168112027Sjungma@eit.uni-kl.de    static data_type dummy;
168212027Sjungma@eit.uni-kl.de#endif
168312027Sjungma@eit.uni-kl.de};
168412027Sjungma@eit.uni-kl.de
168512027Sjungma@eit.uni-kl.de
168612027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
168712027Sjungma@eit.uni-kl.de//  CLASS : sc_out<T>
168812027Sjungma@eit.uni-kl.de//
168912027Sjungma@eit.uni-kl.de//  The sc_signal<T> output port class.
169012027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
169112027Sjungma@eit.uni-kl.de
169212027Sjungma@eit.uni-kl.de// sc_out can also read from its port, hence no difference with sc_inout.
169312027Sjungma@eit.uni-kl.de// For debugging reasons, a class is provided instead of a define.
169412027Sjungma@eit.uni-kl.de
169512027Sjungma@eit.uni-kl.detemplate <class T>
169612027Sjungma@eit.uni-kl.declass sc_out
169712027Sjungma@eit.uni-kl.de: public sc_inout<T>
169812027Sjungma@eit.uni-kl.de{
169912027Sjungma@eit.uni-kl.depublic:
170012027Sjungma@eit.uni-kl.de
170112027Sjungma@eit.uni-kl.de    // typedefs
170212027Sjungma@eit.uni-kl.de
170312027Sjungma@eit.uni-kl.de    typedef T                                   data_type;
170412027Sjungma@eit.uni-kl.de
170512027Sjungma@eit.uni-kl.de    typedef sc_out<data_type>                   this_type;
170612027Sjungma@eit.uni-kl.de    typedef sc_inout<data_type>                 base_type;
170712027Sjungma@eit.uni-kl.de
170812027Sjungma@eit.uni-kl.de    typedef typename base_type::in_if_type      in_if_type;
170912027Sjungma@eit.uni-kl.de    typedef typename base_type::in_port_type    in_port_type;
171012027Sjungma@eit.uni-kl.de    typedef typename base_type::inout_if_type   inout_if_type;
171112027Sjungma@eit.uni-kl.de    typedef typename base_type::inout_port_type inout_port_type;
171212027Sjungma@eit.uni-kl.de
171312027Sjungma@eit.uni-kl.depublic:
171412027Sjungma@eit.uni-kl.de
171512027Sjungma@eit.uni-kl.de    // constructors
171612027Sjungma@eit.uni-kl.de
171712027Sjungma@eit.uni-kl.de    sc_out()
171812027Sjungma@eit.uni-kl.de	: base_type()
171912027Sjungma@eit.uni-kl.de	{}
172012027Sjungma@eit.uni-kl.de
172112027Sjungma@eit.uni-kl.de    explicit sc_out( const char* name_ )
172212027Sjungma@eit.uni-kl.de	: base_type( name_ )
172312027Sjungma@eit.uni-kl.de	{}
172412027Sjungma@eit.uni-kl.de
172512027Sjungma@eit.uni-kl.de    explicit sc_out( inout_if_type& interface_ )
172612027Sjungma@eit.uni-kl.de	: base_type( interface_ )
172712027Sjungma@eit.uni-kl.de	{}
172812027Sjungma@eit.uni-kl.de
172912027Sjungma@eit.uni-kl.de    sc_out( const char* name_, inout_if_type& interface_ )
173012027Sjungma@eit.uni-kl.de	: base_type( name_, interface_ )
173112027Sjungma@eit.uni-kl.de	{}
173212027Sjungma@eit.uni-kl.de
173312027Sjungma@eit.uni-kl.de    explicit sc_out( inout_port_type& parent_ )
173412027Sjungma@eit.uni-kl.de	: base_type( parent_ )
173512027Sjungma@eit.uni-kl.de	{}
173612027Sjungma@eit.uni-kl.de
173712027Sjungma@eit.uni-kl.de    sc_out( const char* name_, inout_port_type& parent_ )
173812027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ )
173912027Sjungma@eit.uni-kl.de	{}
174012027Sjungma@eit.uni-kl.de
174112027Sjungma@eit.uni-kl.de    sc_out( this_type& parent_ )
174212027Sjungma@eit.uni-kl.de	: base_type( parent_ )
174312027Sjungma@eit.uni-kl.de	{}
174412027Sjungma@eit.uni-kl.de
174512027Sjungma@eit.uni-kl.de    sc_out( const char* name_, this_type& parent_ )
174612027Sjungma@eit.uni-kl.de	: base_type( name_, parent_ )
174712027Sjungma@eit.uni-kl.de	{}
174812027Sjungma@eit.uni-kl.de
174912027Sjungma@eit.uni-kl.de
175012027Sjungma@eit.uni-kl.de    // destructor (does nothing)
175112027Sjungma@eit.uni-kl.de
175212027Sjungma@eit.uni-kl.de    virtual ~sc_out()
175312027Sjungma@eit.uni-kl.de	{}
175412027Sjungma@eit.uni-kl.de
175512027Sjungma@eit.uni-kl.de
175612027Sjungma@eit.uni-kl.de    // write the new value
175712027Sjungma@eit.uni-kl.de
175812027Sjungma@eit.uni-kl.de    this_type& operator = ( const data_type& value_ )
175912027Sjungma@eit.uni-kl.de	{ (*this)->write( value_ ); return *this; }
176012027Sjungma@eit.uni-kl.de
176112027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_if_type& interface_ )
176212027Sjungma@eit.uni-kl.de	{ (*this)->write( interface_.read() ); return *this; }
176312027Sjungma@eit.uni-kl.de
176412027Sjungma@eit.uni-kl.de    this_type& operator = ( const in_port_type& port_ )
176512027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
176612027Sjungma@eit.uni-kl.de
176712027Sjungma@eit.uni-kl.de    this_type& operator = ( const inout_port_type& port_ )
176812027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
176912027Sjungma@eit.uni-kl.de
177012027Sjungma@eit.uni-kl.de    this_type& operator = ( const this_type& port_ )
177112027Sjungma@eit.uni-kl.de	{ (*this)->write( port_->read() ); return *this; }
177212027Sjungma@eit.uni-kl.de
177312027Sjungma@eit.uni-kl.de    virtual const char* kind() const
177412027Sjungma@eit.uni-kl.de        { return "sc_out"; }
177512027Sjungma@eit.uni-kl.de
177612027Sjungma@eit.uni-kl.deprivate:
177712027Sjungma@eit.uni-kl.de
177812027Sjungma@eit.uni-kl.de    // disabled
177912027Sjungma@eit.uni-kl.de    sc_out( const this_type& );
178012027Sjungma@eit.uni-kl.de};
178112027Sjungma@eit.uni-kl.de
178212027Sjungma@eit.uni-kl.de
178312027Sjungma@eit.uni-kl.de// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
178412027Sjungma@eit.uni-kl.de
178512027Sjungma@eit.uni-kl.de
178612027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
178712027Sjungma@eit.uni-kl.de//  FUNCTION : sc_trace
178812027Sjungma@eit.uni-kl.de// ----------------------------------------------------------------------------
178912027Sjungma@eit.uni-kl.de
179012027Sjungma@eit.uni-kl.detemplate <class T>
179112027Sjungma@eit.uni-kl.deinline
179212027Sjungma@eit.uni-kl.devoid
179312027Sjungma@eit.uni-kl.desc_trace(sc_trace_file* tf, const sc_in<T>& port, const std::string& name)
179412027Sjungma@eit.uni-kl.de{
179512027Sjungma@eit.uni-kl.de    const sc_signal_in_if<T>* iface = 0;
179612027Sjungma@eit.uni-kl.de    if (sc_get_curr_simcontext()->elaboration_done() )
179712027Sjungma@eit.uni-kl.de    {
179812027Sjungma@eit.uni-kl.de	iface = DCAST<const sc_signal_in_if<T>*>( port.get_interface() );
179912027Sjungma@eit.uni-kl.de    }
180012027Sjungma@eit.uni-kl.de
180112027Sjungma@eit.uni-kl.de    if ( iface )
180212027Sjungma@eit.uni-kl.de	sc_trace( tf, iface->read(), name );
180312027Sjungma@eit.uni-kl.de    else
180412027Sjungma@eit.uni-kl.de	port.add_trace_internal( tf, name );
180512027Sjungma@eit.uni-kl.de}
180612027Sjungma@eit.uni-kl.de
180712027Sjungma@eit.uni-kl.detemplate <class T>
180812027Sjungma@eit.uni-kl.deinline
180912027Sjungma@eit.uni-kl.devoid
181012027Sjungma@eit.uni-kl.desc_trace( sc_trace_file* tf, const sc_inout<T>& port,
181112027Sjungma@eit.uni-kl.de    const std::string& name )
181212027Sjungma@eit.uni-kl.de{
181312027Sjungma@eit.uni-kl.de    const sc_signal_in_if<T>* iface = 0;
181412027Sjungma@eit.uni-kl.de    if (sc_get_curr_simcontext()->elaboration_done() )
181512027Sjungma@eit.uni-kl.de    {
181612027Sjungma@eit.uni-kl.de	iface =DCAST<const sc_signal_in_if<T>*>( port.get_interface() );
181712027Sjungma@eit.uni-kl.de    }
181812027Sjungma@eit.uni-kl.de
181912027Sjungma@eit.uni-kl.de    if ( iface )
182012027Sjungma@eit.uni-kl.de	sc_trace( tf, iface->read(), name );
182112027Sjungma@eit.uni-kl.de    else
182212027Sjungma@eit.uni-kl.de	port.add_trace_internal( tf, name );
182312027Sjungma@eit.uni-kl.de}
182412027Sjungma@eit.uni-kl.de
182512027Sjungma@eit.uni-kl.de} // namespace sc_core
182612027Sjungma@eit.uni-kl.de
182712027Sjungma@eit.uni-kl.de#undef SC_VIRTUAL_
182812027Sjungma@eit.uni-kl.de
182912027Sjungma@eit.uni-kl.de/*****************************************************************************
183012027Sjungma@eit.uni-kl.de
183112027Sjungma@eit.uni-kl.de  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
183212027Sjungma@eit.uni-kl.de  changes you are making here.
183312027Sjungma@eit.uni-kl.de
183412027Sjungma@eit.uni-kl.de      Name, Affiliation, Date:  Jason Elbaum, Motorola, Inc., 2001-11-12
183512027Sjungma@eit.uni-kl.de  Description of Modification:  Added a static, private, otherwise
183612027Sjungma@eit.uni-kl.de                                unused data member to the sc_in
183712027Sjungma@eit.uni-kl.de                                and sc_inout classes to address
183812027Sjungma@eit.uni-kl.de                                a bug in the GNU compiler *only*.
183912027Sjungma@eit.uni-kl.de                                This works around a bug in g++ 2.95.2
184012027Sjungma@eit.uni-kl.de                                regarding implicit casting from a
184112027Sjungma@eit.uni-kl.de                                templated class to a C++ intrinsic type.
184212027Sjungma@eit.uni-kl.de
184312027Sjungma@eit.uni-kl.de *****************************************************************************/
184412027Sjungma@eit.uni-kl.de//$Log: sc_signal_ports.h,v $
184512027Sjungma@eit.uni-kl.de//Revision 1.10  2011/08/29 18:04:32  acg
184612027Sjungma@eit.uni-kl.de// Philipp A. Hartmann: miscellaneous clean ups.
184712027Sjungma@eit.uni-kl.de//
184812027Sjungma@eit.uni-kl.de//Revision 1.9  2011/08/26 20:45:43  acg
184912027Sjungma@eit.uni-kl.de// Andy Goodrich: moved the modification log to the end of the file to
185012027Sjungma@eit.uni-kl.de// eliminate source line number skew when check-ins are done.
185112027Sjungma@eit.uni-kl.de//
185212027Sjungma@eit.uni-kl.de//Revision 1.8  2011/08/07 19:08:01  acg
185312027Sjungma@eit.uni-kl.de// Andy Goodrich: moved logs to end of file so line number synching works
185412027Sjungma@eit.uni-kl.de// better between versions.
185512027Sjungma@eit.uni-kl.de//
185612027Sjungma@eit.uni-kl.de//Revision 1.7  2011/08/07 18:53:09  acg
185712027Sjungma@eit.uni-kl.de// Philipp A. Hartmann: add virtual instances of the bind function for
185812027Sjungma@eit.uni-kl.de// base classes to eliminate warning messages for clang platforms.
185912027Sjungma@eit.uni-kl.de//
186012027Sjungma@eit.uni-kl.de//Revision 1.6  2011/04/02 00:03:23  acg
186112027Sjungma@eit.uni-kl.de// Andy Goodrich: catch the other bind()'s that I missed in Philipp's update.
186212027Sjungma@eit.uni-kl.de//
186312027Sjungma@eit.uni-kl.de//Revision 1.5  2011/04/01 22:33:31  acg
186412027Sjungma@eit.uni-kl.de// Philipp A. Harmann: Use const interface signature to implement non-const
186512027Sjungma@eit.uni-kl.de// interface signature for virtual bind(...).
186612027Sjungma@eit.uni-kl.de//
186712027Sjungma@eit.uni-kl.de//Revision 1.4  2011/03/30 16:46:10  acg
186812027Sjungma@eit.uni-kl.de// Andy Goodrich: added a signature and removed a virtual specification
186912027Sjungma@eit.uni-kl.de// to eliminate warnings with certain compilers.
187012027Sjungma@eit.uni-kl.de//
187112027Sjungma@eit.uni-kl.de//Revision 1.3  2011/02/18 20:23:45  acg
187212027Sjungma@eit.uni-kl.de// Andy Goodrich: Copyright update.
187312027Sjungma@eit.uni-kl.de//
187412027Sjungma@eit.uni-kl.de//Revision 1.2  2011/01/20 16:52:15  acg
187512027Sjungma@eit.uni-kl.de// Andy Goodrich: changes for IEEE 1666 2011.
187612027Sjungma@eit.uni-kl.de//
187712027Sjungma@eit.uni-kl.de//Revision 1.1.1.1  2006/12/15 20:20:04  acg
187812027Sjungma@eit.uni-kl.de//SystemC 2.3
187912027Sjungma@eit.uni-kl.de//
188012027Sjungma@eit.uni-kl.de//Revision 1.11  2006/04/18 23:36:50  acg
188112027Sjungma@eit.uni-kl.de// Andy Goodrich: made add_trace_internal public until I can figure out
188212027Sjungma@eit.uni-kl.de// how to do a friend specification for sc_trace in an environment where
188312027Sjungma@eit.uni-kl.de// there are partial template and full template specifications for its
188412027Sjungma@eit.uni-kl.de// arguments.
188512027Sjungma@eit.uni-kl.de//
188612027Sjungma@eit.uni-kl.de//Revision 1.10  2006/04/18 18:01:26  acg
188712027Sjungma@eit.uni-kl.de// Andy Goodrich: added an add_trace_internal() method to the various port
188812027Sjungma@eit.uni-kl.de// classes so that sc_trace has something to call that won't emit an
188912027Sjungma@eit.uni-kl.de// IEEE 1666 deprecation message.
189012027Sjungma@eit.uni-kl.de//
189112027Sjungma@eit.uni-kl.de//Revision 1.9  2006/03/13 20:19:44  acg
189212027Sjungma@eit.uni-kl.de// Andy Goodrich: changed sc_event instances into pointers to sc_event instances
189312027Sjungma@eit.uni-kl.de// that are allocated as needed. This saves considerable storage for large
189412027Sjungma@eit.uni-kl.de// numbers of signals, etc.
189512027Sjungma@eit.uni-kl.de//
189612027Sjungma@eit.uni-kl.de//Revision 1.8  2006/02/02 23:42:37  acg
189712027Sjungma@eit.uni-kl.de// Andy Goodrich: implemented a much better fix to the sc_event_finder
189812027Sjungma@eit.uni-kl.de// proliferation problem. This new version allocates only a single event
189912027Sjungma@eit.uni-kl.de// finder for each port for each type of event, e.g., pos(), neg(), and
190012027Sjungma@eit.uni-kl.de// value_change(). The event finder persists as long as the port does,
190112027Sjungma@eit.uni-kl.de// which is what the LRM dictates. Because only a single instance is
190212027Sjungma@eit.uni-kl.de// allocated for each event type per port there is not a potential
190312027Sjungma@eit.uni-kl.de// explosion of storage as was true in the 2.0.1/2.1 versions.
190412027Sjungma@eit.uni-kl.de//
190512027Sjungma@eit.uni-kl.de//Revision 1.7  2006/02/02 21:38:12  acg
190612027Sjungma@eit.uni-kl.de// Andy Goodrich: fix to the comment log.
190712027Sjungma@eit.uni-kl.de//
190812027Sjungma@eit.uni-kl.de//Revision 1.4  2006/01/24 20:46:32  acg
190912027Sjungma@eit.uni-kl.de//Andy Goodrich: changes to eliminate use of deprecated features. For instance,
191012027Sjungma@eit.uni-kl.de//using notify(SC_ZERO_TIME) in place of notify_delayed().
191112027Sjungma@eit.uni-kl.de//
191212027Sjungma@eit.uni-kl.de//Revision 1.3  2006/01/13 18:47:42  acg
191312027Sjungma@eit.uni-kl.de//Added $Log command so that CVS comments are reproduced in the source.
191412027Sjungma@eit.uni-kl.de//
191512027Sjungma@eit.uni-kl.de//Revision 1.2  2006/01/03 23:18:26  acg
191612027Sjungma@eit.uni-kl.de//Changed copyright to include 2006.
191712027Sjungma@eit.uni-kl.de//
191812027Sjungma@eit.uni-kl.de//Revision 1.1.1.1  2005/12/19 23:16:43  acg
191912027Sjungma@eit.uni-kl.de//First check in of SystemC 2.1 into its own archive.
192012027Sjungma@eit.uni-kl.de//
192112027Sjungma@eit.uni-kl.de//Revision 1.18  2005/09/15 23:01:52  acg
192212027Sjungma@eit.uni-kl.de//Added std:: prefix to appropriate methods and types to get around
192312027Sjungma@eit.uni-kl.de//issues with the Edison Front End.
192412027Sjungma@eit.uni-kl.de//
192512027Sjungma@eit.uni-kl.de//Revision 1.17  2005/06/10 22:43:55  acg
192612027Sjungma@eit.uni-kl.de//Added CVS change log annotation.
192712027Sjungma@eit.uni-kl.de//
192812027Sjungma@eit.uni-kl.de
192912027Sjungma@eit.uni-kl.de#endif
193012027Sjungma@eit.uni-kl.de
193112027Sjungma@eit.uni-kl.de// Taf!
1932