Constraint using functions

Is it possible to create a constraint for variable x, such that f(x) = some_constant?
Here’s a small example:


        rand bit [3:0] start_addr;
               
        constraint addr_c { transform(start_addr) == 4; }

        function bit [3:0] transform(bit [3:0] s_addr);
            transform = s_addr + 1;
        endfunction

Note: actual transform function may be more complex. I’d like to know in general whether this is possible.

Thanks!

In reply to bitfiddler0:

No. The function inputs get randomized first in a separate solution space from the output.

In reply to dave_59:

Can it be solved by using solve…before constraint?

In reply to kangrh007:

No to that as well. See constrain random variable result to enumerated type | Verification Academy