Archive for July 3rd, 2008

What Is A Mask?

Add comment July 3rd, 2008

The word mask has different meanings depending on your role in the design process. For many in the software development role a mask is a special value used to extract a set of bits from a larger quantity. For many in the hardware development role a mask is a quantity used to control the propagation of a signal.

In the software domain a developer writing code that interacts with hardware often finds the need to get at the value of a specific set of bits in a byte or word from the hardware. A special value called a mask is created to be an operand of an arithmetic AND operation with the byte or word obtained from the hardware. The result of the operation is a new quantity that can only have zeros in the undesired bit positions. If the quantity is considered a Boolean value it is ready to be used as a Boolean in several programming languages. Otherwise, the next operation is often a compare with zero or a right-shift operation to move the bits into the least significant bit positions. The mask is constructed by placing ones in the desired bit positions and zeros in the undesired bit positions.

In the hardware domain the designer may provide software control over the propagation of select signals. A common example of a signal that may need this control is an interrupt signal. The design provides a bit called a mask in a software accessible register to control the propagation of an interrupt up the interrupt hierarchy to its eventual destination at a CPU. The mask bit and the interrupt are both inputs to an AND gate in the interrupt hierarchy. Unfortunately, the presence of an INVERTER gate between the mask bit and the AND gate is not standardized. Both the hardware and software developers need to verify the required value of the mask bit that allows the propagation of the signal to correctly implement their solutions.