diff --git a/libopenfpga/libfpgabitstream/src/bitstream_manager.cpp b/libopenfpga/libfpgabitstream/src/bitstream_manager.cpp index 990423802..eb62222fb 100644 --- a/libopenfpga/libfpgabitstream/src/bitstream_manager.cpp +++ b/libopenfpga/libfpgabitstream/src/bitstream_manager.cpp @@ -123,14 +123,14 @@ int BitstreamManager::block_path_id(const ConfigBlockId& block_id) const { return block_path_ids_[block_id]; } -std::vector BitstreamManager::block_input_net_ids(const ConfigBlockId& block_id) const { +std::string BitstreamManager::block_input_net_ids(const ConfigBlockId& block_id) const { /* Ensure the input ids are valid */ VTR_ASSERT(true == valid_block_id(block_id)); return block_input_net_ids_[block_id]; } -std::vector BitstreamManager::block_output_net_ids(const ConfigBlockId& block_id) const { +std::string BitstreamManager::block_output_net_ids(const ConfigBlockId& block_id) const { /* Ensure the input ids are valid */ VTR_ASSERT(true == valid_block_id(block_id)); @@ -246,29 +246,13 @@ void BitstreamManager::add_path_id_to_block(const ConfigBlockId& block, const in block_path_ids_[block] = path_id; } -void BitstreamManager::reserve_block_input_net_ids(const ConfigBlockId& block, - const size_t& num_input_net_ids) { - /* Ensure the input ids are valid */ - VTR_ASSERT(true == valid_block_id(block)); - - block_input_net_ids_[block].reserve(num_input_net_ids); -} - void BitstreamManager::add_input_net_id_to_block(const ConfigBlockId& block, const std::string& input_net_id) { /* Ensure the input ids are valid */ VTR_ASSERT(true == valid_block_id(block)); /* Add the bit to the block */ - block_input_net_ids_[block].push_back(input_net_id); -} - -void BitstreamManager::reserve_block_output_net_ids(const ConfigBlockId& block, - const size_t& num_output_net_ids) { - /* Ensure the input ids are valid */ - VTR_ASSERT(true == valid_block_id(block)); - - block_output_net_ids_[block].reserve(num_output_net_ids); + block_input_net_ids_[block] = input_net_id; } void BitstreamManager::add_output_net_id_to_block(const ConfigBlockId& block, @@ -277,7 +261,7 @@ void BitstreamManager::add_output_net_id_to_block(const ConfigBlockId& block, VTR_ASSERT(true == valid_block_id(block)); /* Add the bit to the block */ - block_output_net_ids_[block].push_back(output_net_id); + block_output_net_ids_[block] = output_net_id; } /****************************************************************************** diff --git a/libopenfpga/libfpgabitstream/src/bitstream_manager.h b/libopenfpga/libfpgabitstream/src/bitstream_manager.h index 6f2e56c38..84c3ec97c 100644 --- a/libopenfpga/libfpgabitstream/src/bitstream_manager.h +++ b/libopenfpga/libfpgabitstream/src/bitstream_manager.h @@ -138,10 +138,10 @@ class BitstreamManager { int block_path_id(const ConfigBlockId& block_id) const; /* Find input net ids of a block */ - std::vector block_input_net_ids(const ConfigBlockId& block_id) const; + std::string block_input_net_ids(const ConfigBlockId& block_id) const; /* Find input net ids of a block */ - std::vector block_output_net_ids(const ConfigBlockId& block_id) const; + std::string block_output_net_ids(const ConfigBlockId& block_id) const; public: /* Public Mutators */ /* Add a new configuration bit to the bitstream manager */ @@ -177,15 +177,9 @@ class BitstreamManager { /* Add a path id to a block */ void add_path_id_to_block(const ConfigBlockId& block, const int& path_id); - /* Reserve input net ids for a block */ - void reserve_block_input_net_ids(const ConfigBlockId& block, const size_t& num_input_net_ids); - /* Add an input net id to a block */ void add_input_net_id_to_block(const ConfigBlockId& block, const std::string& input_net_id); - /* Reserve output net ids for a block */ - void reserve_block_output_net_ids(const ConfigBlockId& block, const size_t& num_output_net_ids); - /* Add an output net id to a block */ void add_output_net_id_to_block(const ConfigBlockId& block, const std::string& output_net_id); @@ -233,8 +227,8 @@ class BitstreamManager { * -Bitstream manager will NOT check if the id is good for bitstream builders * It just store the results */ - vtr::vector> block_input_net_ids_; - vtr::vector> block_output_net_ids_; + vtr::vector block_input_net_ids_; + vtr::vector block_output_net_ids_; /* Unique id of a bit in the Bitstream */ size_t num_bits_; diff --git a/libopenfpga/libfpgabitstream/src/read_xml_arch_bitstream.cpp b/libopenfpga/libfpgabitstream/src/read_xml_arch_bitstream.cpp index 04e0918f1..be39c4e64 100644 --- a/libopenfpga/libfpgabitstream/src/read_xml_arch_bitstream.cpp +++ b/libopenfpga/libfpgabitstream/src/read_xml_arch_bitstream.cpp @@ -62,9 +62,16 @@ void rec_read_xml_bitstream_block(pugi::xml_node& xml_bitstream_block, input_nets[id] = net_name; } + std::string input_nets_str; + bool need_splitter = false; for (const std::string& input_net : input_nets) { - bitstream_manager.add_input_net_id_to_block(curr_block, input_net); + if (true == need_splitter) { + input_nets_str += std::string(" "); + } + input_nets_str += input_net; + need_splitter = true; } + bitstream_manager.add_input_net_id_to_block(curr_block, input_nets_str); } /* Parse output nets if defined */ @@ -86,9 +93,16 @@ void rec_read_xml_bitstream_block(pugi::xml_node& xml_bitstream_block, output_nets[id] = net_name; } + std::string output_nets_str; + bool need_splitter = false; for (const std::string& output_net : output_nets) { - bitstream_manager.add_output_net_id_to_block(curr_block, output_net); + if (true == need_splitter) { + output_nets_str += std::string(" "); + } + output_nets_str += output_net; + need_splitter = true; } + bitstream_manager.add_output_net_id_to_block(curr_block, output_nets_str); } /* Parse configuration bits */ diff --git a/libopenfpga/libfpgabitstream/src/write_xml_arch_bitstream.cpp b/libopenfpga/libfpgabitstream/src/write_xml_arch_bitstream.cpp index 0cc8c88b0..17e94cd15 100644 --- a/libopenfpga/libfpgabitstream/src/write_xml_arch_bitstream.cpp +++ b/libopenfpga/libfpgabitstream/src/write_xml_arch_bitstream.cpp @@ -13,6 +13,7 @@ /* Headers from openfpgautil library */ #include "openfpga_digest.h" +#include "openfpga_tokenizer.h" #include "openfpga_reserved_words.h" @@ -95,7 +96,9 @@ void rec_write_block_bitstream_to_xml_file(std::fstream& fp, write_tab_to_file(fp, hierarchy_level + 1); fp << "\n"; size_t path_counter = 0; - for (const std::string& net : bitstream_manager.block_input_net_ids(block)) { + /* Split with space */ + StringToken input_net_tokenizer(bitstream_manager.block_input_net_ids(block)); + for (const std::string& net : input_net_tokenizer.split(std::string(" "))) { write_tab_to_file(fp, hierarchy_level + 2); fp << "\n"; size_t path_counter = 0; - for (const std::string& net : bitstream_manager.block_output_net_ids(block)) { + /* Split with space */ + StringToken output_net_tokenizer(bitstream_manager.block_output_net_ids(block)); + for (const std::string& net : output_net_tokenizer.split(std::string(" "))) { write_tab_to_file(fp, hierarchy_level + 2); fp << "