How to use boolean to control switch with fixed point data.

3 ビュー (過去 30 日間)
Joshua Wright
Joshua Wright 2019 年 4 月 15 日
コメント済み: Joshua Wright 2019 年 4 月 17 日
I am trying to use a boolean output from inside of Matlab function block to control a switch, which has 16-bit fixed point data. However, I keep getting the following error:
This assignment writes a 'logical' value into a 'double' type. Code generation does not support changing types through assignment. Check preceding assignments or input type specifications for type mismatches. Function 'FSM' (#1424.358.366), line 20, column 13: "path_sel" Launch diagnostic report.
It appears to force my output into a double type and fails. I noticed if I leave the switch data inputs open (floating) it runs fine and interprets the switch states as T and F.
2019-04-15_13-02-41.png
2019-04-15_13-02-10.png

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2019 年 4 月 15 日
You set the criteria of the Switch block as u2>=1, which implies that u2 is double data type. Through back propagation, it requies "path_sel" to be double.
Just change the criteria of the Switch block to be "u2~=0"
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2019 年 4 月 15 日
check the z delay block to see if somewhere "double" is specified. It should output a 'boolean' just as "fftlk_valid".
Joshua Wright
Joshua Wright 2019 年 4 月 15 日
Did not see any speicification on the delay unit. I tried removing the delay and directly connecting but had the same errors.

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


Bharath Venkataraman
Bharath Venkataraman 2019 年 4 月 17 日
S1 and S2 when they are assigned to mealy_state_reg likely need to be fixed point.
Try using assignements as follows:
mealy_state_reg(:) = S1;
mealy_state_reg(:) = S2;
  1 件のコメント
Joshua Wright
Joshua Wright 2019 年 4 月 17 日
I added a convert block to ufix1 and that resolved the issue.

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by