/******************************************************************** * This file includes functions that outputs a simulation setting to XML format *******************************************************************/ /* Headers from system goes first */ #include #include /* Headers from vtr util library */ #include "vtr_assert.h" #include "vtr_log.h" #include "openfpga_digest.h" /* Headers from readarchopenfpga library */ #include "write_xml_utils.h" #include "write_xml_simulation_setting.h" /******************************************************************** * A writer to output a clock setting in a simulation setting to XML format *******************************************************************/ static void write_xml_clock_setting(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t" << "" << "\n"; } /******************************************************************** * A writer to output a simulator option in a simulation setting to XML format *******************************************************************/ static void write_xml_simulator_option(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t" << "" << "\n"; } /******************************************************************** * A writer to output a monte carlo simulation setting * in a simulation setting to XML format *******************************************************************/ static void write_xml_monte_carlo(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* This is an optional setting, * If defined, we will output the monte carlo simulation */ if (false == sim_setting.run_monte_carlo_simulation()) { return; } fp << "\t\t" << "" << "\n"; } /******************************************************************** * A writer to output the slew measurement setting in a simulation setting to XML format *******************************************************************/ static void write_xml_slew_measurement(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting, const e_sim_signal_type& signal_type) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t\t\t" << "<" << SIM_SIGNAL_TYPE_STRING[signal_type]; write_xml_attribute(fp, "upper_thres_pct", sim_setting.measure_slew_upper_threshold(signal_type)); write_xml_attribute(fp, "lower_thres_pct", sim_setting.measure_slew_lower_threshold(signal_type)); fp << "/>" << "\n"; } /******************************************************************** * A writer to output the delay measurement setting in a simulation setting to XML format *******************************************************************/ static void write_xml_delay_measurement(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting, const e_sim_signal_type& signal_type) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t\t\t" << "<" << SIM_SIGNAL_TYPE_STRING[signal_type]; write_xml_attribute(fp, "input_thres_pct", sim_setting.measure_delay_input_threshold(signal_type)); write_xml_attribute(fp, "output_thres_pct", sim_setting.measure_delay_output_threshold(signal_type)); fp << "/>" << "\n"; } /******************************************************************** * A writer to output a measurement setting in a simulation setting to XML format *******************************************************************/ static void write_xml_measurement(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; write_xml_slew_measurement(fp, fname, sim_setting, SIM_SIGNAL_RISE); write_xml_slew_measurement(fp, fname, sim_setting, SIM_SIGNAL_FALL); fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; write_xml_delay_measurement(fp, fname, sim_setting, SIM_SIGNAL_RISE); write_xml_delay_measurement(fp, fname, sim_setting, SIM_SIGNAL_FALL); fp << "\t\t" << "" << "\n"; fp << "\t" << "" << "\n"; } /******************************************************************** * A writer to output a stimulus setting in a simulation setting to XML format *******************************************************************/ static void write_xml_stimulus(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t\t" << "" << "\n"; fp << "\t\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t\t\t" << "" << "\n"; fp << "\t\t\t" << "" << "\n"; fp << "\t\t" << "" << "\n"; fp << "\t" << "" << "\n"; } /******************************************************************** * A writer to output a simulation setting to XML format *******************************************************************/ void write_xml_simulation_setting(std::fstream& fp, const char* fname, const openfpga::SimulationSetting& sim_setting) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* Write the root node */ fp << "" << "\n"; /* Write clock settings */ write_xml_clock_setting(fp, fname, sim_setting); /* Write simulator option */ write_xml_simulator_option(fp, fname, sim_setting); /* Write monte carlo simulation setting */ write_xml_monte_carlo(fp, fname, sim_setting); /* Write measurement setting */ write_xml_measurement(fp, fname, sim_setting); /* Write stimuli setting */ write_xml_stimulus(fp, fname, sim_setting); /* Write the root node */ fp << "" << "\n"; }