diff --git a/libopenfpga/libarchopenfpga/arch/sample_arch.xml b/libopenfpga/libarchopenfpga/arch/sample_arch.xml
index 0b39e54b0..5d7809c26 100644
--- a/libopenfpga/libarchopenfpga/arch/sample_arch.xml
+++ b/libopenfpga/libarchopenfpga/arch/sample_arch.xml
@@ -278,12 +278,12 @@
-
-
+
+
-
-
+
+
diff --git a/libopenfpga/libarchopenfpga/src/simulation_setting.cpp b/libopenfpga/libarchopenfpga/src/simulation_setting.cpp
index 08b04cb03..2e332a29d 100644
--- a/libopenfpga/libarchopenfpga/src/simulation_setting.cpp
+++ b/libopenfpga/libarchopenfpga/src/simulation_setting.cpp
@@ -53,10 +53,6 @@ e_sim_accuracy_type SimulationSetting::simulation_accuracy_type() const {
}
float SimulationSetting::simulation_accuracy() const {
- /* If fractional accuracy is selected, we give a zero accuracy */
- if (SIM_ACCURACY_FRAC == simulation_accuracy_type()) {
- return 0.;
- }
return simulation_accuracy_;
}
@@ -97,10 +93,6 @@ e_sim_accuracy_type SimulationSetting::stimuli_clock_slew_type(const e_sim_signa
}
float SimulationSetting::stimuli_clock_slew(const e_sim_signal_type& signal_type) const {
- /* If fractional accuracy is selected, we give a zero accuracy */
- if (SIM_ACCURACY_FRAC == stimuli_clock_slew_type(signal_type)) {
- return 0.;
- }
return clock_slews_[signal_type];
}
@@ -109,10 +101,6 @@ e_sim_accuracy_type SimulationSetting::stimuli_input_slew_type(const e_sim_signa
}
float SimulationSetting::stimuli_input_slew(const e_sim_signal_type& signal_type) const {
- /* If fractional accuracy is selected, we give a zero accuracy */
- if (SIM_ACCURACY_FRAC == stimuli_input_slew_type(signal_type)) {
- return 0.;
- }
return input_slews_[signal_type];
}
@@ -153,10 +141,6 @@ void SimulationSetting::set_simulation_accuracy_type(const e_sim_accuracy_type&
}
void SimulationSetting::set_simulation_accuracy(const float& accuracy) {
- /* If fractional accuracy is selected, we do nothing */
- if (SIM_ACCURACY_FRAC == simulation_accuracy_type()) {
- return;
- }
simulation_accuracy_ = accuracy;
}
@@ -204,10 +188,6 @@ void SimulationSetting::set_stimuli_clock_slew_type(const e_sim_signal_type& sig
void SimulationSetting::set_stimuli_clock_slew(const e_sim_signal_type& signal_type,
const float& clock_slew) {
- /* If fractional accuracy is selected, we do nothing */
- if (SIM_ACCURACY_FRAC == stimuli_clock_slew_type(signal_type)) {
- return;
- }
clock_slews_[signal_type] = clock_slew;
}
@@ -219,10 +199,6 @@ void SimulationSetting::set_stimuli_input_slew_type(const e_sim_signal_type& sig
void SimulationSetting::set_stimuli_input_slew(const e_sim_signal_type& signal_type,
const float& input_slew) {
- /* If fractional accuracy is selected, we do nothing */
- if (SIM_ACCURACY_FRAC == stimuli_input_slew_type(signal_type)) {
- return;
- }
input_slews_[signal_type] = input_slew;
}
diff --git a/libopenfpga/libarchopenfpga/src/simulation_setting.h b/libopenfpga/libarchopenfpga/src/simulation_setting.h
index 0b3f51aa1..f2e4add5c 100644
--- a/libopenfpga/libarchopenfpga/src/simulation_setting.h
+++ b/libopenfpga/libarchopenfpga/src/simulation_setting.h
@@ -32,7 +32,7 @@ enum e_sim_accuracy_type {
NUM_SIM_ACCURACY_TYPES
};
/* Strings correspond to each accuracy type */
-constexpr std::array SIM_ACCUARCY_TYPE_STRING = {{"frac", "abs"}};
+constexpr std::array SIM_ACCURACY_TYPE_STRING = {{"frac", "abs"}};
/********************************************************************
* A data structure to describe simulation settings
diff --git a/libopenfpga/libarchopenfpga/src/write_xml_openfpga_arch.cpp b/libopenfpga/libarchopenfpga/src/write_xml_openfpga_arch.cpp
index 7e6f1dc25..20201e995 100644
--- a/libopenfpga/libarchopenfpga/src/write_xml_openfpga_arch.cpp
+++ b/libopenfpga/libarchopenfpga/src/write_xml_openfpga_arch.cpp
@@ -10,6 +10,7 @@
/* Headers from readarchopenfpga library */
#include "write_xml_circuit_library.h"
#include "write_xml_technology_library.h"
+#include "write_xml_simulation_setting.h"
#include "write_xml_openfpga_arch.h"
/********************************************************************
@@ -34,5 +35,8 @@ void write_xml_openfpga_arch(const char* fname,
/* Write the circuit library */
write_xml_circuit_library(fp, fname, openfpga_arch.circuit_lib);
+ /* Write the simulation */
+ write_xml_simulation_setting(fp, fname, openfpga_arch.sim_setting);
+
fp << "" << "\n";
}
diff --git a/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.cpp b/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.cpp
new file mode 100644
index 000000000..c5ff0beca
--- /dev/null
+++ b/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.cpp
@@ -0,0 +1,244 @@
+/********************************************************************
+ * 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 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 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 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 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 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 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 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 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";
+}
diff --git a/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.h b/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.h
new file mode 100644
index 000000000..1c23ef0ca
--- /dev/null
+++ b/libopenfpga/libarchopenfpga/src/write_xml_simulation_setting.h
@@ -0,0 +1,17 @@
+#ifndef WRITE_XML_SIMULATION_SETTING_H
+#define WRITE_XML_SIMULATION_SETTING_H
+
+/********************************************************************
+ * Include header files that are required by function declaration
+ *******************************************************************/
+#include
+#include "simulation_setting.h"
+
+/********************************************************************
+ * Function declaration
+ *******************************************************************/
+void write_xml_simulation_setting(std::fstream& fp,
+ const char* fname,
+ const SimulationSetting& sim_setting);
+
+#endif