-
Notifications
You must be signed in to change notification settings - Fork 1
/
accregs.h
64 lines (50 loc) · 2.15 KB
/
accregs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _ACCREGS_H_
#define _ACCREGS_H_
#define ACCREG3_WMODE_MASK 0x0000000F
#define ACCREG3_WMODE_FRAME 0x00000001
#define ACCREG3_WMODE_LEVEL1 0x00000002
#define ACCREG3_WMODE_RECODE12 0x00000004
#define ACCREG3_WMODE_LEVEL2 0x00000008
#define ACCREG3_FLAG_CLEAR 0x00000100
#define ACCREG3_FLAG_BUSYW 0x00000200
#define ACCREG3_FLAG_BUSYR 0x00000400
#define accreg_get_lvl1_nbneu() (accreg_rd(0) & 0x0FFFF)
#define accreg_get_lvl2_nbneu() ((accreg_rd(0) >> 16) & 0x0FFFF)
#define accreg_get_lvl1_nbin() (accreg_rd(1) & 0x0FFFF)
#define accreg_set_wmode_frame() accreg_wr(3, \
(accreg_rd(3) & ~ACCREG3_WMODE_MASK) | ACCREG3_WMODE_FRAME)
#define accreg_set_wmode_lvl1() accreg_wr(3, \
(accreg_rd(3) & ~ACCREG3_WMODE_MASK) | ACCREG3_WMODE_LEVEL1)
#define accreg_set_wmode_rec12() accreg_wr(3, \
(accreg_rd(3) & ~ACCREG3_WMODE_MASK) | ACCREG3_WMODE_RECODE12)
#define accreg_set_wmode_lvl2() accreg_wr(3, \
(accreg_rd(3) & ~ACCREG3_WMODE_MASK) | ACCREG3_WMODE_LEVEL2)
#define accreg_set_lvl1_fsize(nb) accreg_wr(0, \
(accreg_rd(0) & 0xFFFF0000) | (nb))
#define accreg_set_lvl1_nbneu(nb) accreg_wr(1, \
(accreg_rd(1) & 0xFFFF0000) | (nb))
#define accreg_set_lvl2_nbneu(nb) accreg_wr(2, \
(accreg_rd(2) & 0xFFFF0000) | (nb))
#define accreg_clear() accreg_wr(3, accreg_rd(3) | ACCREG3_FLAG_CLEAR)
#define accreg_check_clear() ((accreg_rd(3) & ACCREG3_FLAG_CLEAR) != 0)
#define accreg_check_busyw() ((accreg_rd(3) & ACCREG3_FLAG_BUSYW) != 0)
#define accreg_check_busyr() ((accreg_rd(3) & ACCREG3_FLAG_BUSYR) != 0)
#define accreg_set_nboutputs(nb) accreg_wr(6, nb)
/*
* Send size of the 32 bits array and returns the needed number of bursts.
*/
//#define MINIMUM_BURSTS(n) (((n) + 15) / 16)
#define MINIMUM_BURSTS(n) ((((n) % 16 == 0) ? (n) : ((n) + 16)) / 16)
extern volatile unsigned* accregs_ptr;
static inline uint32_t accreg_rd(unsigned reg)
{
return accregs_ptr[reg];
}
static inline void accreg_wr(unsigned reg, uint32_t v)
{
accregs_ptr[reg] = v;
}
void accreg_print_regs();
void accregs_print_fifo_counts();
int32_t accregs_pop();
#endif /* _ACCREGS_H_*/