Forum Discussion
Altera_Forum
Honored Contributor
16 years agoStoring value in a reg
input [11:0] stimulus; reg val; always @(posedge clk) val <=# 1 |(stimulus); what should be the value stored in the register val? Is it the same as saying val = val | stimu...
Altera_Forum
Honored Contributor
16 years agoThe use of the '|' operator in this case is referred to as a reduction operator. val will get the bitwise OR of all the bits in stimulus. So basically if any bit in stimulus is set, val will be a '1', otherwise, it will be '0';
It's the same as writing val <= stimulus[11] | stimulus[10] | stimulus[9] ..... | stimulus[1] | stimulus[0]; only obviously signicantly shorter. Jake