The if
condition is inferring a generate block and the parameters are being locally scoped.
if(ch_ID==1)
parameter FILE_OUT= "file1.txt"; // scope: genblk1.FILE_OUT
else
parameter FILE_OUT= "file2.txt"; // scope: genblk2.FILE_OUT
// parent scope: genblk1.FILE_OUT and genblk2.FILE_OUT exist, not FILE_OUT
Solution, inline the operation:
parameter FILE_OUT= (ch_ID==1) ? "file1.txt" : "file2.txt";
// FILE_OUT exists in the module's scope with the desired name
Example on edaplayground