Simulink block to extract signal at index from vector signal doesn't exist?

17 ビュー (過去 30 日間)
Eike
Eike 2012 年 3 月 21 日
回答済み: Bibek 2015 年 4 月 1 日
Hey,
I'm looking for a block that takes 2 input signals: One vector signal and one integer index signal. The output would be
vector(index)
Am I just too stupid to find it or does that block really not exist? Any workarounds?
Also see my other question for my personal workaround. (Which I regard as being not so nice.)
I need this for use with the Simulink HDL Coder.
Kind regards and many thanks in advance,
Eike

採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 3 月 21 日
You need the Selector block. It is supported for HDL Code Generation.
  1 件のコメント
Eike
Eike 2012 年 3 月 23 日
Thank you, that is indeed exactly what I was looking for! To be honest, I had seen that block before but did not really understand how it works / in which ways I can configure it.

サインインしてコメントする。

その他の回答 (3 件)

Tim McBrayer
Tim McBrayer 2012 年 3 月 21 日
The block you are looking for is the Multiport Switch block, located in the Simulink->Signal Routing library. This block is supported by Simulink HDL Coder. For your use case you will want to configure it to have one input port. Connect port one to your index signal, and port 2 to your vector signal. The output will be:
vector(index)
You can choose either zero-based or one-based indexing.
  3 件のコメント
Eike
Eike 2012 年 3 月 23 日
But how can I configure the Multiport Switch to work on a vector signal?
Tim McBrayer
Tim McBrayer 2012 年 3 月 27 日
Configure it to have one data port, and connect a vector to it.

サインインしてコメントする。


David Amor
David Amor 2014 年 6 月 10 日
Are you trying to get a single bit from a vector at an index? If so bitget would be easier and less verbose.
ans = bitget(vector,index);
but if you are trying to access a vector from an array of vectors then yeah, you need the selector block.

Bibek
Bibek 2015 年 4 月 1 日
Is there any block which will give the index from the value selected!!

カテゴリ

Help Center および File ExchangeHDL Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by