File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / macro4 / cosf.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:30:56 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

#include "fpp_defs.h"



/***************************************************************************
*
*	COSF - SINGLE PRECISION FLOATING POINT COSF FUNCTION TEST
*
*			COSF TEST MONITOR
*
*****************************************************************************/
cosf()
{
	asm(".globl _cosf_t");
	asm("_cosf_t:");			/* entry address            */
	if( ( cycle == 1 ) && ( prt_hdrs ) )	/* print headers on 1st pass */
	{
	   writes(" COSF");
	}
	cosf_1();				/* test square root w/ delay  */
	cosf_2();				/* test square root           */
	cosf_3();				/* register corruption        */
/*	cosf_4();				/* test the PSL               */
	cosf_5();				/* pipelined entry            */
	cosf_6();				/* pipelined exit             */
	asm("jmp *return");			/* return to the test monitor */
}

/***************************************************************************
*
*	SUBTEST 1 - COSF FUNCTION 
*
***************************************************************************/
cosf_1() 
{
#define DELAY 20		/* wait 40 ticks between COSF and STF */
	force_loop = FALSE;			   /* clear the LOOP flag */
	subtest = 1;
        index = 0;
	do 
	{
	   sgl_ld_acc   = cosf_1_data[index].ld;   /* get the operand      */
	   sgl_expected = cosf_1_data[index].exp;  /* get expected results */
	   sgl_dummy1 = DELAY;
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
	   asm("_cosf_1_lp1:");
	   asm("movl _sgl_ld_acc,r4");		/* set the data to load     */
	   asm("ldf r4");			/* load the accumulator     */
	   asm("movl _sgl_dummy1,r0");		/* get the delay factor     */
           asm("cosf");			        /* get ACC.'s cosine        */
	   asm("1:");
	   asm("decl r0");			/* delay to let the COSF    */
	   asm("bgtr 1b");			/*   instruction finish     */
	   asm("stf r5");			/* store the result         */
           if( force_loop )
                asm("brb _cosf_1_lp1");;      /* loop on the error     */
/* 
 * end error loop 
*/
	   asm("movl r5,_sgl_st_acc");		/* save the result          */
	   if( sgl_st_acc != sgl_expected )   	/* COMPARE the values       */
	   {
	      errcnt++;				/* bump the error count     */
	      if ( prt_error ) {
		 writes(" \n");		/* start a new print line   */
		 writes("cycle: ");
		 writed( cycle );
		 writes("   COSF test ");
		 writed( test_no );
		 writes(", subtest 1 (delayed store) - BAD FINAL ACC\n");
	         print_cosf_data();
                 writes(",  data index = ");
                 writed( index );
                 writec('\n');
                 writes("                      Acc expected = ");
                 write32h( sgl_expected );
                 writec('\n');
              }
              if ( halt_flg ) 			/* halt on error?        */
	         cosf_er_halt( BAD_ACC_HLT );
              if ( loop_on_err ) 
	      {
		 force_loop = TRUE;		/* set the force loop flag */
		 asm("jmp _cosf_1_lp1");	/* and loop                */
	      }
	   }   /* end of compare error */
	} while( index++ < max_cosf_1_index );
}  /* end of subtest 1 */
  


