sc_port / sc_interface / sc_export (part 3)

sc_export

sc_export的一个主要作用是,在层次化的绑定过程中,给submodule内的interface提供了一个可以对外与sc_port绑定的方法。

Class sc_export allows a module to provide an interface to its parent module. An export forwards interface method calls to the channel to which the export is bound.

sc_export 也是模板类,但只有interface的参数(相比较与sc_port,没有了绑定数N和policy,也就是说只能绑定1个),bind的参数 可以是一个interface,也可以是一个sc_export。注意,如果参数是 一个sc_export,其实是先调用了 隐式类型转换函数 sc_export<IF>::operator IF&,将sc_export的参数转换为 interface,然后再 调用 virtual void bind( IF& );的bind函数。

The actual argument could be an export, in which case operator IF& would be called as an implicit conversion.

class sc_export_base
: public sc_object { implementation-defined };
template<class IF>
class sc_export
: public sc_export_base

void operator() ( IF& );
virtual void bind( IF& );

在 sc_port.bind(sc_export) 和  sc_export.bind(sc_export) 的时候,都会先调用 隐式类型转换函数 sc_export<IF>::operator IF&,在 src/sysc/communication/sc_export.h 中对应的代码如下。可以看到,在进行隐式类型转换的时候会 先判断当前sc_export是不是已经绑定了sc_interface (对应代码m_interface_p == 0)。尤其是,在 sc_export.bind(sc_export) 的时候,bind的方向不能搞反,否则就会在Simulation的时候报错。

    operator IF& ()
    {
        if ( m_interface_p == 0 )
        {
            SC_REPORT_ERROR(SC_ID_SC_EXPORT_HAS_NO_INTERFACE_,name());
            sc_abort(); // can't recover from here
        }
        return *m_interface_p;
    }
    operator const IF&() const
        { return *const_cast<this_type*>(this); }

仿真过程中如果出现这个错误  Error: (E120) sc_export instance has no interface:,xxxxx

In file: /usr/local/systemc-2.3.3/include/sysc/communication/sc_export.h:174

说明 export_1.bind (export_2) 的bind 方向错误。可以尝试 export_2.bind (export_1)。

sc_interface

sc_interface是一个抽象类,需要用户自己定义派生类,并添加相应的API实现,供sc_port 端调用。sc_interface 中以下两个抽象函数 的作用 还不太清楚。

class sc_interface
{
public:
virtual void register_port( sc_port_base& , const char* );
virtual const sc_event& default_event() const;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

123axj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值