asm_swar.inc
1.76 KB
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
/* -----------------------------------------------------------------------------
* Copyright (C) 2019 daiteq s.r.o. http://www.daiteq.com
*
* This program is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE.
*
* -----------------------------------------------------------------------------
* Filename : asm_swar.inc
* Authors : Martin Danek
* Description : inline assembly routines
* Release :
* Version : 1.0
* Date : 9.4.2019
* -----------------------------------------------------------------------------
*/
#define op_swar(A,B,RES) \
asm volatile ( \
"swar %0,%1,%2\n" \
: "=r"(RES) \
: "r"(A), "r"(B) \
)
#define op_set_ctrl(A) \
asm volatile ( \
"csrw swarctrlstat, %0\n" \
: : "r"(A) \
)
#define op_get_stat(RES) \
asm volatile ( \
"csrr %0, swarctrlstat\n" \
: "=r"(RES) \
)
#define op_get_acc(A,RES) \
asm volatile ( \
"csrw swaracc, %1\n" \
"csrr %0, swaracc\n" \
: "=r"(RES) : "r"(A) \
)
#ifdef DIRECT_ACCUM
#define op_get_acc(RES) \
asm volatile ( \
"csrr %0, swaracc\n" \
: "=r"(RES) \
)
#define op_get_acchi(RES) \
asm volatile ( \
"csrr %0, swaracchi\n" \
: "=r"(RES) \
)
#endif