A wait statement instructs SCL 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 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 isbeginwait; // terminate the process now!end process;
The sensitivity wait statment 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 change
The condition wait statment 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 4
The timeout wait statment waits for a specified amount of time.
wait for 10 ic; //wait 10 instruction cycleswait for 10 ms; //wait 10 milliseconds
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