Jump to content
M Thajmal

wait() is not suspending the thread

Recommended Posts

I had modeled a spi module in which i have a thread for the module,  and a testbench thread to test the module. I am using MOSI and MISO lines for data transfer. I have a CLK line, which will be zero if slave is reading or writing data. And 1 when master is writing or reading data. Master have the control over CLK. So slave has to wait for master to make CLK line zero and suspend itself. After reading and writing on the line, Slave now suspend itself to give master control again. But the problem is master is not suspending. It will just execute wait(); and go for the next line. I am including the lines of code where the error is occurring. Sensitivity has anything to do with wait() statement?

Module Code:

if (rd_buf   == 0)
        {

            DRIVE.write(false);  // Here, clock is made zero, and waiting for slave to write on MISO pin...
            wait();                        // Not suspending and jumping to testbench...
            for (char i = 7; i >= 0; i--)
            {
                DRIVE.write(true);
                rd_buf|= MISO.read()<<i;
                cout << "MISO in spi " << MISO.read() << endl;
                DRIVE.write(false);

                wait();  
            }
        }

Test Bench:

            for (i = 7; i >= 0; i--)
            {
                if (clock.read ()== 0)
                {
                    cout << "write_buff contents " << ((write_buff >> i) & 1) << endl;
                    miso.write(write_buff >> i & 1);  
                    wait();
                }

            }

Thank you

Share this post


Link to post
Share on other sites

Does is make a difference to explicitly qualify wait() with its namespace?

  sc_core::wait();

If you happen to call unqualified wait() outside of an immediate SystemC module/channel member function, the compiler might accidentally pick up something else coming from a system header on your platform.

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

×