| 1 | /***************************************************************************** |
| 2 | |
| 3 | The following code is derived, directly or indirectly, from the SystemC |
| 4 | source code Copyright (c) 1996-2004 by all Contributors. |
| 5 | All Rights reserved. |
| 6 | |
| 7 | The contents of this file are subject to the restrictions and limitations |
| 8 | set forth in the SystemC Open Source License Version 2.4 (the "License"); |
| 9 | You may not use this file except in compliance with such restrictions and |
| 10 | limitations. You may obtain instructions on how to receive a copy of the |
| 11 | License at http://www.systemc.org/. Software distributed by Contributors |
| 12 | under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF |
| 13 | ANY KIND, either express or implied. See the License for the specific |
| 14 | language governing rights and limitations under the License. |
| 15 | |
| 16 | *****************************************************************************/ |
| 17 | |
| 18 | |
| 19 | #ifndef _TLM_TARGET_PORT_BASE_H_ |
| 20 | #define _TLM_TARGET_PORT_BASE_H_ |
| 21 | |
| 22 | /*------------------------------------------------------------------------------ |
| 23 | * Includes |
| 24 | *----------------------------------------------------------------------------*/ |
| 25 | #include <vector> |
| 26 | |
| 27 | #include "systemc.h" |
| 28 | |
| 29 | |
| 30 | |
| 31 | //---------------------------------------------------------------------------- |
| 32 | /// Class tlm_target_port_base: This class is a base class for tlm_target port class. |
| 33 | /** |
| 34 | * |
| 35 | * \n It provides a container to store registered target ports as pointer list. |
| 36 | * \n In addition, it provides a target port ID used by to identify the input export port. |
| 37 | * This ID is injected in the request structure by the initiator at run time. |
| 38 | * |
| 39 | * \n Accessors are provided for the port list and port ID. |
| 40 | **/ |
| 41 | //---------------------------------------------------------------------------- |
| 42 | class tlm_target_port_base { |
| 43 | |
| 44 | typedef tlm_target_port_base this_type; |
| 45 | |
| 46 | public: |
| 47 | |
| 48 | //-------------- |
| 49 | // Constructor |
| 50 | //-------------- |
| 51 | tlm_target_port_base(): |
| 52 | m_tlm_export_id(0) { |
| 53 | m_target_port_list.push_back(this); |
| 54 | } |
| 55 | |
| 56 | //------------------------------------------ |
| 57 | /// @name Data members access methods |
| 58 | //------------------------------------------ |
| 59 | /// @{ |
| 60 | |
| 61 | /// Returns the port id |
| 62 | inline int get_tlm_export_id() const { |
| 63 | return(m_tlm_export_id); |
| 64 | } |
| 65 | |
| 66 | /// Sets the port id |
| 67 | void set_tlm_export_id(int tlm_export_id) { |
| 68 | m_tlm_export_id = tlm_export_id; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | //--------------------------------------------------------------------------- |
| 73 | |
| 74 | /// Register the target port |
| 75 | inline void register_target_port(this_type * target_port) { |
| 76 | m_target_port_list.push_back(target_port); |
| 77 | } |
| 78 | |
| 79 | /// Returns the vector of registered target port(s) |
| 80 | inline std::vector<this_type *>& get_target_port_list() { |
| 81 | return(m_target_port_list); |
| 82 | } |
| 83 | |
| 84 | /// Sets the vector of registered target port(s) (port propagation) |
| 85 | inline void set_target_port_list(std::vector<this_type*>& target_port_list) { |
| 86 | m_target_port_list = target_port_list; |
| 87 | } |
| 88 | |
| 89 | /// @} |
| 90 | |
| 91 | |
| 92 | protected: |
| 93 | |
| 94 | /// Port instance ID |
| 95 | int m_tlm_export_id; |
| 96 | |
| 97 | /// target port objects registration |
| 98 | /** |
| 99 | * Direct registration of the target port(s) into current target port. |
| 100 | * \n Used for transaction recording and target port id propagation in case of target port binding |
| 101 | * through a module hierarchy |
| 102 | **/ |
| 103 | std::vector<this_type *> m_target_port_list; |
| 104 | |
| 105 | }; |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | #endif /* _TLM_TARGET_PORT_BASE_H_ */ |
| 112 | |
| 113 | |