A little #define macro in C for selecting a bit range from an integer
This is a simple utility C macro for selecting a bit range from an integer: #define bits(x, y, z) (((x) >> (z)) & ((((long int) 2) << ((y) – (z))) – 1)) This picks the part that is equivalent to the expression x[y:z] in Verilog. The cast to long int may need adjustment to the [...]