add read bin (with bugs)
This commit is contained in:
parent
1d6f9901bb
commit
59f1e4adc9
|
@ -12,10 +12,12 @@
|
|||
#include "arch_error.h"
|
||||
#include "command_exit_codes.h"
|
||||
#include "device_rr_gsb_utils.h"
|
||||
#include "mmap_file.h"
|
||||
#include "openfpga_digest.h"
|
||||
#include "read_xml_unique_blocks.h"
|
||||
#include "read_xml_util.h"
|
||||
#include "rr_gsb.h"
|
||||
#include "unique_blocks_uxsdcxx.capnp.h"
|
||||
#include "write_xml_utils.h"
|
||||
|
||||
/********************************************************************
|
||||
|
@ -155,9 +157,79 @@ int read_xml_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
|
|||
}
|
||||
}
|
||||
|
||||
int read_bin_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
|
||||
bool verbose_output) {
|
||||
return 0;
|
||||
/*read the instances' coordinate of a unique block from a bin file*/
|
||||
std::vector<vtr::Point<size_t>> read_bin_unique_instance_coords(
|
||||
const uniqueblockcap::BlockInfo::Reader& unique_block) {
|
||||
std::vector<vtr::Point<size_t>> instance_coords;
|
||||
if (unique_block.hasInstanceList()) {
|
||||
auto instance_list = unique_block.getInstanceList();
|
||||
for (auto instance : instance_list) {
|
||||
int instance_x = instance.getX();
|
||||
int instance_y = instance.getY();
|
||||
vtr::Point<size_t> instance_coordinate(instance_x, instance_y);
|
||||
instance_coords.push_back(instance_coordinate);
|
||||
}
|
||||
}
|
||||
return instance_coords;
|
||||
}
|
||||
|
||||
/*read the unique block coordinate from a bin file */
|
||||
vtr::Point<size_t> read_bin_unique_block_coord(
|
||||
const uniqueblockcap::BlockInfo::Reader& unique_block) {
|
||||
auto block_info = unique_block.getBlockInfo();
|
||||
std::string type = block_info.getType().Cstr();
|
||||
int block_x = block_info.getX();
|
||||
int block_y = block_info.getY();
|
||||
vtr::Point<size_t> block_coordinate(block_x, block_y);
|
||||
return block_coordinate;
|
||||
}
|
||||
|
||||
/*top-level function to read unique blocks from bin file*/
|
||||
int read_bin_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
|
||||
bool verbose_output) {
|
||||
/* clear unique modules & reserve memory to relavant vectors */
|
||||
device_rr_gsb.clear_unique_modules();
|
||||
// vtr::Point<size_t> grid_coord(rr_gsb_.size());
|
||||
device_rr_gsb.reserve_unique_modules();
|
||||
MmapFile f(file_name);
|
||||
::uniqueblockcap::FlatArrayMessageReader reader(f.getData());
|
||||
auto root = reader.getRoot<uniqueblockcap::UniqueBlockCompactInfo>();
|
||||
if (root.hasAtomInfo()) {
|
||||
auto block_list = root.getAtomInfo();
|
||||
for (auto unqiue_block : block_list) {
|
||||
auto block_info = unique_block.getBlockInfo();
|
||||
std::string type = block_info.getType().Cstr();
|
||||
int block_x = block_info.getX();
|
||||
int block_y = block_info.getY();
|
||||
vtr::Point<size_t> block_coordinate(block_x, block_y);
|
||||
if (unique_block.hasInstanceList()) {
|
||||
auto instance_list = unique_block.getInstanceList();
|
||||
std::vector<vtr::Point<size_t>> instance_coords;
|
||||
for (auto instance : instance_list) {
|
||||
int instance_x = instance.getX();
|
||||
int instance_y = instance.getY();
|
||||
vtr::Point<size_t> instance_coordinate(instance_x, instance_y);
|
||||
instance_coords.push_back(instance_coordinate);
|
||||
}
|
||||
}
|
||||
/* get block coordinate and instance coordinate, try to setup
|
||||
* device_rr_gsb */
|
||||
if (type == "sb") {
|
||||
device_rr_gsb.preload_unique_sb_module(block_coordinate,
|
||||
instance_coords);
|
||||
} else if (type == "cby") {
|
||||
device_rr_gsb.preload_unique_cby_module(block_coordinate,
|
||||
instance_coords);
|
||||
} else if (type == "cbx") {
|
||||
device_rr_gsb.preload_unique_cbx_module(block_coordinate,
|
||||
instance_coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
device_rr_gsb.build_gsb_unique_module();
|
||||
if (verbose_output) {
|
||||
report_unique_module_status_read(device_rr_gsb, true);
|
||||
}
|
||||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
} // namespace openfpga
|
||||
|
|
|
@ -36,7 +36,14 @@ void report_unique_module_status_read(const DeviceRRGSB& device_rr_gsb,
|
|||
int read_xml_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
|
||||
bool verbose_output);
|
||||
|
||||
std::vector<vtr::Point<size_t>> read_bin_unique_instance_coords(
|
||||
const uniqueblockcap::BlockInfo::Reader& unique_block);
|
||||
|
||||
vtr::Point<size_t> read_bin_unique_block_coord(
|
||||
const uniqueblockcap::BlockInfo::Reader& unique_block);
|
||||
|
||||
int read_bin_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
|
||||
bool verbose_output);
|
||||
bool verbose_output)
|
||||
} // namespace openfpga
|
||||
|
||||
#endif
|
||||
|
|
|
@ -224,7 +224,6 @@ int write_bin_unique_blocks(const DeviceRRGSB& device_rr_gsb, const char* fname,
|
|||
const auto unique_block_coord = device_rr_gsb.get_sb_unique_block_coord(id);
|
||||
const std::vector<vtr::Point<size_t>> instance_map =
|
||||
device_rr_gsb.get_sb_unique_block_instance_coord(unique_block_coord);
|
||||
std::cout << "what is instance size: " << instance_map.size() << std::endl;
|
||||
auto unique_block = block_list[id];
|
||||
int status_code =
|
||||
write_bin_atom_block(instance_map, unique_block_coord,
|
||||
|
|
Loading…
Reference in New Issue