Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
language:expressions [2026/06/24 19:31] – [Using bit-width information] rajitlanguage:expressions [2026/07/21 16:35] (current) – [Expressions] rajit
Line 10: Line 10:
    * Logical shift operators are ''<<'' (left shift),  ''>>'' (logical right shift), and the arithmetic right shift operator ''>>>''.    * Logical shift operators are ''<<'' (left shift),  ''>>'' (logical right shift), and the arithmetic right shift operator ''>>>''.
    * Bit operations: For a variable ''x'', the value ''x{b..a}'' extracts bits ''b'' through ''a'' (both included, with ''b'' at least ''a''). Both ''b'' and ''a'' must be constants (or computed by parameters, i.e. constants after expansion). The syntax ''x{a}'' is syntactic sugar for ''x{a..a}'', and extracts one bit from ''x''. Note that ''b'' must be at least ''a''; for example ''x{3..2}'' corresponds to two bits, but ''x{2..3}'' is not a valid reference.    * Bit operations: For a variable ''x'', the value ''x{b..a}'' extracts bits ''b'' through ''a'' (both included, with ''b'' at least ''a''). Both ''b'' and ''a'' must be constants (or computed by parameters, i.e. constants after expansion). The syntax ''x{a}'' is syntactic sugar for ''x{a..a}'', and extracts one bit from ''x''. Note that ''b'' must be at least ''a''; for example ''x{3..2}'' corresponds to two bits, but ''x{2..3}'' is not a valid reference.
 +   * Bit operations can also be applied to a parenthesized expression. For example, ''(x+y){3..2}'' would extract the specified bits from the result of ''x+y''.
    * Concatenation: Given a set of expressions, ''{e1,e2,e3,...,eN}'' concatenates the bits of the expressions to form a wide result.    * Concatenation: Given a set of expressions, ''{e1,e2,e3,...,eN}'' concatenates the bits of the expressions to form a wide result.