2 * Copyright 2019 Google, Inc.
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.
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.
30 #include "arch/arm/fastmodel/iris/cpu.hh"
32 #include "arch/arm/fastmodel/iris/thread_context.hh"
34 #include "sim/serialize.hh"
39 BaseCPU::BaseCPU(BaseCPUParams
*params
, sc_core::sc_module
*_evs
) :
40 ::BaseCPU::BaseCPU(params
), evs(_evs
),
41 clockEvent(nullptr), periodAttribute(nullptr)
43 sc_core::sc_attr_base
*base
;
45 const auto &event_vec
= evs
->get_child_events();
46 auto event_it
= std::find_if(event_vec
.begin(), event_vec
.end(),
47 [](const sc_core::sc_event
*e
) -> bool {
48 return e
->basename() == ClockEventName
; });
49 if (event_it
!= event_vec
.end())
50 clockEvent
= *event_it
;
52 base
= evs
->get_attribute(PeriodAttributeName
);
53 periodAttribute
= dynamic_cast<sc_core::sc_attribute
<Tick
> *>(base
);
54 panic_if(base
&& !periodAttribute
,
55 "The EVS clock period attribute is not of type "
56 "sc_attribute<Tick>.");
58 base
= evs
->get_attribute(SendFunctionalAttributeName
);
60 dynamic_cast<sc_core::sc_attribute
<PortProxy::SendFunctionalFunc
> *>(
62 panic_if(base
&& !sendFunctional
,
63 "The EVS send functional attribute is not of type "
64 "sc_attribute<PortProxy::SendFunctionalFunc>.");
66 // Make sure fast model knows we're using debugging mechanisms to control
67 // the simulation, and it shouldn't shut down if simulation time stops
68 // for some reason. Despite the misleading name, this doesn't start a CADI
69 // server because it's first parameter is false.
70 scx::scx_start_cadi_server(false, false, true);
75 for (auto &tc
: threadContexts
)
77 threadContexts
.clear();
81 BaseCPU::totalInsts() const
84 for (auto *tc
: threadContexts
)
85 count
+= tc
->getCurrentInstCount();
93 for (auto *tc
: threadContexts
)
94 tc
->initMemProxies(tc
);
98 BaseCPU::serializeThread(CheckpointOut
&cp
, ThreadID tid
) const
100 ::serialize(*threadContexts
[tid
], cp
);