Verilog定义计算位宽的函数clogb2
生活随笔
收集整理的這篇文章主要介紹了
Verilog定义计算位宽的函数clogb2
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在很多情況下要計(jì)算輸入輸出的位寬,比如你寫一個(gè)8*8的ram,那么地址需要三位去表示,那么這個(gè)函數(shù)的方便就體現(xiàn)出來了,你需要使用函數(shù)定義就好了。
//位寬計(jì)算函數(shù) function integer clogb2 (input integer depth); beginfor (clogb2=0; depth>0; clogb2=clogb2+1) depth = depth >>1; end endfunction舉個(gè)栗子
parameter p_cnt_max = p_rev_time*p_clk_fre*1000_000 - 1; //翻轉(zhuǎn)時(shí)間內(nèi)所需計(jì)數(shù)的最大值 //位寬計(jì)算函數(shù) function integer clogb2 (input integer depth); beginfor (clogb2=0; depth>0; clogb2=clogb2+1) depth = depth >>1; end endfunctionwire [clogb2(p_cnt_max)-1:0] w_cnt_max;?
以上。
轉(zhuǎn)載于:https://www.cnblogs.com/kingstacker/p/7662364.html
總結(jié)
以上是生活随笔為你收集整理的Verilog定义计算位宽的函数clogb2的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: windows平台搭建Mongo数据库复
- 下一篇: C语言消息队列