Home / Learn Verilog / Bitwise Operators: & | ^ ~ ~^
Bitwise Operators: & | ^ ~ ~^
Act on each bit pair.
Quick summaryAct on each bit pair.
How to think about this
The basic idea
Each bit of the result depends on the bits at the same position.
Why this comes up
Masks, flags and parity logic.
The mechanics
Mask with &, set with |, toggle with ^.
Where it is used
- Everyday RTL design
- FPGA and ASIC projects
- Testbenches and debugging
Try it
Mask, set, toggleVerilog: edit and run
Flag manipulation as in register control.
Quick check
1. Mask the low nibble with...
AND keeps selected bits.