gem5.cc (11617:a51ae096ca25) gem5.cc (11618:37b0af2c7ba8)
1// Copyright (c) 2015 ARM Limited
1// Copyright (c) 2015-2016 ARM Limited
2// All rights reserved.
3//
4// The license below extends only to copyright in the software and shall
5// not be construed as granting a license to any other intellectual
6// property including but not limited to intellectual property relating
7// to a hardware implementation of the functionality of the software
8// licensed hereunder. You may use the software subject to the license
9// terms below provided that you ensure that this notice is replicated

--- 50 unchanged lines hidden (view full) ---

60#include <base/misc.hh>
61#include <base/debug.hh>
62
63#ifdef fatal // gem5 sets this
64#undef fatal
65#endif
66
67// More SST Headers
2// All rights reserved.
3//
4// The license below extends only to copyright in the software and shall
5// not be construed as granting a license to any other intellectual
6// property including but not limited to intellectual property relating
7// to a hardware implementation of the functionality of the software
8// licensed hereunder. You may use the software subject to the license
9// terms below provided that you ensure that this notice is replicated

--- 50 unchanged lines hidden (view full) ---

60#include <base/misc.hh>
61#include <base/debug.hh>
62
63#ifdef fatal // gem5 sets this
64#undef fatal
65#endif
66
67// More SST Headers
68#include <sst/core/params.h>
69#include <sst/core/link.h>
70#include <sst/core/timeConverter.h>
68#include <core/timeConverter.h>
71
72using namespace SST;
73using namespace SST::gem5;
74
75gem5Component::gem5Component(ComponentId_t id, Params &params) :
76 SST::Component(id)
77{
78 dbg.init("@t:gem5:@p():@l " + getName() + ": ", 0, 0,
69
70using namespace SST;
71using namespace SST::gem5;
72
73gem5Component::gem5Component(ComponentId_t id, Params &params) :
74 SST::Component(id)
75{
76 dbg.init("@t:gem5:@p():@l " + getName() + ": ", 0, 0,
79 (Output::output_location_t)params.find_integer("comp_debug", 0));
77 (Output::output_location_t)params.find<int>("comp_debug", 0));
80 info.init("gem5:" + getName() + ": ", 0, 0, Output::STDOUT);
81
82 TimeConverter *clock = registerClock(
78 info.init("gem5:" + getName() + ": ", 0, 0, Output::STDOUT);
79
80 TimeConverter *clock = registerClock(
83 params.find_string("frequency", "1GHz"),
81 params.find<std::string>("frequency", "1GHz"),
84 new Clock::Handler<gem5Component>(this, &gem5Component::clockTick));
85
86 // This sets how many gem5 cycles we'll need to simulate per clock tick
87 sim_cycles = clock->getFactor();
88
89 // Disable gem5's inform() messages.
90 want_info = false;
91
82 new Clock::Handler<gem5Component>(this, &gem5Component::clockTick));
83
84 // This sets how many gem5 cycles we'll need to simulate per clock tick
85 sim_cycles = clock->getFactor();
86
87 // Disable gem5's inform() messages.
88 want_info = false;
89
92 std::string cmd = params.find_string("cmd", "");
90 std::string cmd = params.find<std::string>("cmd", "");
93 if (cmd.empty()) {
94 dbg.fatal(CALL_INFO, -1, "Component %s must have a 'cmd' parameter.\n",
95 getName().c_str());
96 }
97
98 std::vector<char*> args;
99 args.push_back(const_cast<char*>("sst.x")); // TODO: Compute this somehow?
100 splitCommandArgs(cmd, args);
101 args.push_back(const_cast<char*>("--initialize-only"));
102 dbg.output(CALL_INFO, "Command string: [sst.x %s --initialize-only]\n",
103 cmd.c_str());
104 for (size_t i = 0; i < args.size(); ++i) {
105 dbg.output(CALL_INFO, " Arg [%02zu] = %s\n", i, args[i]);
106 }
107
108 std::vector<char*> flags;
91 if (cmd.empty()) {
92 dbg.fatal(CALL_INFO, -1, "Component %s must have a 'cmd' parameter.\n",
93 getName().c_str());
94 }
95
96 std::vector<char*> args;
97 args.push_back(const_cast<char*>("sst.x")); // TODO: Compute this somehow?
98 splitCommandArgs(cmd, args);
99 args.push_back(const_cast<char*>("--initialize-only"));
100 dbg.output(CALL_INFO, "Command string: [sst.x %s --initialize-only]\n",
101 cmd.c_str());
102 for (size_t i = 0; i < args.size(); ++i) {
103 dbg.output(CALL_INFO, " Arg [%02zu] = %s\n", i, args[i]);
104 }
105
106 std::vector<char*> flags;
109 std::string gem5DbgFlags = params.find_string("gem5DebugFlags", "");
107 std::string gem5DbgFlags = params.find<std::string>("gem5DebugFlags", "");
110 splitCommandArgs(gem5DbgFlags, flags);
111 for (auto flag : flags) {
112 dbg.output(CALL_INFO, " Setting Debug Flag [%s]\n", flag);
113 setDebugFlag(flag);
114 }
115
116 ExternalMaster::registerHandler("sst", this); // these are idempotent
117 ExternalSlave ::registerHandler("sst", this);

--- 39 unchanged lines hidden (view full) ---

157}
158
159void
160gem5Component::finish(void)
161{
162 for (auto m : masters) {
163 m->finish();
164 }
108 splitCommandArgs(gem5DbgFlags, flags);
109 for (auto flag : flags) {
110 dbg.output(CALL_INFO, " Setting Debug Flag [%s]\n", flag);
111 setDebugFlag(flag);
112 }
113
114 ExternalMaster::registerHandler("sst", this); // these are idempotent
115 ExternalSlave ::registerHandler("sst", this);

--- 39 unchanged lines hidden (view full) ---

155}
156
157void
158gem5Component::finish(void)
159{
160 for (auto m : masters) {
161 m->finish();
162 }
165 info.output("Complete. Clocks Processed: %"PRIu64"\n", clocks_processed);
163 info.output("Complete. Clocks Processed: %" PRIu64"\n", clocks_processed);
166}
167
168bool
169gem5Component::clockTick(Cycle_t cycle)
170{
171 dbg.output(CALL_INFO, "Cycle %lu\n", cycle);
172
173 for (auto m : masters) {

--- 98 unchanged lines hidden ---
164}
165
166bool
167gem5Component::clockTick(Cycle_t cycle)
168{
169 dbg.output(CALL_INFO, "Cycle %lu\n", cycle);
170
171 for (auto m : masters) {

--- 98 unchanged lines hidden ---