參考資料:xilinx AXI4 Stream Peripherals 源碼
//************************************************************************
Verilog中函數使用方法這里不再贅述,只給出函數原型及其調用方式。
//************************************************************************
//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);
轉載:http://www.eefocus.com/mastershifu2015/blog/16-08/389919_64de0.html