Jump to content


  • Content Count

  • Joined

  • Last visited

  1. apoorv_kumar247

    Mutex unlock delay in SystemC 2.2.0

    Hi, I am creating a RTL simulation model of a chip which involves arbitrating 2 common channels among multiple cores. I have implemented the channels using 1 mutex (sc_mutex) each, one of which any core wishing to transmit needs to lock before accessing the channel. Every core first tries to lock on first mutex, if unsuccessful, it tries the same on the second mutex. If it fails to lock either, it backs out until next cycle. The issue is that the mutex doesn't become available until many cycles after a resource calls mutex.unlock() . Consider the following trace. <CYCLE NO.> : <EVENT> 1033: Channel[0] lock attempt by - Router[0] 1033: Channel[0] locked by - Router[0] 1037: Channel[0] UNlocked by - Router[0] 1038: Channel[0] lock attempt by - Router[12] ----> locking unsuccessful. 1038: Channel[1] lock attempt by - Router[12] 1038: Channel[1] locked by - Router[12] In the above trace it might look like the problem is only for a single cycle, but it actually shows across hundreds of cycles at times. To further investigate the problem, I added a small snippet just after the mutex.unlock() that looks something like - mutex[0].unlock(); if ( mutex[0].trylock() != -1 ){ cout << "SUCCESS!"; } else{ cout << "FAILURE!"; } the code essentially unlocks the mutex and then tries to lock it within the same cycle (however, a later delta cycle in any sequentially consistent simulation kernel). The output invariably comes out as "FAILURE!". I cannot use semaphore because of design issues. I don't understand why the unlock fails to be detected across many cycles when it should be done within a delta cycle. Any help would be appreciated. Thanks in advance.