/***************************************************************************
*
*	SUBTEST 2 - COSF FUNCTION 
*
***************************************************************************/
cosf_2() 
{
	force_loop = FALSE;			   /* clear the LOOP flag */
	subtest = 2;
        index = 0;
	do 
	{
	   sgl_ld_acc   = cosf_1_data[index].ld;   /* get the operand      */
	   sgl_expected = cosf_1_data[index].exp;  /* get expected results */
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
	   asm("_cosf_2_lp1:");
	   asm("movl _sgl_ld_acc,r4");		/* set the data to load     */
	   asm("ldf r4");			/* load the accumulator     */
           asm("cosf");			        /* get ACC.'s cosine        */
	   asm("stf r5");			/* store the result         */
           if( force_loop )
                  asm("brb _cosf_2_lp1");;      /* loop on the error     */
/* 
 * end error loop 
*/
	   asm("movl r5,_sgl_st_acc");		/* save the result          */
	   if( sgl_st_acc != sgl_expected )   	/* COMPARE the values       */
	   {
	      errcnt++;				/* bump the error count     */
	      if ( prt_error ) {
		 writes(" \n");		/* start a new print line   */
		 writes("cycle: ");
		 writed( cycle );
		 writes("   COSF test ");
		 writed( test_no );
		 writes(", subtest 2 (immediate store) - BAD FINAL ACC\n");
	         print_cosf_data();
                 writes(",  data index = ");
                 writed( index );
                 writec('\n');
                 writes("                      Acc expected = ");
                 write32h( sgl_expected );
                 writec('\n');
              }
              if ( halt_flg ) 			/* halt on error?        */
	         cosf_er_halt( BAD_ACC_HLT );
              if ( loop_on_err ) 
	      {
		 force_loop = TRUE;		/* set the force loop flag */
		 asm("jmp _cosf_2_lp1");	/* and loop                */
	      }
	   }   /* end of compare error */
	} while( index++ < max_cosf_1_index );
}  /* end of subtest 2 */
  


/***************************************************************************
*
*	SUBTEST 3 - REGISTER INTEGRITY WITH THE COSF FUNCTION 
*
***************************************************************************/
cosf_3() 
{
	fill_reg_buf( load_regs );		/* set reg values to load */
	force_loop = FALSE;			/* clear the LOOP flag */
	subtest = 3;
        index = 0;
	do 
	{
	   sgl_ld_acc   = cosf_1_data[index].ld;   /* get the operand      */
	   sgl_expected = cosf_1_data[index].exp;  /* get expected results */
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
	   asm("_cosf_3_lp1:");
	   asm("loadr $0x1fff,_load_regs");	/* load regs 0 - 12         */
	   asm("ldf _sgl_ld_acc");		/* load the accumulator     */
	   asm("cosf");			        /* get ACC.'s cosf          */
	   asm("stf _sgl_st_acc");		/* store the result         */
	   asm("storer $0x1fff,_store_regs");	/* store regs 0 - 12        */
           if( force_loop )
                asm("brb _cosf_3_lp1");;      /* loop on the error     */
/* 
 * end error loop 
*/
	   reg_no = 0;
	   regs_ok = TRUE;
	   while( (reg_no < 13) && (regs_ok) )  /* check 1st 12 regs */
	      if( store_regs[ reg_no ] == load_regs[ reg_no ] )
		  reg_no++;
	      else
		  regs_ok = FALSE;
	   if( !regs_ok )
	   {
	      errcnt++;				/* bump the error count     */
	      if ( prt_error ) {
		 writes(" \n");		/* start a new print line   */
		 writes("cycle: ");
		 writed( cycle );
		 writes("   COSF test ");
		 writed( test_no );
		 writes(", subtest 3 - A REGISTER WAS MODIFIED\n"); {
		 print_cosf_data();
		 writec('\n');
		 writes("register ");
                 writed( reg_no );
		 writes(" = ");
		 write32h( load_regs[reg_no] );
		 writes(",  should be = ");
		 write32h( store_regs[reg_no] );
		 writec('\n');
	      }
	      if ( halt_flg ) 			/* halt on error?        */
	         cosf_er_halt( BAD_REG_HLT );
	      if ( loop_on_err ) 
	      {
		 force_loop = TRUE;		/* get the force loop flag */
		 asm("jmp _cosf_3_lp1");	/* and loop                */
	      }
	   }   /* end of compare error */
         } /* end of while loop */
    } while( index++ < max_cosf_1_index );
}  /* end of subtest 3 */
  


