Jump to content

Is it possible to bind the output of a sub-module to two different output ports?


Recommended Posts

Posted (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 by Clematrics
The text size was way too high (I still can't edit the text size of the code)
Posted

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

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.

Guest
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...