OpenCores
URL https://opencores.org/ocsvn/mips789/mips789/trunk

Subversion Repositories mips789

[/] [mips789/] [branches/] [avendor/] [bench/] [cal_PI/] [cal_pi.c] - Blame information for rev 15

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 mcupro
#include "..\..\clib\dvc_lib.h"
2
 
3
void print_num(unsigned long num)
4
{
5
    unsigned long digit,offset ;
6
    for(offset=1000;offset;offset/=10)
7
    {
8
        digit=num/offset ;
9
        uart0_putc('0'+digit);
10
        num-=digit*offset ;
11
    }
12
}
13
 
14
long a=10000,b=0,c=56,d=0,e=0,f[57]={0},g=0 ;
15
 
16
void cal_PI(void)
17
{
18
    uart0_putstr("\nPI = ");
19
    a=10000 ;
20
    b=0 ;
21
    c=56 ;
22
    d=0 ;
23
    e=0 ;
24
    g=0 ;
25
    for(;b-c;)f[b++]=a/5 ;
26
    for(;d=0,g=c*2;c-=14,print_num(e+d/a),e=d%a)
27
    for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
28
    uart0_putc('\n');
29
}
30
 
31
main2()
32
{
33
 
34
while(1)
35
{
36
    uart0_putstr("Hello CPU World ,this is  MIPS789...");
37
cal_PI();
38
}
39
 
40
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.