If statement in tb_top

I have this in a module and it works.


 assign tb.foo.fie.module.signal_name = 1'b1;

If I try to do this, it does not compile.


if (condition) 
    assign tb.foo.fie.module.signal_name = 1'b1;

If I do the following, it compiles without error.


initial begin
    if (condition) 
        force tb.foo.fie.module.signal_name = 1'b1;
end 

Why does the ‘if’ statement not work without the initial begin block?

Thanks!

In reply to new_to_uvm:

When you write


if (condition) 
    assign tb.foo.fie.module.signal_name = 1'b1;

you are creating an implicit generate block


generate
    if (condition) 
        assign tb.foo.fie.module.signal_name = 1'b1;
endgenerate

and condition must be a parameter or macro whose value is known during compilation and elaboration.