svinco

sc_vector and TLM

3 posts in this topic

I need to create a TLM module (that here we will call top_level) containing an array of TLM target modules (defined by class reg). As a consequence, the top_level module should implement the tlm_bw interface, and contain an array of initiator sockets, each bound to a target socket of the reg modules. Is it possible to implement this hierarchy by using the sc_vector construct?

Here is a snapshot of the code that I am trying to implement, to give a clearer idea:

Top level

#include "reg.h"

class top_level
    : public sc_module , public virtual tlm::tlm_bw_transport_if<>
{
private:
    sc_time time;
    sc_vector<reg*> register_file;
    tlm::tlm_generic_payload reg_trans; 

public:

    sc_vector <tlm::tlm_initiator_socket<>*> initiator_socket; 
    ...
};

 Target module: 

class reg
  : public sc_module , public virtual tlm::tlm_fw_transport_if<>
{

  public:
    tlm::tlm_target_socket<> target_socket;

    virtual void b_transport(tlm::tlm_generic_payload& trans, sc_time& t);
    reg(sc_module_name name_);
    ...
};

When trying to compile, the compiler returns this error: 

error: ISO C++ forbids declaration of ‘sc_vector’ with no type
error: expected ‘;’ before ‘<’ token

referring to both the instances of sc_vector, as if neither my class nor the initiator_socket class were recognized as datatypes... 

Best regards,
S. 

Share this post


Link to post
Share on other sites

Dear S.

Hard to tell exactly from what you posted. Often this error appears when the compiler does not identify the first identifier given in a declaration as the name of a type. Maybe, the compiler does not see the declaration of class sc_vector.

What version of SystemC are you using?

Can you check if all your include and using statements are correct? Or use the fully quallified name 'sc_core::sc_vector'?

One more issue:

sc_vector is meant to contain objects derived from sc_object and not pointers (this is one of the advantages over std::vector). So you should do sc_vector<reg>. But I am not sure if this causes the error here.

Greetings

Ralph

Share this post


Link to post
Share on other sites

Ralph, 

thank you for your prompt answer. I hadn't realized that the sc_vector is a novel construct of the 2.3.0 version of SystemC - and for some reason my files were working with the 2.2 version. It now works :) I also avoided using the class pointer. The resulting declarations are: 

sc_vector<reg > register_file;
sc_vector <tlm::tlm_initiator_socket<> > initiator_socket; 

Thank you for your support. 
Regards,
S. 

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