Skip to content

Commit eb8c186

Browse files
Merge pull request #2770 from verilog-to-routing/temp_place_macro_static
Remove remaining global and static varaibels in the placement stage
2 parents 92babb5 + 89d17a2 commit eb8c186

File tree

118 files changed

+1982
-2334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1982
-2334
lines changed

doc/src/arch/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,8 +2337,8 @@ The ``<direct>`` tag and its contents are described below.
23372337
:req_param y_offset: The y location of the receiving CLB relative to the driving CLB.
23382338
:req_param z_offset: The z location of the receiving CLB relative to the driving CLB.
23392339
:opt_param switch_name: [Optional, defaults to delay-less switch if not specified] The name of the ``<switch>`` from ``<switchlist>`` to be used for this direct connection.
2340-
:opt_param from_side: The associated from_pin's block size (must be one of ``left``, ``right``, ``top``, ``bottom`` or left unspecified)
2341-
:opt_param to_side: The associated to_pin's block size (must be one of ``left``, ``right``, ``top``, ``bottom`` or left unspecified)
2340+
:opt_param from_side: The associated from_pin's block side (must be one of ``left``, ``right``, ``top``, ``bottom`` or left unspecified)
2341+
:opt_param to_side: The associated to_pin's block side (must be one of ``left``, ``right``, ``top``, ``bottom`` or left unspecified)
23422342

23432343
Describes a dedicated connection between two complex block pins that skips general interconnect.
23442344
This is useful for describing structures such as carry chains as well as adjacent neighbour connections.

libs/libarchfpga/src/arch_check.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void check_port_direct_mappings(t_physical_tile_type_ptr physical_tile, t_sub_ti
101101
if (pb_type->num_pins > (sub_tile->num_phy_pins / sub_tile->capacity.total())) {
102102
archfpga_throw(__FILE__, __LINE__,
103103
"Logical Block (%s) has more pins than the Sub Tile (%s).\n",
104-
logical_block->name, sub_tile->name);
104+
logical_block->name.c_str(), sub_tile->name.c_str());
105105
}
106106

107107
auto& pin_direct_maps = physical_tile->tile_block_pin_directs_map.at(logical_block->index);
@@ -110,7 +110,7 @@ void check_port_direct_mappings(t_physical_tile_type_ptr physical_tile, t_sub_ti
110110
if (pb_type->num_pins != (int)pin_direct_map.size()) {
111111
archfpga_throw(__FILE__, __LINE__,
112112
"Logical block (%s) and Sub tile (%s) have a different number of ports.\n",
113-
logical_block->name, physical_tile->name);
113+
logical_block->name.c_str(), physical_tile->name.c_str());
114114
}
115115

116116
for (auto pin_map : pin_direct_map) {
@@ -126,7 +126,7 @@ void check_port_direct_mappings(t_physical_tile_type_ptr physical_tile, t_sub_ti
126126
|| sub_tile_port->equivalent != block_port->equivalent) {
127127
archfpga_throw(__FILE__, __LINE__,
128128
"Logical block (%s) and Physical tile (%s) do not have equivalent port specifications. Sub tile port %s, logical block port %s\n",
129-
logical_block->name, sub_tile->name, sub_tile_port->name, block_port->name);
129+
logical_block->name.c_str(), sub_tile->name.c_str(), sub_tile_port->name, block_port->name);
130130
}
131131
}
132132
}

libs/libarchfpga/src/arch_util.cpp

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,11 @@ void free_arch(t_arch* arch) {
152152
return;
153153
}
154154

155-
delete[] arch->Switches;
156-
arch->Switches = nullptr;
157-
158155
free_arch_models(arch->models);
159156

160-
for (int i = 0; i < arch->num_directs; ++i) {
161-
vtr::free(arch->Directs[i].name);
162-
vtr::free(arch->Directs[i].from_pin);
163-
vtr::free(arch->Directs[i].to_pin);
164-
}
165-
vtr::free(arch->Directs);
157+
vtr::release_memory(arch->switches);
158+
159+
vtr::release_memory(arch->directs);
166160

167161
vtr::free(arch->architecture_id);
168162

@@ -235,7 +229,7 @@ t_model* free_arch_model(t_model* model) {
235229
return next_model;
236230
}
237231

