How can I convert from decimal to binary for HDL Coder?

3 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2020 年 12 月 21 日
回答済み: Kiran Kintali 2020 年 12 月 30 日
I am creating a Simulink model for HDL code generation. I would like to convert a signal into a vector of bits so that I can perform operations on each individual bit. There is no block that performs this operation, so I would like to create a custom implementation. What is the best way to do this that will not generate excessive code?

採用された回答

MathWorks Support Team
MathWorks Support Team 2020 年 12 月 21 日
A convenient way to perform this operation is to use the MATLAB Function block. There is an example implementation of this type of block within the eml_hdl_design_patterns example library. The Integer to Bits block within this library can be added to a model to convert a scalar to a vector of bits. Refer to the following for more information on this example:
Note that the following modifications may be required to ensure compatibility with an existing model:
  1. Specify output vector length by creating variable maxWordLength or directly entering a value in the block's mask.
  2. This block outputs a 1xN vector. If downstream blocks expect an Nx1 vector, either the MATLAB function can be edited to switch vector dimensions, or the output signal can be reshaped to the expected dimensions.

その他の回答 (1 件)

Kiran Kintali
Kiran Kintali 2020 年 12 月 30 日
Attaching the model in the example for convenience.

タグ

タグが未入力です。

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by