//定义函数
function integer clogb2(
input integer depth
);
begin
clog2=0;
while(2**clog2<depth)begin//2**clog表示2的n次幂,比如clog2=0,它就是2的0次幂为1。
clog2=clog+1;
end
end
endfunction
//调用函数
localparam cnt=32;
localparam cnt_width=clog2(cnt);
//调用clog2函数,cnt=depth,假如cnt=4,进行clog2计算cnt_width等于2,cnt=15,cnt_width=4;
verilog位宽计算函数
最新推荐文章于 2024-04-11 17:08:25 发布