- Documentation
- Flux C++ extension
- Fixed-width bit types
Fixed-width bit types
bits<N> is an unsigned value of exactly N bits. Arithmetic wraps modulo 2N.
Literals
Section titled “Literals”A sized literal gives the width, then b, then the binary digits.
| Literal | Width | Value |
|---|---|---|
1b0 |
1 | 0 |
4b0000 |
4 | 0 |
8b00000001 |
8 | 1 |
Plain integers such as 1 are accepted when generating hardware. Simulation currently rejects some of them; use a sized literal in designs you simulate.
Individual bits
Section titled “Individual bits”Index a value to read or write one bit.
__fpga void swapEnds(bits<4> value, bits<4>& result) { result[0] = value[3]; result[1] = value[1]; result[2] = value[2]; result[3] = value[0];}