Quantcast
Channel: SystemC Language Forum RSS Feed
Viewing all articles
Browse latest Browse all 595

While executing this systemc program i am getting an error binary not found

$
0
0

/*
 * sensor.h
 *
 *  Created on: 22.08.2013
 *      Author: Stieber
 */

#ifndef _SENSOR_H_
#define _SENSOR_H_

#include "systemc.h"

/*
 * SystemC Class Macro
 */
SC_MODULE (Sensor) {

    std::string filename; // Input File Name
    bool loop;

    void read_from_file()
    {
        bool force_exit = false; // used to exit while loop, for example, when file has ended

        sc_bv<16> x_bv,y_bv,z_bv; // Input Values in 16bit Bit Vector format

        sc_uint<16> x_uint, y_uint, z_uint; // Input Values in 16bit Unsigned Integer Format

        while(!force_exit)
        {
            ifstream input_file;
            input_file.open(filename.c_str());
            if (input_file.is_open())
            {
                while (!input_file.eof())
                {    
                    // Read Sensorvalues from File (decimal LSB Format)
                    std::string line;
                    getline(input_file, line, ';'); //X
                    x_bv = atoi(line.c_str());
                    getline(input_file, line, ';'); //Y
                    y_bv = atoi(line.c_str());
                    getline(input_file, line, ';'); //Z
                    z_bv = atoi(line.c_str());

                    // optional conversion into Unsigned Integer
                    x_uint = x_bv.to_uint();
                    y_uint = y_bv.to_uint();
                    z_uint = z_bv.to_uint();
                    
                    // print data
                    cout << "[" << sc_time_stamp() << "] New sensor data!" << endl;
                    cout << "\tX_BV: " << x_bv << " X_UINT: " << x_uint << endl;
                    cout << "\tY_BV: " << y_bv << " Y_UINT: " << y_uint << endl;
                    cout << "\tZ_BV: " << z_bv << " Z_UINT: " << z_uint << endl;
                    cout << endl;

                    //... here could the data be written to output, if connected to further modules
                    
                    // never forget the wait, if simulation time should go on
                    wait(1,SC_MS);
                }
                input_file.close();
            }
            else
            {
                cout << "WARNING: No sensor data found!" << endl;
                force_exit = true;
            }

            cout << "End of file reached." << endl;

            if(!loop)
                force_exit = true;
        }

        cout << "End of sensor input. Simulation is stopping now." << endl;
    }

    void setFilename(std::string _filename)
    {
        filename = _filename;
    }

    void setLoop(bool _loop)
    {
        loop = _loop;
    }

        SC_CTOR(Sensor)
    :     filename("sensordata.csv")
    ,    loop(false)
    {
                SC_THREAD(read_from_file);
    }
};

#endif /* _SENSOR_H_ */

 

 

after execution of this program i am getting an error stating: launch failed. Binary not found. and the following error

 

16:26:48 **** Incremental Build of configuration Debug for project sensor ****
make all
Building target: sensor
Invoking: GCC C++ Linker
g++  -o "sensor"  ./src/sensor.o   -lsystemc
/usr/lib/gcc/i686-linux-gnu/4.6/../../../../lib/libsystemc.so: undefined reference to `sc_main'
collect2: ld returned 1 exit status
make: *** [sensor] Error 1

16:26:48 Build Finished (took 170ms)


 


Viewing all articles
Browse latest Browse all 595

Trending Articles