Assertion error, why?

Because all active constraints must be met when calling randomize(), regardless of which variables are being randomized. When you call randomize(aa) while bb is still uninitialized to 3’b0, the randomization fails because constraint cbb cannot be met. aa is left in its original state. Same thing happens again for randomize(bb). When you call randomize(null), no variables are randomized, but all active constraints are checked.

When randomizing select variables in a class, it is the user’s responsibility to either disable unwanted constraints with constraint_mode(0), or put the non-random variables unto a state that satisfies the active constraints.

It is also possible to use local scope std::randomize(aa) with { some constraints} . This randomizes the variables in the list as local variables, and ignores the class constraints. See LRM 18.12.