systemc 构造函数和普通 C++ 构造函数之间的主要区别是什么?我们可以私下声明 systemc 构造函数吗?

What is the main difference between the systemc constructor and normal C++ constructor? Can we declare the systemc constructor in private?

在系统 c 程序中工作时,我在构造函数之前遗漏了 public 关键字,但程序运行正常。 但是在 C++ 中,它抛出一个错误

SystemC 要求模块构造函数的第一个参数应该是 sc_module_name。除此之外,没有什么特别的。 SystemC 宏 SC_MODULESC_CTOR 只是为您节省了一些时间,但您并非必须使用它们。

SC_MODULE( dut ) {
    SC_CTOR(dut) { }
};

相当于:

struct dut : sc_core::sc_module {
    typedef dut SC_CURRENT_USER_MODULE;
    dut(::sc_core::sc_module_name) {}
};

请注意 struct 成员默认为 public,而 class 成员默认为私有。如果您使用 class 而不是 struct,则需要通过显式添加 public: 来使它们 public:

class dut : public sc_core::sc_module {
    typedef dut SC_CURRENT_USER_MODULE;

public:
    dut(::sc_core::sc_module_name) {}
};