bridge.h

Go to the documentation of this file.
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_BRIDGE_H
00020 #define SAMPA_BRIDGE_H
00021 
00022 #include "sampa/component/protocol.h"
00023 #include "sampa/core/gated.h"
00024 #include "sampa/core/select.h"
00025 
00026 namespace Sampa {
00027 
00028   class Bridge : public Module, public TargetRequestInterface, public InitiatorResponseInterface {
00029     SAMPA_MODULE(Bridge);
00030   public:
00031     Bridge(const Name& name);
00032    
00033     void bind_target_clock(Clock* clock);
00034     void bind_target(Target* slave);
00035     Initiator* get_initiator() { return &p_slave; }
00036 
00037     void bind_initiator_clock(Clock* clock);
00038     void bind_initiator(Initiator* master);
00039     Target* get_target()    { return &p_master; }
00040 
00041     bool recieve_request(const Request& request);
00042     bool recieve_response(const Response& response);
00043     
00044   private: 
00045 
00046     void complete_restart();
00047     
00048     enum State {
00049       WAIT_REQUEST_FROM_MASTER,
00050       FORWARD_REQUEST_TO_SLAVE,
00051       WAIT_SLAVE_RESPONSE,
00052       FORWARD_RESPONSE_TO_MASTER,
00053       WAIT_RESPONSE_ACCEPTED_BY_MASTER
00054     };
00055 
00056     void execute();
00057 
00058     Clock*          p_master_clock;
00059     Target          p_master;
00060     Clock*          p_slave_clock;
00061     Initiator       p_slave;
00062     State           m_state;
00063     bool            m_accept_request;
00064     EventListener   e_new_request; 
00065     ClockedEvent    e_sync_master; 
00066     ClockedEvent    e_sync_slave; 
00067     Gated<Request>  m_request;
00068     Gated<Response> m_response;
00069   };
00070   
00071 }
00072 
00073 #endif

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3