Jump to content

Graph Generation


Recommended Posts

Hello All,

Using get_chil d_objects() I can traverse through hierarchy and can find any ports & instances

But I cannot find how these ports are connected. All what I want to do is to create a database which I can use for visualization by post processing.

Is there any way to do this ?



Link to comment
Share on other sites

In some cases yes, you can do it by playing with dynamic casts. For example:

#include <systemc.h>

SC_MODULE(test) {
    sc_signal <int> xsig{"xsig"};
    sc_signal <unsigned> xsig2{"xsig2"};
    sc_in <int> xin{"xin"};
    sc_out <unsigned> xout{"xout"};

    SC_CTOR(test) {

int sc_main(int argc, char **argv) {
    test t0{"t0"};

    cout << hex;

    for (auto * obj : t0.get_child_objects()) {
        cout << obj->kind()  << " " << obj->name() << " @ " << obj;

        if(sc_port_base* port = dynamic_cast<sc_port_base*>(obj))
            if (sc_prim_channel * chan = dynamic_cast<sc_prim_channel*>(port->get_interface()))
                std::cout << " ( binded to " << chan->name() << " @ " << chan << ")";
        cout << endl;

    return 0;

Possible output:

sc_signal t0.xsig @ 0x111f878
sc_signal t0.xsig2 @ 0x111f938
sc_in t0.xin @ 0x111f9e8 ( binded to t0.xsig @ 0x111f878)
sc_out t0.xout @ 0x111fa90 ( binded to t0.xsig2 @ 0x111f938)

SystemC however does not store information about hierarchical bindings. 

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