【问题标题】:SystemC Port ConversionSystemC 端口转换
【发布时间】:2017-06-15 08:15:58
【问题描述】:

我正在尝试将一种 SystemC 端口转换为另一种:

来自:

sc_port<sc_fifo_out_if<Type> > 

到:

sc_export<tlm::tlm_analysis_if<Type> > 

我用这个类和一个线程在类型之间进行转换。

class port_converter : public sc_core::sc_module{
public:
    sc_port<sc_fifo_in_if<Type> > in_converter;
    sc_port<tlm::tlm_analysis_if<Type> > out_converter;

    // c'tor
    SC_HAS_PROCESS(port_converter);
    port_converter(sc_module_name nm) :
        sc_module(nm), in_converter("in"), out_converter("out") {
        SC_THREAD(main_action);
    }

    // main action 
    void main_action() {
        while (1){
            out_converter->write(in_converter->read());
        }
    }
};

The solution diagram

有没有更简单的方法在这些类型的端口之间进行转换?

【问题讨论】:

    标签: c++ ports systemc


    【解决方案1】:

    接口sc_fifo_out_iftlm_analysis_if 不完全兼容。所以这可能是你能得到的最好的。如果有人尝试使用不兼容的方法,模拟将停止并出现错误。

    更新:我不确定tlm_analysis_if 是否保证非阻塞操作。

    template <typename T>
    struct my_converter : sc_fifo_out_if<T>, sc_core::sc_module {
    
        sc_export<sc_fifo_out_if<T>>          in{"in"};
        sc_port<tlm::tlm_analysis_if<T>>      out{"out"};
    
        my_converter(sc_core::sc_module_name){
            in.bind(*this);
        }
    
        bool nb_write(const T &t) override {
            out->write(t);
        }
    
        const sc_event &data_read_event() const override {
            SC_REPORT_ERROR("my_converter", "data_read_event not supported!!");
            return m_data_read_event;
        }
    
        void write(const T &t) override {
            nb_write(t);
        }
    
        int num_free() const override {
            SC_REPORT_ERROR("my_converter", "num_free not supported!!");
            return 1;
        }
    
    private:
        sc_event m_data_read_event; // this even will never happen;
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-08
      • 2021-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-08
      • 1970-01-01
      相关资源
      最近更新 更多