A test program


int nk[9],ng[9],npc[9],npk[9],a[9],b[9],q[9];

int nbendix(int n)
{
  int nlfk,nlfc;

  if(n==5) //leapfrog test: fast carry
  {
    nlfc=~(npk[1]&nk[1]&nk[2]&nk[3]&nk[4]);
    nlfk=~(npc[1]&ng[1]&ng[2]&ng[3]&ng[4]);

    npc[n]=~(nlfk&ng[n]&nk[n]&nk[n-1]&npk[n-1]);
    npk[n]=~(nlfc&ng[n]&nk[n]&ng[n-1]&npc[n-1]);
  }
  else

  {
   npc[n]=~(ng[n]&nk[n]&nk[n-1]&npk[n-1]);
   npk[n]=~(ng[n]&nk[n]&ng[n-1]&npc[n-1]);
  }

  q[n]=~(npk[n]&~(npk[n-1]&nk[n-1]&npc[n]));

  return(0);
}

int test(int ia, int ib)
{
  int cin, i, oq;

  for(i=1;i<9;i++)
  {
    a[i]=0; if(ia&1) a[i]=-1; ia>>=1;
    b[i]=0; if(ib&1) b[i]=-1; ib>>=1;
  }

  cin=-0;

  ng[0]=~cin; npc[0]=~cin;
  nk[0]=cin;  npk[0]=cin;

  for(i=1; i<9; i++) {nk[i]=~(~a[i]&~b[i]); ng[i]=~(a[i]&b[i]);}

  for(i=1; i<9; i++) nbendix(i);

  oq=0;
  for(i=8;i>0;i--) {oq<<=1; if(q[i]) oq++;}

  return(oq);
}


int main(void)
{
  int x,y,q_ist, q_soll;
  long err;

  clrscr();

  err=0;
  for(x=0;x<0x100;x++)
  {
    for(y=0;y<0x100;y++)
    {
      q_ist=test(x,y) & 0x0ff;
      q_soll=(x+y)&0xff;
      if(q_ist!=q_soll) err++;
    }
  }

  printf("\nErrors: %ld",err);
  return(0);
}

Just a little program to test the concept of the schematics
on the previous page.

To cite the words,
which scientists use to strike fear
at the hearts of the technicians:
"In the simulation, it worked."


[HOME] [UP]/ [BACK] [1] [2] [3] [4] [5] [6] [7] [8]

(c) Dieter Mueller 2012