Expressions¶

Expressions are used in the Function Block and CDK Components to enable programmable components and signals.

Expressions are like Cell calculations in spreadsheets like Excel.

```FUNCTION( Parmeter1, Parameter2,.. ParameterN )
```

Expressions have a root function FUNCTION which operate on a collection of Parameters where each Parameter can also be a function.

Expression Grammar¶

```Expression = Primitive | Function
Primitive ::= Numeric | Pn | PINn
Function ::= functionName( expression [, expression]* )
functionName ::= CONST | RISING | FALLING | ISHIGH | ISLOW | PULSIN | CINT | NAND | NOR | XOR | XOR | MIN | MAX | ABSDIFF | CSIGN | CEN | SIGN | PWM | NEG | IF | MUL | ADD | SUB | RANGE | MAP | OR | NOT | GT | LT | VOLTS | DAC
```

Usage¶

Expressions can contain other functions as parameters. For example:

AND(OR(P1,P2),OR(P3,P4) Complex Logic

MUL(SUB(P1,P2),2)’ Differential amplifier gain = 2

Function Groups¶

FunctionName::= Pin Functions | Logic Functions |Math Functions | Special Functions

Pin Functions ::= ISHIGH | ISLOW | RISING | FALLING

Logic Functions ::= AND, OR, XOR, NOT, NAND, NOR, XNOR

Math Functions ::= ABSDIFF, ADD, CEN, CONST, CSIGN, DIV, GT, IF, LT, MAP, MIN, MUL, NEG, RANGE, SIGN, SUB

Special Functions::= DAC, PULSIN,PWM,VOLTS

Pins¶

PN return a value 0 for logic level GND and 1 for Vdd which is nominally 5V

Pin Functions¶

ISHIGH ( PIN ) : Returns 1 if the PIN is HIGH else returns 0

ISLOW( PIN ) : Returns 1 if the PIN is LOW else returns 0

RISING( PIN ) : Returns 1 if the PIN has a rising edge

FALLING( PINS ) : Returns 1 if the PIN has a falling edge

ISPWRD( PIN ) : Returns 1 if the PIN is a voltage source

ISOPEN( PIN ): Returns 1 is the PIN is not wired

Logic Functions¶

AND(F1,F2,..,F3): Returns 1 if all FN return 1

OR(F1,F2,..,FN): Returns 1 if any FN return 1

XOR(F1,F2,…FN): Returns 1 if equal numbers of FN are 1 and 0

NAND(F1,F2,…,F3): Returns 1 if any FN is 0

NOR(F1,F2,…,FN): Returns 1 if no FN is 1

XNOR(F1,F2,…,FN): Returns 1 if odd numbers of FN are 1 and 0

NOT(F1): Return 1 if F1 is 0

Math Functions¶

ABSDIFF(FA,FB): Evaluates a ∣FB−FB∣

CEN(FA) : Evaluates ∣FA−FB∣−0.5

CINT(FA): Converts floating FA to integer

CONST( string ) : Evaluates string as numeric

CSIGN(FA): if FA > 0.5 returns 1 else returns 0

DIV(FA,FB,..,FN) : Evaluates FA÷FB÷…÷FN

GT( FA, FB ): If FA > FB returns 1 else returns 0

GTE( FA, FB ): If FA >= FB returns 1 else returns 0

IF( FA, FB, FC ): If FA != 0 returns RB else returns FC

LT( FA, FB ): If FA < FB returns 1 else returns 0

LTE( FA, FB ): If FA <= FB returns 1 else returns 0

MAP( FA, FB, FC ): Evaluates FA−FBFC−FB clipped to range 0 to 1

MIN(FA,FB,..,FN) : returns the lowest value in the parameter list FA,.. ,FN

MAX(FA,FB,..,FN) : returns the highest value in the parameter list FA,.. ,FN

MUL(FA,FB,..,FN) : Evaluates FA∗FB∗⋯∗FN

NEG( FA ) : Evaluates −FA

RANGE( FA, FB, FC ) : Evaluates FA+(FB−FA)∗FC

SIGN( FA, FB ) : if( FA > FB ) returns 1 else returns 0

SUB( FA,FB,..,FN ) : Evaluates FA−FB−⋯−FN

Special Functions¶

DAC(FA,FB,..FN): Digital To Analog converter using N binary bits to create analog range between 0 and 1

TAP(FA,..FN) : Digital To Analog converter using N taps to create analog range between 0 and 1 where each step is 1/N

PULSIN( FA ): Measure the time in seconds of a pulse where the time is measured between the rising and falling edge

PWM (FA ): Digital to Analog converter using the PWM pulse duty on FA to create an analog value between 0 and 1

PWM(FA,FB): Digital to Analog converter using the PWM pulse duty on Differential FA - FB to create an analog value between 0 and 1

VOLTS (FA) : Converts the result of FA into a volts value by dividing by the nominal voltage value of 5.

ROM()