0

I got this error on SystemC, and I don't understand why. The error is:


  • 'write': is not a member of 'sc_core::sc_in' ConsoleApplication1
  • 'write': is not a member of 'sc_core::sc_in'
  • class "sc_core::sc_in" has no member "write"
  • class "sc_core::sc_in" has no member "write"

Here I put together the code.

#include<systemc.h>

SC_MODULE(prin) {

    sc_in<bool> a;

    void print() {

        cout << "Hello World\n";
    }

    SC_CTOR(prin) {

        SC_METHOD(print);
        sensitive << a;

    }
};

SC_MODULE(input) {
    prin b;

    void in() {
        b.a.write(false);
        wait();
        b.a.write(true);
        wait();

    }

    SC_CTOR(input) : b("sds"){

        SC_THREAD(in);
    }
};

int sc_main(int argc, char* argv[]) {
    input prin1("pint");
    sc_start();
    return 0;


}

If the error seems confusing, here I put together the picture of my error: The error printscreen

toolic
  • 57,801
  • 17
  • 75
  • 117
user13626458
  • 3
  • 1
  • 3

1 Answers1

1

The port "a" is an input port so cannot be written to. If you make it an output port then you can write to it. Also, the port is not bound so you will also get an error for that so I have bound a signal to it just so it compiles.

#include <systemc.h>

SC_MODULE(prin) {

    sc_out<bool> a; //output port
    sc_signal<bool> sig; //something to bind port a to

    void print() {
        cout << "Hello World\n";
    }

    SC_CTOR(prin) {
        SC_METHOD(print);
        sensitive << a;
        a(sig); //bind port a to s signal
    }
};

SC_MODULE(input) {
    prin b;

        void in() {
        b.a.write(false);
        wait();
        b.a.write(true);
        wait();
    }

    SC_CTOR(input) : b("sds"){
        SC_THREAD(in);
    }
};

int sc_main(int argc, char* argv[]) {
    input prin1("pint");
    sc_start();
    return 0;
}

Then

g++ -file.cpp -lsystemc
./a.out

Gives me the output

    SystemC 2.3.2-Accellera --- Apr 16 2018 00:15:03
    Copyright (c) 1996-2017 by all Contributors,
    ALL RIGHTS RESERVED

Hello World
systemcpro
  • 856
  • 1
  • 7
  • 15