Redian新闻
>
Re: 求教:有VHDL格式的随机生成0/1的程序吗?
avatar
x*l
2
e【 在 ccfantasia (cc-time killer) 的大作中提到: 】
首先,俺是菜鸟。赫赫:)
其次,
如果只是用在测试模块,VHDL不知道,verilog看样子该有。(在最后面)
但是要到fpga里面,呵呵:)
如果对随机性要求不高,建议用移位寄存器搭一个伪随机序列生成器。
如果要求高, 要么自己设计 true random number generator
要么去找 IP core.
3.8.7.系统任务 $random
这个系统函数提供了一个产生随机数的手段。当函数被调用时返回一个32bit的随机数。
它是一个带符号的整形数。
$random一般的用法是:$ramdom % b ,其中 b>0.它给出了一个范围在(-b+1):(b-1)中
的随机数。下面给出一个产生随机数的例子:
reg[23:0] rand;
rand = $random % 60;
上面的例子给出了一个范围在-59到59之间的随机数,下面的例子通过位并接操作产生
一个值在0到59之间的数。
reg[23:0] rand;
rand = {$random} % 60;
avatar
j*h
3
What you need is a google on "LFSR", linear feedback shift registers, such as
this one:
http://www-math.cudenver.edu/~wcherowi/courses/m5410/m5410fsr.html
This is how the "library functions" generate PN sequences anyway.
To form your own generator, you just need to look up a "primitive polynomial"
from the back of a math book. It is very easy to implement yet the theory
behind it is kind of fascinating.


b>0.它给出了一个范围在(-b+1):(b-1)中
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。