Verilog寫ones counter
时间:10-02
整理:3721RD
点击:
有個題目我寫不太出來 有請神人幫忙
Write and verify a Verilog module that produces 4-bit output code indicating the number of 1s in an 8-bit input word.
testbench 也要謝謝
Write and verify a Verilog module that produces 4-bit output code indicating the number of 1s in an 8-bit input word.
testbench 也要謝謝
简单的查找表不可以么?
什麼意思?
做一个LUT是4bit输出,8bit输入的就ok了
类似于数字逻辑课程中的真值表的思想。根据你的需求,有两种实现方法:
1.关于楼上提到的LUT方法,采用case语句即可,罗列所有的可能输入。2^8=256,写起来累一点,呵呵。建议采用软件自动生成格式。这样的方法速度很快,资源也不多,纯组合逻辑
2.引入加法器的帮助,定义个4bit宽度的寄存器,引入时钟,每个cycle 加其中的一位数,8个时钟即可输出你要的结果。
其他的方法暂时还没想清楚,呵呵,希望有帮助
