Code Search for Developers
 
 
  

genericBridge.h from GreenSocs at Krugle


Show genericBridge.h syntax highlighted

/*
Copyright (c) 2006 : Technical University of Braunschweig, Germany

All rights reserved.

Authors: Wolfgang Klingauf, TU Braunschweig, E.I.S.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.  Redistributions
in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.  Neither the name of
the Technical University of Braunschweig, Germany nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/



#ifndef __genericBridge_h__
#define __genericBridge_h__

#include <systemc.h>

#include "gstlm/tlm.h"
#include "protocol/generic.h"


/**
 * This is the generic bridge. You can use it two connect two GreenBusses.
 * It owns an initiator and a target port.
 */
template <class TRANSACTION,     /* the transaction */
          class PHASE,           /* the phases that are supported by the protocol */
          class TRANSACTION_P = boost::shared_ptr<TRANSACTION>,
          class PHASE_P = PHASE,
          class ATOM = unevenpair<TRANSACTION_P, PHASE_P>,
          class INITPORT = initiator_port<TRANSACTION,GenericRouterAccess,PHASE>,
          class TARGETPORT = target_port<TRANSACTION,GenericRouterAccess,PHASE> >
class GenericBridge 
: public sc_module,
  public tlm_b_if<TRANSACTION_P>,
  public tlm_slave_if<MAddr>
{
public:
  TARGETPORT target_port;
  INITPORT init_port;


  SC_HAS_PROCESS(GenericBridge);

  GenericBridge(sc_module_name name_) 
    : sc_module(name_),
      target_port("target_port"),
      init_port("init_port"),
      m_setAddress_has_been_called(false)
  {
    GS_TRACE(name(), "I am a generic bridge.");

    // DUST structure analysis
#ifdef DUST_ENABLE
    DUST_BRIDGE("GenericBridge");
#endif

    // bind PV interface
    target_port.bind_b_if(*this);
    
    SC_METHOD( MasterAccessMonitor );
    sensitive << target_port.default_event();
    dont_initialize();

    SC_METHOD( SlaveAccessMonitor );
    sensitive << init_port.default_event();
    dont_initialize();
  }



  void MasterAccessMonitor()
  {
    GS_TRACE(name(), "Forwarding master atom");

    // forward payload to slave
    init_port.out->notify(target_port.get_payload());
  }


  void SlaveAccessMonitor() 
  {
    GS_TRACE(name(), "Forwarding slave atom");

    // forward payload to master
    target_port.out->notify(init_port.get_payload());
  }


  // PV blocking if ///////////////////////////////////////////////////////////

  void b_transact(TRANSACTION_P t)
  {
    GS_TRACE(name(), "forwarding PV transaction directly to target bus.");
    init_port.b_out->b_transact(t);
  }


  // TLM slave if /////////////////////////////////////////////////////////////

  typedef MAddr ADDRTYPE;


  /**
   * Currently, this bridge only supports the configuration of _one_ 
   * address range. This range is used for forwarding into both directions,
   * i.e. from bus A to bus B and vice versa.
   */
  virtual void setAddress(ADDRTYPE  base, ADDRTYPE  high) 
  {
    if (m_setAddress_has_been_called)
      SC_REPORT_WARNING(name(), "genericBridge does not support multiple address ranges");

    m_setAddress_has_been_called = true;
    m_base = base;
    m_high = high;
  }

  /**
   * TODO: man kˆnnte den Slave eine Addressliste zur¸ckgeben lassen, so dass auch Slaves
   * mit mehreren Addressranges mˆglich werden (wie z.B. diese BRidge..)
   */
  virtual void getAddress(ADDRTYPE& base, ADDRTYPE& high) 
  {
    base = m_base;
    high = m_high;
  }

protected:

  bool m_setAddress_has_been_called;
  ADDRTYPE m_base, m_high;
  
};

#endif




See more files for this project here

GreenSocs

To develop SystemC infrustructure, basic IP, patches and add on library code for eventual standerdization.\r\nThe GreenSocs project is made up of a number of contributions (sub projects). Please visit www.greensocs.com for more information.

Project homepage: http://sourceforge.net/projects/greensocs
Programming language(s): C,C++,Java,Perl,XML
License: other

  protocol/
    PLB/
      PLBBusProtocol.h
      PLBBusProtocol.tpp
    SimpleBus/
      simpleBusProtocol.h
    simpleAddressMap.h
  scheduler/
    dynamicPriorityScheduler.h
    fixedPriorityScheduler.h
  README_ROUTER
  genericBridge.h
  genericProtocol_if.h
  genericRouter.h
  genericRouter_call.h
  genericRouter_event.h
  genericRouter_if.h
  genericScheduler_if.h