simple 16bit signal arithmetic problem

4 ビュー (過去 30 日間)
Cheolhwan Lim
Cheolhwan Lim 2015 年 4 月 9 日
回答済み: TAB 2015 年 4 月 9 日
Hello
I have a question about N bit signal arithmetic.
I want to calculate (16bit input 1) - (16bit input 2), but 'adder' or 'sum' block shows weird results.
The blocks subtract like this way: (assuming that the signals are 8 bits for an example)
ex) (0 0 0 1 1 1 0 0) - (1 1 1 1 1 1 1 1) = (-1 -1 -1 0 0 0 -1 -1)
Is there any way to calculate binary codes?
Should I make digital adder?

採用された回答

TAB
TAB 2015 年 4 月 9 日
Addition and Subtraction blocks in simulink performs integer addition and subtraction, not bitwise.
What is your expectation for bitwise operation ?
Addition:
0 0 --> 0
0 1 --> 1
1 0 --> 1
1 1 --> ? What about carry ?
Subtraction:
0 0 --> 0
0 1 --> ? Borrow ?
1 0 --> 1
1 1 --> 0
Depending upon your expectation, you can extracts the bits from your integer and construct the logic using Logical blocks to perform the bitwise operation.

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by