Gerardo Carmona
/
info_04_sumador2datos2bits
main.cpp
- Committer:
- gcarmonar
- Date:
- 2014-05-09
- Revision:
- 0:1d6044b1911c
File content as of revision 0:1d6044b1911c:
#include "mbed.h" DigitalIn A(D2); DigitalIn B(D3); DigitalIn C(D4); DigitalIn D(D5); BusOut bout(D13, D12, D11, D10); int sumador(int a, int b, int ci){ int x,s,co; x = a&!b | !a&b; s = x&!ci | !x&ci; co = x&ci | a&b; return s | (co << 1); } int main() { while(1) { int c = 0; bout = sumador (A,B,c); bout = bout & 0x01 | (sumador(C,D,bout>>1) << 1); wait(.1); } }