In reply to Siva Namathoti:
You can, but SystemVerilog requires all variable declarations precede all procedural code. The statement ‘num_slaves = 128;’ is procedural, so declaring ‘int i’ can not come after it. Move the declaration of ‘i’ to the top of the function.