In the function component each output is defined by a mathematical expression that can take inputs states and voltages as well as previous output states.

You can combine logic and analog values in an output function.

To edit funtions there is a button next to each output pin, clicking on it will open a dialog to set the function.

You can also edit the function in component properties.

For example in a model of an OR gate with 2 inputs, the output function would look like this:

i0|i1

**Logic operations:**

- Not:

**!**

- And:

**&**

- Or:

**|**

- Xor:

**^**

**Logic states:**

- Input n: "

**in**"

- Output n: "

**on**"

**Analog operations:**

- Any mathematical operation aplicable to float numbers.

**Voltages:**

- Input n: "

**vin**"

- Output n: "

**von**"

For example a model for a diferential amplifier with 2 inputs and 1 output, the output function would look like this (gain=10):

vo = (vi1-vi0)*10

Note that to get output voltages instead of logis states, expression must start by "vo="

You can combine logic and analog operations to get more complex behaivors.

For exaple this expression...

vo = (vi1>vi0)*(vi1-vi0)+(vi1<=vi0)*vi0

..Will do:

- If Vi1 >Vi0: output = Vi1-Vi0

- Else: output = Vi0