SCode provides the ~ and - operators. ~ is the NOT operator, and - creates a negative expression.
The ~ operator can be used for both bitwise NOT and logical NOT.
a <= ~b
a <= (b, ~(c == 1), d)
In the second case, while ~(c == 1) is valid, c != 1 is generally more readable. Therefore, ~ is primarily used for bitwise NOT operations.
SCode can automatically treat a logic signal as active-high when a conditional expression is expected.
a <= (b, c, d)
In the code above, b is assigned to a if c is 1; otherwise, d is assigned. To assign b when c is 0 and d otherwise, you would write:
a <= (b, c == 0, d)
This can be expressed more concisely using the - operator:
a <= (b, -c, d)
SCode also has & and | operators for AND and OR operations. Since these operators have a higher precedence than ==, parentheses are required in the following case:
a <= (b, (c1 == 0) & (c2 == 0), d)
However, if you use the - operator, parentheses are not necessary because - has higher precedence than &:
a <= (b, -c1 & -c2, d)
Using the - operator allows for significantly more concise conditional statements.