Can someone clearly and intuitively explain what is the difference between an sc_port
and an sc_export
in SystemC? When does one use a port, and when an export?
I've been reading portions of the manual but I still fail to grasp the main conceptual difference between the two.
SystemC requirement is that every port or export MUST be bound/connected to a channel (exception of unbound ports, but let us ignore them for now). Where this channel is instantiated is what differentiates ports and exports.
For an export, the channel instance MUST reside within the same module that has the export, or inside a submodule located inside it.
For a port, the channel instance MUST reside outside the module with the port.
Imagine a module top_module with two submodules sender and receiver instantiated inside it with a one-bit data connecting sender to receiver. If you choose to make the sender's output data to be of type sc_port<>, then you will need to instantiate the channel, say sc_signal<>, in the top_module and the bind statement would ideally be in the constructor of the top_module. But if you choose to make the sender's output data to be of type sc_export<>, then you will need to instantiate the channel inside the submodule sender. Because you are essentially "exporting" the functionality of the channel to the world outside of sender.
This is my intuitive understanding of ports and exports. Please take my "MUST" statement with a grain of salt as the Accellera implementation enforces no such rule but has more to do with binding order (top-down vs bottom-up) than anything else.
As a thumb-rule, I always use exports for outputs and ports for inputs for all my modules. My philosophy is, "you drive it, you own it".