2020-01-18 22:19:20 -06:00
|
|
|
/********************************************************************
|
2022-10-06 19:08:50 -05:00
|
|
|
* This file includes functions that outputs a configuration protocol to XML
|
|
|
|
*format
|
2020-01-18 22:19:20 -06:00
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from system goes first */
|
|
|
|
#include <algorithm>
|
2022-10-06 19:08:50 -05:00
|
|
|
#include <string>
|
2020-01-18 22:19:20 -06:00
|
|
|
|
|
|
|
/* Headers from vtr util library */
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "openfpga_digest.h"
|
2020-01-18 22:19:20 -06:00
|
|
|
#include "vtr_assert.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
|
|
|
/* Headers from readarchopenfpga library */
|
|
|
|
#include "write_xml_config_protocol.h"
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "write_xml_utils.h"
|
2020-01-18 22:19:20 -06:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* A writer to output a configuration memory organization to XML format
|
|
|
|
*******************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
static void write_xml_config_organization(std::fstream& fp, const char* fname,
|
|
|
|
const ConfigProtocol& config_protocol,
|
|
|
|
const CircuitLibrary& circuit_lib) {
|
2020-01-18 22:19:20 -06:00
|
|
|
/* Validate the file stream */
|
|
|
|
openfpga::check_file_stream(fname, fp);
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t\t"
|
|
|
|
<< "<organization";
|
|
|
|
write_xml_attribute(fp, "type",
|
|
|
|
CONFIG_PROTOCOL_TYPE_STRING[config_protocol.type()]);
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "circuit_model_name",
|
|
|
|
circuit_lib.model_name(config_protocol.memory_model()).c_str());
|
|
|
|
fp << "/>"
|
|
|
|
<< "\n";
|
2020-01-18 22:19:20 -06:00
|
|
|
|
2021-09-28 16:20:35 -05:00
|
|
|
/* Output BL/WL protocols */
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t\t\t"
|
|
|
|
<< "<bl";
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "protocol",
|
|
|
|
BLWL_PROTOCOL_TYPE_STRING[config_protocol.bl_protocol_type()]);
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "circuit_model_name",
|
|
|
|
circuit_lib.model_name(config_protocol.bl_memory_model()).c_str());
|
2021-09-28 16:20:35 -05:00
|
|
|
write_xml_attribute(fp, "num_banks", config_protocol.bl_num_banks());
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "/>"
|
|
|
|
<< "\n";
|
2021-09-28 16:20:35 -05:00
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t\t\t"
|
|
|
|
<< "<wl";
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "protocol",
|
|
|
|
BLWL_PROTOCOL_TYPE_STRING[config_protocol.wl_protocol_type()]);
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "circuit_model_name",
|
|
|
|
circuit_lib.model_name(config_protocol.wl_memory_model()).c_str());
|
2021-09-28 16:20:35 -05:00
|
|
|
write_xml_attribute(fp, "num_banks", config_protocol.wl_num_banks());
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "/>"
|
|
|
|
<< "\n";
|
2021-09-28 16:20:35 -05:00
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t"
|
|
|
|
<< "</organization>"
|
|
|
|
<< "\n";
|
2020-01-18 22:19:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* A writer to output a configuration protocol to XML format
|
|
|
|
* Note:
|
|
|
|
* This function should be run AFTER the function
|
|
|
|
* link_config_protocol_to_circuit_library()
|
|
|
|
*******************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
void write_xml_config_protocol(std::fstream& fp, const char* fname,
|
2020-01-18 22:19:20 -06:00
|
|
|
const ConfigProtocol& config_protocol,
|
|
|
|
const CircuitLibrary& circuit_lib) {
|
|
|
|
/* Validate the file stream */
|
|
|
|
openfpga::check_file_stream(fname, fp);
|
2022-10-06 19:08:50 -05:00
|
|
|
|
2020-01-18 22:19:20 -06:00
|
|
|
/* Write the root node */
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t"
|
|
|
|
<< "<configuration_protocol>"
|
|
|
|
<< "\n";
|
2020-01-18 22:19:20 -06:00
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
/* Write configuration memory organization */
|
2020-01-18 22:19:20 -06:00
|
|
|
write_xml_config_organization(fp, fname, config_protocol, circuit_lib);
|
|
|
|
|
|
|
|
/* Finish writing the root node */
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t"
|
|
|
|
<< "</configuration_protocol>"
|
|
|
|
<< "\n";
|
2020-01-18 22:19:20 -06:00
|
|
|
}
|