Averest
// ************************************************************************** //
//                                                                            //
//    eses                   eses                                             //
//   eses                     eses                                            //
//  eses    eseses  esesese    eses   Embedded Systems Group                  //
//  ese    ese  ese ese         ese                                           //
//  ese    eseseses eseseses    ese   Department of Computer Science          //
//  eses   eses          ese   eses                                           //
//   eses   eseses  eseseses  eses    University of Kaiserslautern            //
//    eses                   eses                                             //
//                                                                            //
// ************************************************************************** //
// The following module implements a basic cell that can be used for the      //
// construction of multiplier arrays. It is intended for the most significant //
// digits that have to be interpreted by function alpha first, and the most   //
// significant digit cout is therefore mapped by function gamma as well.      //
// For even B=2b, we have sm <= (B-1)*(b-1)+(B-1)+(B-1)=2b^2-1 and a lower    //
// bound is sm >= (B-1)*(-b) + (-b) + 0 = -2b^2, thus sm fits into int{B*B}.  //
// Thus, sm/B is of type int{B} so that gamma maps it to nat{B}.              //
// ************************************************************************** //

macro B = 4;      // base of the radix numbers
macro alpha(x) = (x<B/2 ? +x : +x-B);
macro gamma(y) = (y<0 ? y+B : y);


module FullMulBC(int{B} ?x,nat{B} ?y,?pin,int{B} ?cin,nat{B} !cout,!pout) {
    event int{B*B} sm;
    sm   = x * alpha(y) + alpha(pin) + cin;
    cout = gamma(sm / B);
    pout = sm % B;
}

           

averest