Gerardo Carmona
/
info_04_sumador2datos2bits
Revision 0:1d6044b1911c, committed 2014-05-09
- Comitter:
- gcarmonar
- Date:
- Fri May 09 15:30:17 2014 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 1d6044b1911c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 09 15:30:17 2014 +0000 @@ -0,0 +1,25 @@ +#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); + } +}
diff -r 000000000000 -r 1d6044b1911c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 09 15:30:17 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file