弱问一个简单的问题
也就是random加拼接运算符后产生的值就略去了负的部分呢?
期望有人解答,谢谢!~!~!~!
You ask a very good question.
According IEEE 1364-2005 page 341:
The system function $random provides a mechanism for generating random numbers. The function returns
a new 32-bit random number each time it is called. The random number is a signed integer; it can be positive
or negative. For further information on probabilistic random number generators, see 17.9.2.
The seed argument controls the numbers that $random returns so that different seeds generate different
random streams. The seed argument shall be either a reg, an integer, or a time variable. The seed value
should be assigned to this variable prior to calling $random.
For example:
Example 1—Where b is greater than 0, the expression ($random % b) gives a number in the following
range: [(-b+1): (b-1)].
So I think your assumption is wrong.
我是看到夏宇闻老师书上他是这么写的,因为我不是很明白,所以才问的。
很简单,说明书错了:)
好好干,你能成为一个优秀的工程师的.
夏宇闻 is right. I make a mistake.
The {} treats all parameter as unsigned value and so products an unsigned value too.
You can run the following test program in simulator.
You can try to remove {} to watch the different effect.
// test program
module top;
initial repeat(80) #1 $display("%d ($random) mod 60 -> %d", $random, {$random}%60);
initial #100 $finish;
endmodule
上海保洁公司
回复
对这个系统函数,我还没有用过。不过现在学到了一些新的知识了。
恩,不错的问题
汗。这个人家就是说加了{}只有正,没加正负都有,你知道怎么用就行了撒,你还去研究为什么啊?这个是人家定的标准撒,就像文件是用"..."一样。
楼上的,话是这么说,不过多思考一番就会发现,标准的定义是连贯同意的,对于初学者还是很有好处的,支持提问的!
