Hans64 Posted September 13, 2013 Report Share Posted September 13, 2013 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_MODULE(PROC3) { 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) { pout.write(pin.read()); } void entry_clk() { while(true) { doff(dbusin,dbusout); wait(); } } SC_CTOR(PROC3) { SC_CTHREAD(entry_clk,clk.pos()); } }; # ** 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 nsThanks,Hans. Annossyenudge 1 Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted September 13, 2013 Report Share Posted September 13, 2013 Hans, 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). /Philipp Quote Link to comment Share on other sites More sharing options...
Hans64 Posted September 13, 2013 Author Report Share Posted September 13, 2013 Hi Philipp, Thanks, that fixed it, Regards, Hans. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.