#include <rc_switch.h>
The Concept
A class that implements the pure virtual interface rc_switch is regarded to be a "switch" (as specified in The Concept behind ReChannel).
A switch is a helper component that serves as a connector of the dynamic and the static side. The basic principle of a switch is similar to that of a multiplexer (or demultiplexer, respectively). The switch's task is to control communication between the static side and an arbitrary number of reconfigurable modules on the dynamic side. The communication has to be channeled from a static interface to a dynamic interface, or vice versa.
Binding
The binding of a switch to a communication object of a reconfigurable module includes registering the reconfigurable module with the switch and registering the switch with the reconfigurable module. (see also: rc_switch::register_reconfigurable(), rc_reconfigurable::rc_register_switch())
Binding may only be performed during the elaboration phase. Whereas registering or unregistering of reconfigurable modules is allowed during elaboration and simulation.
The single communication object of the static side, that has has to be bound to this switch, is fixed during simulation. Whereas, the bound reconfigurable module on the dynamic side may vary over time. The reconfigurable modules that represent the dynamic side have to be registered with the switch.
Among all registered reconfigurable module at most one shall be loaded. A switch shall enforce the rule that only one reconfigurable can be loaded at a time. In case of a conflict an error shall be reported.
Control
The switch is a passive object that receives commands from a rc_reconfigurable instance (in most cases this will be the currently active one which is holding an exclusive lock on this switch). Most getter members of rc_switch are publicly accessible. Whereas all control methods are declared as "protected" and may only be accessed by friend classes, i.e. primarily by rc_reconfigurable.
Switch States
Switches possess a basic "switch behaviour", as they can be opened and closed just like ordinary switches. Hence, the valid switch states are UNDEF, OPEN and CLOSED. A state transition to OPEN shall only be performed if a registered reconfigurable module actually is loaded. UNDEF will be the current state if a switch is opened but currently no registered module exists that is loaded. A switch may be closed at every time when no blocking transactions are pending on this switch.
Communication
The switch has to ensure that only the currently active module is allowed to communicate. Unloaded modules shall be blocked from any external events and access attempts. If the switch is CLOSED or UNDEF all communication has to be blocked.
The communication may be filtered by a chain of interface filters, which can be set when the switch is opened up for a particular reconfigurable module instance.
Events shall be forwarded to the interface of the opposite side they arised.
The switch implementation is solely responsible for a correct communication flow. A particular switch implementation may impose additional restrictions or constraints on its usage.
Definition at line 127 of file rc_switch.h.
Public Types | |
enum | state_type { UNDEF = 0, OPEN, CLOSED } |
The three possible states of a switch. More... | |
enum | { STATE_COUNT = 3 } |
The number of possible switch states. More... | |
typedef std::vector < rc_interface_filter * > | filter_chain |
Type of the filter chain. | |
Public Member Functions | |
virtual std::string | get_switch_kind () const =0 |
The kind of the switch. | |
virtual std::string | get_switch_name () const =0 |
The name of the switch. | |
virtual state_type | get_switch_state () const =0 |
The current state. | |
virtual unsigned int | get_transaction_count () const =0 |
The number of pending transactions at this switch. | |
virtual sc_interface * | get_static_interface () const =0 |
Returns the static side's communication interface. | |
virtual sc_interface * | get_dynamic_interface () const =0 |
Returns the currently active reconfigurable side's interface. | |
virtual rc_reconfigurable * | get_current_reconfigurable () const =0 |
Returns the current reconfigurable module. | |
virtual bool | is_locked () const =0 |
Is the switch locked by a rc_reconfigurable? | |
virtual bool | is_registered (const rc_reconfigurable &reconf) const =0 |
Is the given rc_reconfigurable registered with this switch? | |
virtual bool | is_registered (const sc_interface &dyn_if) const =0 |
Is the given dynamic interface registered with this switch? | |
Protected Member Functions | |
virtual void | bind_static_object (const rc_object_handle &obj_to_bind)=0 |
Instructs the switch to bind itself to the given static object. | |
virtual void | bind_dynamic_object (const rc_object_handle &obj_to_bind)=0 |
Instructs the switch to bind itself to the given dynamic object. | |
virtual void | open ()=0 |
Opens up the switch. | |
virtual void | open (rc_reconfigurable &reconf, const filter_chain &filters=filter_chain())=0 |
Opens up the switch for a particular reconfigurable module. | |
virtual void | close ()=0 |
Closes the switch. | |
virtual void | set_undefined ()=0 |
Sets the switch to UNDEF state. | |
virtual void | refresh_notify ()=0 |
Request a refresh of the event notifications. | |
virtual void | register_reconfigurable (rc_reconfigurable &reconf, sc_interface &dyn_if)=0 |
Registers a rc_reconfigurable instance. | |
virtual void | unregister_reconfigurable (rc_reconfigurable &reconf)=0 |
Unregisters a previously registered rc_reconfigurable instance. | |
virtual sc_interface * | get_registered_interface (rc_reconfigurable &reconf) const =0 |
Returns the dynamic interface of a registered rc_reconfigurable. | |
virtual bool | is_lock_owner (const rc_reconfigurable &reconf) const =0 |
Has the switch been locked by the given rc_reconfigurable? | |
virtual bool | set_locked (rc_reconfigurable &lock_owner, bool lock)=0 |
Sets/unsets the lock owner. | |
virtual | ~rc_switch () |
Virtual destructor. | |
Friends | |
class | rc_reconfigurable |
Grant rc_reconfigurable full access to control the switch. | |
class | rc_switch_connector_base |
Allow rc_switch_connector_base to call the binding methods. |
typedef std::vector<rc_interface_filter*> filter_chain |
Type of the filter chain.
A filter chain is a vector of interface filters.
Reimplemented in rc_exportal_base, and rc_portal_base.
Definition at line 155 of file rc_switch.h.
enum state_type |
The three possible states of a switch.
Reimplemented in rc_exportal_base, rc_abstract_exportal, rc_portal_base, rc_portal_b, rc_abstract_switch_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
Definition at line 143 of file rc_switch.h.
anonymous enum |
virtual ~rc_switch | ( | ) | [inline, protected, virtual] |
virtual std::string get_switch_kind | ( | ) | const [pure virtual] |
The kind of the switch.
Implemented in rc_abstract_exportal, rc_portal_b, rc_abstract_switch_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
virtual std::string get_switch_name | ( | ) | const [pure virtual] |
The name of the switch.
Implemented in rc_abstract_exportal, rc_portal_b, rc_abstract_switch_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
Referenced by rc_reconfigurable::lock_switches(), and rc_reconfigurable::rc_register_switch().
virtual state_type get_switch_state | ( | ) | const [pure virtual] |
virtual unsigned int get_transaction_count | ( | ) | const [pure virtual] |
virtual sc_interface* get_static_interface | ( | ) | const [pure virtual] |
Returns the static side's communication interface.
This method is intended for informational purposes only. Invoking methods of the interface returned by this method is not allowed from outside of the portal.
Implemented in rc_abstract_exportal, rc_portal_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
virtual sc_interface* get_dynamic_interface | ( | ) | const [pure virtual] |
Returns the currently active reconfigurable side's interface.
Implemented in rc_exportal_base, and rc_portal_base.
virtual rc_reconfigurable* get_current_reconfigurable | ( | ) | const [pure virtual] |
Returns the current reconfigurable module.
Implemented in rc_exportal_base, and rc_portal_base.
virtual bool is_locked | ( | ) | const [pure virtual] |
Is the switch locked by a rc_reconfigurable?
Implemented in rc_abstract_switch_b.
Referenced by rc_reconfigurable::lock_switches().
virtual bool is_registered | ( | const rc_reconfigurable & | reconf | ) | const [pure virtual] |
virtual bool is_registered | ( | const sc_interface & | dyn_if | ) | const [pure virtual] |
Is the given dynamic interface registered with this switch?
Implemented in rc_abstract_switch, rc_abstract_switch< if_type >, rc_abstract_switch< sc_fifo_out_if< T > >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_abstract_switch< sc_fifo_in_if< T > >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_abstract_switch< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
virtual void bind_static_object | ( | const rc_object_handle & | obj_to_bind | ) | [protected, pure virtual] |
Instructs the switch to bind itself to the given static object.
Implemented in rc_abstract_exportal, rc_abstract_portal, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_abstract_portal< sc_in_rv< W > >, rc_abstract_portal< sc_port< sc_mutex_if > >, rc_abstract_portal< sc_in_resolved >, rc_abstract_portal< sc_inout< T > >, rc_abstract_portal< sc_in< T > >, rc_abstract_portal< sc_inout_rv< W > >, rc_abstract_portal< sc_inout_resolved >, rc_abstract_portal< sc_fifo_in< T > >, rc_abstract_portal< sc_fifo_out< T > >, rc_abstract_portal< sc_port< sc_event_queue_if > >, and rc_abstract_portal< sc_port< sc_semaphore_if > >.
Referenced by rc_switch_connector_base::bind_static().
virtual void bind_dynamic_object | ( | const rc_object_handle & | obj_to_bind | ) | [protected, pure virtual] |
Instructs the switch to bind itself to the given dynamic object.
Implemented in rc_abstract_exportal, rc_abstract_portal, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_abstract_portal< sc_in_rv< W > >, rc_abstract_portal< sc_port< sc_mutex_if > >, rc_abstract_portal< sc_in_resolved >, rc_abstract_portal< sc_inout< T > >, rc_abstract_portal< sc_in< T > >, rc_abstract_portal< sc_inout_rv< W > >, rc_abstract_portal< sc_inout_resolved >, rc_abstract_portal< sc_fifo_in< T > >, rc_abstract_portal< sc_fifo_out< T > >, rc_abstract_portal< sc_port< sc_event_queue_if > >, and rc_abstract_portal< sc_port< sc_semaphore_if > >.
Referenced by rc_switch_connector_base::bind_dynamic().
virtual void open | ( | ) | [protected, pure virtual] |
Opens up the switch.
If the switch is connected to an active rc_reconfigurable, the state is changed to OPEN, otherwise to UNDEF.
Implemented in rc_exportal_base, and rc_portal_base.
Referenced by rc_reconfigurable::change_switch_state().
virtual void open | ( | rc_reconfigurable & | reconf, | |
const filter_chain & | filters = filter_chain() | |||
) | [protected, pure virtual] |
Opens up the switch for a particular reconfigurable module.
If the switch is connected to an active rc_reconfigurable, the state is changed to OPEN, otherwise to UNDEF.
A filter chain can be specified that shall filter the communication.
virtual void close | ( | ) | [protected, pure virtual] |
Closes the switch.
Sets the switch to CLOSED state.
Implemented in rc_exportal_base, and rc_portal_base.
Referenced by rc_reconfigurable::change_switch_state().
virtual void set_undefined | ( | ) | [protected, pure virtual] |
Sets the switch to UNDEF state.
Implemented in rc_exportal_base, and rc_portal_base.
Referenced by rc_reconfigurable::change_switch_state().
virtual void refresh_notify | ( | ) | [protected, pure virtual] |
virtual void register_reconfigurable | ( | rc_reconfigurable & | reconf, | |
sc_interface & | dyn_if | |||
) | [protected, pure virtual] |
Registers a rc_reconfigurable instance.
reconf | the rc_reconfigurable instance | |
dyn_if | the connected dynamic interface |
Implemented in rc_exportal_base, rc_abstract_exportal, rc_portal_base, rc_portal_b, rc_abstract_switch_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
Referenced by rc_reconfigurable::move(), and rc_reconfigurable::rc_register_switch().
virtual void unregister_reconfigurable | ( | rc_reconfigurable & | reconf | ) | [protected, pure virtual] |
Unregisters a previously registered rc_reconfigurable instance.
Implemented in rc_exportal_base, rc_abstract_exportal, rc_portal_base, rc_portal_b, rc_abstract_switch_b, rc_abstract_exportal< if_type >, rc_abstract_exportal< sc_fifo_out_if< T > >, rc_abstract_exportal< sc_fifo_in_if< T > >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_portal_b< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_portal_b< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
Referenced by rc_reconfigurable::move().
virtual sc_interface* get_registered_interface | ( | rc_reconfigurable & | reconf | ) | const [protected, pure virtual] |
Returns the dynamic interface of a registered rc_reconfigurable.
This method is intended for informational purposes only. Invoking methods of the interface returned by this method is not allowed from outside of the portal.
Implemented in rc_abstract_switch, rc_abstract_switch< if_type >, rc_abstract_switch< sc_fifo_out_if< T > >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_mutex_if > >::if_type >, rc_abstract_switch< sc_fifo_in_if< T > >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_semaphore_if > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_fifo_in< T > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout_resolved >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< PORT >::port_traits::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_in_rv< W > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_fifo_out< T > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_port< sc_event_queue_if > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout_rv< W > >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_in_resolved >::if_type >, rc_abstract_switch< ReChannel::rc_port_traits< sc_inout< T > >::if_type >, and rc_abstract_switch< ReChannel::rc_port_traits< sc_in< T > >::if_type >.
Referenced by rc_portal_base::open(), rc_exportal_base::open(), and rc_reconfigurable::rc_register_switch().
virtual bool is_lock_owner | ( | const rc_reconfigurable & | reconf | ) | const [protected, pure virtual] |
Has the switch been locked by the given rc_reconfigurable?
Implemented in rc_abstract_switch_b.
Referenced by rc_reconfigurable::lock_switches().
virtual bool set_locked | ( | rc_reconfigurable & | lock_owner, | |
bool | lock | |||
) | [protected, pure virtual] |
Sets/unsets the lock owner.
Implemented in rc_abstract_switch_b.
Referenced by rc_reconfigurable::lock_switches(), and rc_reconfigurable::unlock_switches().
friend class rc_reconfigurable [friend] |
Grant rc_reconfigurable full access to control the switch.
Definition at line 132 of file rc_switch.h.
friend class rc_switch_connector_base [friend] |
Allow rc_switch_connector_base to call the binding methods.
Definition at line 136 of file rc_switch.h.