First, be sure this variable doesn't cause you trouble in a
non-swept (single OP) simulation. If it does then look to
variable declaration, may have to make it global / exported
or something?
Also try assigning a default value within the initial declaration
if it appears that the variable being uninitialized might be
the complaint.
I'm pretty sure I have passed variables into veriloga blocks
in the past. So I don't think variables-passing is inherently
broken. But you might need to loop (parametric analysis)
rather than sweep a variable that's down in a veriloga block,
Spectre may not "own" that level of variable to be able to
sweep (rather than step, by passing value) it (?). Give a
parametric analysis loop a try and see whether it works.