how to create function half adder in matlab

조회 수: 4 (최근 30일)
manaf nehad
manaf nehad 2018년 4월 2일
답변: Roger Stafford 2018년 4월 2일
halfAdder : it accepts 2 bits as input arguments. It adds these bits and returns 2 bits as output arguments: the sum and the output carry
  댓글 수: 1
James Tursa
James Tursa 2018년 4월 2일
What is this for? How are the bits passed in? I.e., what are the variable classes involved?

댓글을 달려면 로그인하십시오.

채택된 답변

Roger Stafford
Roger Stafford 2018년 4월 2일
If the input bits are numeric scalars or logical values, b1 and b2, then the sum bit, 's', would be:
s = b1 xor b2;
or else
s = (b1&~b2) | (~b1&b2);
These are equivalent. That leaves you with the 'carry' bit to figure out.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by