
static rsa_pat(n,cin,cout,over,overn,not,csa,sub,addsub,
                deci,stretch,stretch2,name,msb0)
int n,cin,cout,over,overn,not,csa,sub,addsub,
    deci,stretch,stretch2,msb0;
char  *name ;
{
 int  d=msb0?0:n-1;
 int  f=msb0?n-1:0;
 int  l=n-1;
 int  p;
 int  i;
 FILE *fpat;
 int  j;
 char *updown;


   if ( stretch || stretch2 || deci )
      printf("Warning : options deci, stretch, stretch2 are not taken into account for vhdl view\n");

   mbkenv() ;

   fpat = (FILE *)mbkfopen( name, "pat", "w" ) ;

   updown=msb0?NAME("to"):NAME("downto");

               fprintf( fpat, "in a ( %3d %s %3d ) B;;\n",d,updown,f ) ;
               fprintf( fpat, "in b ( %3d %s %3d ) B;;\n",d,updown,f ) ;
   if( csa )   fprintf( fpat, "in c ( %3d %s %3d ) B;;\n",d,updown,f ) ;
   if( cin )   fprintf( fpat, "in cin B;;\n" ) ;
   if( cout )  fprintf( fpat, "out co ( %3d %s %3d ) B;;\n",d,updown,f ) ;
   if( csa )   fprintf( fpat, "out coc B;;\n" ) ;
               fprintf( fpat, "out cout%s B;;\n", (rsa_puiss(n-1)&1) ? "" : "_n" ) ;
   if( over || overn )
               fprintf( fpat, "out over%s B;;\n", (rsa_puiss(n-2)&1) ? "" : "_n" ) ;
               fprintf( fpat, "out s (%3d %s %3d ) B;;\n",d,updown,f ) ;
   if(addsub)  fprintf( fpat, "in sub B;;\n");
               fprintf( fpat, "in vdd B;;\n");
               fprintf( fpat, "in vss B;;\n");
               fprintf( fpat, "\nbegin\n\n" ) ;
               fprintf( fpat, "pat_%8.8X : ",0);
               for(i=0;i<n;i++) fprintf(fpat,"0"); fprintf( fpat, " ");
               for(i=0;i<n;i++) fprintf(fpat,"0"); fprintf( fpat, " ");
   if( csa ) { for(i=0;i<n;i++) fprintf(fpat,"0");fprintf( fpat, " ");}
   if( cin )   fprintf( fpat,"0 ");
   if( cout) { fprintf( fpat, "?");for(i=0;i<n;i++) fprintf(fpat,"0");fprintf( fpat, " ");}
   if( csa )   fprintf( fpat,"- ");
               fprintf( fpat,"- ");
   if( over || overn )
               fprintf( fpat,"* ");
               fprintf( fpat, "?");for(i=0;i<n;i++) fprintf(fpat,not?"1":"0"); fprintf( fpat, " ");
   if(addsub)  fprintf( fpat,"0 ");
               fprintf( fpat,"1 0 ;\n\nend;\n");

   fclose(fpat);
}
