ビット論理演算方法

8 ビュー (過去 30 日間)
maruti
maruti 2019 年 12 月 6 日
回答済み: Musashi Ito 2019 年 12 月 7 日
assign a = (x > 17'd1000)|(x < 17'd300);
assign b = (x > 17'd3620)|(x < 17'd583);
assign c = (x > 17'd2512)|(x < 17'd121);
assign d = (x > 17'd2133)|(x < 17'd363);
assign e = (x > 17'd3145)|(x < 17'd696);
assign f = (x > 17'd1525)|(x < 17'd99);
assign g = (x > 17'd3055)|(x < 17'd69);
をsimulinkのブロックを使って実装しようとしているが、
そのままx信号とconstantの比較をしてそれを一々ORゲートを通すとすると
余計にブロック図は大きくなり非効率的だと思い
質問します。
質問:constant信号を1 x nの入力でORゲートを通すことで可能な方法があるのでしょうか?
いくつか試してみたところで欲しい結果を得られなくて質問しました。

採用された回答

Musashi Ito
Musashi Ito 2019 年 12 月 7 日
Simulinkではベクトルが使用できますので、Constant ブロックにベクトルで定義する方法はいかがでしょうか。Relational Operator ブロックでベクトルの要素ごとに比較され、Logical Operator ブロック(OR) でもベクトルの要素ごとに OR されます。取り出すときは、demux や selector ブロックで取り出します。
vector_constant.png
Relational Operator ブロックを使用してますが、Compare to Constant ブロックに直接設定しても良いかと思います。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!