ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
FastMemory.cpp
Go to the documentation of this file.
1 /*
2 
3  @copyright
4 
5  <pre>
6 
7  Copyright 2018 Infineon Technologies AG
8 
9  This file is part of ETISS tool, see <https://github.com/tum-ei-eda/etiss>.
10 
11  The initial version of this software has been created with the funding support by the German Federal
12  Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
13 
14  Redistribution and use in source and binary forms, with or without modification, are permitted
15  provided that the following conditions are met:
16 
17  1. Redistributions of source code must retain the above copyright notice, this list of conditions and
18  the following disclaimer.
19 
20  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
21  and the following disclaimer in the documentation and/or other materials provided with the distribution.
22 
23  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
24  or promote products derived from this software without specific prior written permission.
25 
26  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
27  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
28  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
29  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  POSSIBILITY OF SUCH DAMAGE.
34 
35  </pre>
36 
37  @author Chair of Electronic Design Automation, TUM
38 
39  @version 0.1
40 
41 */
42 
43 #include "etiss/FastMemory.h"
44 #include "etiss/jit/ReturnCode.h"
45 #include <cstring>
46 
48 {
49  return 0;
50 }
51 static etiss_int32 system_call_iwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
53 {
54  return etiss::RETURNCODE::IBUS_WRITE_ERROR;
55 }
56 
57 static etiss_int32 system_call_dread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
59 {
60  memcpy(buffer, ((uint8_t *)handle) + (size_t)addr, length);
61  return 0;
62 }
63 static etiss_int32 system_call_dwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer,
65 {
66  memcpy(((uint8_t *)handle) + (size_t)addr, buffer, length);
67  return 0;
68 }
69 
71 {
72  memcpy(buffer, ((uint8_t *)handle) + (size_t)addr, length);
73  return 0;
74 }
75 
77 {
78  memcpy(((uint8_t *)handle) + (size_t)addr, buffer, length);
79  return 0;
80 }
81 
82 static void system_call_syncTime(void *handle, ETISS_CPU *cpu) {}
83 
84 std::shared_ptr<ETISS_System> etiss::createFastMemory(size_t size)
85 {
86  auto ret = std::make_shared<ETISS_System>();
87 
88  ret->iread = &system_call_iread;
89  ret->iwrite = &system_call_iwrite;
90 
91  ret->dread = &system_call_dread;
92  ret->dwrite = &system_call_dwrite;
93 
94  ret->dbg_read = &system_call_dbg_read;
95  ret->dbg_write = &system_call_dbg_write;
96 
97  ret->syncTime = &system_call_syncTime;
98 
99  ret->handle = new uint8_t[size];
100 
101  return ret;
102 }
static void system_call_syncTime(void *handle, ETISS_CPU *cpu)
Definition: FastMemory.cpp:82
static etiss_int32 system_call_dbg_read(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
Definition: FastMemory.cpp:70
static etiss_int32 system_call_iread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint32 length)
Definition: FastMemory.cpp:47
static etiss_int32 system_call_dwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
Definition: FastMemory.cpp:63
static etiss_int32 system_call_dread(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
Definition: FastMemory.cpp:57
static etiss_int32 system_call_dbg_write(void *handle, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
Definition: FastMemory.cpp:76
static etiss_int32 system_call_iwrite(void *handle, ETISS_CPU *cpu, etiss_uint64 addr, etiss_uint8 *buffer, etiss_uint32 length)
Definition: FastMemory.cpp:51
provides a fast memory implementation for ETISS
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
static __inline__ uint8_t
Definition: arm_mve.h:323
uint64_t etiss_uint64
Definition: types.h:96
uint32_t etiss_uint32
Definition: types.h:93
uint8_t etiss_uint8
Definition: types.h:87
int32_t etiss_int32
Definition: types.h:92
std::shared_ptr< ETISS_System > createFastMemory(size_t size)
creates a very fast ETISS_System structure.
Definition: FastMemory.cpp:84
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
basic cpu state structure needed for execution of any cpu architecture.
Definition: CPU.h:89