238-
//Frees all the model portss in a linked list
232+
//Frees all the model ports in a linked list
239233
void free_arch_model_ports(t_model_ports* model_ports) {
240234
t_model_ports* model_port = model_ports;
241235
while (model_port) {
@@ -256,16 +250,17 @@ t_model_ports* free_arch_model_port(t_model_ports* model_port) {
256250
}
257251

258252
void free_type_descriptors(std::vector<t_physical_tile_type>& type_descriptors) {
259-
for (auto& type : type_descriptors) {
260-
vtr::free(type.name);
253+
for (t_physical_tile_type& type : type_descriptors) {
254+
vtr::release_memory(type.name);
255+
261256
if (type.index == EMPTY_TYPE_INDEX) {
262257
continue;
263258
}
264259

265-
for (auto& sub_tile : type.sub_tiles) {
266-
vtr::free(sub_tile.name);
260+
for (t_sub_tile& sub_tile : type.sub_tiles) {
261+
vtr::release_memory(sub_tile.name);
267262

268-
for (auto port : sub_tile.ports) {
263+
for (t_physical_tile_port& port : sub_tile.ports) {
269264
vtr::free(port.name);
270265
}
271266
}
@@ -276,8 +271,8 @@ void free_type_descriptors(std::vector<t_physical_tile_type>& type_descriptors)
276271
void free_type_descriptors(std::vector<t_logical_block_type>& type_descriptors) {
277272
free_all_pb_graph_nodes(type_descriptors);
278273

279-
for (auto& type : type_descriptors) {
280-
vtr::free(type.name);
274+
for (t_logical_block_type& type : type_descriptors) {
275+
vtr::release_memory(type.name);
281276
if (type.index == EMPTY_TYPE_INDEX) {
282277
continue;
283278
}
@@ -522,7 +517,7 @@ t_port* findPortByName(const char* name, t_pb_type* pb_type, int* high_index, in
522517

523518
t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NAME*/) {
524519
t_physical_tile_type type;
525-
type.name = vtr::strdup(name);
520+
type.name = name;
526521
type.num_pins = 0;
527522
type.width = 1;
528523
type.height = 1;
@@ -540,7 +535,7 @@ t_physical_tile_type get_empty_physical_type(const char* name /*= EMPTY_BLOCK_NA
540535

541536
t_logical_block_type get_empty_logical_type(const char* name /*=EMPTY_BLOCK_NAME*/) {
542537
t_logical_block_type type;
543-
type.name = vtr::strdup(name);
538+
type.name = name;
544539
type.pb_type = nullptr;
545540

546541
return type;
@@ -1104,7 +1099,6 @@ void SyncModelsPbTypes(t_arch* arch,
11041099

11051100
void SyncModelsPbTypes_rec(t_arch* arch,
11061101
t_pb_type* pb_type) {
1107-
int i, j, p;
11081102
t_model *model_match_prim, *cur_model;
11091103
t_model_ports* model_port;
11101104
vtr::t_linked_vptr* old;
@@ -1143,7 +1137,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
11431137
}
11441138
cur_model = cur_model->next;
11451139
}
1146-
if (found != true) {
1140+
if (!found) {
11471141
archfpga_throw(get_arch_file_name(), 0,
11481142
"No matching model for pb_type %s\n", pb_type->blif_model);
11491143
}
@@ -1154,7 +1148,7 @@ void SyncModelsPbTypes_rec(t_arch* arch,
11541148
model_match_prim->pb_types->next = old;
11551149
model_match_prim->pb_types->data_vptr = pb_type;
11561150

1157-
for (p = 0; p < pb_type->num_ports; p++) {
1151+
for (int p = 0; p < pb_type->num_ports; p++) {
11581152
found = false;
11591153
/* TODO: Parse error checking - check if INPUT matches INPUT and OUTPUT matches OUTPUT (not yet done) */
11601154
model_port = model_match_prim->inputs;
@@ -1203,17 +1197,16 @@ void SyncModelsPbTypes_rec(t_arch* arch,
12031197
}
12041198
model_port = model_port->next;
12051199
}
1206-
if (found != true) {
1200+
if (!found) {
12071201
archfpga_throw(get_arch_file_name(), 0,
12081202
"No matching model port for port %s in pb_type %s\n",
12091203
pb_type->ports[p].name, pb_type->name);
12101204
}
12111205
}
12121206
} else {
1213-
for (i = 0; i < pb_type->num_modes; i++) {
1214-
for (j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
1215-
SyncModelsPbTypes_rec(arch,
1216-
&(pb_type->modes[i].pb_type_children[j]));
1207+
for (int i = 0; i < pb_type->num_modes; i++) {
1208+
for (int j = 0; j < pb_type->modes[i].num_pb_type_children; j++) {
1209+
SyncModelsPbTypes_rec(arch, &(pb_type->modes[i].pb_type_children[j]));
12171210
}
12181211
}
12191212
}
@@ -1229,11 +1222,11 @@ void SyncModelsPbTypes_rec(t_arch* arch,
12291222
void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
12301223
t_pb_type* parent_pb_type) {
12311224
int i_port;
1232-
bool clock_valid = false; //Determine if annotation's clock is same as primtive's clock
1225+
bool clock_valid = false; //Determine if annotation's clock is same as primitive's clock
12331226

12341227
if (!parent_pb_type || !annotation) {
12351228
archfpga_throw(__FILE__, __LINE__,
1236-
"Annotation_clock check encouters invalid annotation or primitive.\n");
1229+
"Annotation_clock check encounters invalid annotation or primitive.\n");
12371230
}
12381231

12391232
for (i_port = 0; i_port < parent_pb_type->num_ports; i_port++) {
@@ -1253,18 +1246,17 @@ void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
12531246
}
12541247
}
12551248

1256-
const t_segment_inf* find_segment(const t_arch* arch, std::string name) {
1257-
for (size_t i = 0; i < (arch->Segments).size(); ++i) {
1258-
const t_segment_inf* seg = &arch->Segments[i];
1259-
if (seg->name == name) {
1260-
return seg;
1249+
const t_segment_inf* find_segment(const t_arch* arch, std::string_view name) {
1250+
for (const auto& segment : arch->Segments) {
1251+
if (segment.name == name) {
1252+
return &segment;
12611253
}
12621254
}
12631255

12641256
return nullptr;
12651257
}
12661258

1267-
bool segment_exists(const t_arch* arch, std::string name) {
1259+
bool segment_exists(const t_arch* arch, std::string_view name) {
12681260
return find_segment(arch, name) != nullptr;
12691261
}
12701262

@@ -1342,7 +1334,7 @@ const t_pin_to_pin_annotation* find_sequential_annotation(const t_pb_type* pb_ty
13421334
return nullptr;
13431335
}
13441336

1345-
const t_pin_to_pin_annotation* find_combinational_annotation(const t_pb_type* pb_type, std::string in_port, std::string out_port) {
1337+
const t_pin_to_pin_annotation* find_combinational_annotation(const t_pb_type* pb_type, std::string_view in_port, std::string_view out_port) {
13461338
for (int iannot = 0; iannot < pb_type->num_annotations; ++iannot) {
13471339
const t_pin_to_pin_annotation* annot = &pb_type->annotations[iannot];
13481340
for (const auto& annot_in_str : vtr::split(annot->input_pins)) {
@@ -1386,24 +1378,24 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
13861378

13871379
std::sort(equivalent_sites.begin(), equivalent_sites.end(), criteria);
13881380

1389-
for (auto& logical_block : LogicalBlockTypes) {
1381+
for (t_logical_block_type& logical_block : LogicalBlockTypes) {
13901382
for (auto site : equivalent_sites) {
1391-
if (0 == strcmp(logical_block.name, site->pb_type->name)) {
1383+
if (logical_block.name == site->pb_type->name) {
13921384
logical_block.equivalent_tiles.push_back(&physical_tile);
13931385
break;
13941386
}
13951387
}
13961388
}
13971389
}
13981390

1399-
for (auto& logical_block : LogicalBlockTypes) {
1391+
for (t_logical_block_type& logical_block : LogicalBlockTypes) {
14001392
if (logical_block.index == EMPTY_TYPE_INDEX) continue;
14011393

14021394
auto& equivalent_tiles = logical_block.equivalent_tiles;
14031395

14041396
if ((int)equivalent_tiles.size() <= 0) {
14051397
archfpga_throw(__FILE__, __LINE__,
1406-
"Logical Block %s does not have any equivalent tiles.\n", logical_block.name);
1398+
"Logical Block %s does not have any equivalent tiles.\n", logical_block.name.c_str());
14071399
}
14081400

14091401
std::unordered_map<int, bool> ignored_pins_check_map;
@@ -1439,7 +1431,7 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14391431
if (result == direct_map.end()) {
14401432
archfpga_throw(__FILE__, __LINE__,
14411433
"Logical pin %d not present in pin mapping between Tile %s and Block %s.\n",
1442-
pin, tile->name, logical_block.name);
1434+
pin, tile->name.c_str(), logical_block.name.c_str());
14431435
}
14441436

14451437
int sub_tile_pin_index = result->second.pin;
@@ -1453,15 +1445,15 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14531445
archfpga_throw(__FILE__, __LINE__,
14541446
"Physical Tile %s has a different value for the ignored pin (physical pin: %d, logical pin: %d) "
14551447
"different from the corresponding pins of the other equivalent site %s\n.",
1456-
tile->name, phy_index, pin, logical_block.name);
1448+
tile->name.c_str(), phy_index, pin, logical_block.name.c_str());
14571449
}
14581450

14591451
auto global_result = global_pins_check_map.insert(std::pair<int, bool>(pin, is_global));
14601452
if (!global_result.second && global_result.first->second != is_global) {
14611453
archfpga_throw(__FILE__, __LINE__,
14621454
"Physical Tile %s has a different value for the global pin (physical pin: %d, logical pin: %d) "
14631455
"different from the corresponding pins of the other equivalent sites\n.",
1464-
tile->name, phy_index, pin);
1456+
tile->name.c_str(), phy_index, pin);
14651457
}
14661458
}
14671459
}
@@ -1471,27 +1463,25 @@ void link_physical_logical_types(std::vector<t_physical_tile_type>& PhysicalTile
14711463

14721464
/* Sets up the pin classes for the type. */
14731465
void setup_pin_classes(t_physical_tile_type* type) {
1474-
int i, k;
1475-
int pin_count;
14761466
int num_class;
14771467

1478-
for (i = 0; i < type->num_pins; i++) {
1468+
for (int i = 0; i < type->num_pins; i++) {
14791469
type->pin_class.push_back(OPEN);
14801470
type->is_ignored_pin.push_back(true);
14811471
type->is_pin_global.push_back(true);
14821472
}
14831473

1484-
pin_count = 0;
1474+
int pin_count = 0;
14851475

14861476
t_class_range class_range;
14871477

14881478
/* Equivalent pins share the same class, non-equivalent pins belong to different pin classes */
1489-
for (auto& sub_tile : type->sub_tiles) {
1479+
for (const t_sub_tile& sub_tile : type->sub_tiles) {
14901480
int capacity = sub_tile.capacity.total();
14911481
class_range.low = type->class_inf.size();
14921482
class_range.high = class_range.low - 1;
1493-
for (i = 0; i < capacity; ++i) {
1494-
for (const auto& port : sub_tile.ports) {
1483+
for (int i = 0; i < capacity; ++i) {
1484+
for (const t_physical_tile_port& port : sub_tile.ports) {
14951485
if (port.equivalent != PortEquivalence::NONE) {
14961486
t_class class_inf;
14971487
num_class = (int)type->class_inf.size();
@@ -1505,7 +1495,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15051495
class_inf.type = DRIVER;
15061496
}
15071497

1508-
for (k = 0; k < port.num_pins; ++k) {
1498+
for (int k = 0; k < port.num_pins; ++k) {
15091499
class_inf.pinlist.push_back(pin_count);
15101500
type->pin_class[pin_count] = num_class;
15111501
// clock pins and other specified global ports are initially specified
@@ -1525,7 +1515,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15251515
type->class_inf.push_back(class_inf);
15261516
class_range.high++;
15271517
} else if (port.equivalent == PortEquivalence::NONE) {
1528-
for (k = 0; k < port.num_pins; ++k) {
1518+
for (int k = 0; k < port.num_pins; ++k) {
15291519
t_class class_inf;
15301520
num_class = (int)type->class_inf.size();
15311521
class_inf.num_pins = 1;
@@ -1544,7 +1534,7 @@ void setup_pin_classes(t_physical_tile_type* type) {
15441534
// as ignored pins (i.e. connections are not created in the rr_graph and
15451535
// nets connected to the port are ignored as well).
15461536
type->is_ignored_pin[pin_count] = port.is_clock || port.is_non_clock_global;
1547-
// clock pins and other specified global ports are flaged as global
1537+
// clock pins and other specified global ports are flagged as global
15481538
type->is_pin_global[pin_count] = port.is_clock || port.is_non_clock_global;
15491539

15501540
if (port.is_clock) {

libs/libarchfpga/src/arch_util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void SyncModelsPbTypes_rec(t_arch* arch,
9595
void primitives_annotation_clock_match(t_pin_to_pin_annotation* annotation,
9696
t_pb_type* parent_pb_type);
9797

98-
bool segment_exists(const t_arch* arch, std::string name);
99-
const t_segment_inf* find_segment(const t_arch* arch, std::string name);
98+
bool segment_exists(const t_arch* arch, std::string_view name);
99+
const t_segment_inf* find_segment(const t_arch* arch, std::string_view name);
100100
bool is_library_model(const char* model_name);
101101
bool is_library_model(const t_model* model);
102102

@@ -107,7 +107,7 @@ bool block_type_contains_blif_model(t_logical_block_type_ptr type, const std::st
107107
bool pb_type_contains_blif_model(const t_pb_type* pb_type, const std::string& blif_model_name);
108108

109109
const t_pin_to_pin_annotation* find_sequential_annotation(const t_pb_type* pb_type, const t_model_ports* port, enum e_pin_to_pin_delay_annotations annot_type);
110-
const t_pin_to_pin_annotation* find_combinational_annotation(const t_pb_type* pb_type, std::string in_port, std::string out_port);
110+
const t_pin_to_pin_annotation* find_combinational_annotation(const t_pb_type* pb_type, std::string_view in_port, std::string_view out_port);
111111

112112
/**
113113
* @brief Updates the physical and logical types based on the equivalence between one and the other.

0 commit comments

Comments
 (0)