Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Storing value in a reg

Altera_Forum
Honored Contributor II
747 Views

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 | stimulus? And does value always store the lower bit of the stimulus since val is just 1 bit but stimulus is 12 bits? 

 

Thanks.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
58 Views

The 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
Reply