00001 // sampalib.org ESL library and tools 00002 // Copyright (C) 2007 Thierry Grellier 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License version 2 as 00006 // published by the Free Software Foundation. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along 00014 // with this program; if not, write to the Free Software Foundation, Inc., 00015 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 // 00017 // contact: www.sampalib.org 00018 00019 #ifndef SAMPA_ROUTER_H 00020 #define SAMPA_ROUTER_H 00021 00022 #include "sampa/component/protocol.h" 00023 #include "sampa/core/gated.h" 00024 #include "sampa/core/sarray.h" 00025 #include "sampa/core/fifo.h" 00026 00027 namespace Sampa { 00028 00096 class Router : public Module, public TargetRequestInterface, public InitiatorResponseInterface { 00098 SAMPA_MODULE(Router); 00100 public: 00101 Router(const Name&); 00102 00103 void bind_clock(Clock*); 00104 void bind_initiator(Initiator*); 00105 Target* get_target() { return &p_target; } 00106 void bind_target(Target*); 00107 Initiator* get_initiator(const std::string&); 00108 00110 const char* get_target_name() const; 00111 bool recieve_request(const Request& request); 00112 bool recieve_response(const Response& response); 00113 00114 class Destination : public Initiator { 00115 SAMPA_PERSISTENT(Destination); 00116 public: 00117 Destination(const Name&); 00118 bool accept_address(const Address& address) const; 00119 private: 00120 HexParameter m_start_address; 00121 Address m_end_address; 00122 }; 00123 00124 private: 00125 void complete_restart(); 00126 int decode(const Address&); 00127 int check(int); 00128 void push(); 00129 void sync_route(); 00130 void route(); 00131 00132 Target p_target; 00133 SizeParameter m_num_destination; 00134 int m_bound; 00135 Array<Destination> m_destinations; 00136 Fifo m_fifo; 00137 Gated<Request> m_request; 00138 Array<Request> m_requests; 00139 Array<int> m_decoded; 00140 EventListenerSingle e_push; 00141 ClockedEventSingle e_sync_route; 00142 EventSingle e_route; 00143 int m_num_pending; 00144 int m_num_responses; 00145 int m_destination; 00146 bool m_pending_routing; 00147 bool m_blocked_on_response; 00148 bool m_pushing; 00150 }; 00151 00153 00154 } 00155 00156 #endif
1.5.3