SystemC:单个 cpp 文件中的多个模块实现
SystemC: Multiple module implementations in single cpp file
编辑:通过将SC_HAS_PROCESS(Module);
语句从.cpp文件移动到头文件中的类定义中找到的解决方案。
我正在用SystemC编写一个模块,其中包含小的子模块。我想将所有声明保存在一个头文件中,并将实现保存在单个.cpp
文件中。我认为这种方法没有任何固有的错误,但是我遇到了与使用SC_HAS_PROCESS
宏重新定义SC_CURRENT_USER_MODULE
相关的错误。
In file included from /.../systemc/2.3.1/include/systemc:72:0,
from src/Decoder.cpp:39:
/.../systemc/2.3.1/include/sysc/kernel/sc_module.h:403:30: error: conflicting declaration ‘typedef struct Fifo_shift SC_CURRENT_USER_MODULE’
typedef user_module_name SC_CURRENT_USER_MODULE
^
src/Decoder.cpp:146:1: note: in expansion of macro ‘SC_HAS_PROCESS’
SC_HAS_PROCESS(Fifo_shift);
^
/.../systemc/2.3.1/include/sysc/kernel/sc_module.h:403:30: error: ‘SC_CURRENT_USER_MODULE’ has a previous declaration as ‘typedef struct Decoder SC_CURRENT_USER_MODULE’
typedef user_module_name SC_CURRENT_USER_MODULE
^
src/Decoder.cpp:50:1: note: in expansion of macro ‘SC_HAS_PROCESS’
SC_HAS_PROCESS(Decoder);
错误似乎是我第二次使用SC_HAS_PROCESS
.我的代码的一般格式如下(为简洁起见,删除了部分内容(。
在">解码器.h"中:
SC_MODULE(Fifo_shift)
{
public:
/* Port declarations */
/* Variable declarations */
Fifo_shift(sc_module_name nm, int chunk_size_in);
~Fifo_shift();
/* Member functions */
private:
/* Private variables */
};
/* Other modules */
SC_MODULE(Decoder)
{
public:
/* Port declarations */
/* Variable declarations */
Decoder(sc_module_name nm, int num_mac_in); // constructor
~Decoder(); // destructor
/* Member functions */
private:
/* Private variables */
};
在">解码器.cpp"中:
/* First Use of SC_HAS_PROCESS */
SC_HAS_PROCESS(Decoder);
Decoder::Decoder(sc_module_name nm, int num_mac_in) :
/* Member variable init */
{
/* Do some initializing of dynamic variables */
/* Connect sub-modules */
/* Specify thread process */
SC_THREAD(do_Decoder);
sensitive << CLK.pos();
}
// Destructor
Decoder::~Decoder()
{ /* Delete dynamic variables */ }
void Decoder::do_Decoder()
{ /* Process implementation */ }
/* Second use of SC_HAS_PROCESS */
SC_HAS_PROCESS(Fifo_shift);
Fifo_shift::Fifo_shift(sc_module_name nm, int chunk_size_in) :
/* Member variable init */
{
// Create thread and specify sensitivity
SC_THREAD(do_Fifo_shift);
sensitive << CLK.pos();
}
// Destructor
Fifo_shift::~Fifo_shift()
{ /* Delete dynamic variables */ }
// Function to perform opperation
void Fifo_shift::do_Fifo_shift()
{ /* Process implementation */ }
/* Additional module implementations */
有没有办法使用SC_HAS_PROCESS
宏在单个文件中实现模块的多个实现来实现这种格式?我是SystemC的新手,所以我希望有一个简单的解决方案,但通过搜索网络没有找到任何解决方案。
IEEE1666-2011 LRM(SystemC的标准定义(说
宏SC_HAS_PROCESS只能在类定义中使用, 构造函数体,或模块的成员函数体。的名称 正在构造的模块类应作为参数传递给 宏观。宏调用应以分号终止。
看起来您正在全局范围内使用宏。
如果您还没有,可以从此处下载 LRM 的副本。
看起来您在多个区域中具有相同的代码。
在下面/上面的误差测量中可以看出:
src/Decoder.cpp:146:1: note: in expansion of macro ‘SC_HAS_PROCESS’
SC_HAS_PROCESS(Fifo_shift);
^
src/Decoder.cpp:50:1: note: in expansion of macro ‘SC_HAS_PROCESS’
SC_HAS_PROCESS(Decoder);
查看第 146 行和第 50 行。
我遇到了关于SC_HAS_PROCESS()
的类似错误,并且能够通过将SC_HAS_PROCESS()
宏的使用放在构造函数的定义中来解决它们,如下所述:链接。
Fifo_shift::Fifo_shift(sc_module_name nm, int chunk_size_in) :
/* Member variable init */
{
SC_HAS_PROCESS(Fifo_shift);
// Create thread and specify sensitivity
SC_THREAD(do_Fifo_shift);
sensitive << CLK.pos();
}
相关文章:
- 如果没有malloc,链表实现将失败
- 如何在c++中实现处理器调度模拟器
- 尝试导入pybind-opencv模块时出现libgtk错误
- 如何在c++中使用引用实现类似python的行为
- 实现无开销push_back的最佳方法是什么
- 使用简单类型列表实现的指数编译时间.为什么
- 如何在BST的这个简单递归实现中消除警告
- 实现一个在集合上迭代的模板函数
- 我应该实现右值推送功能吗?我应该使用std::move吗
- 如何正确实现和访问运算符的各种自定义枚举器
- 如何为模块化应用程序实现C++插件系统
- 为 n 维系统实现模块化龙格-库塔四阶方法
- SystemC:单个 cpp 文件中的多个模块实现
- C++模块:模块实现单元进行不必要的重新编译?
- OmNET++动态检查NED模块是否实现了接口
- 如何在安卓中实现 sqlite3 虚拟表模块
- 如何实现动态模块(在头文件中)加载c++
- 为什么在外部模块之外实现的方法仍然可以访问该模块
- 模块化快速排序实现(c++)
- 我们应该如何在c++中实现实用工具/助手模块