ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
RV64IMACFDArch.cpp
Go to the documentation of this file.
1 
7 /*********************************************************************************************************************************
8 
9 * Modification guidelines:
10 
11  1. The initial value of SP register should be initialized by ctr0.S/board.S. If not, it could be initialized
12  through utility class etiss::VirtualStruct::Field.
13 
14  2. Debug mode print out all assignment results. GDB in 8 is prefered.
15 
16  3. Manually copy the content in bracket ["return ETISS_RETURNCODE_CPUFINISHED; \n"] to terminating instruction,
17  otherwise the emulation can not be ended.
18 
19  4. If subset of encoding error occurs, it means the format of the encoding in the input model was not appropriate
20 
21  5. If the PC register points to wrong address, please notice that some assembly may cause branch operation
22  implicitly such as "MOV Rd Rn" in ARMv6-M
23 
24  6. If a variable is the result of dynamic slicing such as, var_1 = var_2<Hshift-1..Lshift-2>, the size would be
25  calculated during process (if possible), otherwise it is assumed to be the register size. Problems may occur when
26  var_1 encounters bit manipulation such as "~" due to bit expansion. To change the nml model with explicit slicing
27  e.g var_1 = val_2<3..0> or avoid bit manipulation for dynamic sliced variable. Otherwise, you have to manually
28  correct it.
29 
30  7. Implementation dependent functionalities such as exception handling should be manully added. Corresponding interfaces
31  are provided in RV64IMACFDArchSpecificImp.h
32 
33  8. RV64IMACFDGDBCore.h provides the GDBCore class to support gdb flavor debugging feature, modify iy if in need.
34 
35  *********************************************************************************************************************************/
36 
37 #include "RV64IMACFDArch.h"
38 #include "RV64IMACFDFuncs.h"
39 
40 #define RV64IMACFD_DEBUG_CALL 0
41 using namespace etiss ;
42 using namespace etiss::instr ;
43 
44 RV64IMACFDArch::RV64IMACFDArch(unsigned int coreno):CPUArch("RV64IMACFD"), coreno_(coreno)
45 {
46  headers_.insert("Arch/RV64IMACFD/RV64IMACFD.h");
47 }
48 
49 const std::set<std::string> & RV64IMACFDArch::getListenerSupportedRegisters()
50 {
52 }
53 
55 {
56  ETISS_CPU * ret = (ETISS_CPU *) new RV64IMACFD() ;
57  resetCPU (ret, 0);
58  return ret;
59 }
60 
62 {
63  memset (cpu, 0, sizeof(RV64IMACFD));
64  RV64IMACFD * rv64imacfdcpu = (RV64IMACFD *) cpu;
65 
66  if (startpointer) cpu->instructionPointer = *startpointer & ~((etiss::uint64)0x1);
67  else cpu->instructionPointer = 0x0; // reference to manual
68  cpu->nextPc = cpu->instructionPointer;
69  cpu->mode = 1;
70  cpu->cpuTime_ps = 0;
71  cpu->cpuCycleTime_ps = 31250;
72 
73 
74  for (int i = 0; i < 32; ++i) {
75  rv64imacfdcpu->ins_X[i] = 0;
76  rv64imacfdcpu->X[i] = &rv64imacfdcpu->ins_X[i];
77  }
78  for (int i = 0; i < 4096; ++i) {
79  rv64imacfdcpu->ins_CSR[i] = 0;
80  rv64imacfdcpu->CSR[i] = &rv64imacfdcpu->ins_CSR[i];
81  }
82 
83  rv64imacfdcpu->ZERO = 0;
84  rv64imacfdcpu->RA = 0;
85  rv64imacfdcpu->SP = 0;
86  rv64imacfdcpu->GP = 0;
87  rv64imacfdcpu->TP = 0;
88  rv64imacfdcpu->T0 = 0;
89  rv64imacfdcpu->T1 = 0;
90  rv64imacfdcpu->T2 = 0;
91  rv64imacfdcpu->S0 = 0;
92  rv64imacfdcpu->S1 = 0;
93  rv64imacfdcpu->A0 = 0;
94  rv64imacfdcpu->A1 = 0;
95  rv64imacfdcpu->A2 = 0;
96  rv64imacfdcpu->A3 = 0;
97  rv64imacfdcpu->A4 = 0;
98  rv64imacfdcpu->A5 = 0;
99  rv64imacfdcpu->A6 = 0;
100  rv64imacfdcpu->A7 = 0;
101  rv64imacfdcpu->S2 = 0;
102  rv64imacfdcpu->S3 = 0;
103  rv64imacfdcpu->S4 = 0;
104  rv64imacfdcpu->S5 = 0;
105  rv64imacfdcpu->S6 = 0;
106  rv64imacfdcpu->S7 = 0;
107  rv64imacfdcpu->S8 = 0;
108  rv64imacfdcpu->S9 = 0;
109  rv64imacfdcpu->S10 = 0;
110  rv64imacfdcpu->S11 = 0;
111  rv64imacfdcpu->T3 = 0;
112  rv64imacfdcpu->T4 = 0;
113  rv64imacfdcpu->T5 = 0;
114  rv64imacfdcpu->T6 = 0;
115  for (int i = 0; i < 8; ++i) {
116  rv64imacfdcpu->FENCE[i] = 0;
117  }
118  for (int i = 0; i < 8; ++i) {
119  rv64imacfdcpu->RES[i] = 0;
120  }
121  rv64imacfdcpu->PRIV = 0;
122  rv64imacfdcpu->DPC = 0;
123  rv64imacfdcpu->FCSR = 0;
124  rv64imacfdcpu->MSTATUS = 0;
125  rv64imacfdcpu->MIE = 0;
126  rv64imacfdcpu->MIP = 0;
127  for (int i = 0; i < 32; ++i) {
128  rv64imacfdcpu->F[i] = 0;
129  }
130  rv64imacfdcpu->RES_ADDR = 0;
131 
132  rv64imacfdcpu->X[0] = &rv64imacfdcpu->ZERO;
133  rv64imacfdcpu->X[1] = &rv64imacfdcpu->RA;
134  rv64imacfdcpu->X[2] = &rv64imacfdcpu->SP;
135  rv64imacfdcpu->X[3] = &rv64imacfdcpu->GP;
136  rv64imacfdcpu->X[4] = &rv64imacfdcpu->TP;
137  rv64imacfdcpu->X[5] = &rv64imacfdcpu->T0;
138  rv64imacfdcpu->X[6] = &rv64imacfdcpu->T1;
139  rv64imacfdcpu->X[7] = &rv64imacfdcpu->T2;
140  rv64imacfdcpu->X[8] = &rv64imacfdcpu->S0;
141  rv64imacfdcpu->X[9] = &rv64imacfdcpu->S1;
142  rv64imacfdcpu->X[10] = &rv64imacfdcpu->A0;
143  rv64imacfdcpu->X[11] = &rv64imacfdcpu->A1;
144  rv64imacfdcpu->X[12] = &rv64imacfdcpu->A2;
145  rv64imacfdcpu->X[13] = &rv64imacfdcpu->A3;
146  rv64imacfdcpu->X[14] = &rv64imacfdcpu->A4;
147  rv64imacfdcpu->X[15] = &rv64imacfdcpu->A5;
148  rv64imacfdcpu->X[16] = &rv64imacfdcpu->A6;
149  rv64imacfdcpu->X[17] = &rv64imacfdcpu->A7;
150  rv64imacfdcpu->X[18] = &rv64imacfdcpu->S2;
151  rv64imacfdcpu->X[19] = &rv64imacfdcpu->S3;
152  rv64imacfdcpu->X[20] = &rv64imacfdcpu->S4;
153  rv64imacfdcpu->X[21] = &rv64imacfdcpu->S5;
154  rv64imacfdcpu->X[22] = &rv64imacfdcpu->S6;
155  rv64imacfdcpu->X[23] = &rv64imacfdcpu->S7;
156  rv64imacfdcpu->X[24] = &rv64imacfdcpu->S8;
157  rv64imacfdcpu->X[25] = &rv64imacfdcpu->S9;
158  rv64imacfdcpu->X[26] = &rv64imacfdcpu->S10;
159  rv64imacfdcpu->X[27] = &rv64imacfdcpu->S11;
160  rv64imacfdcpu->X[28] = &rv64imacfdcpu->T3;
161  rv64imacfdcpu->X[29] = &rv64imacfdcpu->T4;
162  rv64imacfdcpu->X[30] = &rv64imacfdcpu->T5;
163  rv64imacfdcpu->X[31] = &rv64imacfdcpu->T6;
164  rv64imacfdcpu->CSR[3] = &rv64imacfdcpu->FCSR;
165  rv64imacfdcpu->CSR[768] = &rv64imacfdcpu->MSTATUS;
166  rv64imacfdcpu->CSR[772] = &rv64imacfdcpu->MIE;
167  rv64imacfdcpu->CSR[836] = &rv64imacfdcpu->MIP;
168 
169  rv64imacfdcpu->PRIV = 3ULL;
170  rv64imacfdcpu->DPC = 0LL;
171  *rv64imacfdcpu->CSR[0] = 11ULL;
172  *rv64imacfdcpu->CSR[256] = 11ULL;
173  *rv64imacfdcpu->CSR[768] = 11ULL;
174  *rv64imacfdcpu->CSR[769] = 9223372036856090925ULL;
175  *rv64imacfdcpu->CSR[3088] = 3ULL;
176  *rv64imacfdcpu->CSR[772] = 4294966203ULL;
177  *rv64imacfdcpu->CSR[260] = 4294964019ULL;
178  *rv64imacfdcpu->CSR[4] = 4294963473ULL;
179  rv64imacfdcpu->RES_ADDR = -1LL;
180 
181 }
182 
184 {
185  delete (RV64IMACFD *) cpu ;
186 }
187 
192 {
193  return 8;
194 }
195 
200 {
201  return 2;
202 }
203 
207 const std::set<std::string> & RV64IMACFDArch::getHeaders() const
208 {
209  return headers_ ;
210 }
211 
213 {
214  cb.fileglobalCode().insert("#include \"Arch/RV64IMACFD/RV64IMACFD.h\"\n");
215  cb.fileglobalCode().insert("#include \"Arch/RV64IMACFD/RV64IMACFDFuncs.h\"\n");
216  cb.functionglobalCode().insert("cpu->exception = 0;\n");
217  cb.functionglobalCode().insert("cpu->return_pending = 0;\n");
218  cb.functionglobalCode().insert("etiss_uint32 mem_ret_code = 0;\n");
219 }
220 
222 {
223  return gdbcore_;
224 }
225 
226 const char * const reg_name[] =
227 {
228  "X0",
229  "X1",
230  "X2",
231  "X3",
232  "X4",
233  "X5",
234  "X6",
235  "X7",
236  "X8",
237  "X9",
238  "X10",
239  "X11",
240  "X12",
241  "X13",
242  "X14",
243  "X15",
244  "X16",
245  "X17",
246  "X18",
247  "X19",
248  "X20",
249  "X21",
250  "X22",
251  "X23",
252  "X24",
253  "X25",
254  "X26",
255  "X27",
256  "X28",
257  "X29",
258  "X30",
259  "X31",
260 };
261 
266 
etiss_uint64 uint64
Definition: 386-GCC.h:82
const char *const reg_name[]
Generated on Thu, 24 Oct 2024 10:16:12 +0200.
etiss::instr::InstructionClass ISA16_RV64IMACFDClass(1, "ISA16_RV64IMACFD", 16, ISA16_RV64IMACFD)
etiss::instr::InstructionCollection RV64IMACFDISA("RV64IMACFDISA", ISA16_RV64IMACFDClass, ISA32_RV64IMACFDClass)
etiss::instr::InstructionGroup ISA32_RV64IMACFD("ISA32_RV64IMACFD", 32)
etiss::instr::InstructionClass ISA32_RV64IMACFDClass(1, "ISA32_RV64IMACFD", 32, ISA32_RV64IMACFD)
etiss::instr::InstructionGroup ISA16_RV64IMACFD("ISA16_RV64IMACFD", 16)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
struct RV64IMACFD RV64IMACFD
Definition: RV64IMACFD.h:67
std::set< std::string > listenerSupportedRegisters_
virtual void deleteCPU(ETISS_CPU *)
delete cpu structure
virtual unsigned getInstructionSizeInBytes()
virtual unsigned getMaximumInstructionSizeInBytes()
RV64IMACFDGDBCore gdbcore_
RV64IMACFDArch(unsigned int)
virtual const std::set< std::string > & getHeaders() const
required headers (RV64IMACFD.h)
virtual ETISS_CPU * newCPU()
allocate new cpu structure
virtual void resetCPU(ETISS_CPU *cpu, etiss::uint64 *startpointer)
reset cpu (structure)
virtual void initCodeBlock(etiss::CodeBlock &cb) const
called before instructions are translated for the code block
virtual etiss::plugin::gdb::GDBCore & getGDBCore()
get the GDBcore for RV64IMACFD architecture
std::set< std::string > headers_
virtual const std::set< std::string > & getListenerSupportedRegisters()
the interface to translate instructions of and processor architecture
Definition: CPUArch.h:162
A list of CodeSets.
Definition: CodePart.h:570
std::set< std::string > & functionglobalCode()
Definition: CodePart.h:605
std::set< std::string > & fileglobalCode()
Definition: CodePart.h:604
maps to VariableInstructionSet
Definition: Instruction.h:638
maps to ModedInstructionSet
Definition: Instruction.h:605
maps to InstructionSet
Definition: Instruction.h:677
provides to architecture dependent registers as defined by gdb
Definition: GDBCore.h:77
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53
basic cpu state structure needed for execution of any cpu architecture.
Definition: CPU.h:89
etiss_uint64 instructionPointer
pointer to next instruction.
Definition: CPU.h:92
etiss_uint64 cpuCycleTime_ps
frequency of the cpu. use to allign e.g. memory delays
Definition: CPU.h:105
etiss_uint64 cpuTime_ps
simulation time of cpu
Definition: CPU.h:97
etiss_uint64 nextPc
Definition: CPU.h:95
etiss_uint32 mode
instruction set mode of the processor
Definition: CPU.h:109
Generated on Thu, 24 Oct 2024 10:16:12 +0200.
Definition: RV64IMACFD.h:16
etiss_uint64 S8
Definition: RV64IMACFD.h:42
etiss_uint64 A6
Definition: RV64IMACFD.h:34
etiss_uint64 A1
Definition: RV64IMACFD.h:29
etiss_uint64 T1
Definition: RV64IMACFD.h:24
etiss_uint64 S2
Definition: RV64IMACFD.h:36
etiss_uint64 FENCE[8]
Definition: RV64IMACFD.h:52
etiss_uint64 RES_ADDR
Definition: RV64IMACFD.h:63
etiss_uint64 A5
Definition: RV64IMACFD.h:33
etiss_uint64 MIP
Definition: RV64IMACFD.h:59
etiss_uint64 ins_X[32]
Definition: RV64IMACFD.h:51
etiss_uint8 PRIV
Definition: RV64IMACFD.h:54
etiss_uint64 S1
Definition: RV64IMACFD.h:27
etiss_uint64 MIE
Definition: RV64IMACFD.h:58
etiss_uint64 ins_CSR[4096]
Definition: RV64IMACFD.h:61
etiss_uint64 T2
Definition: RV64IMACFD.h:25
etiss_uint64 S10
Definition: RV64IMACFD.h:44
etiss_uint64 * CSR[4096]
Definition: RV64IMACFD.h:60
etiss_uint64 RA
Definition: RV64IMACFD.h:19
etiss_uint64 S6
Definition: RV64IMACFD.h:40
etiss_uint64 S0
Definition: RV64IMACFD.h:26
etiss_uint64 S4
Definition: RV64IMACFD.h:38
etiss_uint64 T3
Definition: RV64IMACFD.h:46
etiss_uint64 FCSR
Definition: RV64IMACFD.h:56
etiss_uint64 S7
Definition: RV64IMACFD.h:41
etiss_uint64 SP
Definition: RV64IMACFD.h:20
etiss_uint64 A7
Definition: RV64IMACFD.h:35
etiss_uint64 * X[32]
Definition: RV64IMACFD.h:50
etiss_uint64 S3
Definition: RV64IMACFD.h:37
etiss_uint64 A0
Definition: RV64IMACFD.h:28
etiss_uint64 T6
Definition: RV64IMACFD.h:49
etiss_uint64 ZERO
Definition: RV64IMACFD.h:18
etiss_uint8 RES[8]
Definition: RV64IMACFD.h:53
etiss_uint64 TP
Definition: RV64IMACFD.h:22
etiss_uint64 T0
Definition: RV64IMACFD.h:23
etiss_uint64 A3
Definition: RV64IMACFD.h:31
etiss_uint64 S5
Definition: RV64IMACFD.h:39
etiss_uint64 F[32]
Definition: RV64IMACFD.h:62
etiss_uint64 A2
Definition: RV64IMACFD.h:30
etiss_uint64 T5
Definition: RV64IMACFD.h:48
etiss_uint64 GP
Definition: RV64IMACFD.h:21
etiss_uint64 MSTATUS
Definition: RV64IMACFD.h:57
etiss_uint64 A4
Definition: RV64IMACFD.h:32
etiss_uint64 S9
Definition: RV64IMACFD.h:43
etiss_uint64 S11
Definition: RV64IMACFD.h:45
etiss_uint64 T4
Definition: RV64IMACFD.h:47
etiss_uint64 DPC
Definition: RV64IMACFD.h:55