Rework the command line paramters for python output and how
output files and the output directory are are handled. Make the output directory configuration via a command line parameter, or an environment variable. SConscript: Add new output file stuff base/misc.cc: dev/simconsole.cc: use new output file code cpu/base_cpu.cc: use new output file code to generate output streams dev/etherdump.cc: use the output file code to find the output directory use a real stream instead of a pointer dev/etherdump.hh: use a real stream instead of a pointer objects/Root.mpy: output_dir and config_output_file are not longer configured here. sim/main.cc: - Completely rework the command line argument passing to deal with changes in python and output files. - Update help output to reflect changes. - Remove all direct support for .ini files. They are strictly for intermediate representation. - Remove the --foo:bar=blah syntax for .ini files and add --foo.bar=blah syntax for python. This will generate: foo.bar = 'blah' in the python script. - Add '-d' to set the output directory. - Use new output file code to access the output stream. sim/serialize.cc: use the new code to find the output directory sim/universe.cc: Get rid of makeOutputStream. Use the new output file code. Remove output_dir and config_output_file as parameters. --HG-- extra : convert_revision : df2f0e13d401c3a60cae1239aa1ec3511721544d
This commit is contained in:
parent
200246d1ca
commit
06a4686af9
12 changed files with 352 additions and 258 deletions
|
@ -63,6 +63,7 @@ base_sources = Split('''
|
||||||
base/intmath.cc
|
base/intmath.cc
|
||||||
base/match.cc
|
base/match.cc
|
||||||
base/misc.cc
|
base/misc.cc
|
||||||
|
base/output.cc
|
||||||
base/pollevent.cc
|
base/pollevent.cc
|
||||||
base/python.cc
|
base/python.cc
|
||||||
base/range.cc
|
base/range.cc
|
||||||
|
|
|
@ -30,10 +30,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/cprintf.hh"
|
#include "base/cprintf.hh"
|
||||||
#include "sim/host.hh"
|
|
||||||
#include "base/hostinfo.hh"
|
#include "base/hostinfo.hh"
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "base/trace.hh"
|
#include "base/trace.hh"
|
||||||
|
#include "sim/host.hh"
|
||||||
#include "sim/universe.hh"
|
#include "sim/universe.hh"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -116,7 +117,7 @@ __warn(const string &format, cp::ArgList &args, const char *func,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
args.dump(cerr, fmt);
|
args.dump(cerr, fmt);
|
||||||
if (outputStream != &cerr && outputStream != &cout)
|
if (simout.isFile(*outputStream))
|
||||||
args.dump(*outputStream, fmt);
|
args.dump(*outputStream, fmt);
|
||||||
|
|
||||||
delete &args;
|
delete &args;
|
||||||
|
|
129
base/output.cc
Normal file
129
base/output.cc
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005 The Regents of The University of Michigan
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met: redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer;
|
||||||
|
* redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution;
|
||||||
|
* neither the name of the copyright holders nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
OutputDirectory simout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
OutputDirectory::OutputDirectory()
|
||||||
|
{}
|
||||||
|
|
||||||
|
OutputDirectory::~OutputDirectory()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void
|
||||||
|
OutputDirectory::setDirectory(const string &d)
|
||||||
|
{
|
||||||
|
if (!dir.empty())
|
||||||
|
panic("Output directory already set!\n");
|
||||||
|
|
||||||
|
dir = d;
|
||||||
|
|
||||||
|
if (dir != ".") {
|
||||||
|
if (mkdir(dir.c_str(), 0777) < 0 && errno != EEXIST)
|
||||||
|
panic("couldn't make output dir %s: %s\n",
|
||||||
|
dir, strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
// guarantee that directory ends with a '/'
|
||||||
|
if (dir[dir.size() - 1] != '/')
|
||||||
|
dir += "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
const string &
|
||||||
|
OutputDirectory::directory()
|
||||||
|
{
|
||||||
|
if (dir.empty())
|
||||||
|
panic("Output directory not set!");
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
OutputDirectory::resolve(const string &name)
|
||||||
|
{
|
||||||
|
return (name[0] != '/') ? dir + name : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream *
|
||||||
|
OutputDirectory::create(const string &name)
|
||||||
|
{
|
||||||
|
if (name == "cerr" || name == "stderr")
|
||||||
|
return &cerr;
|
||||||
|
|
||||||
|
if (name == "cout" || name == "stdout")
|
||||||
|
return &cout;
|
||||||
|
|
||||||
|
ofstream *file = new ofstream(resolve(name).c_str(), ios::trunc);
|
||||||
|
if (!file->is_open())
|
||||||
|
panic("Cannot open file %s", name);
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
ostream *
|
||||||
|
OutputDirectory::find(const string &name)
|
||||||
|
{
|
||||||
|
if (name == "cerr" || name == "stderr")
|
||||||
|
return &cerr;
|
||||||
|
|
||||||
|
if (name == "cout" || name == "stdout")
|
||||||
|
return &cout;
|
||||||
|
|
||||||
|
string filename = resolve(name);
|
||||||
|
map_t::iterator i = files.find(filename);
|
||||||
|
if (i != files.end())
|
||||||
|
return (*i).second;
|
||||||
|
|
||||||
|
ofstream *file = new ofstream(filename.c_str(), ios::trunc);
|
||||||
|
if (!file->is_open())
|
||||||
|
panic("Cannot open file %s", filename);
|
||||||
|
|
||||||
|
files[filename] = file;
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
OutputDirectory::isFile(const std::ostream *os)
|
||||||
|
{
|
||||||
|
return os && os != &cerr && os != &cout;
|
||||||
|
}
|
61
base/output.hh
Normal file
61
base/output.hh
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005 The Regents of The University of Michigan
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met: redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer;
|
||||||
|
* redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution;
|
||||||
|
* neither the name of the copyright holders nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BASE_OUTPUT_HH__
|
||||||
|
#define __BASE_OUTPUT_HH__
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class OutputDirectory
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
typedef std::map<std::string, std::ostream *> map_t;
|
||||||
|
|
||||||
|
map_t files;
|
||||||
|
std::string dir;
|
||||||
|
|
||||||
|
public:
|
||||||
|
OutputDirectory();
|
||||||
|
~OutputDirectory();
|
||||||
|
|
||||||
|
void setDirectory(const std::string &dir);
|
||||||
|
const std::string &directory();
|
||||||
|
|
||||||
|
std::string resolve(const std::string &name);
|
||||||
|
std::ostream *create(const std::string &name);
|
||||||
|
std::ostream *find(const std::string &name);
|
||||||
|
|
||||||
|
static bool isFile(const std::ostream *os);
|
||||||
|
static inline bool isFile(const std::ostream &os) { return isFile(&os); }
|
||||||
|
};
|
||||||
|
|
||||||
|
extern OutputDirectory simout;
|
||||||
|
|
||||||
|
#endif // __BASE_OUTPUT_HH__
|
|
@ -26,13 +26,14 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "base/cprintf.hh"
|
#include "base/cprintf.hh"
|
||||||
#include "base/loader/symtab.hh"
|
#include "base/loader/symtab.hh"
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "cpu/base_cpu.hh"
|
#include "cpu/base_cpu.hh"
|
||||||
#include "cpu/exec_context.hh"
|
#include "cpu/exec_context.hh"
|
||||||
#include "sim/param.hh"
|
#include "sim/param.hh"
|
||||||
|
@ -132,8 +133,7 @@ BaseCPU::BaseCPU(const string &_name, int _number_of_threads, bool _def_reg,
|
||||||
|
|
||||||
functionTracingEnabled = false;
|
functionTracingEnabled = false;
|
||||||
if (_function_trace) {
|
if (_function_trace) {
|
||||||
std::string filename = csprintf("ftrace.%s", name());
|
functionTraceStream = simout.find(csprintf("ftrace.%s", name()));
|
||||||
functionTraceStream = makeOutputStream(filename);
|
|
||||||
currentFunctionStart = currentFunctionEnd = 0;
|
currentFunctionStart = currentFunctionEnd = 0;
|
||||||
functionEntryTick = _function_trace_start;
|
functionEntryTick = _function_trace_start;
|
||||||
|
|
||||||
|
@ -157,11 +157,8 @@ BaseCPU::enableFunctionTrace()
|
||||||
|
|
||||||
BaseCPU::~BaseCPU()
|
BaseCPU::~BaseCPU()
|
||||||
{
|
{
|
||||||
if (functionTracingEnabled)
|
|
||||||
closeOutputStream(functionTraceStream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BaseCPU::init()
|
BaseCPU::init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,14 +36,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "dev/etherdump.hh"
|
#include "dev/etherdump.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
#include "sim/universe.hh"
|
#include "sim/universe.hh"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
EtherDump::EtherDump(const string &name, std::ostream *_stream, int max)
|
EtherDump::EtherDump(const string &name, const string &file, int max)
|
||||||
: SimObject(name), stream(_stream), maxlen(max)
|
: SimObject(name), stream(file.c_str()), maxlen(max)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ EtherDump::init()
|
||||||
hdr.sigfigs = 0;
|
hdr.sigfigs = 0;
|
||||||
hdr.linktype = DLT_EN10MB;
|
hdr.linktype = DLT_EN10MB;
|
||||||
|
|
||||||
stream->write(reinterpret_cast<char *>(&hdr), sizeof(hdr));
|
stream.write(reinterpret_cast<char *>(&hdr), sizeof(hdr));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* output an empty packet with the current time so that we know
|
* output an empty packet with the current time so that we know
|
||||||
|
@ -98,9 +99,9 @@ EtherDump::init()
|
||||||
pkthdr.microseconds = 0;
|
pkthdr.microseconds = 0;
|
||||||
pkthdr.caplen = 0;
|
pkthdr.caplen = 0;
|
||||||
pkthdr.len = 0;
|
pkthdr.len = 0;
|
||||||
stream->write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
|
stream.write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
|
||||||
|
|
||||||
stream->flush();
|
stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -111,9 +112,9 @@ EtherDump::dumpPacket(PacketPtr &packet)
|
||||||
pkthdr.microseconds = (curTick / us_freq) % ULL(1000000);
|
pkthdr.microseconds = (curTick / us_freq) % ULL(1000000);
|
||||||
pkthdr.caplen = std::min(packet->length, maxlen);
|
pkthdr.caplen = std::min(packet->length, maxlen);
|
||||||
pkthdr.len = packet->length;
|
pkthdr.len = packet->length;
|
||||||
stream->write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
|
stream.write(reinterpret_cast<char *>(&pkthdr), sizeof(pkthdr));
|
||||||
stream->write(reinterpret_cast<char *>(packet->data), pkthdr.caplen);
|
stream.write(reinterpret_cast<char *>(packet->data), pkthdr.caplen);
|
||||||
stream->flush();
|
stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherDump)
|
BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherDump)
|
||||||
|
@ -132,7 +133,7 @@ END_INIT_SIM_OBJECT_PARAMS(EtherDump)
|
||||||
|
|
||||||
CREATE_SIM_OBJECT(EtherDump)
|
CREATE_SIM_OBJECT(EtherDump)
|
||||||
{
|
{
|
||||||
return new EtherDump(getInstanceName(), makeOutputStream(file), maxlen);
|
return new EtherDump(getInstanceName(), simout.resolve(file), maxlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_SIM_OBJECT("EtherDump", EtherDump)
|
REGISTER_SIM_OBJECT("EtherDump", EtherDump)
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
class EtherDump : public SimObject
|
class EtherDump : public SimObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::ostream *stream;
|
std::ofstream stream;
|
||||||
const int maxlen;
|
const int maxlen;
|
||||||
void dumpPacket(PacketPtr &packet);
|
void dumpPacket(PacketPtr &packet);
|
||||||
void init();
|
void init();
|
||||||
|
@ -53,7 +53,7 @@ class EtherDump : public SimObject
|
||||||
Tick us_freq;
|
Tick us_freq;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EtherDump(const std::string &name, std::ostream *_stream, int max);
|
EtherDump(const std::string &name, const std::string &file, int max);
|
||||||
|
|
||||||
inline void dump(PacketPtr &pkt) { dumpPacket(pkt); }
|
inline void dump(PacketPtr &pkt) { dumpPacket(pkt); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "base/socket.hh"
|
#include "base/socket.hh"
|
||||||
#include "base/trace.hh"
|
#include "base/trace.hh"
|
||||||
#include "dev/platform.hh"
|
#include "dev/platform.hh"
|
||||||
|
@ -71,7 +72,7 @@ SimConsole::Event::process(int revent)
|
||||||
cons->detach();
|
cons->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimConsole::SimConsole(const string &name, std::ostream *os, int num)
|
SimConsole::SimConsole(const string &name, ostream *os, int num)
|
||||||
: SimObject(name), event(NULL), number(num), in_fd(-1), out_fd(-1),
|
: SimObject(name), event(NULL), number(num), in_fd(-1), out_fd(-1),
|
||||||
listener(NULL), txbuf(16384), rxbuf(16384), outfile(os)
|
listener(NULL), txbuf(16384), rxbuf(16384), outfile(os)
|
||||||
#if TRACING_ON == 1
|
#if TRACING_ON == 1
|
||||||
|
@ -85,8 +86,6 @@ SimConsole::SimConsole(const string &name, std::ostream *os, int num)
|
||||||
SimConsole::~SimConsole()
|
SimConsole::~SimConsole()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
if (outfile)
|
|
||||||
closeOutputStream(outfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -313,18 +312,16 @@ END_INIT_SIM_OBJECT_PARAMS(SimConsole)
|
||||||
|
|
||||||
CREATE_SIM_OBJECT(SimConsole)
|
CREATE_SIM_OBJECT(SimConsole)
|
||||||
{
|
{
|
||||||
string filename;
|
string filename = output;
|
||||||
|
ostream *stream = NULL;
|
||||||
|
|
||||||
if (filename.empty()) {
|
if (!filename.empty()) {
|
||||||
filename = getInstanceName();
|
if (append_name)
|
||||||
} else if (append_name) {
|
filename += "." + getInstanceName();
|
||||||
filename = (string)output + "." + getInstanceName();
|
stream = simout.find(filename);
|
||||||
} else {
|
|
||||||
filename = output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimConsole *console = new SimConsole(getInstanceName(),
|
SimConsole *console = new SimConsole(getInstanceName(), stream, number);
|
||||||
makeOutputStream(filename), number);
|
|
||||||
((ConsoleListener *)listener)->add(console);
|
((ConsoleListener *)listener)->add(console);
|
||||||
|
|
||||||
return console;
|
return console;
|
||||||
|
|
|
@ -6,10 +6,7 @@ from Trace import Trace
|
||||||
simobj Root(SimObject):
|
simobj Root(SimObject):
|
||||||
type = 'Root'
|
type = 'Root'
|
||||||
frequency = Param.Tick(200000000, "tick frequency")
|
frequency = Param.Tick(200000000, "tick frequency")
|
||||||
output_dir = Param.String('.', "directory to output data to")
|
|
||||||
output_file = Param.String('cout', "file to dump simulator output to")
|
output_file = Param.String('cout', "file to dump simulator output to")
|
||||||
config_output_file = Param.String('m5config.out',
|
|
||||||
"file to dump simulator config to")
|
|
||||||
full_system = Param.Bool("Full system simulation?")
|
full_system = Param.Bool("Full system simulation?")
|
||||||
hier = HierParams(do_data = False, do_events = True)
|
hier = HierParams(do_data = False, do_events = True)
|
||||||
checkpoint = Param.String('', "Checkpoint file")
|
checkpoint = Param.String('', "Checkpoint file")
|
||||||
|
|
259
sim/main.cc
259
sim/main.cc
|
@ -42,6 +42,7 @@
|
||||||
#include "base/embedfile.hh"
|
#include "base/embedfile.hh"
|
||||||
#include "base/inifile.hh"
|
#include "base/inifile.hh"
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "base/pollevent.hh"
|
#include "base/pollevent.hh"
|
||||||
#include "base/statistics.hh"
|
#include "base/statistics.hh"
|
||||||
#include "base/str.hh"
|
#include "base/str.hh"
|
||||||
|
@ -109,25 +110,32 @@ abortHandler(int sigtype)
|
||||||
const char *myProgName = "";
|
const char *myProgName = "";
|
||||||
|
|
||||||
/// Show brief help message.
|
/// Show brief help message.
|
||||||
static void
|
void
|
||||||
showBriefHelp(ostream &out)
|
showBriefHelp(ostream &out)
|
||||||
{
|
{
|
||||||
out << "Usage: " << myProgName
|
char *prog = basename(myProgName);
|
||||||
<< " [-hnu] [-Dname[=def]] [-Uname] [-I[dir]] "
|
|
||||||
<< "<config-spec> [<config-spec> ...]\n"
|
ccprintf(out, "Usage:\n");
|
||||||
<< "[] [<config file> ...]\n"
|
ccprintf(out,
|
||||||
<< " -h: print long help (including parameter listing)\n"
|
"%s [-d <dir>] [-E <var>[=<val>]] [-I <dir>] [-P <python>]\n"
|
||||||
<< " -u: don't quit on unreferenced parameters\n"
|
" [--<var>=<val>] <config file>\n"
|
||||||
<< " -D,-U,-I: passed to cpp for preprocessing .ini files\n"
|
"\n"
|
||||||
<< " <config-spec>: config file name (.ini or .py) or\n"
|
" -d set the output directory to <dir>\n"
|
||||||
<< " single param (--<section>:<param>=<value>)"
|
" -E set the environment variable <var> to <val> (or 'True')\n"
|
||||||
<< endl;
|
" -I add the directory <dir> to python's path\n"
|
||||||
|
" -P execute <python> directly in the configuration\n"
|
||||||
|
" --var=val set the python variable <var> to '<val>'\n"
|
||||||
|
" <configfile> config file name (.py or .mpy)\n",
|
||||||
|
prog);
|
||||||
|
|
||||||
|
ccprintf(out, "%s -X\n -X extract embedded files\n", prog);
|
||||||
|
ccprintf(out, "%s -h\n -h print long help\n", prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Show verbose help message. Includes parameter listing from
|
/// Show verbose help message. Includes parameter listing from
|
||||||
/// showBriefHelp(), plus an exhaustive list of ini-file parameters
|
/// showBriefHelp(), plus an exhaustive list of ini-file parameters
|
||||||
/// and SimObjects (with their parameters).
|
/// and SimObjects (with their parameters).
|
||||||
static void
|
void
|
||||||
showLongHelp(ostream &out)
|
showLongHelp(ostream &out)
|
||||||
{
|
{
|
||||||
showBriefHelp(out);
|
showBriefHelp(out);
|
||||||
|
@ -152,7 +160,7 @@ showLongHelp(ostream &out)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Print welcome message.
|
/// Print welcome message.
|
||||||
static void
|
void
|
||||||
sayHello(ostream &out)
|
sayHello(ostream &out)
|
||||||
{
|
{
|
||||||
extern const char *compileDate; // from date.cc
|
extern const char *compileDate; // from date.cc
|
||||||
|
@ -176,7 +184,7 @@ sayHello(ostream &out)
|
||||||
/// Echo the command line for posterity in such a way that it can be
|
/// Echo the command line for posterity in such a way that it can be
|
||||||
/// used to rerun the same simulation (given the same .ini files).
|
/// used to rerun the same simulation (given the same .ini files).
|
||||||
///
|
///
|
||||||
static void
|
void
|
||||||
echoCommandLine(int argc, char **argv, ostream &out)
|
echoCommandLine(int argc, char **argv, ostream &out)
|
||||||
{
|
{
|
||||||
out << "command line: " << argv[0];
|
out << "command line: " << argv[0];
|
||||||
|
@ -208,16 +216,20 @@ echoCommandLine(int argc, char **argv, ostream &out)
|
||||||
out << endl << endl;
|
out << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
getOptionString(int &index, int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *option = argv[index] + 2;
|
||||||
|
if (*option != '\0')
|
||||||
|
return option;
|
||||||
|
|
||||||
///
|
// We didn't find an argument, it must be in the next variable.
|
||||||
/// The simulator configuration database. This is the union of all
|
if (++index >= argc)
|
||||||
/// specified .ini files. This shouldn't need to be visible outside
|
panic("option string for option '%s' not found", argv[index - 1]);
|
||||||
/// this file, as it is passed as a parameter to all the param-parsing
|
|
||||||
/// routines.
|
return argv[index];
|
||||||
///
|
}
|
||||||
static IniFile simConfigDB;
|
|
||||||
|
|
||||||
/// M5 entry point.
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -233,18 +245,9 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
sayHello(cerr);
|
sayHello(cerr);
|
||||||
|
|
||||||
// Initialize statistics database
|
bool configfile_found = false;
|
||||||
Stats::InitSimStats();
|
PythonConfig pyconfig;
|
||||||
|
string outdir;
|
||||||
vector<char *> cppArgs;
|
|
||||||
|
|
||||||
// Should we quit if there are unreferenced parameters? By
|
|
||||||
// default, yes... it's a good way of catching typos in
|
|
||||||
// section/parameter names (which otherwise go by silently). Use
|
|
||||||
// -u to override.
|
|
||||||
bool quitOnUnreferenced = true;
|
|
||||||
|
|
||||||
bool python_initialized = false;
|
|
||||||
|
|
||||||
// Parse command-line options.
|
// Parse command-line options.
|
||||||
// Since most of the complex options are handled through the
|
// Since most of the complex options are handled through the
|
||||||
|
@ -253,12 +256,53 @@ main(int argc, char **argv)
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
char *arg_str = argv[i];
|
char *arg_str = argv[i];
|
||||||
|
|
||||||
// if arg starts with '-', parse as option,
|
// if arg starts with '--', parse as a special python option
|
||||||
// else treat it as a configuration file name and load it
|
// of the format --<python var>=<string value>, if the arg
|
||||||
if (arg_str[0] == '-') {
|
// starts with '-', it should be a simulator option with a
|
||||||
|
// format similar to getopt. In any other case, treat the
|
||||||
|
// option as a configuration file name and load it.
|
||||||
|
if (arg_str[0] == '-' && arg_str[1] == '-') {
|
||||||
|
string str = &arg_str[2];
|
||||||
|
string var, val;
|
||||||
|
|
||||||
|
if (!split_first(str, var, val, '='))
|
||||||
|
panic("Could not parse configuration argument '%s'\n"
|
||||||
|
"Expecting --<variable>=<value>\n", arg_str);
|
||||||
|
|
||||||
|
pyconfig.setVariable(var, val);
|
||||||
|
} else if (arg_str[0] == '-') {
|
||||||
|
char *option;
|
||||||
|
string var, val;
|
||||||
|
|
||||||
// switch on second char
|
// switch on second char
|
||||||
switch (arg_str[1]) {
|
switch (arg_str[1]) {
|
||||||
|
case 'd':
|
||||||
|
outdir = getOptionString(i, argc, argv);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
showLongHelp(cerr);
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
case 'E':
|
||||||
|
option = getOptionString(i, argc, argv);
|
||||||
|
if (!split_first(option, var, val, '='))
|
||||||
|
val = "True";
|
||||||
|
|
||||||
|
if (setenv(var.c_str(), val.c_str(), true) == -1)
|
||||||
|
panic("setenv: %s\n", strerror(errno));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'I':
|
||||||
|
option = getOptionString(i, argc, argv);
|
||||||
|
pyconfig.addPath(option);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'P':
|
||||||
|
option = getOptionString(i, argc, argv);
|
||||||
|
pyconfig.writeLine(option);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'X': {
|
case 'X': {
|
||||||
list<EmbedFile> lst;
|
list<EmbedFile> lst;
|
||||||
EmbedMap::all(lst);
|
EmbedMap::all(lst);
|
||||||
|
@ -274,124 +318,58 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'h':
|
|
||||||
// -h: show help
|
|
||||||
showLongHelp(cerr);
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
case 'u':
|
|
||||||
// -u: don't quit on unreferenced parameters
|
|
||||||
quitOnUnreferenced = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D':
|
|
||||||
case 'U':
|
|
||||||
// cpp options: record & pass to cpp. Note that these
|
|
||||||
// cannot have spaces, i.e., '-Dname=val' is OK, but
|
|
||||||
// '-D name=val' is not. I don't consider this a
|
|
||||||
// problem, since even though gnu cpp accepts the
|
|
||||||
// latter, other cpp implementations do not (Tru64,
|
|
||||||
// for one).
|
|
||||||
cppArgs.push_back(arg_str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'I': {
|
|
||||||
// We push -I as an argument to cpp
|
|
||||||
cppArgs.push_back(arg_str);
|
|
||||||
|
|
||||||
string arg = arg_str + 2;
|
|
||||||
eat_white(arg);
|
|
||||||
|
|
||||||
// Send this as the python path
|
|
||||||
addPythonPath(arg);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 'P':
|
|
||||||
if (!python_initialized) {
|
|
||||||
initPythonConfig();
|
|
||||||
python_initialized = true;
|
|
||||||
}
|
|
||||||
writePythonString(arg_str + 2);
|
|
||||||
writePythonString("\n");
|
|
||||||
|
|
||||||
case 'E':
|
|
||||||
if (putenv(arg_str + 2) == -1)
|
|
||||||
panic("putenv: %s\n", strerror(errno));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '-':
|
|
||||||
// command-line configuration parameter:
|
|
||||||
// '--<section>:<parameter>=<value>'
|
|
||||||
if (!simConfigDB.add(arg_str + 2)) {
|
|
||||||
// parse error
|
|
||||||
ccprintf(cerr,
|
|
||||||
"Could not parse configuration argument '%s'\n"
|
|
||||||
"Expecting --<section>:<parameter>=<value>\n",
|
|
||||||
arg_str);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
showBriefHelp(cerr);
|
showBriefHelp(cerr);
|
||||||
ccprintf(cerr, "Fatal: invalid argument '%s'\n", arg_str);
|
panic("invalid argument '%s'\n", arg_str);
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
string file(arg_str);
|
||||||
// no '-', treat as config file name
|
string base, ext;
|
||||||
|
|
||||||
// make STL string out of file name
|
if (!split_last(file, base, ext, '.') ||
|
||||||
string filename(arg_str);
|
ext != "py" && ext != "mpy")
|
||||||
|
panic("Config file '%s' must end in '.py' or '.mpy'\n", file);
|
||||||
|
|
||||||
int ext_loc = filename.rfind(".");
|
pyconfig.load(file);
|
||||||
|
configfile_found = true;
|
||||||
string ext =
|
|
||||||
(ext_loc != string::npos) ? filename.substr(ext_loc) : "";
|
|
||||||
|
|
||||||
if (ext == ".ini") {
|
|
||||||
if (!simConfigDB.loadCPP(filename, cppArgs)) {
|
|
||||||
cprintf("Error processing file %s\n", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else if (ext == ".py" || ext == ".mpy") {
|
|
||||||
if (!python_initialized) {
|
|
||||||
initPythonConfig();
|
|
||||||
python_initialized = true;
|
|
||||||
}
|
|
||||||
loadPythonConfig(filename);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cprintf("Config file name '%s' must end in '.py' or '.ini'.\n",
|
|
||||||
filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (python_initialized && !finishPythonConfig(simConfigDB)) {
|
if (outdir.empty()) {
|
||||||
cprintf("Error processing python code\n");
|
char *env = getenv("OUTPUT_DIR");
|
||||||
exit(1);
|
outdir = env ? env : ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simout.setDirectory(outdir);
|
||||||
|
|
||||||
|
char *env = getenv("CONFIG_OUTPUT");
|
||||||
|
if (!env)
|
||||||
|
env = "config.out";
|
||||||
|
configStream = simout.find(env);
|
||||||
|
|
||||||
|
if (!configfile_found)
|
||||||
|
panic("no configuration file specified!");
|
||||||
|
|
||||||
// The configuration database is now complete; start processing it.
|
// The configuration database is now complete; start processing it.
|
||||||
|
IniFile inifile;
|
||||||
|
if (!pyconfig.output(inifile))
|
||||||
|
panic("Error processing python code");
|
||||||
|
|
||||||
// Parse and check all non-config-hierarchy parameters.
|
// Initialize statistics database
|
||||||
ParamContext::parseAllContexts(simConfigDB);
|
Stats::InitSimStats();
|
||||||
ParamContext::checkAllContexts();
|
|
||||||
|
|
||||||
// Print header info into stats file. Can't do this sooner since
|
|
||||||
// the stat file name is set via a .ini param... thus it just got
|
|
||||||
// opened above during ParamContext::checkAllContexts().
|
|
||||||
|
|
||||||
// Now process the configuration hierarchy and create the SimObjects.
|
// Now process the configuration hierarchy and create the SimObjects.
|
||||||
ConfigHierarchy configHierarchy(simConfigDB);
|
ConfigHierarchy configHierarchy(inifile);
|
||||||
configHierarchy.build();
|
configHierarchy.build();
|
||||||
configHierarchy.createSimObjects();
|
configHierarchy.createSimObjects();
|
||||||
|
|
||||||
|
// Parse and check all non-config-hierarchy parameters.
|
||||||
|
ParamContext::parseAllContexts(inifile);
|
||||||
|
ParamContext::checkAllContexts();
|
||||||
|
|
||||||
// Print hello message to stats file if it's actually a file. If
|
// Print hello message to stats file if it's actually a file. If
|
||||||
// it's not (i.e. it's cout or cerr) then we already did it above.
|
// it's not (i.e. it's cout or cerr) then we already did it above.
|
||||||
if (outputStream != &cout && outputStream != &cerr)
|
if (simout.isFile(*outputStream))
|
||||||
sayHello(*outputStream);
|
sayHello(*outputStream);
|
||||||
|
|
||||||
// Echo command line and all parameter settings to stats file as well.
|
// Echo command line and all parameter settings to stats file as well.
|
||||||
|
@ -406,13 +384,8 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
// Done processing the configuration database.
|
// Done processing the configuration database.
|
||||||
// Check for unreferenced entries.
|
// Check for unreferenced entries.
|
||||||
if (simConfigDB.printUnreferenced() && quitOnUnreferenced) {
|
if (inifile.printUnreferenced())
|
||||||
cerr << "Fatal: unreferenced .ini sections/entries." << endl
|
panic("unreferenced sections/entries in the intermediate ini file");
|
||||||
<< "If this is not an error, add 'unref_section_ok=y' or "
|
|
||||||
<< "'unref_entries_ok=y' to the appropriate sections "
|
|
||||||
<< "to suppress this message." << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SimObject::regAllStats();
|
SimObject::regAllStats();
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include "base/inifile.hh"
|
#include "base/inifile.hh"
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "base/str.hh"
|
#include "base/str.hh"
|
||||||
#include "base/trace.hh"
|
#include "base/trace.hh"
|
||||||
#include "sim/config_node.hh"
|
#include "sim/config_node.hh"
|
||||||
|
@ -333,7 +334,7 @@ SerializeParamContext::~SerializeParamContext()
|
||||||
void
|
void
|
||||||
SerializeParamContext::checkParams()
|
SerializeParamContext::checkParams()
|
||||||
{
|
{
|
||||||
checkpointDirBase = outputDirectory + (string)serialize_dir;
|
checkpointDirBase = simout.resolve(serialize_dir);
|
||||||
|
|
||||||
// guarantee that directory ends with a '/'
|
// guarantee that directory ends with a '/'
|
||||||
if (checkpointDirBase[checkpointDirBase.size() - 1] != '/')
|
if (checkpointDirBase[checkpointDirBase.size() - 1] != '/')
|
||||||
|
|
|
@ -26,10 +26,6 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -37,6 +33,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/misc.hh"
|
#include "base/misc.hh"
|
||||||
|
#include "base/output.hh"
|
||||||
#include "sim/builder.hh"
|
#include "sim/builder.hh"
|
||||||
#include "sim/host.hh"
|
#include "sim/host.hh"
|
||||||
#include "sim/sim_object.hh"
|
#include "sim/sim_object.hh"
|
||||||
|
@ -51,7 +48,7 @@ double __ticksPerUS;
|
||||||
double __ticksPerNS;
|
double __ticksPerNS;
|
||||||
double __ticksPerPS;
|
double __ticksPerPS;
|
||||||
|
|
||||||
string outputDirectory;
|
bool fullSystem;
|
||||||
ostream *outputStream;
|
ostream *outputStream;
|
||||||
ostream *configStream;
|
ostream *configStream;
|
||||||
|
|
||||||
|
@ -61,81 +58,40 @@ class Root : public SimObject
|
||||||
public:
|
public:
|
||||||
Root(const std::string &name) : SimObject(name) {}
|
Root(const std::string &name) : SimObject(name) {}
|
||||||
};
|
};
|
||||||
Root *root = NULL;
|
|
||||||
|
|
||||||
std::ostream *
|
|
||||||
makeOutputStream(std::string &name)
|
|
||||||
{
|
|
||||||
if (name == "cerr" || name == "stderr")
|
|
||||||
return &std::cerr;
|
|
||||||
|
|
||||||
if (name == "cout" || name == "stdout")
|
|
||||||
return &std::cout;
|
|
||||||
|
|
||||||
string path = (name[0] != '/') ? outputDirectory + name : name;
|
|
||||||
|
|
||||||
// have to dynamically allocate a stream since we're going to
|
|
||||||
// return it... though the caller can't easily free it since it
|
|
||||||
// may be cerr or cout. need GC!
|
|
||||||
ofstream *s = new ofstream(path.c_str(), ios::trunc);
|
|
||||||
|
|
||||||
if (!s->is_open())
|
|
||||||
fatal("Cannot open file %s", path);
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
closeOutputStream(std::ostream *os)
|
|
||||||
{
|
|
||||||
// can't close cerr or cout
|
|
||||||
if (os == &std::cerr || os == &std::cout)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// can only close ofstreams, not generic ostreams, so try to
|
|
||||||
// downcast and close only if the downcast succeeds
|
|
||||||
std::ofstream *ofs = dynamic_cast<std::ofstream *>(os);
|
|
||||||
if (ofs)
|
|
||||||
ofs->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BEGIN_DECLARE_SIM_OBJECT_PARAMS(Root)
|
BEGIN_DECLARE_SIM_OBJECT_PARAMS(Root)
|
||||||
|
|
||||||
Param<bool> full_system;
|
Param<bool> full_system;
|
||||||
Param<Tick> frequency;
|
Param<Tick> frequency;
|
||||||
Param<string> output_dir;
|
|
||||||
Param<string> output_file;
|
Param<string> output_file;
|
||||||
Param<string> config_output_file;
|
|
||||||
|
|
||||||
END_DECLARE_SIM_OBJECT_PARAMS(Root)
|
END_DECLARE_SIM_OBJECT_PARAMS(Root)
|
||||||
|
|
||||||
BEGIN_INIT_SIM_OBJECT_PARAMS(Root)
|
BEGIN_INIT_SIM_OBJECT_PARAMS(Root)
|
||||||
|
|
||||||
INIT_PARAM_DFLT(full_system, "full system simulation", true),
|
INIT_PARAM(full_system, "full system simulation"),
|
||||||
INIT_PARAM_DFLT(frequency, "tick frequency", 200000000),
|
INIT_PARAM(frequency, "tick frequency"),
|
||||||
INIT_PARAM_DFLT(output_dir, "directory to output data to", "."),
|
INIT_PARAM(output_file, "file to dump simulator output to")
|
||||||
INIT_PARAM_DFLT(output_file, "file to dump simulator output to", "cout"),
|
|
||||||
INIT_PARAM_DFLT(config_output_file, "file to dump simulator config to",
|
|
||||||
"m5config.out")
|
|
||||||
|
|
||||||
END_INIT_SIM_OBJECT_PARAMS(Root)
|
END_INIT_SIM_OBJECT_PARAMS(Root)
|
||||||
|
|
||||||
CREATE_SIM_OBJECT(Root)
|
CREATE_SIM_OBJECT(Root)
|
||||||
{
|
{
|
||||||
|
static bool created = false;
|
||||||
|
if (created)
|
||||||
|
panic("only one root object allowed!");
|
||||||
|
|
||||||
|
created = true;
|
||||||
|
fullSystem = full_system;
|
||||||
|
|
||||||
#ifdef FULL_SYSTEM
|
#ifdef FULL_SYSTEM
|
||||||
if (!bool(full_system))
|
if (!fullSystem)
|
||||||
panic("FULL_SYSTEM compiled and configuration not full_system");
|
panic("FULL_SYSTEM compiled and configuration not full_system");
|
||||||
#else
|
#else
|
||||||
if (bool(full_system))
|
if (fullSystem)
|
||||||
panic("FULL_SYSTEM not compiled but configuration is full_system");
|
panic("FULL_SYSTEM not compiled but configuration is full_system");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (root)
|
|
||||||
panic("only one root object allowed!");
|
|
||||||
root = new Root(getInstanceName());
|
|
||||||
|
|
||||||
ticksPerSecond = frequency;
|
ticksPerSecond = frequency;
|
||||||
double freq = double(ticksPerSecond);
|
double freq = double(ticksPerSecond);
|
||||||
__ticksPerMS = freq / 1.0e3;
|
__ticksPerMS = freq / 1.0e3;
|
||||||
|
@ -143,29 +99,9 @@ CREATE_SIM_OBJECT(Root)
|
||||||
__ticksPerNS = freq / 1.0e9;
|
__ticksPerNS = freq / 1.0e9;
|
||||||
__ticksPerPS = freq / 1.0e12;
|
__ticksPerPS = freq / 1.0e12;
|
||||||
|
|
||||||
outputDirectory = output_dir;
|
outputStream = simout.find(output_file);
|
||||||
if (!outputDirectory.empty()) {
|
|
||||||
outputDirectory = output_dir;
|
|
||||||
|
|
||||||
// guarantee that directory ends with a '/'
|
return new Root(getInstanceName());
|
||||||
if (outputDirectory[outputDirectory.size() - 1] != '/')
|
|
||||||
outputDirectory += "/";
|
|
||||||
|
|
||||||
if (mkdir(outputDirectory.c_str(), 0777) < 0) {
|
|
||||||
if (errno != EEXIST) {
|
|
||||||
panic("%s\ncould not make output directory: %s\n",
|
|
||||||
strerror(errno), outputDirectory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outputStream = makeOutputStream(output_file);
|
|
||||||
configStream = outputStream;
|
|
||||||
string cof = config_output_file;
|
|
||||||
if (!cof.empty())
|
|
||||||
configStream = makeOutputStream(cof);
|
|
||||||
|
|
||||||
return root;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_SIM_OBJECT("Root", Root)
|
REGISTER_SIM_OBJECT("Root", Root)
|
||||||
|
|
Loading…
Reference in a new issue