#include <genpat.h>
/* problems under cyg win32
#include <stdio.h>
#include <mut316.h>
*/

char *inttostr(entier)
int entier;
  {
  char *str;
  str = (char *) mbkalloc (32 * sizeof (char));
  sprintf (str, "%d",entier);
  return(str);
  }
   /*------------------------------*/
   /* end of the description       */
   /*------------------------------*/

 main ()
 {
 int i;
 int j;
 int cur_vect;

 DEF_GENPAT("vecteurs");

 /* interface */
 DECLAR ("a", ":2", "X", IN, "0  to 3");
 DECLAR ("b", ":2", "X", IN, "0  to 3");
 DECLAR ("sel", ":2", "B", IN, "");
 DECLAR ("ck", ":2", "B", IN, "");
 DECLAR ("s", ":2", "X", OUT, "0 to 3");

 LABEL ("additionneur");
 AFFECT ("0", "ck", "0b0");
 AFFECT ("0", "sel", "0b0");

 for (i=0; i<16; i++)
     for (j=0; j<16; j++)
     {
         cur_vect = i*16 + j;
         AFFECT (inttostr(cur_vect), "a", inttostr(i));
         AFFECT (inttostr(cur_vect), "b", inttostr(j));
     }

 cur_vect = cur_vect + 1;
 AFFECT (inttostr(cur_vect), "a", "0b0");
 AFFECT (inttostr(cur_vect), "b", "0b0");
 AFFECT (inttostr(cur_vect), "sel", "0b0");
 AFFECT (inttostr(cur_vect), "ck" , "0b0");

 SAV_GENPAT ();
}
