Appearance
Bit Operation
Bit Extract, Mask, Shift Left or Shift Right on an integer signal, chosen with the Operation parameter. Bit Extract: out = (in >> bit) & 1, for picking one flag out of a status word. Mask: out = in & mask, for isolating a bit field. Shift Left: out = in << shift (multiply by 2^shift, bits past the MSB are discarded). Shift Right: out = in >> shift, zero-filled (logical) or sign-extended (arithmetic).
Category: Digital Logic / Bits
Ports
| Port | Kind | Signal | Notes |
|---|---|---|---|
in | Control input | Integer | |
out | Control output | Integer |
Parameters
| Parameter | Type | Default | Units | Description | ID |
|---|---|---|---|---|---|
| Operation | Choice: Bit Extract / Mask / Shift Left / Shift Right | Bit Extract | — | Bit Extract: out = (in >> bit) & 1. Mask: out = in & mask. Shift Left: out = in << shift. Shift Right: out = in >> shift. | op |
| Bit | Integer | 0 | — | Bit position to extract (0 = LSB, clamped to 0-31). Result is 0 or 1. | bit_index |
| Mask | Integer | 255 | — | Bit mask AND-ed with the input. Default 255 (0xFF) keeps the low 8 bits. Use any int — e.g. 0xF0 to extract the high nibble of a byte, 0x80000000 to isolate the sign bit. | mask |
| Shift | Integer | 1 | — | Number of bit positions to shift (clamped to 0-31). | shift |
| Mode | Choice: logical (zero-fill) / arithmetic (sign-extend) | logical (zero-fill) | — | Logical right shift fills with zeros from the left. Arithmetic right shift replicates the sign bit, so negative numbers stay negative (divide by 2^shift). | arithmetic |