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_ARBITER_H 00020 #define SAMPA_ARBITER_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 Arbiter : public Module, public InitiatorResponseInterface { 00098 SAMPA_MODULE(Arbiter); 00099 public: 00100 class Requester : public Target, public TargetRequestInterface { 00101 SAMPA_PERSISTENT(Requester); 00102 public: 00103 Requester(const Name& name); 00104 const Request& get_request() const; 00105 bool recieve_request(const Request& request); 00106 bool is_requesting() const; 00107 void bind_initiator(Initiator*); 00108 protected: 00109 Arbiter* m_arbiter; 00110 Gated<Request> m_request; 00111 Gated<bool> m_requesting; 00112 }; 00114 00115 Arbiter(const Name& name); 00116 00117 void bind_initiator(Initiator* initiator); 00118 Target* get_target(const std::string&); 00119 void bind_target(Target* target); 00120 Initiator* get_initiator() { return &p_initiator; } 00121 void bind_clock(Clock*); 00122 00123 enum SchedulingPolicy { 00124 PRIORITY, 00125 ROUND_ROBIN 00126 }; 00127 00129 private: 00130 friend class Requester; 00131 00132 void complete_restart(); 00133 bool recieve_response(const Response& response); 00134 const char* get_initiator_name() const; 00135 void recieve_request(); 00136 void arbitrate_priority(); 00137 void arbitrate_roundrobin(); 00138 void acknowledge_request_forwarded(); 00139 void forward_elected(); 00140 void forward_response(); 00141 int check(int); 00142 void acknowledge_response_forwarded(); 00143 00144 SizeParameter m_num_requester; 00145 Array<Requester> m_requesters; 00146 Initiator p_initiator; 00147 Gated<short> m_elected; 00148 short m_num_requesting; 00149 short m_arbitrated; 00150 short m_stalled; 00151 short m_bound; 00152 Fifo m_outstanding_fifo; 00153 Array<int> m_outstandings; 00154 ClockedEventSingle e_elected; 00155 Gated<Response> m_response; 00156 Gated<bool> m_response_pending; 00157 Gated<bool> m_accept_response; 00158 EventSingle e_arbitration; 00159 EnumeratedParameter<SchedulingPolicy> m_policy; 00161 }; 00162 00164 } 00165 00166 #endif 00167
1.5.3