/******************************************************************** * This file includes functions that outputs a configuration protocol to XML format *******************************************************************/ /* Headers from system goes first */ #include #include /* Headers from vtr util library */ #include "vtr_assert.h" #include "vtr_log.h" #include "vtr_time.h" #include "openfpga_digest.h" /* Headers from arch openfpga library */ #include "write_xml_utils.h" /* Headers from fabrickey library */ #include "write_xml_fabric_key.h" /******************************************************************** * A writer to output a component key to XML format * * Return 0 if successful * Return 1 if there are more serious bugs in the architecture * Return 2 if fail when creating files *******************************************************************/ static int write_xml_fabric_component_key(std::fstream& fp, const FabricKey& fabric_key, const FabricKeyId& component_key) { /* Validate the file stream */ if (false == openfpga::valid_file_stream(fp)) { return 2; } fp << "\t" << "" << "\n"; return 0; } /******************************************************************** * A writer to output a fabric key to XML format * * Return 0 if successful * Return 1 if there are more serious bugs in the architecture * Return 2 if fail when creating files *******************************************************************/ int write_xml_fabric_key(const char* fname, const FabricKey& fabric_key) { vtr::ScopedStartFinishTimer timer("Write Fabric Key"); /* Create a file handler */ std::fstream fp; /* Open the file stream */ fp.open(std::string(fname), std::fstream::out | std::fstream::trunc); /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* Write the root node */ fp << "" << "\n"; int err_code = 0; /* Write component by component */ for (const FabricKeyId& key : fabric_key.keys()) { err_code = write_xml_fabric_component_key(fp, fabric_key, key); if (0 != err_code) { return err_code; } } /* Finish writing the root node */ fp << "" << "\n"; /* Close the file stream */ fp.close(); return err_code; }