Jump to content

IO port by reference


Recommended Posts

Hi All,

Can I pass a reference to IO port?

The code below results in a Modelsim error which I suspect is because of the sc_out reference


    sc_in<bool >    clk;
    sc_in<bool >    reset;
    sc_in<bool >      dbusin;
    sc_out<bool >     dbusout;
    void doff(const sc_core::sc_in<bool>pin, sc_core::sc_out<bool>&pout) {
    void entry_clk() { 
        while(true) {

    SC_CTOR(PROC3) {

# ** Error: (vsim-6511) Insert port failed: simulation running: port '/proc3_tb/DUT/entry_clk/port_0' (sc_port_base)
# In process: /proc3_tb/DUT/entry_clk @ 55 ns


Link to comment
Share on other sites



Can I pass a reference to IO port?


Yes, you can (no pun intended).


    void doff(const sc_core::sc_in<bool>pin, sc_core::sc_out<bool>&pout) {


Here, you try to pass pin by value, which invokes a (deprecated, non-naming) copy-constructor, taking a non-const reference to dbusin.  Since the simulation is already running (as it is said in the error message), this port creation fails.


Add the missing & to pass pin by const-reference (as probably intended anyway).



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...