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 ?



Share this post

Link to post
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. 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now