-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRISCVmem.h
87 lines (73 loc) · 2.44 KB
/
RISCVmem.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* RISC-V memory access header file: */
#ifndef RISCVMEM_H_
#define RISCVMEM_H_
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
/* Define memory size and create global memory */
#define MEM_SIZE 4096
extern int32_t mem[];
/* Functions: */
/* Function 'dump_mem':
Receives a memory address and prints memory content in hex until address specified.
Inputs: addr - initial memory address;
wsize - number of words to be printed.
*/
void dump_mem(uint32_t addr, uint32_t wsize);
/* Fuction 'lw'
Loads a word (32-bits) from memory.
Inputs: address - base address from where to load;
kte - constant to add to address.
Output: Returns the loaded word.
*/
int32_t lw(uint32_t address, int32_t kte);
/* Fuction 'lh'
Loads a halfword (16-bits) from memory.
Inputs: address - base address from where to load;
kte - constant to add to address.
Output: Returns the loaded halfword.
*/
int32_t lh(uint32_t address, int32_t kte);
/* Fuction 'lhu'
Loads an unsigned halfword (16-bits) from memory.
Inputs: address - base address from where to load;
kte - constant to add to address.
Output: Returns the loaded unsigned halfword.
*/
int32_t lhu(uint32_t address, int32_t kte);
/* Fuction 'lb'
Loads a byte (8-bits) from memory.
Inputs: address - base address from where to load;
kte - constant to add to address.
Output: Returns the loaded byte.
*/
int32_t lb(uint32_t address, int32_t kte);
/* Fuction 'lbu'
Loads an unsigned byte (8-bits) from memory.
Inputs: address - base address from where to load;
kte - constant to add to address.
Output: Returns the loaded unsigned byte.
*/
int32_t lbu(uint32_t address, int32_t kte);
/* Fuction 'sw'
Stores a word (32-bits) in memory.
Inputs: address - base address from where to store;
kte - constant to add to address;
dado - data to store.
*/
void sw(uint32_t address, int32_t kte, int32_t dado);
/* Fuction 'sh'
Stores a halfword (16-bits) in memory.
Inputs: address - base address from where to store;
kte - constant to add to address;
dado - data to store.
*/
void sh(uint32_t address, int32_t kte, int32_t dado);
/* Fuction 'sb'
Stores a byte (8-bits) in memory.
Inputs: address - base address from where to store;
kte - constant to add to address;
dado - data to store.
*/
void sb(uint32_t address, int32_t kte, int32_t dado);
#endif