ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
RV32IMACFDArch.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 RV32IMACFDArchSpecificImp.h
32 
33  8. RV32IMACFDGDBCore.h provides the GDBCore class to support gdb flavor debugging feature, modify iy if in need.
34 
35  *********************************************************************************************************************************/
36 
37 #include "RV32IMACFDArch.h"
38 #include "RV32IMACFDFuncs.h"
39 
40 #define RV32IMACFD_DEBUG_CALL 0
41 using namespace etiss ;
42 using namespace etiss::instr ;
43 
44 RV32IMACFDArch::RV32IMACFDArch(unsigned int coreno):CPUArch("RV32IMACFD"), coreno_(coreno)
45 {
46  headers_.insert("Arch/RV32IMACFD/RV32IMACFD.h");
47 }
48 
49 const std::set<std::string> & RV32IMACFDArch::getListenerSupportedRegisters()
50 {
52 }
53 
55 {
56  ETISS_CPU * ret = (ETISS_CPU *) new RV32IMACFD() ;
57  resetCPU (ret, 0);
58  return ret;
59 }
60 
62 {
63  memset (cpu, 0, sizeof(RV32IMACFD));
64  RV32IMACFD * rv32imacfdcpu = (RV32IMACFD *) 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  rv32imacfdcpu->ins_X[i] = 0;
76  rv32imacfdcpu->X[i] = &rv32imacfdcpu->ins_X[i];
77  }
78  for (int i = 0; i < 4096; ++i) {
79  rv32imacfdcpu->ins_CSR[i] = 0;
80  rv32imacfdcpu->CSR[i] = &rv32imacfdcpu->ins_CSR[i];
81  }
82 
83  rv32imacfdcpu->ZERO = 0;
84  rv32imacfdcpu->RA = 0;
85  rv32imacfdcpu->SP = 0;
86  rv32imacfdcpu->GP = 0;
87  rv32imacfdcpu->TP = 0;
88  rv32imacfdcpu->T0 = 0;
89  rv32imacfdcpu->T1 = 0;
90  rv32imacfdcpu->T2 = 0;
91  rv32imacfdcpu->S0 = 0;
92  rv32imacfdcpu->S1 = 0;
93  rv32imacfdcpu->A0 = 0;
94  rv32imacfdcpu->A1 = 0;
95  rv32imacfdcpu->A2 = 0;
96  rv32imacfdcpu->A3 = 0;
97  rv32imacfdcpu->A4 = 0;
98  rv32imacfdcpu->A5 = 0;
99  rv32imacfdcpu->A6 = 0;
100  rv32imacfdcpu->A7 = 0;
101  rv32imacfdcpu->S2 = 0;
102  rv32imacfdcpu->S3 = 0;
103  rv32imacfdcpu->S4 = 0;
104  rv32imacfdcpu->S5 = 0;
105  rv32imacfdcpu->S6 = 0;
106  rv32imacfdcpu->S7 = 0;
107  rv32imacfdcpu->S8 = 0;
108  rv32imacfdcpu->S9 = 0;
109  rv32imacfdcpu->S10 = 0;
110  rv32imacfdcpu->S11 = 0;
111  rv32imacfdcpu->T3 = 0;
112  rv32imacfdcpu->T4 = 0;
113  rv32imacfdcpu->T5 = 0;
114  rv32imacfdcpu->T6 = 0;
115  for (int i = 0; i < 8; ++i) {
116  rv32imacfdcpu->FENCE[i] = 0;
117  }
118  for (int i = 0; i < 8; ++i) {
119  rv32imacfdcpu->RES[i] = 0;
120  }
121  rv32imacfdcpu->PRIV = 0;
122  rv32imacfdcpu->DPC = 0;
123  rv32imacfdcpu->FCSR = 0;
124  rv32imacfdcpu->MSTATUS = 0;
125  rv32imacfdcpu->MIE = 0;
126  rv32imacfdcpu->MIP = 0;
127  for (int i = 0; i < 32; ++i) {
128  rv32imacfdcpu->F[i] = 0;
129  }
130  rv32imacfdcpu->RES_ADDR = 0;
131 
132  rv32imacfdcpu->X[0] = &rv32imacfdcpu->ZERO;
133  rv32imacfdcpu->X[1] = &rv32imacfdcpu->RA;
134  rv32imacfdcpu->X[2] = &rv32imacfdcpu->SP;
135  rv32imacfdcpu->X[3] = &rv32imacfdcpu->GP;
136  rv32imacfdcpu->X[4] = &rv32imacfdcpu->TP;
137  rv32imacfdcpu->X[5] = &rv32imacfdcpu->T0;
138  rv32imacfdcpu->X[6] = &rv32imacfdcpu->T1;
139  rv32imacfdcpu->X[7] = &rv32imacfdcpu->T2;
140  rv32imacfdcpu->X[8] = &rv32imacfdcpu->S0;
141  rv32imacfdcpu->X[9] = &rv32imacfdcpu->S1;
142  rv32imacfdcpu->X[10] = &rv32imacfdcpu->A0;
143  rv32imacfdcpu->X[11] = &rv32imacfdcpu->A1;
144  rv32imacfdcpu->X[12] = &rv32imacfdcpu->A2;
145  rv32imacfdcpu->X[13] = &rv32imacfdcpu->A3;
146  rv32imacfdcpu->X[14] = &rv32imacfdcpu->A4;
147  rv32imacfdcpu->X[15] = &rv32imacfdcpu->A5;
148  rv32imacfdcpu->X[16] = &rv32imacfdcpu->A6;
149  rv32imacfdcpu->X[17] = &rv32imacfdcpu->A7;
150  rv32imacfdcpu->X[18] = &rv32imacfdcpu->S2;
151  rv32imacfdcpu->X[19] = &rv32imacfdcpu->S3;
152  rv32imacfdcpu->X[20] = &rv32imacfdcpu->S4;
153  rv32imacfdcpu->X[21] = &rv32imacfdcpu->S5;
154  rv32imacfdcpu->X[22] = &rv32imacfdcpu->S6;
155  rv32imacfdcpu->X[23] = &rv32imacfdcpu->S7;
156  rv32imacfdcpu->X[24] = &rv32imacfdcpu->S8;
157  rv32imacfdcpu->X[25] = &rv32imacfdcpu->S9;
158  rv32imacfdcpu->X[26] = &rv32imacfdcpu->S10;
159  rv32imacfdcpu->X[27] = &rv32imacfdcpu->S11;
160  rv32imacfdcpu->X[28] = &rv32imacfdcpu->T3;
161  rv32imacfdcpu->X[29] = &rv32imacfdcpu->T4;
162  rv32imacfdcpu->X[30] = &rv32imacfdcpu->T5;
163  rv32imacfdcpu->X[31] = &rv32imacfdcpu->T6;
164  rv32imacfdcpu->CSR[3] = &rv32imacfdcpu->FCSR;
165  rv32imacfdcpu->CSR[768] = &rv32imacfdcpu->MSTATUS;
166  rv32imacfdcpu->CSR[772] = &rv32imacfdcpu->MIE;
167  rv32imacfdcpu->CSR[836] = &rv32imacfdcpu->MIP;
168 
169  rv32imacfdcpu->PRIV = 3ULL;
170  rv32imacfdcpu->DPC = 0LL;
171  *rv32imacfdcpu->CSR[0] = 11ULL;
172  *rv32imacfdcpu->CSR[256] = 11ULL;
173  *rv32imacfdcpu->CSR[768] = 11ULL;
174  *rv32imacfdcpu->CSR[769] = 1075056941ULL;
175  *rv32imacfdcpu->CSR[3088] = 3ULL;
176  *rv32imacfdcpu->CSR[772] = 4294966203ULL;
177  *rv32imacfdcpu->CSR[260] = 4294964019ULL;
178  *rv32imacfdcpu->CSR[4] = 4294963473ULL;
179  rv32imacfdcpu->RES_ADDR = -1LL;
180 
181 }
182 
184 {
185  delete (RV32IMACFD *) cpu ;
186 }
187 
192 {
193  return 8;
194 }
195 
200 {
201  return 2;
202 }
203 
207 const std::set<std::string> & RV32IMACFDArch::getHeaders() const
208 {
209  return headers_ ;
210 }
211 
213 {
214  cb.fileglobalCode().insert("#include \"Arch/RV32IMACFD/RV32IMACFD.h\"\n");
215  cb.fileglobalCode().insert("#include \"Arch/RV32IMACFD/RV32IMACFDFuncs.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::InstructionCollection RV32IMACFDISA("RV32IMACFDISA", ISA16_RV32IMACFDClass, ISA32_RV32IMACFDClass)
etiss::instr::InstructionGroup ISA32_RV32IMACFD("ISA32_RV32IMACFD", 32)
etiss::instr::InstructionClass ISA16_RV32IMACFDClass(1, "ISA16_RV32IMACFD", 16, ISA16_RV32IMACFD)
etiss::instr::InstructionGroup ISA16_RV32IMACFD("ISA16_RV32IMACFD", 16)
etiss::instr::InstructionClass ISA32_RV32IMACFDClass(1, "ISA32_RV32IMACFD", 32, ISA32_RV32IMACFD)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
struct RV32IMACFD RV32IMACFD
Definition: RV32IMACFD.h:67
RV32IMACFDArch(unsigned int)
virtual void deleteCPU(ETISS_CPU *)
delete cpu structure
virtual ETISS_CPU * newCPU()
allocate new cpu structure
RV32IMACFDGDBCore gdbcore_
virtual const std::set< std::string > & getHeaders() const
required headers (RV32IMACFD.h)
virtual unsigned getMaximumInstructionSizeInBytes()
std::set< std::string > listenerSupportedRegisters_
virtual unsigned getInstructionSizeInBytes()
virtual etiss::plugin::gdb::GDBCore & getGDBCore()
get the GDBcore for RV32IMACFD architecture
virtual const std::set< std::string > & getListenerSupportedRegisters()
virtual void initCodeBlock(etiss::CodeBlock &cb) const
called before instructions are translated for the code block
virtual void resetCPU(ETISS_CPU *cpu, etiss::uint64 *startpointer)
reset cpu (structure)
std::set< std::string > headers_
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: RV32IMACFD.h:16
etiss_uint32 MIP
Definition: RV32IMACFD.h:59
etiss_uint32 MSTATUS
Definition: RV32IMACFD.h:57
etiss_uint32 RES_ADDR
Definition: RV32IMACFD.h:63
etiss_uint32 S11
Definition: RV32IMACFD.h:45
etiss_uint32 A5
Definition: RV32IMACFD.h:33
etiss_uint32 S4
Definition: RV32IMACFD.h:38
etiss_uint32 * X[32]
Definition: RV32IMACFD.h:50
etiss_uint32 A7
Definition: RV32IMACFD.h:35
etiss_uint32 T1
Definition: RV32IMACFD.h:24
etiss_uint32 T4
Definition: RV32IMACFD.h:47
etiss_uint32 S0
Definition: RV32IMACFD.h:26
etiss_uint64 F[32]
Definition: RV32IMACFD.h:62
etiss_uint32 * CSR[4096]
Definition: RV32IMACFD.h:60
etiss_uint32 SP
Definition: RV32IMACFD.h:20
etiss_uint32 S1
Definition: RV32IMACFD.h:27
etiss_uint32 A3
Definition: RV32IMACFD.h:31
etiss_uint32 ins_CSR[4096]
Definition: RV32IMACFD.h:61
etiss_uint32 A2
Definition: RV32IMACFD.h:30
etiss_uint32 T5
Definition: RV32IMACFD.h:48
etiss_uint32 S5
Definition: RV32IMACFD.h:39
etiss_uint32 ZERO
Definition: RV32IMACFD.h:18
etiss_uint32 S8
Definition: RV32IMACFD.h:42
etiss_uint32 TP
Definition: RV32IMACFD.h:22
etiss_uint32 A1
Definition: RV32IMACFD.h:29
etiss_uint32 ins_X[32]
Definition: RV32IMACFD.h:51
etiss_uint8 PRIV
Definition: RV32IMACFD.h:54
etiss_uint32 A4
Definition: RV32IMACFD.h:32
etiss_uint32 MIE
Definition: RV32IMACFD.h:58
etiss_uint32 T3
Definition: RV32IMACFD.h:46
etiss_uint32 S10
Definition: RV32IMACFD.h:44
etiss_uint32 S7
Definition: RV32IMACFD.h:41
etiss_uint32 FCSR
Definition: RV32IMACFD.h:56
etiss_uint32 T6
Definition: RV32IMACFD.h:49
etiss_uint32 S3
Definition: RV32IMACFD.h:37
etiss_uint32 S6
Definition: RV32IMACFD.h:40
etiss_uint32 DPC
Definition: RV32IMACFD.h:55
etiss_uint32 S9
Definition: RV32IMACFD.h:43
etiss_uint32 T0
Definition: RV32IMACFD.h:23
etiss_uint32 RA
Definition: RV32IMACFD.h:19
etiss_uint8 RES[8]
Definition: RV32IMACFD.h:53
etiss_uint32 GP
Definition: RV32IMACFD.h:21
etiss_uint32 T2
Definition: RV32IMACFD.h:25
etiss_uint32 A0
Definition: RV32IMACFD.h:28
etiss_uint32 A6
Definition: RV32IMACFD.h:34
etiss_uint32 FENCE[8]
Definition: RV32IMACFD.h:52
etiss_uint32 S2
Definition: RV32IMACFD.h:36