-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulator.hpp
135 lines (107 loc) · 4.31 KB
/
simulator.hpp
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/// This is the main header file, it contains all the prototypes and
/// describes the relations between classes.
#ifndef _ORCS_ORCS_HPP_
#define _ORCS_ORCS_HPP_
/// C Includes
#include <unistd.h> /* for getopt */
#include <getopt.h> /* for getopt_long; POSIX standard getopt is in unistd.h */
#include <inttypes.h> /* for uint32_t */
#include <zlib.h>
/// C++ Includes
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
// ============================================================================
/// Classes
// ============================================================================
class orcs_engine_t;
class trace_reader_t;
class opcode_package_t;
class processor_t;
// ============================================================================
/// Global SINUCA_ENGINE instantiation
// ============================================================================
extern orcs_engine_t orcs_engine;
// ============================================================================
/// Definitions for Log, Debug, Warning, Error and Statistics
// ============================================================================
#define FAIL 0 /// FAIL when return is int32_t or uint32_t
#define OK 1 /// OK when return is int32_t or uint32_t
#define TRACE_LINE_SIZE 512
/// DETAIL DESCRIPTION: Almost all errors and messages use this definition.
/// It will DEACTIVATE all the other messages below
#define ORCS_PRINTF(...) printf(__VA_ARGS__);
// ~ #define ORCS_DEBUG
#ifdef ORCS_DEBUG
#define DEBUG_PRINTF(...) {\
ORCS_PRINTF("DEBUG: ");\
ORCS_PRINTF(__VA_ARGS__);\
}
#else
#define DEBUG_PRINTF(...)
#endif
#define ERROR_INFORMATION() {\
ORCS_PRINTF("ERROR INFORMATION\n");\
ORCS_PRINTF("ERROR: File: %s at Line: %u\n", __FILE__, __LINE__);\
ORCS_PRINTF("ERROR: Function: %s\n", __PRETTY_FUNCTION__);\
ORCS_PRINTF("ERROR: Cycle: %" PRIu64 "\n", orcs_engine.get_global_cycle());\
}
#define ERROR_ASSERT_PRINTF(v, ...) if (!(v)) {\
ERROR_INFORMATION();\
ORCS_PRINTF("ERROR_ASSERT: %s\n", #v);\
ORCS_PRINTF("\nERROR: ");\
ORCS_PRINTF(__VA_ARGS__);\
exit(EXIT_FAILURE);\
}
#define ERROR_PRINTF(...) {\
ERROR_INFORMATION();\
ORCS_PRINTF("\nERROR: ");\
ORCS_PRINTF(__VA_ARGS__);\
exit(EXIT_FAILURE);\
}
// ==============================================================================
/// Enumerations
// ==============================================================================
// ============================================================================
/// Enumerates the INSTRUCTION (Opcode and Uop) operation type
enum instruction_operation_t {
/// NOP
INSTRUCTION_OPERATION_NOP,
/// INTEGERS
INSTRUCTION_OPERATION_INT_ALU,
INSTRUCTION_OPERATION_INT_MUL,
INSTRUCTION_OPERATION_INT_DIV,
/// FLOAT POINT
INSTRUCTION_OPERATION_FP_ALU,
INSTRUCTION_OPERATION_FP_MUL,
INSTRUCTION_OPERATION_FP_DIV,
/// BRANCHES
INSTRUCTION_OPERATION_BRANCH,
/// MEMORY OPERATIONS
INSTRUCTION_OPERATION_MEM_LOAD,
INSTRUCTION_OPERATION_MEM_STORE,
/// NOT IDENTIFIED
INSTRUCTION_OPERATION_OTHER,
/// SYNCHRONIZATION
INSTRUCTION_OPERATION_BARRIER,
/// HMC
INSTRUCTION_OPERATION_HMC_ROA, //#12 READ+OP +Answer
INSTRUCTION_OPERATION_HMC_ROWA //#13 READ+OP+WRITE +Answer
};
// ============================================================================
/// Enumerates the types of branches
enum branch_t {
BRANCH_SYSCALL,
BRANCH_CALL,
BRANCH_RETURN,
BRANCH_UNCOND,
BRANCH_COND
};
/// Our Includes
#include "./simulator.hpp"
#include "./orcs_engine.hpp"
#include "./trace_reader.hpp"
#include "./opcode_package.hpp"
#include "./processor.hpp"
#endif // _ORCS_ORCS_HPP_