Jump to content

makefile SystemC


olá

Recommended Posts

You can check out the example Makefiles in the installation (examples/build-unix/Makefile.{config,rules} and e.g. examples/sysc/simple_bus/Makefile) as a starting point. The files in examples/build-unix are reasonably generic, and you may "just" need to adjust the settings in Makefile.config. In the project's Makefile itself, you then set the PROJECT variable and your SRCS (to point to your source files).  Admittedly, documentation could be better (as usual), but you can ask here, if you have further questions.

The CMake support included in SystemC 2.3.2 is still experimental and is mostly targeted for early adopters with CMake knowledge.

Greetings from Duisburg,
  Philipp

Link to comment
Share on other sites

Thank you very much.

Before, I tried to only use the bash for compiling the file. I was able to compile HelloWorld.cpp.

My current beginner's project compiles, but the signals are not connected. Thus, their is no exchange between the modules.

Probably, my faults are quite obvious but their is no person in my environment having knowledge in SystemC.

So, in the following are the .cpp file and the command to compile. Is the .cpp file faulty, the bash command or both of them?

Thanks for your time and answer.

 

----------------------

$ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME
/lib-linux -Wl,-rpath=$SYSTEMC_HOME/lib-linux -o sc_main sc_main.cpp -lsystemc -lm

--------------------

#include <systemc.h>


SC_MODULE( stimuli_pressure_mech ) {

    sc_out<double> force_out;
    sc_out<double> area_out;

    void stimuli_pressure_mech_process();

    SC_CTOR(stimuli_pressure_mech) {
        std::cout << std::endl << "Hallo stimuli" << std::endl;
        SC_METHOD(stimuli_pressure_mech_process);
    }
};

void stimuli_pressure_mech::stimuli_pressure_mech_process() {
    double force_mech = 1;
    double area = 5;

   // while(1){
    std::cout << "force_mech: " << force_mech << ",\t" << "area: " <<area << std::endl;
    force_out.write(force_mech);
    area_out.write(area);
    //wait();
    //}
}


SC_MODULE( pass_on_impulse ) {

    sc_in<double> force_in;
    sc_in<double> area_in;

// sc_out<double> energy_air_out;
    void pass_on_impulse_process();

SC_CTOR( pass_on_impulse ) {
    std::cout << std::endl << "Hallo pass_on_impulse" << std::endl;
    SC_METHOD(pass_on_impulse_process);
    sensitive << force_in << area_in;

    }
};

void pass_on_impulse::pass_on_impulse_process() {

    const double MATERIAL_CONST = 1.2;
    double area;
    double force;
    double energy_air;
    //while ( true ) {
    cout << "force_in: " << force_in << endl;
        force = force_in.read();
        area = area_in.read();
        energy_air = force * MATERIAL_CONST;
        cout << "force: " << force << endl;
        cout << "area: " << area << endl;
       // energy_out.write( energy_air );
        cout << "Output pass on impulse: " << energy_air;
      //  wait();
    //}
}


int sc_main(int argc, char *argv[]) {
    //deactivate warnings
    sc_core::sc_report_handler::set_actions( "/IEEE_Std_1666/deprecated",sc_core::SC_DO_NOTHING );

sc_signal<double> force_main;
sc_signal<double> area_main;

stimuli_pressure_mech *S;
pass_on_impulse *PI;


S = new stimuli_pressure_mech("stimuli_pressure_mech");
S->force_out(force_main);
S->area_out(area_main);
S->stimuli_pressure_mech_process();

PI = new pass_on_impulse("pass_on_impulse");
PI->force_in(force_main);
PI->area_in(area_main);
PI->pass_on_impulse_process();

//sc_start(200);
return 0;
}

 

Link to comment
Share on other sites

Your stimuli_pressure_mech_process() member function has to be registered as a SC_THREAD and not a SC_METHOD to be able to use the wait() functions for timing the application of your stimuli.

It is not good practice to use the <systemc.h> header. Instead, you should get used right from the start to use the <systemc> header and prefix SystemC functions and types with the appropriate namespace prefixes. In context of functions, you can abbreviate typing by using "using" statements (e.g., "using namespace sc_core;") (cf. to a good book on C++). Also, instead of deactivating the deprecation warnings, you should fix the source of the problem in your code.

"sc_start(200)" with only the integer argument is non-standard and, if I remember correctly, has been removed from recent versions of the SystemC PoC simulator. Instead, you should also specify the time unit, e.g., "sc_start(200.0, sc_core::SC_NS);".

I suggest you read a good introductory book on SystemC, e.g., "SystemC from the Ground Up".

Link to comment
Share on other sites

In addition to Thorsten's comments, your main problem is that you call the processes directly instead of invoking sc_start.  You should never call process functions manually.  They are  scheduled by the kernel during the simulation instead.

Here's a cleaned up version of your sc_main:

int sc_main(int /*argc*/, char* /*argv*/[])
{
  sc_signal<double> force_main("force main");
  sc_signal<double> area_main("area_main");

  stimuli_pressure_mech S("stimuli_pressure_mech");
    S.force_out(force_main);
    S.area_out(area_main);

  pass_on_impulse PI("pass_on_impulse");
    PI.force_in(force_main);
    PI.area_in(area_main);

  sc_start();
  return 0;
} 

I did the following changes:

  • Drop warning suppression - why do you want to allow deprecated features? They are deprecated for a reason.
  • Add names to your signals
  • Drop dynamic allocation of modules in favor of properly cleaned up local variables
  • Drop manual calls to processes
  • Call sc_start to start the simulation (without specific end time, but Thorsten's suggestions is also possible)

Hope that helps,
  Philipp

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...