/************************************************************************
*
*       SUBTEST 4 - Check for PSL corruption
*
************************************************************************/
cosf_4() 
{
        force_loop = FALSE;                     /* clear force_loop flg */
        subtest = 4;
        fill_reg_buf( load_regs );              /* get patterns for regs */
        for( index = 0; index < 3; index++ ) {
             sgl_ld_acc   = cosf_1_data[index].ld;    /* get operand 1 */
             sgl_expected = cosf_1_data[index].exp;   /* get expected  */
             sgl_dummy1 = status_array[index];	      /* status = +, -, 0 */
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
             asm("_cosf_4_lp1:");
             asm("ldf _sgl_ld_acc");            /* LOAD the accumulator  */
             asm("nop");
             asm("tstl _sgl_dummy1");		/* set the PSL status    */
	     asm("movpsl _init_psl");		/* save the initial PSL  */
             asm("cosf");                      /* do the cosf           */
             asm("nop");
             asm("movpsl _psl_val");            /* save the final PSL    */
             asm("stf _sgl_st_acc");            /* save the accumulator  */
             if( force_loop )
                  asm("brb _cosf_4_lp1");;      /* loop on the error     */
/*
 * Now compare the final PSL to the initial PSL -they should be the same
*/
             exp_psl = init_psl;
	     if( psl_val != exp_psl ) {
                  errcnt++;                     /* bump the error count    */
                  if( prt_error ) {
                       writes(" \n");      /* start a new print line  */
                       writes("cycle: ");
                       writed( cycle );
		       writes("   COSF test ");
		       writed( test_no );
                       writes(", subtest 4 - INCORRECT FINAL PSL\n");
                       print_cosf_data();       /* print the operands      */
		       writec('\n');
                       writes("initial PSL = ");
                       write32h( init_psl );
                       writes(",  final PSL = ");
                       write32h( psl_val );
                       writes(",  expected PSL = ");
                       write32h( exp_psl );
                       writes("\n");
                  }
                  if( halt_flg )   
                       cosf_er_halt( BAD_PSL_HLT );   /* halt on the error */
                   if( loop_on_err ) {
                        force_loop = TRUE;        /* set the force loop flag */
                        asm("brw _cosf_4_lp1");;  /* and loop on the error   */
                   }  /* end of loop on error */
             }  /* end of PSL corruption error */
        }  /* end of WHILE loop */
}  /* end of subtest 4 */
 


/************************************************************************
*
*               SUBTEST 5 - pipelined entry test
*
************************************************************************/
cosf_5() 
{
        force_loop = FALSE;
        subtest = 8;
        for( index = 0; index < max_cosf_1_index; index++ ) {
             sgl_ld_acc   = cosf_1_data[index].ld;   /* get operand 1       */
             sgl_expected = cosf_1_data[index].exp;  /* get expected result */
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
             asm("_cosf_5_lp1:");
             asm("movl $0,r0");                 /* clear r0                */
             asm("ldf r0");                     /* load the Acc. with 0.0  */
             asm("addf _sgl_ld_acc");           /* add the 1st operand     */
             asm("cosf");                      /* get the cosf            */
             asm("stf _sgl_st_acc");            /* store the result        */
             if( force_loop )
                  asm("brb _cosf_5_lp1");;      /* loop on the error       */
/* 
 * end error loop - test the results
*/
             if( sgl_st_acc != sgl_expected ) { /* COMPARE the values     */
                   errcnt++;                    /* bump the error count   */
                   if( prt_error ) {
                        writes(" \n");      /* start a new print line */
                        writes("cycle: ");
                        writed( cycle );
		        writes("   COSF test ");
		        writed( test_no );
                        writes(", subtest 5 (Piped Entry) - BAD FINAL ACC\n");
                        print_cosf_data();
                        writes(",  data index = ");
                        writed( index );
                        writec('\n');
                        writes("                      Acc expected = ");
                        write32h( sgl_expected );
                        writec('\n');
                   }
                   if( halt_flg ) 
                        cosf_er_halt( BAD_ACC_HLT );    /* halt on the error */
                   if( loop_on_err ) {
                        force_loop = TRUE;        /* set the force loop flag */
                        asm("brw _cosf_5_lp1");;  /* and loop on the error   */
                   }  /* end of loop on error */
             }   /* end of compare error */
        }  /* end of WHILE loop */
}  /* end of subtest 5 */
  


