Jump to content

sc_vector and TLM


svinco

Recommended Posts

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. 

Link to comment
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

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

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.

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