ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
resources.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
6
7#include <cstdint>
8#include "etiss/jit/CPU.h"
9
10extern "C"
11{
12 uint32_t handleResources(uint32_t *resource_time, uint32_t (*resources)[ETISS_MAX_RESOURCES], uint32_t num_stages,
13 uint32_t *num_resources, ETISS_CPU *cpu)
14 {
15 for (uint32_t i = 0; i < num_stages; i++)
16 {
17 etiss_uint64 max = 0;
18 for (uint32_t j = 0; j < num_resources[i]; j++)
19 { // set "in use" metric
20 cpu->resourceUsages[resources[i][j]] += resource_time[resources[i][j]];
21 }
22 for (uint32_t j = 0; j < num_resources[i]; j++)
23 { // find max in this stage
24 if (cpu->cycles[resources[i][j]] > max)
25 {
26 max = cpu->cycles[resources[i][j]];
27 }
28 }
29
30 if (!(i == 0))
31 { // find max in stage before this stage
32 for (uint32_t j = 0; j < num_resources[i - 1]; j++)
33 {
34 if (cpu->cycles[resources[i - 1][j]] > max)
35 {
36 max = cpu->cycles[resources[i - 1][j]];
37 }
38 }
39 }
40 uint32_t max_stagetime = 0;
41 for (uint32_t j = 0; j < num_resources[i]; j++)
42 { // find max time in stage
43 if (resource_time[resources[i][j] > max_stagetime])
44 {
45 max_stagetime = resource_time[resources[i][j]];
46 }
47 }
48
49 for (uint32_t j = 0; j < num_resources[i]; j++)
50 { // set new values
51 cpu->cycles[resources[i][j]] = max + max_stagetime;
52 }
53 }
54 return 0;
55 }
56}
__DEVICE__ int max(int __a, int __b)
static __inline__ uint32_t
Definition arm_cde.h:25
#define ETISS_MAX_RESOURCES
Definition CPU.h:21
uint64_t etiss_uint64
Definition types.h:58
uint32_t handleResources(uint32_t *resource_time, uint32_t(*resources)[ETISS_MAX_RESOURCES], uint32_t num_stages, uint32_t *num_resources, ETISS_CPU *cpu)
Definition resources.cpp:12
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:51
etiss_uint64 resourceUsages[ETISS_MAX_RESOURCES]
how many cycles each resource is used
Definition CPU.h:61
etiss_uint64 cycles[ETISS_MAX_RESOURCES]
how many cycles in each resource (including waiting)
Definition CPU.h:65