在verilog中使用clogb2函数可进行log2操作,用来计算数据位宽

//function called clogb2 that returns an integer which has the

//value of the ceiling of the log base 2.
function integer clogb2 (input integer bit_depth);
begin
for(clogb2=0; bit_depth>0; clogb2=clogb2+1)
bit_depth = bit_depth>>1;
end
endfunction
//************************************************************************
 
localparam WIDTH_SRL = 32; 
localparam WIDTH_CNT = clogb2(WIDTH_SRL/8-1);


在verilog中使用clogb2函数可进行log2操作,用来计算数据位宽

你可能感兴趣的:(verilog,fpga)