示例#1
0
文件: chips.c 项目: cbrpnk/HackAlu
/*
 * Add 2 16bit numbers
 */
void add16(const int *a, const int *b, int *sum) {
	int carry=0;
	int i;
	for(i=15; i>=0; i--) {
		fullAdder(a[i], b[i], carry, &sum[i], &carry);
	}
}
示例#2
0
void bitsetAdd(std::bitset<N>& x, const std::bitset<N>& y)
{
  bool carry = false;
  for (int i = 0; i < N; i++) {
    x[i] = fullAdder(x[i], y[i], carry);
  }
}
示例#3
0
void testAnd(){
    
    char a = '1';
    char b = '1';
    char ci = '0';
    char co, sum;

    fullAdder(a, b, ci, co, sum);
    
    std::cout << "1 + 1: " << std::endl;
    std::cout << "The sum is: " << sum << std::endl;
    std::cout << "The carry out is: " << co << std::endl;
    
}