有一天,我在Verilog学到一个很酷的把戏。 当你需要反复做一些事情时, 您可以使用一个转换注册来计算递增次数。 只是将一个 1 从 LSB 转到 MSB, 当它到达 MSB 时, 您可以重新完成 。
在C中是这样的:
for(j=0b1; !(j & (1<<16)); j=j<<1)
{
/*do a thing 16 times*/
}
I know it has limited use because of the bit width, but it isn t involving any addition so it is fast. So my question: Is there any use of this? Is it worth it to use in C or any other high-level language?
也许在资源有限的嵌入系统中。
谢谢 谢谢