今天编译一个以前的SystemC程序,当时是在SystemC2.0下写的,用最新的2.2版本编译下来一堆错误,总结一下这些错误分三类:
1.sc_string类型的问题,2.2版本中的sc_string类型已经废除,但在systemc的源代码里能看到如下定义:
#ifdef SC_USE_SC_STRING_OLD
typedef sc_dt::sc_string_old sc_string;
#endif
#ifdef SC_USE_STD_STRING
typedef ::std::string sc_string;
#endif
sc_string_old 取代了sc_string
SystemC标准里给的解释是:
The new SystemC standard replaces sc_string with std::string, sc_pvector with std::vector, and sc_exception with std::exception. The old nonstandard classes are now deprecated. By default, the name sc_string is undefined, but the old sc_string class is still part of the source code under the name of sc_string_old. All new SystemC applications should use std::string exclusively. These changes will render obsolete code that uses the old classes.
最后用std::string替换sc_string 问题解决。
2.sc_signal的问题。
error C2679: 二进制“<
template
inline
void
sc_signal::print( ::std::ostream& os ) const
{
os << m_cur_val;
}
原因是代码中定义了一个信号如下:
sc_signal PACKET;
可能是2.2中sc_signal多了print这个方法导致找不到操作符<
在packet_type中重载operator <
struct packet_type {
inline bool operator == (const packet_type& rhs) const
{
return (rhs.info == info && rhs.seq == seq && rhs.retry == retry);
}
long info;
int seq;
int retry;
};
extern
void sc_trace(sc_trace_file *tf, const packet_type& v, const std::string& NAME);
inline ostream& operator << (ostream& out, const packet_type& chs)
{
return out<
}
感觉应该有更好的解决方法,SystemC不能让所有只要加到sc_signal上的用户自定义类型都要重载<
3. sc_signal多信号驱动问题
Error: (E115) sc_signal cannot have more than one driver。
查了一下2.2的release notes 有如下说明:
The check for multiple writers of a signal now defaults on rather than
off. This means that if two separate processes write to a signal an
error will be reported. To turn off the check, reverting to the
behavior of previous releases, one needs set an environment variable:
setenv SC_SIGNAL_WRITE_CHECK DISABLE
When set SystemC programs will not perform the write check.
SC_SIGNAL_WRITE_CHECK现在默认是开启的。
systemC中有如下代码
// CHECK FOR ENVIRONMENT VARIABLES THAT MODIFY SIMULATOR EXECUTION:
const char* write_check = std::getenv("SC_SIGNAL_WRITE_CHECK");
m_write_check = ( (write_check==0) || strcmp(write_check,"DISABLE") ) ?
true : false;
这个问题只要设定环境变量把SC_SIGNAL_WRITE_CHECK关掉就行了。