Skip to content

Commit

Permalink
sc_event::none - an event that is never notified
Browse files Browse the repository at this point in the history
This commit adds a new static member `const sc_event none`
to the `sc_event` class, which can be used in contexts
where an event is required, which is never notified.

Current use cases in the kernel are:
 * sc_interface::default_event
 * sc_event_finder_t
 * tlm_event_finder_t
  • Loading branch information
pah committed Apr 29, 2017
1 parent 3740901 commit 55da81d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
5 changes: 3 additions & 2 deletions src/sysc/communication/sc_event_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ const sc_event&
sc_event_finder_t<IF>::find_event( sc_interface* if_p ) const
{
const IF* iface = ( if_p ) ? dynamic_cast<const IF*>( if_p ) :
dynamic_cast<const IF*>( port().get_interface() );
dynamic_cast<const IF*>( port().get_interface() );
if( iface == 0 ) {
report_error( SC_ID_FIND_EVENT_, "port is not bound" );
report_error( SC_ID_FIND_EVENT_, "port is not bound" );
return sc_event::none;
}
return (const_cast<IF*>( iface )->*m_event_method) ();
}
Expand Down
8 changes: 1 addition & 7 deletions src/sysc/communication/sc_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const sc_event&
sc_interface::default_event() const
{
SC_REPORT_WARNING( SC_ID_NO_DEFAULT_EVENT_, 0 );
return m_never_notified;
return sc_event::none;
}


Expand All @@ -67,12 +67,6 @@ sc_interface::~sc_interface()
sc_interface::sc_interface()
{}


// special event for never notified cases, note the special name to keep
// it out of the named event structures.

sc_event sc_interface::m_never_notified( sc_event::kernel_event );

} // namespace sc_core

// $Log: sc_interface.cpp,v $
Expand Down
11 changes: 0 additions & 11 deletions src/sysc/communication/sc_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ class SC_API sc_interface
// disabled
sc_interface( const sc_interface& );
sc_interface& operator = ( const sc_interface& );

private:

static sc_event m_never_notified;

#if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x520)
// Workaround for a bug in the Sun WorkShop 6 update 2 compiler.
// An empty virtual base class can cause the optimizer to
// generate wrong code.
char dummy;
#endif
};

} // namespace sc_core
Expand Down
3 changes: 3 additions & 0 deletions src/sysc/kernel/sc_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ using std::strncmp;
// The event class.
// ----------------------------------------------------------------------------

// kernel-internal event, that is never notified
const sc_event sc_event::none( kernel_event, "none" );

const char*
sc_event::basename() const
{
Expand Down
3 changes: 2 additions & 1 deletion src/sysc/kernel/sc_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class SC_API sc_event
friend class sc_method_process;
friend class sc_thread_process;
friend void sc_thread_cor_fn( void* arg );
friend class sc_interface;
friend class sc_clock;
friend class sc_event_queue;
friend class sc_signal_channel;
Expand Down Expand Up @@ -295,6 +294,8 @@ class SC_API sc_event
sc_event_and_expr operator & ( const sc_event& ) const;
sc_event_and_expr operator & ( const sc_event_and_list& ) const;

// never notified event
static const sc_event none;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ tlm_event_finder_t<IF,T>::find_event( sc_core::sc_interface* if_p ) const
dynamic_cast<const IF*>( port().get_interface() );
if( iface == 0 ) {
report_error( sc_core::SC_ID_FIND_EVENT_, "port is not bound" );
return sc_core::sc_event::none;
}
return (const_cast<IF*>( iface )->*m_event_method) ( 0 );
}
Expand Down

0 comments on commit 55da81d

Please sign in to comment.