Introduce SimulationTime config
Use SimulationTime to forcefully stop simulation at a specified point in time.
This commit is contained in:
@@ -72,6 +72,7 @@ struct SimConfig
|
||||
std::optional<bool> ThermalSimulation;
|
||||
std::optional<bool> UseMalloc;
|
||||
std::optional<unsigned int> WindowSize;
|
||||
std::optional<double> SimulationTime;
|
||||
};
|
||||
|
||||
NLOHMANN_JSONIFY_ALL_THINGS(SimConfig,
|
||||
@@ -86,7 +87,8 @@ NLOHMANN_JSONIFY_ALL_THINGS(SimConfig,
|
||||
StoreMode,
|
||||
ThermalSimulation,
|
||||
UseMalloc,
|
||||
WindowSize)
|
||||
WindowSize,
|
||||
SimulationTime)
|
||||
|
||||
} // namespace DRAMSys::Config
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ int sc_main(int argc, char** argv)
|
||||
DRAMSys::Config::from_path(baseConfig.c_str(), resourceDirectory.c_str());
|
||||
|
||||
Simulator simulator(std::move(configuration), std::move(resourceDirectory));
|
||||
Simulator::run();
|
||||
simulator.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,15 @@ void Simulator::run()
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Start the SystemC simulation
|
||||
sc_core::sc_start();
|
||||
if (configuration.simconfig.SimulationTime.has_value())
|
||||
{
|
||||
sc_core::sc_start(
|
||||
sc_core::sc_time(configuration.simconfig.SimulationTime.value(), sc_core::SC_SEC));
|
||||
}
|
||||
else
|
||||
{
|
||||
sc_core::sc_start();
|
||||
}
|
||||
|
||||
if (!sc_core::sc_end_of_simulation_invoked())
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
Simulator(DRAMSys::Config::Configuration configuration,
|
||||
std::filesystem::path resourceDirectory);
|
||||
|
||||
static void run();
|
||||
void run();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Initiator> instantiateInitiator(const DRAMSys::Config::Initiator& initiator);
|
||||
|
||||
Reference in New Issue
Block a user