From f26550141fd4f1a11ac382b3da6c1f358f23cd9c Mon Sep 17 00:00:00 2001 From: tangxifan Date: Wed, 10 Jun 2020 15:56:37 -0600 Subject: [PATCH] add missing files --- .../test/read_arch_openfpga.cpp | 37 +++++++++++++++++++ .../test/read_simulation_setting_openfpga.cpp | 31 ++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 libopenfpga/libarchopenfpga/test/read_arch_openfpga.cpp create mode 100644 libopenfpga/libarchopenfpga/test/read_simulation_setting_openfpga.cpp diff --git a/libopenfpga/libarchopenfpga/test/read_arch_openfpga.cpp b/libopenfpga/libarchopenfpga/test/read_arch_openfpga.cpp new file mode 100644 index 000000000..7974cf258 --- /dev/null +++ b/libopenfpga/libarchopenfpga/test/read_arch_openfpga.cpp @@ -0,0 +1,37 @@ +/******************************************************************** + * Unit test functions to validate the correctness of + * 1. parser of data structures + * 2. writer of data structures + *******************************************************************/ +/* Headers from vtrutils */ +#include "vtr_assert.h" +#include "vtr_log.h" + +/* Headers from readarchopenfpga */ +#include "check_circuit_library.h" +#include "read_xml_openfpga_arch.h" +#include "write_xml_openfpga_arch.h" + +int main(int argc, const char** argv) { + /* Ensure we have only one or two argument */ + VTR_ASSERT((2 == argc) || (3 == argc)); + + /* Parse the circuit library from an XML file */ + const openfpga::Arch& openfpga_arch = read_xml_openfpga_arch(argv[1]); + VTR_LOG("Parsed %lu circuit models from XML into circuit library.\n", + openfpga_arch.circuit_lib.num_models()); + + /* Check the circuit library */ + check_circuit_library(openfpga_arch.circuit_lib); + + /* Output the circuit library to an XML file + * This is optional only used when there is a second argument + */ + if (3 <= argc) { + write_xml_openfpga_arch(argv[2], openfpga_arch); + VTR_LOG("Echo the OpenFPGA architecture to an XML file: %s.\n", + argv[2]); + } +} + + diff --git a/libopenfpga/libarchopenfpga/test/read_simulation_setting_openfpga.cpp b/libopenfpga/libarchopenfpga/test/read_simulation_setting_openfpga.cpp new file mode 100644 index 000000000..b8540240b --- /dev/null +++ b/libopenfpga/libarchopenfpga/test/read_simulation_setting_openfpga.cpp @@ -0,0 +1,31 @@ +/******************************************************************** + * Unit test functions to validate the correctness of + * 1. parser of data structures + * 2. writer of data structures + *******************************************************************/ +/* Headers from vtrutils */ +#include "vtr_assert.h" +#include "vtr_log.h" + +/* Headers from readarchopenfpga */ +#include "read_xml_openfpga_arch.h" +#include "write_xml_openfpga_arch.h" + +int main(int argc, const char** argv) { + /* Ensure we have only one or two argument */ + VTR_ASSERT((2 == argc) || (3 == argc)); + + /* Parse the simulation settings from an XML file */ + const openfpga::SimulationSetting& openfpga_sim_setting = read_xml_openfpga_simulation_settings(argv[1]); + VTR_LOG("Parsed simulation settings from XML %s.\n", + argv[1]); + + /* Output the simulation settings to an XML file + * This is optional only used when there is a second argument + */ + if (3 <= argc) { + write_xml_openfpga_simulation_settings(argv[2], openfpga_sim_setting); + VTR_LOG("Echo the OpenFPGA simulation settings to an XML file: %s.\n", + argv[2]); + } +}