swar.c
1.54 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
57
58
59
60
61
62
63
64
65
/* -----------------------------------------------------------------------------
* 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 : swar.c
* Authors : Martin Danek
* Description : configuration of SWAR instructions
* Release :
* Version : 1.0
* Date : 9.4.2019
* -----------------------------------------------------------------------------
*/
#include "swar.h"
#include "asm.h"
#include "asi.h"
#include "leon-myuart.h"
void swar_config(unsigned config) {
// pm_print("SWAR CONFIG config: "); i_print(config); m_print("\n");
asm_wr_asr(SWAR_CTL_ASR, config);
}
unsigned swar_readconfig(void) {
unsigned config;
// pm_print("SWAR CONFIG config: "); i_print(config); m_print("\n");
asm_rd_asr(SWAR_CTL_ASR, config);
return config;
}
void swar_selacc(unsigned accid) {
// pm_print("SWAR SELACC accid: "); i_print(accid); m_print("\n");
asm_wr_asr(SWAR_ACC_ASR, accid);
}
int swar_readacc(void) {
int acc;
// pm_print("SWAR READACC accid: "); i_print(accid); m_print("\n");
asm_rd_asr(SWAR_ACC_ASR, acc);
return acc;
}
unsigned exec_swar(unsigned a, unsigned b) {
unsigned out;
asm_swar(a, b, out);
return out;
}
unsigned exec_swarcc(unsigned a, unsigned b) {
unsigned out;
asm_swarcc(a, b, out);
return out;
}