Jump to content

haidangvu93

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. Hi Eyck, In fact, when using sem.wait() and sem.post(), the program is also blocked. So that i only use sem.post() and i dont know whether the semaphore can do the arbitration or not? But the program is running. How is your opinion? void Bus::b_transport(int id, tlm::tlm_generic_payload& trans, sc_core::sc_time& delay) { sc_dt::uint64 global_addr = trans.get_address(); int slaveid = this->address_to_slaveid(global_addr); if(slaveid < 0) { trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE); std::cout << "\e[1;31m" << this->name() << ": " << "\e[1;31mInvalid address " << global_addr << std::endl; return; } sc_dt::uint64 slave_addr = global_addr - this->starts[slaveid]; trans.set_address(slave_addr); // make sure we are allowed to get access sem.wait(); this->initiator_socket[slaveid]->b_transport(trans, delay); // return back the token so that others can access sem.post(); trans.set_address(global_addr); } BR, Hai Dang
  2. Hi Eyck, In fact, "wait()" doesnt work. So can you have a brief utilization of these functions? Kind regards, Hai Dang
  3. Hi Eyck, It works with your solution. I initialized the counter value from 0 then i tried with 1, it seems that there is no difference (or small difference). void Bus::b_transport(int id, tlm::tlm_generic_payload& trans, sc_core::sc_time& delay) { sc_dt::uint64 global_addr = trans.get_address(); int slaveid = this->address_to_slaveid(global_addr); if(slaveid < 0) { trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE); std::cout << "\e[1;31m" << this->name() << ": " << "\e[1;31mInvalid address " << global_addr << std::endl; return; } sc_dt::uint64 slave_addr = global_addr - this->starts[slaveid]; this->post(); trans.set_address(slave_addr); this->initiator_socket[slaveid]->b_transport(trans, delay); trans.set_address(global_addr); //std::cout << "\e[1;31m MB " << id << std::endl; sc_core::wait(this->bus_delay); } And i have a doubt that: "post()" or "wait()" is better in this case? Thank you a lot for your helps. HD
  4. Hello everyone, I want to create a system of 7 initiator sockets (masters) connect to a Bus and then to one target socket (slave). I use the multi_passthrough_initiator_socket and multi_passthrough_target_socket. tlm_utils::multi_passthrough_initiator_socket<Bus> initiator_socket; tlm_utils::multi_passthrough_target_socket<Bus> target_socket; Then i connect the masters and slave to the bus. bus << master_0; bus << master_1; bus << master_2; bus << master_3; bus << master_4; bus << master_5; bus << master_6; bus << sharedmemory; In the b_transport function, i use sc_mutex. void Bus::b_transport(int id, tlm::tlm_generic_payload& trans, sc_core::sc_time& delay) { sc_dt::uint64 global_addr = trans.get_address(); int slaveid = this->address_to_slaveid(global_addr); if(slaveid < 0) { trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE); std::cout << "\e[1;31m" << this->name() << ": " << "\e[1;31mInvalid address " << global_addr << std::endl; return; } sc_dt::uint64 slave_addr = global_addr - this->starts[slaveid]; this->bus_mutex.lock(); trans.set_address(slave_addr); this->initiator_socket[slaveid]->b_transport(trans, delay); trans.set_address(global_addr); std::cout << "Master ID" << id << std::endl; // I print the ID to check if they are working sc_core::wait(this->bus_delay); this->bus_mutex.unlock(); } When i run the program, there are always 3/7 masters working, so the program is blocked. What's the problem here? Thank you alot for your helps. Kind regards, HD
×
×
  • Create New...