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; //unadorned wait on sensitivity; //sensitivity wait wait until condition; //condition wait wait 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 is begin wait; // terminate the process now! end process;
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 change wait on userVar; //wait on a user var to change wait on STATUS; //wait on the STATUS SFR to change wait on PORTD.RD0; //wait on the RD0 bit of PORTD to change
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 high wait until ADCON.ADON == '1'; //wait until field ADON in SFR ADCON is 1 wait until PC == 4; //wait until PC is 4
The timeout wait statement waits for a specified amount of time.
wait for 10 ic; //wait 10 instruction cycles wait 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 pass wait until PC = 20 for 20 ic; //wait until PC is 20 or for 20 instruction cycles
Microchip Technology acquires Atmel