/************************************************************************
*
*               SUBTEST 6 - pipelined exit test
*
************************************************************************/
cosf_6() 
{
        force_loop = FALSE;
        subtest = 8;
        for( index = 0; index < max_cosf_1_index; index++ ) {
             sgl_ld_acc   = cosf_1_data[index].ld;   /* get operand 1       */
             sgl_expected = cosf_1_data[index].exp;  /* get expected result */
/*
 * If LOOP ON ERROR is set, this is the loop for this subtest.
 * The force loop flag is set after the first error.
*/
             asm("_cosf_6_lp1:");
             asm("movl $0,r0");                 /* clear r0                */
             asm("ldf _sgl_ld_acc");             /* load the Acc.           */
             asm("cosf");                      /* get the cosf            */
             asm("addf r0");                    /* add a zero to the acc   */
             asm("stf _sgl_st_acc");            /* store the result        */
             if( force_loop )
                  asm("brb _cosf_6_lp1");;      /* loop on the error       */
/* 
 * end error loop - test the results
*/
             if( sgl_st_acc != sgl_expected ) { /* COMPARE the values     */
                   errcnt++;                    /* bump the error count   */
                   if( prt_error ) {
                        writes(" \n");      /* start a new print line */
                        writes("cycle: ");
                        writed( cycle );
		        writes("   COSF test ");
		        writed( test_no );
                        writes(", subtest 6 (Piped Exit) - BAD FINAL ACC\n");
                        print_cosf_data();
                        writes(",  data index = ");
                        writed( index );
                        writec('\n');
                        writes("                      Acc expected = ");
                        write32h( sgl_expected );
                        writec('\n');
                   }
                   if( halt_flg ) 
                        cosf_er_halt( BAD_ACC_HLT );    /* halt on the error */
                   if( loop_on_err ) {
                        force_loop = TRUE;        /* set the force loop flag */
                        asm("brw _cosf_6_lp1");;  /* and loop on the error   */
                   }  /* end of loop on error */
             }   /* end of compare error */
        }  /* end of WHILE loop */
}  /* end of subtest 6 */
  

/**************************************************************************
*
*       PRINT THE DATA AND STORE RESULTS
*
*  initial Acc = xxxxxxxx,     stored = xxxxxxxx,   data index = xx
*                        Acc expected = xxxxxxxx
**************************************************************************/
print_cosf_data()
{
        writes("initial Acc = ");
        write32h( sgl_ld_acc );
        writes(",  final Acc = ");
        write32h( sgl_st_acc );
}
 


/**************************************************************************
*
*               HALT ON ERROR ROUTINE 
*
**************************************************************************/
cosf_er_halt( halt_code )
int halt_code;
{
        sgl_dummy1 = halt_code;                 /* get the error type    */
        asm("movl _test_no,r0");                /* r0  = test number     */
        asm("movl _subtest,r1");                /* r1  = subtest number  */
        asm("movl _sgl_dummy1,r2");             /* r2  = error code      */
        asm("movl _cycle,r3");                  /* r3  = cycle count     */
        asm("movl _sgl_ld_acc,r4");             /* r4  = initial data    */
        asm("movl _sgl_st_acc,r5");             /* r5  = data stored     */
        asm("movl _sgl_expected,r6");           /* r6  = data expected   */
        asm("movl _index,r7");                  /* r7  = data index      */
        if( halt_code == BAD_REG_HLT ) {
             sgl_dummy1 = load_regs[index2];
             sgl_dummy2 = store_regs[index2];
             asm("movl _index2,r6");            /* r6  = bad register #  */
             asm("movl _sgl_dummy2,r7");        /* r7  = actual value    */
             asm("movl _sgl_dummy1,r8");        /* r8  = expected value  */
        } else
          if( halt_code == BAD_PSL_HLT ) {
             asm("movl _init_psl,r6");          /* r6  = initial PSL     */
             asm("movl _psl_val,r7");           /* r7  = final PSL       */
             asm("movl _exp_psl,r8");           /* r8  = expected PSL    */
        };
        asm("halt");                            /* HALT ...              */
}  

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.