## Pin

The MPLAB X simulator models the device pins (MPLAB 8 did not) and SCL allows injection of values to these pins.

Pins are pretty complex entities. To begin with, most pins multiplex several signals. The simulator models this multiplexing and keeps track of which signal is currently driving the pin.

``` RA5/CLKIN/OSC1/T1OSI/T1CKI/SRNQ/P1A/CCP1/DT/RX ```

When accessing a pin in SCL, the signal name is used. So for example, to set RA5 high.

``` RA5 <= '1'; RA6 <= '0'; // example of setting a pin low ```

Further, pins can be in input or ouput mode, and digital or analog mode. Again the simulator keeps track of the current pin state.

Input verus output is perhaps the most "interesting" characteristic of a pin with regards to SCL. When SCL assigns a value to a pin that value is considered to be the value being driven to the pin from an external source. So if we assign RA5 to high as in the above example, but the pin is currently in output mode and driving low, we'll still read the pin as low.

But if the RA5 pin is subsequently switched to input mode, the high that had been previously injected via SCL will become the value of RA5.

Analog versus digital is an issue of interpretation instead of state of the pin. In other words, pins always have a voltage, which can be interpreted as digital high or low. In the simulator the nominal VDD voltage (from the datasheet) is used to model the digital state. If the voltage is greater than or equal to half the nominal VDD voltage the pin is considered digital high, otherwise the pin is digital low.

SCL allows pins to be set by voltage in addition to being set digitially.

``` AN0 <= 3 V; AN1 <= 3500 mV; // 3.5V (no decimal voltages allowed) ```

Pins can be used in boolean expressions

``` if RA1 == '1' then while AN0 <= 3500 mV loop ```

Sometimes a pin name contains a + or a - as part of it's name. These two characters are illegal as part of variable names in SCL. In this case +'s are replaced with P and -'s replaced with N. So Vref+ and Vref- become VREFP and VREFN.