Altera_Forum
Honored Contributor
15 years agoFor Loop Synthesis Problem
I am trying to write a function that set all bits to the right of the most significant set bit of the input word. For some reason the follow Verilog code does not work correctly in Quartus II 10.0. The code synthesizes as if the different iterations of the for loop are concurrent, even though I'm using a blocking assignment (non-blocking assignment is not allowed in functions). For example, 4h'0080 generates 4h'00e8 instead of 4h'00ff.
Any possible explanation is appreciated.
function mask (input tap);
integer index;
mask = tap;
for (index = 1; index < 32; index = index * 2) begin
mask = mask | (mask >> index);
end
endfunction