Subversion Repositories Shiroi

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* am9511.h
2
 */
3
 
4
#ifndef _AM9511_H
5
#define _AM9511_H
6
 
7
/* Smallest and largest numbers in the AM9511 floating point
8
 * format. 0.5x2^-64 to 0.99999..x2^63.
9
 *
10
 * As a note: these values can be exactly computed:
11
 *
12
 * unsigned char am_small[4], am_big[4];
13
 * fp_put(0, -64, 0x80, 0x0000); will generate AM_SMALL
14
 * fp_am(am_small);
15
 * fp_put(0,  63, 0xff, 0xffff); will generate AM_BIG
16
 * fp_am(am_big);
17
 */
18
#define AM_SMALL 2.71051e-20
19
#define AM_BIG 9.22337e+18
20
#define AM_PI 3.141592
21
 
22
#define AM_SR 0x80     /* service request on completion */
23
#define AM_SINGLE 0x60 /* 16 bit integer */
24
#define AM_DOUBLE 0x20 /* 32 bit integer */
25
#define AM_FIXED 0x20  /* fixed point */
26
#define AM_FLOAT 0x00  /* 32 bit float */
27
 
28
#define AM_NOP 0x00  /* no operation */
29
#define AM_SQRT 0x01 /* square root */
30
#define AM_SIN 0x02  /* sine */
31
#define AM_COS 0x03  /* cosine */
32
#define AM_TAN 0x04  /* tangent */
33
#define AM_ASIN 0x05 /* inverse sine */
34
#define AM_ACOS 0x06 /* inverse cosine */
35
#define AM_ATAN 0x07 /* inverse tangent */
36
#define AM_LOG 0x08  /* common logarithm (base 10) */
37
#define AM_LN 0x09   /* natural logairth (base e) */
38
#define AM_EXP 0x0a  /* exponential (e^x) */
39
#define AM_PWR 0x0b  /* power nos^tos */
40
#define AM_ADD 0x0c  /* add */
41
#define AM_SUB 0x0d  /* subtract nos-tos */
42
#define AM_MUL 0x0e  /* multiply, lower half */
43
#define AM_DIV 0x0f  /* divide nos/tos */
44
#define AM_FADD 0x10 /* floating add */
45
#define AM_FSUB 0x11 /* floating subtract */
46
#define AM_FMUL 0x12 /* floating multiply */
47
#define AM_FDIV 0x13 /* floating divide */
48
#define AM_CHS 0x14  /* change sign */
49
#define AM_CHSF 0x15 /* floating change sign */
50
#define AM_MUU 0x16  /* multiply, upper half */
51
#define AM_PTO 0x17  /* push tos to nos (copy) */
52
#define AM_POP 0x18  /* pop */
53
#define AM_XCH 0x19  /* exchange tos and nos */
54
#define AM_PUPI 0x1a /* push pi */
55
/*                  0x1b */
56
#define AM_FLTD 0x1c /* 32 bit to float */
57
#define AM_FLTS 0x1d /* 16 bit to float */
58
#define AM_FIXD 0x1e /* float to 32 bit */
59
#define AM_FIXS 0x1f /* float to 16 bit */
60
 
61
#define AM_BUSY 0x80	 /* chip is busy */
62
#define AM_SIGN 0x40	 /* tos negative */
63
#define AM_ZERO 0x20	 /* tos zero */
64
#define AM_ERR_MASK 0x1E /* mask for errors */
65
#define AM_CARRY 0x01	 /* carry/borrow from most significant bit */
66
 
67
#define AM_ERR_NONE 0x00 /* no error */
68
#define AM_ERR_DIV0 0x10 /* divide by zero */
69
#define AM_ERR_NEG 0x08	 /* sqrt, log of negative */
70
#define AM_ERR_ARG 0x18	 /* arg of asin, cos, e^x too large */
71
#define AM_ERR_UND 0x04	 /* underflow */
72
#define AM_ERR_OVF 0x02	 /* overflow */
73
 
74
void* am_create(int status, int data);
75
void am_push(void*, unsigned char);
76
unsigned char am_pop(void*);
77
unsigned char am_status(void*);
78
void am_command(void*, unsigned char);
79
void am_reset(void*);
80
 
81
#ifdef NDEBUG
82
#define am_dump(x)
83
#else
84
void am_dump(void*, unsigned char);
85
#endif
86
 
87
#endif