Home / SystemC / Communication via Ports with User-defined Data Types

Communication via Ports with User-defined Data Types

SystemC supports many data types to communicate between 2 ports. eg: bool, unsigned char, unsigned int, sc_uint, … But, in some cases, we want to use a user-defined data type. In this post, we are going to discuss it.

Suppose, DUT_1 model needs some info of DUT_2 model. It is a group, ID, and address. Instead of, we declare 3 input ports for DUT_1 model corresponding 3 output ports of DUT_2 model, we will define an “extension_info” struct to store and information exchange between DUT_1 and DUT_2 model by 1 port.

It is the same as :

For extension_info works correct. We need :

  • Overload “==” operator

“==” operator using for judge value change or not in sc_signal_t::write( const T& value_ ) and sc_signal_t::update() functions (sc_signal.h)

  • Overload “<<“ operator

“<<“ operator using in sc_signal_t::print( ::std::ostream& os ) const and sc_signal_t::dump( ::std::ostream& os ) const functions (sc_signal.h)

  • Implement sc_trace function

It is necessary for end_of_elaboration function (sc_signal_port.h)

And final, you can use extension_info as other data types for sc_in, sc_out, sc_signal… and using read(), write() function to read/write data.

Download :

Google Drive 1


About admin

Check Also

[ SC Tutorial ] 3. SystemC Data types

SystemC có một số kiểu dữ liệu được xác định trước để hỗ trợ các …

Leave a Reply

Your email address will not be published. Required fields are marked *