ChampSim
operable.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 The ChampSim Contributors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef OPERABLE_H
18 #define OPERABLE_H
19 
20 namespace champsim
21 {
22 
23 class operable
24 {
25 public:
26  const double CLOCK_SCALE;
27 
28  double leap_operation = 0;
29  uint64_t current_cycle = 0;
30  bool warmup = true;
31 
32  explicit operable(double scale) : CLOCK_SCALE(scale - 1) {}
33 
34  long _operate()
35  {
36  // skip periodically
37  if (leap_operation >= 1) {
38  leap_operation -= 1;
39  return 0;
40  }
41 
42  auto result = operate();
43 
45  ++current_cycle;
46 
47  return result;
48  }
49 
50  virtual void initialize() {} // LCOV_EXCL_LINE
51  virtual long operate() = 0;
52  virtual void begin_phase() {} // LCOV_EXCL_LINE
53  virtual void end_phase(unsigned) {} // LCOV_EXCL_LINE
54  virtual void print_deadlock() {} // LCOV_EXCL_LINE
55 };
56 
57 } // namespace champsim
58 
59 #endif
Definition: operable.h:24
double leap_operation
Definition: operable.h:28
virtual void print_deadlock()
Definition: operable.h:54
virtual void end_phase(unsigned)
Definition: operable.h:53
bool warmup
Definition: operable.h:30
long _operate()
Definition: operable.h:34
virtual void begin_phase()
Definition: operable.h:52
uint64_t current_cycle
Definition: operable.h:29
virtual void initialize()
Definition: operable.h:50
operable(double scale)
Definition: operable.h:32
virtual long operate()=0
const double CLOCK_SCALE
Definition: operable.h:26
Definition: champsim.h:24