天天看点

Systemc 常见错误

错误类型 编译错误
错误提示

systemc-2.3.1/include/sysc/datatypes/int/sc_uint_base.h:842: undefined reference to `sc_dt::sc_uint_base::to_string

systemc-2.3.1/include/sysc/communication/sc_signal_ports.h:1802: undefined reference to `sc_core::sc_in<bool>::add_trace_internal

….

collect2: error: ld returned 1 exit status

错误分析

出现此错误,很有可能是由于当前环境的默认gcc版本比较低,而安装systemc时使用的gcc版本较高。导致当前低版本的gcc无法识别高版本编译过的systemc库文件。

一般ubuntu16.04环境下,对应的是gcc 5.4.0版本。

修改当前默认gcc的版本号可以参考 https://blog.csdn.net/qq_31175231/article/details/77774971

错误类型 编译错误
错误提示 error: ‘std::gets’ has not been declared
错误分析

std::get() 被C++11 删除了,参考 https://stackoverflow.com/questions/38352801/systemc-error-with-the-library 和https://stackoverflow.com/questions/12893774/what-is-gets-equivalent-in-c11

可以加上编译选项-std=c++98

Ubuntu20.04 (gcc version 9.3.0) 默认使用的是c++11

错误类型 编译通过,执行时报错
错误提示

 Error: (E115) sc_signal<T> cannot have more than one driver: 

    signal `MyTest.test_sig' (sc_signal)

    first driver `MyTest.TestMethod'  (sc_method_process)

    second driver `MyTest.TestThread1' (sc_thread_process)

    In file: ../../../../src/sysc/communication/sc_signal.cpp:73

错误分析

参考 https://blog.csdn.net/zgcjaxj/article/details/106106426

systemc规则中,同一个sc_signal不允许有多个驱动,也就是说,同一个sc_signal,只能在一个SC_METHOD或SC_THREAD中被write赋值

错误类型 编译通过,执行时报错
错误提示

Error:  (E109) complete binding failed: port not bound (sc_in)

In file: external/sysc/sysc/communication/sc_port.cpp:235 或 231

错误分析

说明有port/sc_signal/sc_in/sc_out忘记绑定了 或者 是有port/sc_signal/sc_in/sc_out在还没有绑定的时候就被添加到静态敏感事件列表中了,在simulation过程中发现检索不到敏感事件,报错。关于后者,可参考 https://blog.csdn.net/zgcjaxj/article/details/105455330

一般在end_of_elaboration()函数中添加 SC_METHOD 函数和其敏感事件列表

错误类型 编译通过,执行时报错
错误提示

Error:  (E126) sc_export instance already bound: xxxxxxxx

In file: external/sysc/sysc/communication/sc_export.h:188

错误分析 说明有port 重复绑定,且有提示是哪个port/sc_signal
错误类型 编译通过,执行时报错
错误提示

Error: (E513) an sc_module_name parameter for your constructor is required

In file: external/sysc/sysc/kernel/sc_module.cpp:223

错误分析

一个继承了sc_module的类,必须在列表初始化时对sc_module进行赋值,一般如

MyModule::MyModule(sc_core::sc_module_name name)

    : sc_module(name), ….

错误类型 编译通过,执行时报错
错误提示

Error:  (E565) invalid use of sc_(and|or)_event_list: wait() on empty event list not allowed

In file: external/sysc/sysc/kernel/sc_wait.cpp:103

Systemc 常见错误
错误分析 还在摸索中

继续阅读