计算输入值的位宽函数
function integer clogb2 (input integer bit_depth);
begin
for(clogb2 = 0;bit_depth > 0;clogb2 = clogb2 + 1)
bit_depth = bit_depth >> 1;
end
endfunction
eg:
localparam integer NUM = clogb2(15) = 4
//bit_depth = 15的数(十进制),位宽(NUM)= 4
localparam integer NUM2 = clogb2(256) = 9
//bit_depth = 256的数(十进制),位宽(NUM2)= 9