/******************************************************************** * This file includes functions that outputs a circuit library to XML format *******************************************************************/ /* Headers from system goes first */ #include /* Headers from vtr util library */ #include "vtr_log.h" #include "openfpga_digest.h" /* Headers from readarchopenfpga library */ #include "write_xml_utils.h" #include "write_xml_circuit_library.h" /******************************************************************** * A writer to output the design technology of a circuit model to XML format *******************************************************************/ static void write_xml_design_technology(std::fstream& fp, const char* fname, const CircuitLibrary& circuit_lib, const CircuitModelId& model) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); fp << "\t\t\t" << "" << "\n"; } /******************************************************************** * A writer to output a circuit port to XML format *******************************************************************/ static void write_xml_circuit_port(std::fstream& fp, const char* fname, const CircuitLibrary& circuit_lib, const CircuitPortId& port) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* Get the parent circuit model for this port */ const CircuitModelId& model = circuit_lib.port_parent_model(port); /* Generic information about a port */ fp << "\t\t\t" << "" << "\n"; } /******************************************************************** * A writer to output a circuit model to XML format *******************************************************************/ static void write_xml_circuit_model(std::fstream& fp, const char* fname, const CircuitLibrary& circuit_lib, const CircuitModelId& model) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* Write the definition of circuit model */ fp << "\t\t" << "" << "\n"; /* Write the design technology of circuit model */ write_xml_design_technology(fp, fname, circuit_lib, model); /* Write the input buffer information of circuit model, * only applicable when this circuit model is neither inverter nor buffer */ if (CIRCUIT_MODEL_INVBUF != circuit_lib.model_type(model)) { if (true == circuit_lib.is_input_buffered(model)) { fp << "\t\t\t" << "" << "\n"; } } /* Write the output buffer information of circuit model */ if (CIRCUIT_MODEL_INVBUF != circuit_lib.model_type(model)) { if (true == circuit_lib.is_output_buffered(model)) { fp << "\t\t\t" << "" << "\n"; } } if (CIRCUIT_MODEL_LUT == circuit_lib.model_type(model)) { /* Write the lut input buffer information of circuit model * This is a mandatory attribute for LUT, so it must exist */ fp << "\t\t\t" << "" << "\n"; /* Write the lut input inverter information of circuit model * This is a mandatory attribute for LUT, so it must exist */ fp << "\t\t\t" << "" << "\n"; /* Write the lut intermediate buffer information of circuit model */ if (true == circuit_lib.is_lut_intermediate_buffered(model)) { fp << "\t\t\t" << "" << "\n"; } } /* Write the pass-gate-logic information of circuit model */ if ( (CIRCUIT_MODEL_LUT == circuit_lib.model_type(model)) || (CIRCUIT_MODEL_MUX == circuit_lib.model_type(model)) ) { fp << "\t\t\t" << "" << "\n"; } /* Write the ports of circuit model */ for (const CircuitPortId& port : circuit_lib.model_ports(model)) { write_xml_circuit_port(fp, fname, circuit_lib, port); } /* TODO: Write the wire parasticis of circuit model */ /* TODO: Write the delay matrix of circuit model */ /* Put an end to the XML definition of this circuit model */ fp << "\t\t" << "\n"; } /******************************************************************** * A writer to output a circuit library to XML format * Note: * This function should be run after that the following methods of * CircuitLibrary are executed * 1. build_model_links(); * 2. build_timing_graph(); *******************************************************************/ void write_xml_circuit_library(std::fstream& fp, const char* fname, const CircuitLibrary& circuit_lib) { /* Validate the file stream */ openfpga::check_file_stream(fname, fp); /* Write the root node for circuit_library, * we apply a tab becuase circuit library is a subnode * under the root node */ fp << "\t" << "" << "\n"; /* Write circuit model one by one */ for (const CircuitModelId& model : circuit_lib.models()) { write_xml_circuit_model(fp, fname, circuit_lib, model); } /* Write the root node for circuit_library */ fp << "\t" << "" << "\n"; }