gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpu.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __ARCH_ARM_FASTMODEL_IRIS_CPU_HH__
29 #define __ARCH_ARM_FASTMODEL_IRIS_CPU_HH__
30 
31 #include "cpu/base.hh"
32 #include "iris/detail/IrisInterface.h"
33 #include "params/IrisBaseCPU.hh"
37 
38 namespace gem5
39 {
40 
41 namespace Iris
42 {
43 
44 class ThreadContext;
45 
46 // The base interface of the EVS used by gem5 BaseCPU below.
48 {
49  public:
50  virtual void setClkPeriod(Tick clk_period) = 0;
51  virtual void setSysCounterFrq(uint64_t sys_counter_frq) = 0;
52  virtual void setCluster(SimObject *cluster) = 0;
53  virtual void setResetAddr(int core, Addr addr, bool secure) = 0;
54 };
55 
56 // This CPU class adds some mechanisms which help attach the gem5 and fast
57 // model CPUs to each other. It acts as a base class for the gem5 CPU, and
58 // holds a pointer to the EVS. It also has some methods for setting up some
59 // attributes in the fast model CPU to control its clock rate.
60 class BaseCPU : public gem5::BaseCPU
61 {
62  public:
63  BaseCPU(const BaseCPUParams &params, sc_core::sc_module *_evs);
64  virtual ~BaseCPU();
65 
66  Port &
67  getDataPort() override
68  {
69  panic("%s not implemented.", __FUNCTION__);
70  }
71 
72  Port &
73  getInstPort() override
74  {
75  panic("%s not implemented.", __FUNCTION__);
76  }
77 
78  void
79  wakeup(ThreadID tid) override
80  {
81  auto *tc = threadContexts.at(tid);
82  if (tc->status() == gem5::ThreadContext::Suspended)
83  tc->activate();
84  }
85 
86  Counter totalInsts() const override;
87  Counter totalOps() const override { return totalInsts(); }
88 
89  virtual void
90  setResetAddr(Addr addr, bool secure = false)
91  {
92  panic("%s not implemented.", __FUNCTION__);
93  }
94 
95  protected:
97  // Hold casted pointer to *evs.
99 
100  protected:
102 
103  void
105  {
107  }
108 
109  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
110 };
111 
112 // This class specializes the one above and sets up ThreadContexts based on
113 // its template parameters. These ThreadContexts provide the standard gem5
114 // interface and translate those accesses to use the Iris API to access that
115 // state in the target context.
116 template <class TC>
117 class CPU : public Iris::BaseCPU
118 {
119  public:
120  CPU(const IrisBaseCPUParams &params,
121  iris::IrisConnectionInterface *iris_if) :
123  {
124  const std::string parent_path = evs->name();
125  System *sys = params.system;
126 
127  int thread_id = 0;
128  for (const std::string &sub_path: params.thread_paths) {
129  std::string path = parent_path + "." + sub_path;
130  auto id = thread_id++;
131  auto *tc = new TC(this, id, sys, params.mmu,
132  params.isa[id], iris_if, path);
133  threadContexts.push_back(tc);
134  }
135  }
136 };
137 
138 } // namespace Iris
139 } // namespace gem5
140 
141 #endif // __ARCH_ARM_FASTMODEL_IRIS_CPU_HH__
gem5::Iris::BaseCPU::getInstPort
Port & getInstPort() override
Purely virtual method that returns a reference to the instruction port.
Definition: cpu.hh:73
gem5::Iris::BaseCPU::BaseCPU
BaseCPU(const BaseCPUParams &params, sc_core::sc_module *_evs)
Definition: cpu.cc:40
gem5::Iris::BaseCpuEvs::setClkPeriod
virtual void setClkPeriod(Tick clk_period)=0
gem5::Iris::BaseCPU::setResetAddr
virtual void setResetAddr(Addr addr, bool secure=false)
Definition: cpu.hh:90
gem5::Iris::BaseCpuEvs::setResetAddr
virtual void setResetAddr(int core, Addr addr, bool secure)=0
sc_core::sc_module
Definition: sc_module.hh:101
gem5::Serializable::path
static std::stack< std::string > path
Definition: serialize.hh:315
gem5::Iris::BaseCPU
Definition: cpu.hh:60
gem5::Iris::BaseCpuEvs
Definition: cpu.hh:47
gem5::Iris::BaseCPU::~BaseCPU
virtual ~BaseCPU()
Definition: cpu.cc:53
gem5::Iris::BaseCPU::ThreadContext
friend ThreadContext
Definition: cpu.hh:101
gem5::Iris::BaseCPU::evs_base_cpu
Iris::BaseCpuEvs * evs_base_cpu
Definition: cpu.hh:98
gem5::Iris::BaseCPU::evs
sc_core::sc_module * evs
Definition: cpu.hh:96
gem5::Iris::CPU::CPU
CPU(const IrisBaseCPUParams &params, iris::IrisConnectionInterface *iris_if)
Definition: cpu.hh:120
gem5::Iris::BaseCPU::serializeThread
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: cpu.cc:70
gem5::Iris::BaseCpuEvs::setSysCounterFrq
virtual void setSysCounterFrq(uint64_t sys_counter_frq)=0
sc_event.hh
gem5::Iris::BaseCPU::wakeup
void wakeup(ThreadID tid) override
Definition: cpu.hh:79
gem5::System
Definition: system.hh:74
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
gem5::ThreadContext::Suspended
@ Suspended
Temporarily inactive.
Definition: thread_context.hh:107
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::Iris::BaseCPU::totalOps
Counter totalOps() const override
Definition: cpu.hh:87
gem5::BaseCPU
Definition: base.hh:104
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
sc_module.hh
gem5::Iris::BaseCpuEvs::setCluster
virtual void setCluster(SimObject *cluster)=0
gem5::BaseCPU::threadContexts
std::vector< ThreadContext * > threadContexts
Definition: base.hh:260
base.hh
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
gem5::statistics::Counter
double Counter
All counters are of 64-bit values.
Definition: types.hh:46
gem5::Iris::CPU
Definition: cpu.hh:117
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::Iris::BaseCPU::totalInsts
Counter totalInsts() const override
Definition: cpu.cc:61
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
sc_attr.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:188
gem5::Clocked::clockPeriod
Tick clockPeriod() const
Definition: clocked_object.hh:217
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::Iris::BaseCPU::clockPeriodUpdated
void clockPeriodUpdated() override
A hook subclasses can implement so they can do any extra work that's needed when the clock rate is ch...
Definition: cpu.hh:104
gem5::Iris::BaseCPU::getDataPort
Port & getDataPort() override
Purely virtual method that returns a reference to the data port.
Definition: cpu.hh:67

Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17