I need to randomize variable `rA` and set variable `rB` to 1'b1 if `rA` == 1'b1 or randomized if `rA` == 1'b0. Here is what I am trying:

```
class randomizedVars;
    rand bit rA;
    rand bit rB;
    constraint cB {
        rB == 1'b1;
    }
    task changeConstraints();
        if (this.rA == 1'b1)
            begin
            this.cB.constraint_mode(1); // turn on the constraint for rB
            this.rA.rand_mode(0); // Disable rA from being randomized
            this.randomize(); // Rerandomize to force rB to meet its constraint ?
            this.rA.rand_mode(1); // Reenable rA to be randomized later
            this.cB.constraint_mode(0); // turn off the constraint for rB for later
            end
         else
            this.cB.constraint_mode(0);
    endtask
endclass

```

This method seems to be working, but I'm mostly just wondering if there is a "correct" way of doing this. I feel as if this method is the Brute-Force-And-Difficulty method. Worse yet, I need to call the task after every randomization, which makes me feel as if there is a method I am not seeing.

Just to be clear, my expected results are that when `rA` is randomized and equal to 1, `rB` will be forced to 1. If `rA` is randomized and equal to 0, then `rB` will also be randomized. My actual results match this. Just wondering if there is a way to do this without having to call a task after every `.randomize()` method call.