[lib] format fabric key writer

This commit is contained in:
tangxifan 2023-07-06 19:21:45 -07:00
parent 85f9899588
commit d0831507c0
2 changed files with 15 additions and 10 deletions

View File

@ -1,9 +1,11 @@
<fabric_key>
<region id="0">
<key id="0" name="sb" value="0"/>
<key id="2" name="cb" value="10"/>
<key id="1" name="sb" value="7"/>
<key id="3" name="clb" value="53"/>
<key id="4" name="bram" value="32"/>
</region>
<module name="fpga_top">
<region id="0">
<key id="0" name="sb" value="0"/>
<key id="2" name="cb" value="10"/>
<key id="1" name="sb" value="7"/>
<key id="3" name="clb" value="53"/>
<key id="4" name="bram" value="32"/>
</region>
</module>
</fabric_key>

View File

@ -75,13 +75,14 @@ static int write_xml_fabric_component_sub_key(
*******************************************************************/
static int write_xml_fabric_component_key(std::fstream& fp,
const FabricKey& fabric_key,
const FabricKeyId& component_key) {
const FabricKeyId& component_key,
const size_t& level) {
/* Validate the file stream */
if (false == openfpga::valid_file_stream(fp)) {
return 2;
}
openfpga::write_tab_to_file(fp, 2);
openfpga::write_tab_to_file(fp, level);
fp << "<" << XML_FABRIC_KEY_KEY_NODE_NAME;
if (false == fabric_key.valid_key_id(component_key)) {
@ -253,7 +254,7 @@ static int write_xml_top_module_keys(std::fstream& fp,
/* Write component by component */
for (const FabricKeyId& key : fabric_key.region_keys(region)) {
err_code = write_xml_fabric_component_key(fp, fabric_key, key);
err_code = write_xml_fabric_component_key(fp, fabric_key, key, level + 2);
if (0 != err_code) {
return err_code;
}
@ -264,6 +265,7 @@ static int write_xml_top_module_keys(std::fstream& fp,
<< "\n";
}
openfpga::write_tab_to_file(fp, level);
fp << "</" << XML_FABRIC_KEY_MODULE_NODE_NAME << ">\n";
return err_code;
@ -292,6 +294,7 @@ static int write_xml_module_keys(std::fstream& fp, const FabricKey& fabric_key,
key_idx++;
}
openfpga::write_tab_to_file(fp, level);
fp << "</" << XML_FABRIC_KEY_MODULE_NODE_NAME << ">\n";
return err_code;