Same random value as result in code. How do I get different random values?

In reply to murthy1993:

If the randomize method succeeds then it returns a value of 1, else it returns a value of 0. In your code you are displaying the return value of the randomize method, not the randomized variable. To do that you want to access tt1.val1. It is also considered good practice to check the randomize method’s return value in case randomization fails:

if (!tt1.randomize) $error("Unable to randomize tt1.");