java systemc 兼容_systemC2.2与2.0的兼容问题 | 学步园

今天编译一个以前的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关掉就行了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值