Simulink block to extract signal at index from vector signal doesn't exist?
이전 댓글 표시
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?
I need this for use with the Simulink HDL Coder.
Kind regards and many thanks in advance,
Eike
채택된 답변
추가 답변 (3개)
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
Tim McBrayer
2012년 3월 21일
Kaustubha is also correct. Both blocks will generate identical HDL code, when similarly configured:
Multiport_Switch_out1 <= In2(0) WHEN In1_unsigned = 1 ELSE
In2(1) WHEN In1_unsigned = 2 ELSE
In2(2) WHEN In1_unsigned = 3 ELSE
In2(3) WHEN In1_unsigned = 4 ELSE
In2(4) WHEN In1_unsigned = 5 ELSE
In2(5);
Selector_out1 <= In2(0) WHEN In1_unsigned = 1 ELSE
In2(1) WHEN In1_unsigned = 2 ELSE
In2(2) WHEN In1_unsigned = 3 ELSE
In2(3) WHEN In1_unsigned = 4 ELSE
In2(4) WHEN In1_unsigned = 5 ELSE
In2(5);
Eike
2012년 3월 23일
Tim McBrayer
2012년 3월 27일
Configure it to have one data port, and connect a vector to it.
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
2015년 4월 1일
0 개 추천
Is there any block which will give the index from the value selected!!
카테고리
도움말 센터 및 File Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!