Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <bits/stdc++.h>
- using namespace std;
- #define N 7
- #define M 7
- typedef bitset<8> BYTE;
- typedef bitset<1> BIT;
- struct next_x {BIT next_a ;BIT next_c;};
- bool OnebitMultiplier (bool a, bool x, bool y ,bool c , bool next_a ,bool next_c){
- next_c = ( a & c ) | ( a & ( x & y)) | (c & (x & y));
- next_a = a ^ (x & y) ^ c;
- return a;
- }
- int main (){
- BYTE X(1);
- BYTE Y(2);
- BYTE acc(0);
- bool carry(false),next_a(false),next_c(false);
- size_t i(1),j(1);
- for (i=1 ; i<= pow (2,N) ; i<<=1){
- for (j=1;j<= pow (2,M);j<<=1){
- acc|=OnebitMultiplier( acc [i|j ],X[j],Y[i],& carry, & next_a, & next_c) ;
- }
- }
- cout <<X<< " * "<<Y<< " = "<< acc<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement