-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassembler_dict.py
More file actions
71 lines (65 loc) · 2.82 KB
/
Copy pathassembler_dict.py
File metadata and controls
71 lines (65 loc) · 2.82 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
66
67
68
69
70
71
REGISTERS = {
'zero' : '00000', 'x0': '00000',
'ra': '00001', 'x1': '00001',
'sp': '00010', 'x2': '00010',
'gp': '00011', 'x3': '00011',
'tp': '00100', 'x4': '00100',
't0': '00101', 'x5': '00101',
't1': '00110', 'x6': '00110',
't2': '00111', 'x7': '00111',
's0': '01000', 'fp': '01000', 'x8': '01000',
's1': '01001', 'x9': '01001',
'a0': '01010', 'x10': '01010',
'a1': '01011', 'x11': '01011',
'a2': '01100', 'x12': '01100',
'a3': '01101', 'x13': '01101',
'a4': '01110', 'x14': '01110',
'a5': '01111', 'x15': '01111',
'a6': '10000', 'x16': '10000',
'a7': '10001', 'x17': '10001',
's2': '10010', 'x18': '10010',
's3': '10011', 'x19': '10011',
's4': '10100', 'x20': '10100',
's5': '10101', 'x21': '10101',
's6': '10110', 'x22': '10110',
's7': '10111', 'x23': '10111',
's8': '11000', 'x24': '11000',
's9': '11001', 'x25': '11001',
's10': '11010', 'x26': '11010',
's11': '11011', 'x27': '11011',
't3': '11100', 'x28': '11100',
't4': '11101', 'x29': '11101',
't5': '11110', 'x30': '11110',
't6': '11111', 'x31': '11111'
}
INSTRUCTIONS = {
# R-type
'add': {'type': 'R', 'opcode': '0110011', 'funct3': '000', 'funct7': '0000000'},
'sub': {'type': 'R', 'opcode': '0110011', 'funct3': '000', 'funct7': '0100000'},
'sll': {'type': 'R', 'opcode': '0110011', 'funct3': '001', 'funct7': '0000000'},
'slt': {'type': 'R', 'opcode': '0110011', 'funct3': '010', 'funct7': '0000000'},
'sltu': {'type': 'R', 'opcode': '0110011', 'funct3': '011', 'funct7': '0000000'},
'xor': {'type': 'R', 'opcode': '0110011', 'funct3': '100', 'funct7': '0000000'},
'srl': {'type': 'R', 'opcode': '0110011', 'funct3': '101', 'funct7': '0000000'},
'or': {'type': 'R', 'opcode': '0110011', 'funct3': '110', 'funct7': '0000000'},
'and': {'type': 'R', 'opcode': '0110011', 'funct3': '111', 'funct7': '0000000'},
# I-type
'lw': {'type': 'I', 'opcode': '0000011', 'funct3': '010'},
'addi': {'type': 'I', 'opcode': '0010011', 'funct3': '000'},
'sltiu': {'type': 'I', 'opcode': '0010011', 'funct3': '011'},
'jalr': {'type': 'I', 'opcode': '1100111', 'funct3': '000'},
# S-type
'sw': {'type': 'S', 'opcode': '0100011', 'funct3': '010'},
# B-type
'beq': {'type': 'B', 'opcode': '1100011', 'funct3': '000'},
'bne': {'type': 'B', 'opcode': '1100011', 'funct3': '001'},
'blt': {'type': 'B', 'opcode': '1100011', 'funct3': '100'},
'bge': {'type': 'B', 'opcode': '1100011', 'funct3': '101'},
'bltu': {'type': 'B', 'opcode': '1100011', 'funct3': '110'},
'bgeu': {'type': 'B', 'opcode': '1100011', 'funct3': '111'},
# U-type
'lui': {'type': 'U', 'opcode': '0110111'},
'auipc': {'type': 'U', 'opcode': '0010111'},
# J-type
'jal': {'type': 'J', 'opcode': '1101111'}
}