The following table summarizes bitwise functions in MATLAB® and Fixed-Point Designer™ that are supported for HDL code generation. The following conventions are used in the table:
a,b
: Denote fixed-point integer
operands.
idx
: Denotes an index to a bit
within an operand. Indexes can be scalar or vector, depending on the
function.
MATLAB code uses 1-based indexing conventions. In generated HDL code, such indexes are converted to zero-based indexing conventions.
lidx, ridx
: denote indexes to the
left and right boundaries delimiting bit fields. Indexes can be scalar
or vector, depending on the function.
val
: Denotes a Boolean value.
Indexes, operands, and values passed as arguments bitwise functions can be scalar or vector, depending on the function. For information on the individual functions, see Bitwise Operations (Fixed-Point Designer).
MATLAB Syntax | Description | See Also |
---|---|---|
bitand(a, b) | Bitwise AND | bitand |
bitandreduce(a, lidx, ridx) | Bitwise AND of a field of consecutive bits within Output
data type: For VHDL®, generates the bitwise AND operator operating on a set of individual slices For Verilog®, generates the reduce operator: &a[lidx:ridx] | bitandreduce |
bitcmp(a) | Bitwise complement | bitcmp |
bitconcat(a, b) bitconcat([a_vector]) bitconcat(a, b,c,d,...) | Concatenate fixed-point operands. Operands can be of different signs. Output data type: For VHDL,
generates the concatenation operator: For Verilog,
generates the concatenation operator: | bitconcat |
bitget(a,idx) | Access a bit at position For VHDL,
generates the slice operator: For Verilog,
generates the slice operator: | bitget |
bitor(a, b) | Bitwise OR | bitor |
bitorreduce(a, lidx, ridx) | Bitwise OR of a field of consecutive bits within Output
data type: For VHDL, generates the bitwise OR operator operating on a set of individual slices. For Verilog, generates the reduce operator: |a[lidx:ridx] | bitorreduce |
bitset(a, idx, val) | Set or clear bit(s) at position If | bitset |
bitreplicate(a, n) | Concatenate bits of | bitreplicate |
bitrol(a, idx) | Rotate left.
For VHDL,
generates the For Verilog,
generates the following expression (where a << idx || a >> wl - idx | bitrol |
bitror(a, idx) | Rotate right.
For VHDL,
generates the For Verilog,
generates the following expression (where a >> idx || a << wl - idx | bitror |
bitset(a, idx, val) | Set or clear bit(s) at position If | bitset |
bitshift(a, idx) | Note: For efficient
HDL code generation, use Shift left
or right, based on the positive or negative integer value of‘
For positive values of For negative values
of If Result values saturate if the | bitshift |
bitsliceget(a, lidx, ridx) | Access consecutive set of bits from Output
data type: | bitsliceget |
bitsll(a, idx) | Shift left logical.
0 <= idx < wl wl is
the word length of a .Overflow and
rounding modes of input operand Generates Generates | bitsll |
bitsra(a, idx) | Shift right arithmetic.
0 <= idx < wl wl is
the word length of a ,Overflow and
rounding modes of input operand Generates Generates | bitsra |
bitsrl(a, idx) | Shift right logical.
0 <= idx < wl wl is
the word length of a .Overflow and
rounding modes of input operand Generates Generates | bitsrl |
bitxor(a, b) | Bitwise XOR | bitxor |
bitxorreduce(a, lidx, ridx) | Bitwise XOR reduction. Bitwise XOR of a field
of consecutive bits within Output
data type: For VHDL, generates a set of individual slices. For Verilog, generates the reduce operator: ^a[lidx:ridx] | bitxorreduce |
getlsb(a) | Return value of LSB. | getlsb |
getmsb(a) | Return value of MSB. | getmsb |