gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
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
38namespace gem5
39{
40
41namespace Iris
42{
43
44class 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.
60class 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 wakeup(ThreadID tid) override;
79
80 Counter totalInsts() const override;
81 Counter totalOps() const override { return totalInsts(); }
82
83 virtual void
84 setResetAddr(Addr addr, bool secure = false)
85 {
86 panic("%s not implemented.", __FUNCTION__);
87 }
88
89 protected:
91 // Hold casted pointer to *evs.
93
94 protected:
96
97 void
99 {
100 evs_base_cpu->setClkPeriod(clockPeriod());
101 }
102
103 void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
104};
105
106// This class specializes the one above and sets up ThreadContexts based on
107// its template parameters. These ThreadContexts provide the standard gem5
108// interface and translate those accesses to use the Iris API to access that
109// state in the target context.
110template <class TC>
111class CPU : public Iris::BaseCPU
112{
113 public:
114 CPU(const IrisBaseCPUParams &params,
115 iris::IrisConnectionInterface *iris_if) :
117 {
118 const std::string parent_path = evs->name();
119 System *sys = params.system;
120
121 int thread_id = 0;
122 for (const std::string &sub_path: params.thread_paths) {
123 std::string path = parent_path + "." + sub_path;
124 auto id = thread_id++;
125 auto *tc = new TC(this, id, sys, params.mmu,
126 params.isa[id], iris_if, path);
127 threadContexts.push_back(tc);
128 }
129 }
130};
131
132} // namespace Iris
133} // namespace gem5
134
135#endif // __ARCH_ARM_FASTMODEL_IRIS_CPU_HH__
Tick clockPeriod() const
Counter totalOps() const override
Definition cpu.hh:81
void wakeup(ThreadID tid) override
Definition cpu.cc:62
virtual ~BaseCPU()
Definition cpu.cc:54
Iris::BaseCpuEvs * evs_base_cpu
Definition cpu.hh:92
sc_core::sc_module * evs
Definition cpu.hh:90
BaseCPU(const BaseCPUParams &params, sc_core::sc_module *_evs)
Definition cpu.cc:41
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition cpu.cc:80
virtual void setResetAddr(Addr addr, bool secure=false)
Definition cpu.hh:84
Port & getInstPort() override
Purely virtual method that returns a reference to the instruction port.
Definition cpu.hh:73
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:98
friend ThreadContext
Definition cpu.hh:95
Port & getDataPort() override
Purely virtual method that returns a reference to the data port.
Definition cpu.hh:67
Counter totalInsts() const override
Definition cpu.cc:71
virtual void setSysCounterFrq(uint64_t sys_counter_frq)=0
virtual void setClkPeriod(Tick clk_period)=0
virtual void setResetAddr(int core, Addr addr, bool secure)=0
virtual void setCluster(SimObject *cluster)=0
CPU(const IrisBaseCPUParams &params, iris::IrisConnectionInterface *iris_if)
Definition cpu.hh:114
Ports are used to interface objects to each other.
Definition port.hh:62
Abstract superclass for simulation objects.
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
const Params & params() const
Bitfield< 3 > addr
Definition types.hh:84
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58

Generated on Mon Oct 27 2025 04:13:00 for gem5 by doxygen 1.14.0