ygrec8/VHDL/shared/expressions.txt created mer. 22 nov. 2023 01:31:09 CET by whygee@f-cpu.org version sam. 25 nov. 2023 08:43:39 CET parse_utils.vhdl provides support for textual "Expressions". They are a way to construct numbers more conveniently than whith a string of digits. These are still available, complemented by - external symbols (through the use of a dictionary implemented in this directory) - arithmetic and boolean operations (though C extensions are required for some, due to the arbitrary restrictions of the VHDL LRM) The syntax is quite simple due to the restriction to binary operations, which removes all the usual precedences. The basics : Symbol : [_A-Z][_A-Z0-9]* Number : [-0-9][A-F0-9]*[BDHO]? A string token is defined as a number if it starts with a decimal digit or a minus sign, it's a symbol otherwise (it will be looked up in the dictionary). And there is the Dollar Sign : "$" which reads a global variable. The number token may end with a base suffix (binary/decimal/hexadecimal/octal). Internal representation is unsigned 32-bit integer (uint32_t in C). Internal overflows must trigger an error. Basic operators are taken from the available VHDL vocabulary: + - * / % And some non-native operators: smin : <$ smax : >$ As well as the comparison operators : =, !=, >=, <=, <, > Boolean extensions are also available for compatible platforms: (a slower version is possible without external C) and : & or : | xor : ^ sll : << srl : >> ror : @> rol : <@ Not yet implemented : sra : >>> (parser complexity) umin : ? We get the final definition : Expression : '$' | Symbol | Number | '(' Expression operator Expression ')'