Jump to content

Issue in downcasting to target_base_socket_type(downcasting to initiator_base_socket_type woks fine)


Recommended Posts

Hi Experts

 

I am facing an issue in downcasting the sc_module child objects to target_base_socket_type.

It works fine when I downcast to initiator_base_socket_type.

 

In initiator module I have following lines or code which works fine and tells me which ports are not bound

tlm::tlm_initiator_socket<BUS_WIDTH> initiator_socket;

typedef tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types> fw_interface_type;
typedef tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types> bw_interface_type;
typedef tlm::tlm_base_initiator_socket<BUS_WIDTH,fw_interface_type,bw_interface_type> initiator_base_socket_type;

void before_end_of_elaboration(){
    cout<<this->name()<<" before_end_of_elaboration"<<endl;
    std::vector<sc_object*> module_list = this->get_child_objects();
    for(std::vector<sc_object*>::iterator it=module_list.begin(); it<module_list.end();it++){
        initiator_base_socket_type* ibsoc = dynamic_cast<initiator_base_socket_type*>(*it);
        if(ibsoc != NULL){
            if(ibsoc->get_base_port().size()==0){
                cout<<"\t\t\tInitiator Port "<<ibsoc->name()<<" not connected"<<endl;
            }
        }
    }
}

 

 

I have the same piece of code (following) code in target module, in this case ibsoc is always NULL

tlm::tlm_target_socket<BUS_WIDTH,tlm::tlm_base_protocol_types,2> target_socket;

typedef tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types> fw_interface_type;
typedef tlm::tlm_bw_transport_if<tlm::tlm_base_protocol_types> bw_interface_type;
typedef tlm::tlm_base_target_socket<BUS_WIDTH,fw_interface_type,bw_interface_type> target_base_socket_type;
..
..
void before_end_of_elaboration(){
    std::vector<sc_object*> module_list = this->get_child_objects();
    for(std::vector<sc_object*>::iterator it=module_list.begin(); it<module_list.end();it++){
        target_base_socket_type* ibsoc = dynamic_cast<target_base_socket_type*>(*it);
        if(ibsoc != NULL){
            if(ibsoc->get_base_port().size()==0){
                cout<<"\t\t\tTarget Port "<<ibsoc->name()<<" not connected"<<endl;
            }
        }
    }
}

 

Am I missign something ?

Please note in for target port I have N=2

 

Thanks

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