```// ************************************************************************** //
//                                                                            //
//    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 module below performs subtraction of radix-B numbers by addition of the//
// complement number. The (B-1)-complement number is having digits (B-1-x[i]) //
// so that the sum of a number and its (B-1)-complement number is B^m-1. One  //
// therefore defines the B-complement of a number as its (B-1)-complement     //
// incremented by one. The sum of a radix-B number and its B-complement yields//
// therefore B^m which is the same as zere in the least significant m digits. //
// ************************************************************************** //

macro B = 4;
macro N = 6;

module NatSubByCompl([N]nat{B} ?x,?y,[N+1]nat{B} !s) {
[N+1]nat{2} c;  // carry digits
c[0] = 1;
for(i=0..N-1) {
event nat{2*B} sm;
sm = x[i] + ((B-1) - y[i]) + c[i];
c[i+1] = sm / B;
s[i]   = sm % B;
}
s[N] = 1-c[N];
}
drivenby {
x = [3,2,1,0]; // read reversed
y = [1,2,3,2]; // read reversed
}
drivenby {
x = [1,2,3,2]; // read reversed
y = [3,2,1,0]; // read reversed
}
```