Skip to content

Commit b0223dc

Browse files
authored
Merge pull request #1600 from verilog-to-routing/vpr_constraints_parsing
Vpr constraints parsing
2 parents 5ff8613 + 3b3a874 commit b0223dc

17 files changed

+1452
-0
lines changed

vpr/src/base/SetupVPR.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void SetupVPR(const t_options* Options,
9393
FileNameOpts->PowerFile = Options->PowerFile;
9494
FileNameOpts->CmosTechFile = Options->CmosTechFile;
9595
FileNameOpts->out_file_prefix = Options->out_file_prefix;
96+
FileNameOpts->read_vpr_constraints_file = Options->read_vpr_constraints_file;
9697

9798
FileNameOpts->verify_file_digests = Options->verify_file_digests;
9899

vpr/src/base/ShowSetup.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void ShowSetup(const t_vpr_setup& vpr_setup) {
3131
VTR_LOG("Circuit placement file: %s\n", vpr_setup.FileNameOpts.PlaceFile.c_str());
3232
VTR_LOG("Circuit routing file: %s\n", vpr_setup.FileNameOpts.RouteFile.c_str());
3333
VTR_LOG("Circuit SDC file: %s\n", vpr_setup.Timing.SDCFile.c_str());
34+
VTR_LOG("Vpr Constraints file: %s\n", vpr_setup.FileNameOpts.read_vpr_constraints_file.c_str());
3435
VTR_LOG("\n");
3536

3637
VTR_LOG("Packer: %s\n", (vpr_setup.PackerOpts.doPacking ? "ENABLED" : "DISABLED"));

vpr/src/base/constraints_load.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include "constraints_load.h"
2+
3+
static void print_region(FILE* fp, Region region);
4+
static void print_partition(FILE* fp, Partition part);
5+
static void print_partition_region(FILE* fp, PartitionRegion pr);
6+
static void print_constraints(FILE* fp, VprConstraints constraints, int num_parts);
7+
8+
void print_region(FILE* fp, Region region) {
9+
vtr::Rect<int> rect = region.get_region_rect();
10+
int xmin = rect.xmin();
11+
int xmax = rect.xmax();
12+
int ymin = rect.ymin();
13+
int ymax = rect.ymax();
14+
int subtile = region.get_sub_tile();
15+
16+
fprintf(fp, "\tRegion: \n");
17+
fprintf(fp, "\txmin: %d\n", xmin);
18+
fprintf(fp, "\txmax: %d\n", xmax);
19+
fprintf(fp, "\tymin: %d\n", ymin);
20+
fprintf(fp, "\tymax: %d\n", ymax);
21+
fprintf(fp, "\tsubtile: %d\n\n", subtile);
22+
}
23+
24+
void print_partition(FILE* fp, Partition part) {
25+
std::string name = part.get_name();
26+
fprintf(fp, "\npartition_name: %s\n", name.c_str());
27+
28+
PartitionRegion pr = part.get_part_region();
29+
30+
print_partition_region(fp, pr);
31+
}
32+
33+
void print_partition_region(FILE* fp, PartitionRegion pr) {
34+
std::vector<Region> part_region = pr.get_partition_region();
35+
36+
int pr_size = part_region.size();
37+
38+
fprintf(fp, "\tNumber of regions in partition is: %d\n", pr_size);
39+
40+
for (unsigned int i = 0; i < part_region.size(); i++) {
41+
print_region(fp, part_region[i]);
42+
}
43+
}
44+
45+
void print_constraints(FILE* fp, VprConstraints constraints, int num_parts) {
46+
Partition temp_part;
47+
std::vector<AtomBlockId> atoms;
48+
49+
for (int i = 0; i < num_parts; i++) {
50+
PartitionId part_id(i);
51+
52+
temp_part = constraints.get_partition(part_id);
53+
54+
print_partition(fp, temp_part);
55+
56+
atoms = constraints.get_part_atoms(part_id);
57+
58+
int atoms_size = atoms.size();
59+
60+
fprintf(fp, "\tAtom vector size is %d\n", atoms_size);
61+
fprintf(fp, "\tIds of atoms in partition: \n");
62+
for (unsigned int j = 0; j < atoms.size(); j++) {
63+
AtomBlockId atom_id = atoms[j];
64+
fprintf(fp, "\t#%zu\n", size_t(atom_id));
65+
}
66+
}
67+
}
68+
69+
void echo_constraints(char* filename, VprConstraints constraints, int num_parts) {
70+
FILE* fp;
71+
fp = vtr::fopen(filename, "w");
72+
73+
fprintf(fp, "--------------------------------------------------------------\n");
74+
fprintf(fp, "Constraints\n");
75+
fprintf(fp, "--------------------------------------------------------------\n");
76+
fprintf(fp, "\n");
77+
fprintf(fp, "\n Number of partitions is %d \n", num_parts);
78+
print_constraints(fp, constraints, num_parts);
79+
80+
fclose(fp);
81+
}

vpr/src/base/constraints_load.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef CONSTRAINTS_LOAD_H_
2+
#define CONSTRAINTS_LOAD_H_
3+
4+
#include "region.h"
5+
#include "partition.h"
6+
#include "partition_region.h"
7+
#include "vpr_constraints.h"
8+
#include "vtr_vector.h"
9+
10+
void echo_constraints(char* filename, VprConstraints constraints, int num_parts);
11+
12+
#endif

vpr/src/base/echo_files.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ void alloc_and_load_echo_file_info() {
7171
setEchoFileName(E_ECHO_ATOM_NETLIST_ORIG, "atom_netlist.orig.echo.blif");
7272
setEchoFileName(E_ECHO_ATOM_NETLIST_CLEANED, "atom_netlist.cleaned.echo.blif");
7373

74+
//Vpr constraints
75+
setEchoFileName(E_ECHO_VPR_CONSTRAINTS, "vpr_constraints.echo");
76+
7477
//Intra-block routing
7578
setEchoFileName(E_ECHO_INTRA_LB_FAILED_ROUTE, "intra_lb_failed_route.echo");
7679

vpr/src/base/echo_files.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ enum e_echo_files {
1010
E_ECHO_PRE_PACKING_SLACK,
1111
E_ECHO_PRE_PACKING_CRITICALITY,
1212
E_ECHO_PRE_PACKING_MOLECULES_AND_PATTERNS,
13+
E_ECHO_VPR_CONSTRAINTS,
1314

1415
// Intra-block routing
1516
E_ECHO_INTRA_LB_FAILED_ROUTE,

vpr/src/base/gen/README.gen.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
`vpr_constraints_uxsdcxx.h`and
2+
`vpr_constraints_uxsdcxx_interface.h` are generated via uxsdcxx and are checked in to
3+
avoid requiring python3 and the uxsdcxx depedencies to build VPR.

0 commit comments

Comments
 (0)