2017-09-18 07:30:54 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2017-09-18 12:18:55 +02:00
|
|
|
// Copyright 2017 eyck@minres.com
|
2017-09-25 22:00:46 +02:00
|
|
|
//
|
2017-09-18 07:30:54 +02:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
// use this file except in compliance with the License. You may obtain a copy
|
|
|
|
// of the License at
|
2017-09-25 22:00:46 +02:00
|
|
|
//
|
2017-09-18 07:30:54 +02:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2017-09-25 22:00:46 +02:00
|
|
|
//
|
2017-09-18 07:30:54 +02:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing permissions and limitations under
|
|
|
|
// the License.
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/*
|
|
|
|
* sc_main.cpp
|
|
|
|
*
|
|
|
|
* Created on: 17.09.2017
|
2017-09-18 12:18:55 +02:00
|
|
|
* Author: eyck@minres.com
|
2017-09-18 07:30:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "simple_system.h"
|
|
|
|
#include <boost/program_options.hpp>
|
2017-09-19 17:02:23 +02:00
|
|
|
#include <sstream>
|
2017-10-04 15:16:52 +02:00
|
|
|
#include <scc/report.h>
|
|
|
|
#include <scc/scv_tr_db.h>
|
|
|
|
#include <scc/tracer.h>
|
2018-09-29 20:01:11 +02:00
|
|
|
#include <util/logging.h>
|
2017-09-18 07:30:54 +02:00
|
|
|
|
|
|
|
using namespace sysc;
|
2017-10-04 15:16:52 +02:00
|
|
|
using namespace scc;
|
2017-09-18 07:30:54 +02:00
|
|
|
namespace po = boost::program_options;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
const size_t ERROR_IN_COMMAND_LINE = 1;
|
|
|
|
const size_t SUCCESS = 0;
|
|
|
|
const size_t ERROR_UNHANDLED_EXCEPTION = 2;
|
|
|
|
} // namespace
|
|
|
|
|
2017-09-25 22:00:46 +02:00
|
|
|
int sc_main(int argc, char *argv[]) {
|
2017-09-18 07:30:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// CLI argument parsing
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2017-09-25 22:00:46 +02:00
|
|
|
po::options_description desc("Options");
|
2018-03-27 21:10:22 +02:00
|
|
|
// clang-format off
|
|
|
|
desc.add_options()
|
|
|
|
("help,h", "Print help message")
|
|
|
|
("debug,d", "set debug level")
|
|
|
|
("trace,t", "trace SystemC signals");
|
|
|
|
// clang-format on
|
2017-09-18 07:30:54 +02:00
|
|
|
po::variables_map vm;
|
|
|
|
try {
|
|
|
|
po::store(po::parse_command_line(argc, argv, desc), vm); // can throw
|
|
|
|
// --help option
|
2017-09-25 22:00:46 +02:00
|
|
|
if (vm.count("help")) {
|
2017-09-18 07:30:54 +02:00
|
|
|
std::cout << "JIT-ISS simulator for AVR" << std::endl << desc << std::endl;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
po::notify(vm); // throws on error, so do after help in case
|
|
|
|
// there are any problems
|
2017-09-25 22:00:46 +02:00
|
|
|
} catch (po::error &e) {
|
2017-09-18 07:30:54 +02:00
|
|
|
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
|
|
|
|
std::cerr << desc << std::endl;
|
|
|
|
return ERROR_IN_COMMAND_LINE;
|
|
|
|
}
|
2018-09-29 20:01:11 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// configure logging
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
scc::init_logging(vm.count("debug")?logging::DEBUG:logging::INFO);
|
2018-03-27 21:10:22 +02:00
|
|
|
|
2017-09-18 07:30:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// set up tracing & transaction recording
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2018-11-06 13:22:05 +01:00
|
|
|
tracer trace("simple_system", tracer::COMPRESSED, vm.count("trace"));
|
2017-09-21 11:25:07 +02:00
|
|
|
// todo: fix displayed clock period in VCD
|
|
|
|
|
2017-09-18 07:30:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2017-09-18 10:00:35 +02:00
|
|
|
// instantiate top level
|
2017-09-18 07:30:54 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
simple_system i_simple_system("i_simple_system");
|
2017-09-19 17:02:23 +02:00
|
|
|
|
2017-09-18 10:00:35 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// run simulation
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2017-09-21 11:25:07 +02:00
|
|
|
sc_start(sc_core::sc_time(1, sc_core::SC_MS));
|
|
|
|
// todo: provide end-of-simulation macros
|
|
|
|
|
2017-09-25 22:00:46 +02:00
|
|
|
if (!sc_core::sc_end_of_simulation_invoked()) {
|
2018-09-29 20:01:11 +02:00
|
|
|
SCERR() << "simulation timed out";
|
2017-09-25 22:00:46 +02:00
|
|
|
sc_core::sc_stop();
|
2017-09-21 11:25:07 +02:00
|
|
|
}
|
2018-03-27 21:10:22 +02:00
|
|
|
return SUCCESS;
|
2017-09-18 07:30:54 +02:00
|
|
|
}
|