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?
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--)
cout << "MISO in spi " << MISO.read() << endl;
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);