Clematrics Posted October 20, 2019 Report Posted October 20, 2019 (edited) I am trying to make a circuit which computes the carries for an addition. In this piece of code, I would like to connect the output port rOut of the submodule pg to two output ports (rOut and carries[0]) of the parent module, so both get the same value. template<> struct Carries<1> : ::sc_core::sc_module { sc_vector<sc_in<bool>> a, b; sc_in<bool> rIn; sc_out<bool> p, g, rOut; sc_vector<sc_out<bool>> carries; CarryPropGen pg {"PG"}; SC_CTOR(Carries) : a {"vectA", 1}, b {"vectB", 1}, rIn {"rIn"}, p {"p"}, g {"g"}, rOut {"rOut"}, carries {"vectCarries", 1} { pg.a(a[0]); pg.b(b[0]); pg.r(rIn); pg.p(p); pg.g(g); pg.rOut(rOut); // What I would like to do. pg.rOut(carries[0]); // } }; However, I get the error (E109) complete binding failed: 2 binds exceeds maximum of 1 allowed: port 'Carries.PG.port_5' (sc_out). I also tried with a signal, with and without the writer policy SC_MANY_WRITER, as it was suggested by someone on a forum, but it didn't work either. I am new to SystemC and while I understand the error, I don't really understand why this can't work and how to do it differently. So, is there a way to bind one sub-module output to multiple sc_out of the parent module, and how? Edited October 20, 2019 by Clematrics The text size was way too high (I still can't edit the text size of the code) Quote
David Black Posted October 20, 2019 Report Posted October 20, 2019 No for a port; however, you could accomplish the goal with an sc_port< sc_signal<T> > Quote
Eyck Posted October 20, 2019 Report Posted October 20, 2019 You need to connect the output port to a signal and attach a method to the signal driving the multiple output ports. So something like this: template<> struct Carries<1> : ::sc_core::sc_module { sc_vector<sc_in<bool>> a, b; sc_in<bool> rIn; sc_out<bool> p, g, rOut; sc_vector<sc_out<bool>> carries; CarryPropGen pg {"PG"}; SC_CTOR(Carries) : a {"vectA", 1}, b {"vectB", 1}, rIn {"rIn"}, p {"p"}, g {"g"}, rOut {"rOut"}, carries {"vectCarries", 1} { pg.a(a[0]); pg.b(b[0]); pg.r(rIn); pg.p(p); pg.g(g); pg.rOut(rOutS); // What I would like to do. SC_METHOD(propagate); sensitive<<rOutS.value_changed(); } sc_core::sc_signal<bool> rOutS; void propagate(){ rOut.write(rOutS.read()); carries[0].write(rOutS.read(); } }; BR acc_sysC 1 Quote
Clematrics Posted October 21, 2019 Author Report Posted October 21, 2019 Hi David and Eyck, thank you very much for your answers ! Indeed, it works very well this way. Quote
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.