/* o6fadd61.c  This program generates the OBS mode 4IP 7c264 first adder
	       stage (6+6) (ie., U32,33,34,35) adder EPROM contents. The 
	       contents should be used in all the 4IPs for the Real, & 
	       Imaginary sections.

Note : The inputs are two  5-bit numbers in TWO's Complement format. The PROM
       extends the input sign bits to the 6th bit and adds the two numbers. 
       Ignores the (or masks the) overflow(7th bit), if produced upon addition. 
       Then extend the sum o/p sign bit to the 7th bit. Then it produces the 
       o/p input b                      
							TP  -6/2/98     */
/*    copied from 			
     O6plus61.c            - Dated : 09 Nov '95 */					
/* *************************************************************  */
/* CY 7C264   4IP REAL,IMAGINARY      OBS Subgroup     	  */
/* *************************************************************  */
						      
#include "gac.h"

main()
{	unsigned char data,d1,d2,s ;
	int i ;
	FILE *out,*outt;

   clrscr() ;	
   out = fopen("o6fadd6.bin","wb");     /* 6 full add 6 ver 1 */
   outt = fopen("o6fadd6.txt","wt");    /* Text 6 full add 6 ver 1     */

fprintf(outt,"o6fadd61.c  generated these OBSmode 4IP 7c264 firstadder\n"); 
fprintf(outt,"stage (6+6) (ie., U32,33,34,35) adder EPROM contents. The  \n"); 
fprintf(outt," contents should be used in all the 4IPs for the Real, & Imaginary sections.\n"); 
fprintf(outt," \n");
fprintf(outt," \n");
fprintf(outt," \n");

   fprintf(outt," i  : d2  + d1  = data\n" );  
	/*       0xxx xx0x xxxx  */
   for(i=0;i<=0x1fff;i++)
   {	d1 = i & 0x1f ;
	d2 = (i >> 6) &0x1f ;
	if((d1 & 0x10) == 0x10)
	   d1 = d1 | 0x20  ; /* extend the sign bit */
	if((d2 & 0x10) == 0x10)
	   d2 = d2 | 0x20  ; /* extend the sign bit */

	data = (d1 + d2) & 0x3f ; /*add and ignore the Overflow(7th bit)*/
	if((data & 0x20) == 0x20)
	   data = data | 0x40  ; /* extend the sign bit to the 7 th bit */     

	printf("%4x :  %2x + %2x =  %2x  \n",i,d2,d1,data );  
	fwrite(&data,sizeof(data),1,out);
	fprintf(outt, "%4x :  %2x + %2x =  %2x  \n",i,d2,d1,data );
   }

   fclose(out) ;
   fclose(outt) ;

}
	 
	
