Bits to Word
Libraries:
HDL Coder /
Logic and Bit Operations
Description
The Bits to Word block converts a length-N input vector of bits to an N-bit integer. The output of the block is an unsigned integer that has word length N.
The block treats the first element of the input vector as the least significant bit (LSB)
of the output and treats subsequent bits as the next significant bits in ascending order. This
figure shows the conversion of the bit vector [1 0 1 1 0]
to the integer
value 13
.
Examples
Convert Input Vector of Bits to Integer
Use the Bits to Word block in a Simulink® Model that converts vector of bits to an unsigned integer. You also generate HDL code for the model.
Ports
Input
In — Input signal
binary-valued scalar | binary-valued vector
Input signal to the block, specified as binary-valued scalar or vector. You can specify a vector containing up to 128 elements.
Example:
[0 1 1 0 0 1 1 1]
Data Types: fixdt(0,1,0)
Output
Out — Output signal
scalar
N-bit integer, where N is the size of the
input vector, returned as a nonnegative scalar. For example, when you specify a 1-by-8
input signal, then the output signal is an unsigned integer with the
ufix8
data type.
Data Types: uint8
| uint16
| uint32
| uint64
| fixed point
Parameters
Input bit order — Input bit order
LSB first
(default) | MSB first
Input bit order, specified as 'MSB first'
or 'LSB
first'
.
'MSB first'
–– First bit of the input signal is the most significant bit (MSB).'LSB first'
–– First bit of the input signal is the least significant bit (LSB).
Programmatic Use
Block Parameter:
bitOrder |
Type: character vector |
Values: 'LSB first' |
'MSB first' |
Default: 'LSB
first' |
After bit packing, treat resulting integer values as — Flag for signed integer values after bit packing
Unsigned
(default) | Signed
Specify whether the resulting integer values are treated as signed or unsigned after bit packing.
Programmatic Use
Block Parameter:
signedOutputValues |
Type: character vector |
Values: 'Unsigned' |
'Signed' |
Default:
'Unsigned' |
Extended Capabilities
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
This block has one default HDL architecture.
General | |
---|---|
ConstrainedOutputPipeline | Number of registers to place at
the outputs by moving existing delays within your design. Distributed
pipelining does not redistribute these registers. The default is
|
InputPipeline | Number of input pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
OutputPipeline | Number of output pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
The block supports these data types for HDL code generation:
Input Port | Dimension | Fixed-Point | Floating-Point | Built-in Integers | Bus | Boolean | Complex Signal |
---|---|---|---|---|---|---|---|
In | Scalar Vector | ufix1 | No | No | No | No | No |
Matrix input is not supported.
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)