Forum Discussion
Altera_Forum
Honored Contributor
9 years ago --- Quote Start --- This worked for me going back a number of releases. You have a few typos. Make sure what you posed is exactly what you are compiling. --- Quote End --- Hi, Mr.dave_59. thanks for replying. I'm sorry that I had not made enough tests. After testing the code I found it worked in module, but not in an interface:
package pkg;
function bit bitgen(int bit1idx);
automatic bit res = '0;
if (bit1idx >= 0 && bit1idx < 16)
res = 1'b1;
return res;
endfunction
function bit bit2test(bit bits2test);
if ((bits2test&bitgen(2)) != 0)
return 1'b1;
return 1'b0;
endfunction
endpackage
interface iftest# (
parameter para2test = 15
);
import pkg::*;
localparam bit2set_flag = bit2test(para2test); // modelsim reports compiling error here!
initial begin
if (bit2set_flag == 0)
$error("bit2 of para2test is not set!");
end
end
module mod2test# (
parameter para2test = 15
);
import pkg::*;
localparam bit2set_flag = bit2test(para2test); // the code here passed modelsim's compiling
initial begin
if (bit2set_flag == 0)
$error("bit2 of para2test is not set!");
end
endmodule
can I get it work in interface?