OpenCores
URL https://opencores.org/ocsvn/igor/igor/trunk

Subversion Repositories igor

[/] [igor/] [trunk/] [simulator/] [instructions.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
#ifndef _INSTRUCTIONS_H_
2
#define _INSTRUCTIONS_H_
3
 
4
#include <stdio.h>
5
 
6
#include "types.h"
7
 
8
#define NUM_INSTRUCTIONS                        64
9
#define INS_NOP               0x00
10
#define INS_HALT              0x01
11
 
12
#define INS_ADD               0x02
13
#define INS_SUB               0x03
14
#define INS_MUL               0x04
15
#define INS_DIV               0x05
16
#define INS_AND               0x06
17
#define INS_OR                0x07
18
#define INS_XOR               0x08
19
#define INS_NOT               0x09
20
#define INS_SHIFT_L           0x0A
21
#define INS_MOD               0x0B
22
#define INS_SHIFT_R           0x0C
23
 
24
#define INS_LOAD              0x10
25
#define INS_STORE             0x11
26
 
27
#define INS_BRANCH            0x15
28
#define INS_BRANCH_REG        0x16
29
 
30
#define INS_SET_FLAG          0x17
31
#define INS_CLEAR_FLAG        0x18
32
#define INS_GET_FLAG          0x19
33
 
34
#define INS_GET_TYPE          0x20
35
#define INS_SET_TYPE          0x21
36
#define INS_SET_TYPE_IMM      0x22
37
#define INS_GET_DATUM         0x23
38
#define INS_SET_DATUM_IMM     0x24
39
#define INS_GET_GC            0x25
40
#define INS_SET_GC            0x26
41
#define INS_SET_GC_IMM        0x27
42
#define INS_CPY               0x28
43
 
44
#define INS_CMP_TYPE          0x29
45
#define INS_CMP_TYPE_IMM      0x2A
46
#define INS_CMP_DATUM         0x2B
47
#define INS_CMP_DATUM_IMM     0x2C
48
#define INS_CMP_GC            0x2D
49
#define INS_CMP_GC_IMM        0x2E
50
#define INS_CMP               0x2F
51
 
52
#define OP_0R 0
53
#define OP_1R 1
54
#define OP_2R 2
55
#define OP_BR 3
56
 
57
#define FORMAT_OPC "%s"
58
#define FORMAT_REG "%s"
59
#define FORMAT_IMM "(0x%X)"
60
 
61
#define FORMAT_IBR FORMAT_OPC" "FORMAT_REG" fmask"FORMAT_IMM" fval"FORMAT_IMM" addr"FORMAT_IMM
62
#define FORMAT_I2R FORMAT_OPC" "FORMAT_REG" "FORMAT_REG" "FORMAT_IMM""
63
#define FORMAT_I1R FORMAT_OPC" "FORMAT_REG" "FORMAT_IMM""
64
#define FORMAT_I0R FORMAT_OPC" "FORMAT_IMM""
65
 
66
 
67
#define REG_INSTR(opcode,_format,_func)                         \
68
        do {                                                    \
69
                instructions[INS_##opcode].format=_format;      \
70
                instructions[INS_##opcode].func=_func;          \
71
                instructions[INS_##opcode].name=#opcode; }      \
72
        while (0)
73
 
74
 
75
typedef struct {
76
        int pointer;
77
        int addr;
78
} instr_reg_t;
79
 
80
typedef struct {
81
        int op;
82
        instr_reg_t r1, r2;
83
        int imm;
84
        // for load/store:
85
        int disp;
86
        // for branch instructions:
87
        int flag_mask, flag_values, addr;
88
        // for flag manipulation instructions:
89
        int fnr, fmask, fimm;
90
        // for data movement and comparison operations:
91
        int immval;
92
} instr_t;
93
 
94
extern int print_instructions;
95
 
96
void instructions_init(void);
97
instr_t decode_instruction(uint64_t ins);
98
char* instruction_type(int i);
99
void print_instruction(reg_t addr);
100
void print_instruction_to_file(FILE *f, reg_t addr);
101
void do_instruction(reg_t addr);
102
void do_next_instruction(void);
103
reg_t next_instr_addr(void);
104
reg_t instr_get_reg(instr_reg_t r);
105
void instr_set_reg(instr_reg_t r, reg_t val);
106
#endif /* _INSTRUCTIONS_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.