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 full adder for the construction of mult. //
// arrays. Due to the types of the arguments, the local variable sm is bounded//
// as follows: sm <= (B-1)+(B-1)+1 = 2*B-1 and sm>=0+(-B)+0 = -B, thus sm has //
// type int{2*B}. The carry-out cout is therefore -1,0 or 1.                  // 
// ************************************************************************** //

macro B = 4;      // base of the radix numbers


module FullAddInt(nat{B} ?x,int{B} ?y,int{2} ?cin,!cout,nat{B} !s) {
    event int{2*B} sm;
    sm   = x + y + cin;
    cout = sm / B;
    s    = sm % B;
}

           

averest