reduction operators

You're already familiar with bitwise operations between two values, e.g., a & b or a ^ b. Sometimes, you want to create a wide gate that operates on all of the bits of one vector, like (a[0] & a[1] & a[2] & a[3] ... ), which gets tedious if the vector is long.

The reduction operators can do AND, OR, and XOR of the bits of a vector, producing one bit of output:

Reduction - HDLBits (01xz.net)

1 module top_module (
2     input [7:0] in,
3     output parity); 
4     assign parity=^in[7:0];
5 endmodule

 

posted @ 2023-04-20 10:36  江左子固  阅读(22)  评论(0)    收藏  举报