Code Search for Developers
 
 
  

example_gsconfigurable2.cpp from GreenSocs at Krugle


Show example_gsconfigurable2.cpp syntax highlighted

/**
 * Example demonstrates the usage of GreenBus Configuraiton Framework
 */

#include "utils/dust_model.h"
//#include "userAPI/shipAPI.h"
#include "protocol/generic.h"
#include "gstlm/tlm.h"
#include "utils/gs_config.h"

using namespace tlm;

class master : public sc_module, public gs_configurable {  
public:

  GenericMasterPort out;

  SC_CTOR(master) : out("out") {
    GS_TRACE("I am the master %s", name);

    // register parameters
    GS_PARAM(addr, MAddr);
    GS_PARAM(cmd, MCmd);
    GS_PARAM(data, char[20]);
  }

  gs_param<MAddr> addr;
  gs_param<MCmd> cmd;
  gs_param<char[20]> data;
};


class baby : public sc_module, public gs_configurable {
public:
  
  SC_CTOR(baby) {
    GS_TRACE("I am the baby %s", name);

    GS_PARAM(type, char[20]);
    GS_PARAM(color, char[20]);
  }

  gs_param<char[20]> type;
  gs_param<char[20]> color;
};



class slave : public sc_module, public gs_configurable, public tlm_b_if<GenericTransaction_P> {
public:

  GenericTargetPort in;

  SC_CTOR(slave) : in("in"), mybaby("erik") {
    GS_TRACE("I am the slave %s", name);

    GS_PARAM(addr_base, MAddr);
    GS_PARAM(addr_high, MAddr);    

    // bind PV interface
    in.bind_b_if(*this);
  }

  void b_transact(GenericTransaction_P t)
  {
    cout << name() << " WARNING: PV b_transact not implemented by this slave." << endl;
  }  

  gs_param<MAddr> addr_base, addr_high;
  gs_param<char[5]> foo; 

  baby mybaby;
};


int sc_main(int argc, char *argv[]) {

  DUST_INITIALIZE;

  master m("master");
  slave s("slave");  

  // set some parameters manually
  m.setParam("data", "Hello,GreenBus!");

  // set the rest by configuration file
  gs_config("test3.cfg");

  sc_start();

  return EXIT_SUCCESS;
}




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

  example_configurable.v2p
  example_configurable3.cpp
  example_gsconfigurable.cpp
  example_gsconfigurable2.cpp
  example_primchannel.cpp
  test1.cfg
  test2.cfg
  test3.cfg