|
2 | 2 | #include "PartialPlacement.h"
|
3 | 3 | #include <cmath>
|
4 | 4 | #include <cstddef>
|
5 |
| -#include <cstdint> |
| 5 | +#include <fstream> |
| 6 | +#include <ios> |
6 | 7 | #include <limits>
|
7 | 8 | #include <map>
|
| 9 | +#include <string> |
8 | 10 | #include <unordered_set>
|
9 | 11 | #include <vector>
|
10 | 12 | #include "globals.h"
|
11 |
| -#include "vpr_constraints_uxsdcxx.h" |
12 | 13 | #include "vpr_context.h"
|
13 | 14 | #include "vpr_types.h"
|
14 | 15 | #include "vtr_assert.h"
|
@@ -267,3 +268,42 @@ void PartialPlacement::unicode_art(){
|
267 | 268 | VTR_LOG("unicode_art end\n");
|
268 | 269 | fflush(stderr);
|
269 | 270 | }
|
| 271 | + |
| 272 | +bool PartialPlacement::export_to_flat_placement_file(std::string file_name) { |
| 273 | + // https://doi.org/10.1145/3665283.3665300 |
| 274 | + // Primitive Name /t X /t Y /t Subtile /t Site |
| 275 | + std::ofstream flat_placement_file; |
| 276 | + flat_placement_file.open(file_name, std::ios::out); |
| 277 | + if (!flat_placement_file) { |
| 278 | + VTR_LOG_ERROR("Failed to open the flat placement file '%s' to export the PartialPlacement.\n", |
| 279 | + file_name.c_str()); |
| 280 | + return false; |
| 281 | + } |
| 282 | + |
| 283 | + // FIXME: Are sites just unique IDs per molecule or do they need to start at |
| 284 | + // 0 per tile? |
| 285 | + size_t site_idx = 0; |
| 286 | + for (size_t node_id = 0; node_id < num_nodes; node_id++) { |
| 287 | + int mol_pos_x = std::floor(node_loc_x[node_id]); |
| 288 | + int mol_pos_y = std::floor(node_loc_y[node_id]); |
| 289 | + // FIXME: What is a subtile? |
| 290 | + int mol_subtile = 0; |
| 291 | + t_pack_molecule* mol = node_id_to_mol[node_id]; |
| 292 | + for (AtomBlockId block_id : mol->atom_block_ids) { |
| 293 | + // Primitive's name |
| 294 | + flat_placement_file << atom_netlist.block_name(block_id) << '\t'; |
| 295 | + // Primitive's cluster coordinates |
| 296 | + flat_placement_file << mol_pos_x << '\t' << mol_pos_y << '\t'; |
| 297 | + flat_placement_file << mol_subtile << '\t'; |
| 298 | + // Primitive site index |
| 299 | + flat_placement_file << site_idx << '\n'; |
| 300 | + } |
| 301 | + // Increment the site index per molecule so each molecule has a unique |
| 302 | + // index. |
| 303 | + site_idx++; |
| 304 | + } |
| 305 | + |
| 306 | + flat_placement_file.close(); |
| 307 | + return true; |
| 308 | +} |
| 309 | + |
0 commit comments