In reply to Moein75:
There are several problems with this code.
Calling user defined functions in a constraint break the solution space in that the random variables as inputs to the function must choose their values first. Then the return value of the function becomes a non-random state variable. The constraint solver is not required to keep trying different inputs to make sure its return value satisfies the remaining constraint (==256).
Also functions used in constraint must be “pure” they cannot reference or modify variables outside their scope. Imagine the behavior if there were multiple calls to your function total.
And finally, the LRM does not allow references to random variables that are aggregate arrays without using an iterative construct like foreach or sum reduction method that can be unrolled into a set of boolean equations.