A wait statement instructsSCL to stop executing instructions from the containing process.
SCL executes statements in a process until it encounters a wait statement. If the end of the process is encountered, SCL simply wraps to the beginning of the process and starts over. So every process must have at least one wait statement. Without it the process will perform an infinite loop and hang the simulator. Fortunately, the SCL parser detects processes without a wait statement, issues the following warning, and refuses to load.
SIM004: Failed to parse SCL SCL022: Process contains neither a wait statement nor a sensitivity list line(#)
There are 4 forms of the wait statement.
wait; //unadornedwait on sensitivity; //sensitivity waitwait until condition; //condition waitwait for timeout; //timeout waitUnadorned Wait
The simplest form of wait is unadorned with no argument. It tells SCL to not only stop executing the process statements, but that the process is complete and is terminating.
process is begin wait; // terminate the process now! end process;Sensitivity Wait
The sensitivity wait statement waits for a value to change. There can be several types of values.
wait on RD1; //wait on pin RD1 to changewait on userVar; //wait on a user var to changewait on STATUS; //wait on the STATUS SFR to changewait on PORTD.RD0; //wait on the RD0 bit of PORTD to changeCondition Wait
The condition wait statement waits for an expression to be true.
wait until PORTA == 128; //wait until SFR PORTA equals 128 (0x80)wait until RD1 == '1'; //wait until pin RD1 is highwait until ADCON.ADON == '1'; //wait until field ADON in SFR ADCON is 1wait until PC == 4; //wait until PC is 4Timeout Wait
The timeout wait statement waits for a specified amount of time.
wait for 10 ic; //wait 10 instruction cycleswait for 10 ms; //wait 10 millisecondsCombined wait
The timeout wait can be combined with either a sensitivity or condition wait. When used this way the timeout becomes a true timeout.
wait on RD1 for 10 ms; //wait for pin RD1 to change or 10 ms to passwait until PC = 20 for 20 ic; //wait until PC is 20 or for 20 instruction cycles
