2020-11-10 15:51:46 -06:00
|
|
|
/********************************************************************
|
|
|
|
* This file includes functions that outputs tile annotations to XML format
|
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from system goes first */
|
|
|
|
#include <algorithm>
|
2022-10-06 19:08:50 -05:00
|
|
|
#include <string>
|
2020-11-10 15:51:46 -06:00
|
|
|
|
|
|
|
/* Headers from vtr util library */
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "openfpga_digest.h"
|
2020-11-10 15:51:46 -06:00
|
|
|
#include "vtr_assert.h"
|
|
|
|
#include "vtr_log.h"
|
|
|
|
|
|
|
|
/* Headers from readarchopenfpga library */
|
|
|
|
#include "write_xml_tile_annotation.h"
|
2022-10-06 19:08:50 -05:00
|
|
|
#include "write_xml_utils.h"
|
2020-11-10 15:51:46 -06:00
|
|
|
|
|
|
|
/* namespace openfpga begins */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* A writer to output a device variation in a technology library to XML format
|
|
|
|
*******************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
static void write_xml_tile_annotation_global_port(
|
|
|
|
std::fstream& fp, const char* fname,
|
|
|
|
const openfpga::TileAnnotation& tile_annotation,
|
|
|
|
const TileGlobalPortId& global_port_id) {
|
2020-11-10 15:51:46 -06:00
|
|
|
/* Validate the file stream */
|
|
|
|
openfpga::check_file_stream(fname, fp);
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t\t"
|
|
|
|
<< "<global_port ";
|
|
|
|
|
|
|
|
write_xml_attribute(fp, "name",
|
|
|
|
tile_annotation.global_port_name(global_port_id).c_str());
|
|
|
|
|
|
|
|
write_xml_attribute(fp, "is_clock",
|
|
|
|
tile_annotation.global_port_is_clock(global_port_id));
|
|
|
|
|
|
|
|
write_xml_attribute(fp, "is_set",
|
|
|
|
tile_annotation.global_port_is_set(global_port_id));
|
|
|
|
|
|
|
|
write_xml_attribute(fp, "is_reset",
|
|
|
|
tile_annotation.global_port_is_reset(global_port_id));
|
|
|
|
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "default_value",
|
|
|
|
tile_annotation.global_port_default_value(global_port_id));
|
|
|
|
|
|
|
|
fp << ">"
|
|
|
|
<< "\n";
|
|
|
|
|
|
|
|
for (size_t tile_info_id = 0;
|
|
|
|
tile_info_id <
|
|
|
|
tile_annotation.global_port_tile_names(global_port_id).size();
|
|
|
|
++tile_info_id) {
|
|
|
|
fp << "\t\t\t"
|
|
|
|
<< "<tile ";
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "name",
|
|
|
|
tile_annotation.global_port_tile_names(global_port_id)[tile_info_id]
|
|
|
|
.c_str());
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "port",
|
|
|
|
generate_xml_port_name(
|
|
|
|
tile_annotation.global_port_tile_ports(global_port_id)[tile_info_id])
|
|
|
|
.c_str());
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "x",
|
|
|
|
tile_annotation.global_port_tile_coordinates(global_port_id)[tile_info_id]
|
|
|
|
.x());
|
|
|
|
write_xml_attribute(
|
|
|
|
fp, "y",
|
|
|
|
tile_annotation.global_port_tile_coordinates(global_port_id)[tile_info_id]
|
|
|
|
.y());
|
2021-01-09 19:47:12 -06:00
|
|
|
fp << "/>";
|
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t\t"
|
|
|
|
<< "</global_port>";
|
2020-11-10 15:51:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* A writer to output tile annotations to XML format
|
|
|
|
*******************************************************************/
|
2022-10-06 19:08:50 -05:00
|
|
|
void write_xml_tile_annotations(std::fstream& fp, const char* fname,
|
2020-11-10 15:51:46 -06:00
|
|
|
const TileAnnotation& tile_annotation) {
|
|
|
|
/* Validate the file stream */
|
|
|
|
openfpga::check_file_stream(fname, fp);
|
2022-10-06 19:08:50 -05:00
|
|
|
|
|
|
|
/* Write the root node for pb_type annotations,
|
|
|
|
* we apply a tab becuase pb_type annotations is just a subnode
|
2020-11-10 15:51:46 -06:00
|
|
|
* under the root node <openfpga_arch>
|
|
|
|
*/
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t"
|
|
|
|
<< "<tile_annotations>"
|
|
|
|
<< "\n";
|
|
|
|
|
|
|
|
/* Write device model one by one */
|
|
|
|
for (const TileGlobalPortId& global_port_id :
|
|
|
|
tile_annotation.global_ports()) {
|
|
|
|
write_xml_tile_annotation_global_port(fp, fname, tile_annotation,
|
|
|
|
global_port_id);
|
2020-11-10 15:51:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the root node for pb_type annotations */
|
2022-10-06 19:08:50 -05:00
|
|
|
fp << "\t"
|
|
|
|
<< "</tile_annotations>"
|
|
|
|
<< "\n";
|
2020-11-10 15:51:46 -06:00
|
|
|
}
|
|
|
|
|
2022-10-06 19:08:50 -05:00
|
|
|
} // namespace openfpga
|