[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [fpu] FPU operations
>From: owner-fpu@opencores.org [mailto:owner-fpu@opencores.org]On Behalf
>Of Jamil Khatib
>
>
>Hi all,
>
....
>
>I got your points from the previous email, So we
>should not provide SNAN upon comparisons with NAN
>operands.
Well, I'm not sure about this. I think we need to think
about it more. Perhaps for right now it should be a
configurable item.
>I saw a translater but it is not so effecient and
>anyhow teh result code must be manually modified.
Yes, but that should be still much less work then re-
designing the entire thing from scratch.
It might make more sense to sit down and write a perl
script that does a complete translation. That should
be an effort that would be very useful for many users
for a very long time !
> > Since Jamil is always doing his own thing, and was
> > on the project before
> > me, I'll stop working on my cores, and let Jamil
> > build them.
>
>In fact I am not working alone I try to ask and
>provide some comments to compile them in a document
>and implement the design in the most effecient way. we
>need always to get comments and suggestions from
>everyone.
>I am trying to describe my ideas and put them in VHDL,
>I tried always to get comments on my general design
>block diagrams, flow charts and documents so as to
>reach to a common design for everyone. you can do the
>design in Verilog me in VHDL and may be another in
>schematic!! but we have to reach to a common design no
>matter how it is implemented.
Yes, you are always asking for other peoples opinions,
that's true. But nevertheless, you are wasting your time
and redesigning the same thing I was working on. Several
weeks ago, you and I exchanged a few emails, and I thought
we agreed that you would work on the divider.
I always made it clear that my initial code was incomplete
and I was still working on it.
>I was waiting for your codes and descriptions but you
>did not inform us about your work status. for example
>I do not know that you have a c progam to generate teh
>test vectors (also you did not provide the source).
That is all incorrect, read the PDF file I posted.
>Also when I decided to code the Adder block in VHDL I
>did it for few reasons:
>1. Your adder was not complete and you did not mention
>that you are fixing it before this week.
>2. even If you provided your design structure I'll
>also recoded it in VHDL just to have a complete VHDL
>core.
>3. when I started I did not get any comment from you
>on it. even if it is written in VHDL, I provided
>documentation about it. me also do not know verilog
>but I tried to read your code to know how to implement
>my VHDL code.
Whatever. What you didn't get from me, or did not want to
see, is irrelevant now. You can do the coding, I can
provide some quotes from the standard and some other
personal opinions and suggestion.
>Note: Open Projects do not need some one to dominate
>but the design must dominate, so we have to work for
>the design not for the designers.
Ahm, what's the point here ?
>
>We will be glad if you can stay with us untill we
>(all) finish the FPU project
If I'm not to busy, I will.
>
>Regards
>Jamil Khatib
Attached are two C source files. My test code is based on the
floating point libraries from:
http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/SoftFloat.html
I'm not a C expert, so consider this a "hack", not a 'sure thing'
piece of C code.
Try not to change the output format, that way I can continue using
it for my purposes as well.
rudi
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
/////////////////////////////////////////////////////////////////////
//// ////
//// conv.c ////
//// Floating Point Test Vecor Generaor ////
//// ////
//// Author: Rudolf Usselmann ////
//// russelmann@hotmail.com ////
//// ////
/////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2000 Rudolf Usselmann ////
//// russelmann@hotmail.com ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer.////
//// ////
//// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY ////
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT ////
//// LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ////
//// FITNESS FOR A PARTICULAR PURPOSE. ////
//// ////
/////////////////////////////////////////////////////////////////////
#include "milieu.h"
#include "softfloat.h"
extern int verb;
extern int pat;
extern int large;
extern int append;
extern char *ofile;
i2f(int count) {
float32 f1;
int i1, i2;
int i;
int fp;
char *mode;
printf("\nGenerating %0d i2f vectors ...\n\n",count);
if(append) mode = "a";
else mode = "w";
if(ofile==0) ofile = "i2f.hex";
fp = fopen(ofile,mode);
if(fp == 0) {
printf("ERROR: Could not create file '%s'.\n",ofile);
return(-1);
}
for(i=0;i<count;i++) {
if(large) i2 = rand();
else i2 = 0;
i1 = rand() | (i2<<14);
if( rand() & 0x01) i1 *= -1;
f1 = int32_to_float32( i1 );
if(verb) printf("int: %08x, fp: %08x\n", i1, f1);
fprintf(fp,"%08x %08x\n", i1, f1);
}
close(fp);
printf("\n ... i2f done.\n");
return(0);
}
f2i(int count) {
float32 f1;
int i1, i2;
int i;
int fp;
char *mode;
printf("\nGenerating %0d f2i vectors ...\n",count);
if(append) mode = "a";
else mode = "w";
if(ofile==0) ofile = "f2i.hex";
fp = fopen(ofile,mode);
if(fp == 0) {
printf("ERROR: Could not create file '%s'.\n",ofile);
return(-1);
}
for(i=0;i<count;i++) {
if(large) i2 = rand();
else i2 = 0;
i1 = rand() | (i2<<14);
if( rand() & 0x01) i1 *= -1;
f1 = int32_to_float32( i1 );
if(verb) printf("fp: %08x, int: %08x\n", f1, i1);
fprintf(fp,"%08x %08x\n", f1, i1);
}
close(fp);
printf("\n ... f2i done.\n");
return(0);
}
/////////////////////////////////////////////////////////////////////
//// ////
//// fptpg.c ////
//// Floating Point Test Pattern Generator ////
//// ////
//// Author: Rudolf Usselmann ////
//// russelmann@hotmail.com ////
//// ////
/////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2000 Rudolf Usselmann ////
//// russelmann@hotmail.com ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer.////
//// ////
//// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY ////
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT ////
//// LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ////
//// FITNESS FOR A PARTICULAR PURPOSE. ////
//// ////
/////////////////////////////////////////////////////////////////////
#include "milieu.h"
#include "softfloat.h"
// Global vars ...
int verb=0;
int pat=0;
int large=0;
int append=0;
char *ofile=0;
// Prototypes ...
float32 get_fp();
int arop(int , int );
float32 get_pat(int );
float32 get_pat0(int );
float32 get_pat1(int );
main(int argc, char **argv)
{
int i;
int count=25;
int do_i2f=0;
int do_f2i=0;
int ar = 0;
printf("\nFloating Point Test Vector Generation V1.1\n\n");
printf("\tby Rudolf Usselmann rudi@hotmail.com\n\n");
if(argc<2) {
printf("Usage:\n");
printf(" -n <count> Specifies the number of tests\n");
printf(" vectors to generate. Default: 25.\n");
printf(" -v verbose\n");
printf(" -a append to output file name. Default: Overwrite\n");
printf(" -l Use large numbers\n");
printf(" -p N Use built in patterns. N=Patter Number:\n");
printf(" 0 = Min/Max Bit patters (Max 92416 Vectors)\n");
printf(" 1 = Denormalized/Normalized Mix (Max 92416 Vectors)\n");
printf(" -o <filename> Dump patterns to <filename>\n");
printf(" -r N Round Option. Where N is one of:\n");
printf(" 0 = float_round_nearest_eve (Default)n\n");
printf(" 1 = float_round_down\n");
printf(" 2 = float_round_up\n");
printf(" 3 = float_round_to_zero\n");
printf(" -i2f Generate Integer to Floating Point Conv. Vectors.\n");
printf(" -f2i Generate Floating Point to Integer Conv. Vectors.\n");
printf(" -m N Generate Test patters for operation N.\n");
printf(" Where N is a combination of:\n");
printf(" 1 = Add operations\n");
printf(" 2 = Subtract Operations\n");
printf(" 4 = Multiply Operations\n");
printf(" 8 = Divide operations\n");
return(0);
}
i=1;
while((argc-1)>=i) {
if(strcmp(argv[i],"-i2f")==0) do_i2f=1;
else
if(strcmp(argv[i],"-f2i")==0) do_f2i=1;
else
if(strcmp(argv[i],"-v")==0) verb=1;
else
if(strcmp(argv[i],"-p")==0) {
i++;
pat = atoi(argv[i]) + 1;
if(pat>2) {
printf("ERROR: 'pattern' out of range (%0d), reseting to pattern
0.\n",pat);
pat = 1;
}
}
else
if(strcmp(argv[i],"-l")==0) large=1;
else
if(strcmp(argv[i],"-ll")==0) large=2;
else
if(strcmp(argv[i],"-a")==0) append=1;
else
if(strcmp(argv[i],"-n")==0) {
i++;
count = atoi(argv[i]);
if(count<0 | count>1000000) {
printf("ERROR: 'count' out of range (%0d), reseting to
default.\n",count);
count=25;
}
}
else
if(strcmp(argv[i],"-o")==0) {
i++;
ofile = argv[i];
}
else
if(strcmp(argv[i],"-m")==0) {
i++;
ar = atoi(argv[i]);
}
else
if(strcmp(argv[i],"-r")==0) {
i++;
float_rounding_mode = atoi(argv[i]);
}
else
printf("Unknown Option: %s\n\n",argv[i]);
i++;
}
switch(float_rounding_mode) {
case 0: printf("Rounding mode: float_round_nearest_eve\n"); break;
case 1: printf("Rounding mode: float_round_down\n"); break;
case 2: printf("Rounding mode: float_round_up\n"); break;
case 3: printf("Rounding mode: float_round_to_zero\n"); break;
default: printf("Rounding mode: Unkknown (%0d)\n", float_rounding_mode );
break;
}
if(count==25 & pat!=0) count = 92416;
if(do_i2f) i2f(count);
if(do_f2i) f2i(count);
if(ar) arop(count,ar);
return(0);
}
int arop(int count, int op) {
float32 f1, f2, f3;
int i;
int fp;
char *mode;
int add=0;
int sub=0;
int mul=0;
int div=0;
int oper;
printf("\nGenerating %0d Arithmetic vectors ...\n",count);
if(append) mode = "a";
else mode = "w";
if(ofile==0) ofile = "ar.hex";
fp = fopen(ofile,mode);
if(fp == 0) {
printf("ERROR: Could not create file '%s'.\n",ofile);
return(-1);
}
if(op & 0x1) printf("Add OP\n");
if(op & 0x2) printf("Sub OP\n");
if(op & 0x4) printf("Mul OP\n");
if(op & 0x8) printf("Div OP\n");
if(op & 0x1) add=1;
if(op & 0x2) sub=1;
if(op & 0x4) mul=1;
if(op & 0x8) div=1;
f1 = get_pat(0);
for(i=0;i<count;i++) {
if(pat>0) {
f1 = get_pat(1);
f2 = get_pat(2);
} else {
f1 = get_fp();
f2 = get_fp();
}
// Reset Exceptions
float_exception_flags = 0;
oper = -1;
while(oper == -1) {
if( (rand() % 4)==3 & div) {
oper = 8;
f3 = float32_div( f1, f2);
}
if( (rand() % 4)==2 & mul) {
oper = 4;
f3 = float32_mul( f1, f2);
}
if( (rand() % 4)==1 & sub) {
oper = 2;
f3 = float32_sub( f1, f2);
}
if( (rand() % 4)==0 & add) {
oper = 1;
f3 = float32_add( f1, f2);
}
}
//if(float_exception_flags != 0)
// printf("Exceptions: %x\n",float_exception_flags);
if(verb) printf("except: %02x, oper: %01x opa: %08x, opb: %08x res:
%08x\n", float_exception_flags, oper, f1, f2, f3);
//fprintf(fp,"@%04x %02x%01x%08x%08x%08x\n", i, float_exception_flags,
oper, f1, f2, f3);
fprintf(fp,"%02x%01x%08x%08x%08x\n", float_exception_flags, oper, f1, f2,
f3);
}
close(fp);
printf("\n ... f2i done.\n");
return(0);
}
float32 get_fp() {
float32 f1;
int i1, i2, e;
if(large>0) i2 = rand();
else i2 = 0;
if(large>1) i1 = rand() | (i2<<16);
else i1 = rand() | (i2<<10);
i1 = i1 & 0x007fffff;
e = rand();
e = e & 0x0ff;
f1 = (e << 23) + i1;
if( rand() & 0x01) f1 = f1 | 0x80000000;
return(f1);
}
static int p0, p1;
// 0x00800000 Minimum Posetive Number
// 0x7f7fffff Maximum Posetive Number
/*
float32 pat0[] = { 0x7f7fffff,
0x00800000,
0xff7fffff,
0x80800000
};
*/
float32 pat0[] = { 0x00800000, 0x00800001, 0x00800002, 0x00800004,
0x00800008, 0x00880000, 0x00900000, 0x00a00000,
0x00c00000, 0x00880001, 0x00900001, 0x00a00001,
0x00c00001, 0x00880002, 0x00900002, 0x00a00002,
0x00c00002, 0x00880004, 0x00900004, 0x00a00004,
0x00c00004, 0x00800003, 0x00800007, 0x0080000f,
0x00f80000, 0x00f00000, 0x00e00000, 0x00f80001,
0x00f00001, 0x00e00001, 0x00f80003, 0x00f00003,
0x00e00003, 0x00c00003, 0x00f80007, 0x00f00007,
0x00e00007, 0x00c00007, 0x00ffffff, 0x00fffffe,
0x00fffffd, 0x00fffffb, 0x00fffff7, 0x00f7ffff,
0x00efffff, 0x00dfffff, 0x00bfffff, 0x00f7fffe,
0x00effffe, 0x00dffffe, 0x00bffffe, 0x00f7fffd,
0x00effffd, 0x00dffffd, 0x00bffffd, 0x00f7fffb,
0x00effffb, 0x00dffffb, 0x00bffffb, 0x00fffffc,
0x00fffff8, 0x00fffff0, 0x0087ffff, 0x008fffff,
0x009fffff, 0x0087fffe, 0x008ffffe, 0x009ffffe,
0x0087fffc, 0x008ffffc, 0x009ffffc, 0x00bffffc,
0x0087fff8, 0x008ffff8, 0x009ffff8, 0x00bffff8,
0x7f000000, 0x7f000001, 0x7f000002, 0x7f000004,
0x7f000008, 0x7f080000, 0x7f100000, 0x7f200000,
0x7f400000, 0x7f080001, 0x7f100001, 0x7f200001,
0x7f400001, 0x7f080002, 0x7f100002, 0x7f200002,
0x7f400002, 0x7f080004, 0x7f100004, 0x7f200004,
0x7f400004, 0x7f000003, 0x7f000007, 0x7f00000f,
0x7f780000, 0x7f700000, 0x7f600000, 0x7f780001,
0x7f700001, 0x7f600001, 0x7f780003, 0x7f700003,
0x7f600003, 0x7f400003, 0x7f780007, 0x7f700007,
0x7f600007, 0x7f400007, 0x7f7fffff, 0x7f7ffffe,
0x7f7ffffd, 0x7f7ffffb, 0x7f7ffff7, 0x7f77ffff,
0x7f6fffff, 0x7f5fffff, 0x7f3fffff, 0x7f77fffe,
0x7f6ffffe, 0x7f5ffffe, 0x7f3ffffe, 0x7f77fffd,
0x7f6ffffd, 0x7f5ffffd, 0x7f3ffffd, 0x7f77fffb,
0x7f6ffffb, 0x7f5ffffb, 0x7f3ffffb, 0x7f7ffffc,
0x7f7ffff8, 0x7f7ffff0, 0x7f07ffff, 0x7f0fffff,
0x7f1fffff, 0x7f07fffe, 0x7f0ffffe, 0x7f1ffffe,
0x7f07fffc, 0x7f0ffffc, 0x7f1ffffc, 0x7f3ffffc,
0x7f07fff8, 0x7f0ffff8, 0x7f1ffff8, 0x7f3ffff8,
0x80800000, 0x80800001, 0x80800002, 0x80800004,
0x80800008, 0x80880000, 0x80900000, 0x80a00000,
0x80c00000, 0x80880001, 0x80900001, 0x80a00001,
0x80c00001, 0x80880002, 0x80900002, 0x80a00002,
0x80c00002, 0x80880004, 0x80900004, 0x80a00004,
0x80c00004, 0x80800003, 0x80800007, 0x8080000f,
0x80f80000, 0x80f00000, 0x80e00000, 0x80f80001,
0x80f00001, 0x80e00001, 0x80f80003, 0x80f00003,
0x80e00003, 0x80c00003, 0x80f80007, 0x80f00007,
0x80e00007, 0x80c00007, 0x80ffffff, 0x80fffffe,
0x80fffffd, 0x80fffffb, 0x80fffff7, 0x80f7ffff,
0x80efffff, 0x80dfffff, 0x80bfffff, 0x80f7fffe,
0x80effffe, 0x80dffffe, 0x80bffffe, 0x80f7fffd,
0x80effffd, 0x80dffffd, 0x80bffffd, 0x80f7fffb,
0x80effffb, 0x80dffffb, 0x80bffffb, 0x80fffffc,
0x80fffff8, 0x80fffff0, 0x8087ffff, 0x808fffff,
0x809fffff, 0x8087fffe, 0x808ffffe, 0x809ffffe,
0x8087fffc, 0x808ffffc, 0x809ffffc, 0x80bffffc,
0x8087fff8, 0x808ffff8, 0x809ffff8, 0x80bffff8,
0xff000000, 0xff000001, 0xff000002, 0xff000004,
0xff000008, 0xff080000, 0xff100000, 0xff200000,
0xff400000, 0xff080001, 0xff100001, 0xff200001,
0xff400001, 0xff080002, 0xff100002, 0xff200002,
0xff400002, 0xff080004, 0xff100004, 0xff200004,
0xff400004, 0xff000003, 0xff000007, 0xff00000f,
0xff780000, 0xff700000, 0xff600000, 0xff780001,
0xff700001, 0xff600001, 0xff780003, 0xff700003,
0xff600003, 0xff400003, 0xff780007, 0xff700007,
0xff600007, 0xff400007, 0xff7fffff, 0xff7ffffe,
0xff7ffffd, 0xff7ffffb, 0xff7ffff7, 0xff77ffff,
0xff6fffff, 0xff5fffff, 0xff3fffff, 0xff77fffe,
0xff6ffffe, 0xff5ffffe, 0xff3ffffe, 0xff77fffd,
0xff6ffffd, 0xff5ffffd, 0xff3ffffd, 0xff77fffb,
0xff6ffffb, 0xff5ffffb, 0xff3ffffb, 0xff7ffffc,
0xff7ffff8, 0xff7ffff0, 0xff07ffff, 0xff0fffff,
0xff1fffff, 0xff07fffe, 0xff0ffffe, 0xff1ffffe,
0xff07fffc, 0xff0ffffc, 0xff1ffffc, 0xff3ffffc,
0xff07fff8, 0xff0ffff8, 0xff1ffff8, 0xff3ffff8
};
int pat0_cnt = 304;
float32 pat1[] = { 0x6c800000, 0x3a000001, 0x69800002, 0x79800004,
0x37000008, 0x59080000, 0x7d900000, 0x23200000,
0x59c00000, 0x23880001, 0x5e900001, 0x45a00001,
0x1f400001, 0x63080002, 0x29100002, 0x15200002,
0x43c00002, 0x5d880004, 0x29900004, 0x54200004,
0x09400004, 0x28800003, 0x7f800007, 0x0880000f,
0x3cf80000, 0x4af00000, 0x58e00000, 0x61780001,
0x20700001, 0x0fe00001, 0x15780003, 0x73700003,
0x52e00003, 0x7b400003, 0x10780007, 0x7c700007,
0x30e00007, 0x3dc00007, 0x5f7fffff, 0x45fffffe,
0x407ffffd, 0x18fffffb, 0x48fffff7, 0x60f7ffff,
0x27efffff, 0x145fffff, 0x3e3fffff, 0x5277fffe,
0x3ceffffe, 0x73dffffe, 0x233ffffe, 0x67f7fffd,
0x33effffd, 0x4e5ffffd, 0x243ffffd, 0x4f77fffb,
0x6feffffb, 0x31dffffb, 0x673ffffb, 0x207ffffc,
0x07fffff8, 0x3dfffff0, 0x6187ffff, 0x7f8fffff,
0x7f1fffff, 0x1887fffe, 0x170ffffe, 0x011ffffe,
0x3a87fffc, 0x280ffffc, 0x0a9ffffc, 0x753ffffc,
0x4187fff8, 0x7b8ffff8, 0x2c1ffff8, 0x40bffff8,
0x00000000, 0x00000001, 0x00000002, 0x00000004,
0x00000008, 0x00080000, 0x00100000, 0x00200000,
0x00400000, 0x00080001, 0x00100001, 0x00200001,
0x00400001, 0x00080002, 0x00100002, 0x00200002,
0x00400002, 0x00080004, 0x00100004, 0x00200004,
0x00400004, 0x00000003, 0x00000007, 0x0000000f,
0x00780000, 0x00700000, 0x00600000, 0x00780001,
0x00700001, 0x00600001, 0x00780003, 0x00700003,
0x00600003, 0x00400003, 0x00780007, 0x00700007,
0x00600007, 0x00400007, 0x007fffff, 0x007ffffe,
0x007ffffd, 0x007ffffb, 0x007ffff7, 0x0077ffff,
0x006fffff, 0x005fffff, 0x003fffff, 0x0077fffe,
0x006ffffe, 0x005ffffe, 0x003ffffe, 0x0077fffd,
0x006ffffd, 0x005ffffd, 0x003ffffd, 0x0077fffb,
0x006ffffb, 0x005ffffb, 0x003ffffb, 0x007ffffc,
0x007ffff8, 0x007ffff0, 0x0007ffff, 0x000fffff,
0x001fffff, 0x0007fffe, 0x000ffffe, 0x001ffffe,
0x0007fffc, 0x000ffffc, 0x001ffffc, 0x003ffffc,
0x0007fff8, 0x000ffff8, 0x001ffff8, 0x003ffff8,
0xc7800000, 0xc3800001, 0x84000002, 0xf6800004,
0x90000008, 0xca880000, 0xee900000, 0xc8200000,
0xb0c00000, 0xd3080001, 0xa7100001, 0x84a00001,
0xb6400001, 0xbc880002, 0xee100002, 0xc7a00002,
0xbec00002, 0xe4880004, 0x90100004, 0xfea00004,
0x82c00004, 0x9d000003, 0x9b800007, 0xef00000f,
0xe3780000, 0xadf00000, 0x83e00000, 0xe7f80001,
0xf9700001, 0xbae00001, 0x81f80003, 0xbef00003,
0xb8600003, 0x88400003, 0xf7f80007, 0xcbf00007,
0xa3600007, 0xf2400007, 0x9dffffff, 0xfefffffe,
0xa27ffffd, 0x8ffffffb, 0xc07ffff7, 0xc3f7ffff,
0x806fffff, 0xdcdfffff, 0xda3fffff, 0xd3f7fffe,
0x916ffffe, 0xde5ffffe, 0xd2bffffe, 0x9df7fffd,
0x97effffd, 0x9cdffffd, 0xa43ffffd, 0xf377fffb,
0xe0effffb, 0xe9dffffb, 0xb43ffffb, 0x9c7ffffc,
0xaafffff8, 0xcafffff0, 0xa887ffff, 0xf98fffff,
0xda1fffff, 0xff87fffe, 0xff0ffffe, 0xe19ffffe,
0x8287fffc, 0x808ffffc, 0xab1ffffc, 0xddbffffc,
0xd387fff8, 0xe40ffff8, 0x8d1ffff8, 0xefbffff8,
0x80000000, 0x80000001, 0x80000002, 0x80000004,
0x80000008, 0x80080000, 0x80100000, 0x80200000,
0x80400000, 0x80080001, 0x80100001, 0x80200001,
0x80400001, 0x80080002, 0x80100002, 0x80200002,
0x80400002, 0x80080004, 0x80100004, 0x80200004,
0x80400004, 0x80000003, 0x80000007, 0x8000000f,
0x80780000, 0x80700000, 0x80600000, 0x80780001,
0x80700001, 0x80600001, 0x80780003, 0x80700003,
0x80600003, 0x80400003, 0x80780007, 0x80700007,
0x80600007, 0x80400007, 0x807fffff, 0x807ffffe,
0x807ffffd, 0x807ffffb, 0x807ffff7, 0x8077ffff,
0x806fffff, 0x805fffff, 0x803fffff, 0x8077fffe,
0x806ffffe, 0x805ffffe, 0x803ffffe, 0x8077fffd,
0x806ffffd, 0x805ffffd, 0x803ffffd, 0x8077fffb,
0x806ffffb, 0x805ffffb, 0x803ffffb, 0x807ffffc,
0x807ffff8, 0x807ffff0, 0x8007ffff, 0x800fffff,
0x801fffff, 0x8007fffe, 0x800ffffe, 0x801ffffe,
0x8007fffc, 0x800ffffc, 0x801ffffc, 0x803ffffc,
0x8007fff8, 0x800ffff8, 0x801ffff8, 0x803ffff8,
};
int pat1_cnt = 304;
float32 get_pat(int mode) {
if(mode==0) {
p0 = 0;
p1 = 0;
return(0);
}
else
if(pat==1) return(get_pat0(mode));
else
if(pat==2) return(get_pat1(mode));
else return(0);
}
float32 get_pat0(int mode) {
float32 x;
if(mode==1) {
if(p0==pat0_cnt) p0 = 0;
x = pat0[p0];
p0++;
return(x);
}
if(mode==2) {
x = pat0[p1];
if(p0==(pat0_cnt) ) p1++;
if(p1==pat0_cnt) p1 = 0;
return(x);
}
return(0);
}
float32 get_pat1(int mode) {
float32 x;
if(mode==1) {
if(p0==pat1_cnt) p0 = 0;
x = pat1[p0];
p0++;
return(x);
}
if(mode==2) {
x = pat1[p1];
if(p0==(pat1_cnt) ) p1++;
if(p1==pat1_cnt) p1 = 0;
return(x);
}
return(0);
}