ビット論理演算方法

8 visualizzazioni (ultimi 30 giorni)
maruti
maruti il 6 Dic 2019
Risposto: Musashi Ito il 7 Dic 2019
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ゲートを通すことで可能な方法があるのでしょうか?
いくつか試してみたところで欲しい結果を得られなくて質問しました。

Risposta accettata

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

Più risposte (0)

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!