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