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

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