Skip to content

Commit 0031a71

Browse files
committed
replaced t_clock_arch with std::vector<t_clock_network> (might still be errors)
1 parent 2c12600 commit 0031a71

File tree

7 files changed

+38
-60
lines changed

7 files changed

+38
-60
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ void free_arch(t_arch* arch) {
162162

163163
vtr::free(arch->architecture_id);
164164

165-
if (arch->clocks) {
166-
delete[] arch->clocks->clock_inf;
167-
}
168-
169165
delete (arch->noc);
170166
}
171167

libs/libarchfpga/src/echo_arch.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,20 +334,20 @@ void PrintArchInfo(FILE* Echo, const t_arch* arch) {
334334
//Architecture Clock
335335
fprintf(Echo, "*************************************************\n");
336336
fprintf(Echo, "Clock:\n");
337-
if (arch->clocks) {
338-
for (int i = 0; i < arch->clocks->num_global_clocks; i++) {
339-
if (arch->clocks->clock_inf[i].autosize_buffer) {
340-
fprintf(Echo, "\tClock[%d]: buffer_size auto C_wire %e", i + 1,
341-
arch->clocks->clock_inf->C_wire);
337+
if (!arch->clocks.empty()) {
338+
for (size_t i = 0; i < arch->clocks.size(); i++) {
339+
if (arch->clocks[i].autosize_buffer) {
340+
fprintf(Echo, "\tClock[%zu]: buffer_size auto C_wire %e", i + 1,
341+
arch->clocks[i].C_wire);
342342
} else {
343-
fprintf(Echo, "\tClock[%d]: buffer_size %e C_wire %e", i + 1,
344-
arch->clocks->clock_inf[i].buffer_size,
345-
arch->clocks->clock_inf[i].C_wire);
343+
fprintf(Echo, "\tClock[%zu]: buffer_size %e C_wire %e", i + 1,
344+
arch->clocks[i].buffer_size,
345+
arch->clocks[i].C_wire);
346346
}
347347
fprintf(Echo, "\t\t\t\tstat_prob %f switch_density %f period %e",
348-
arch->clocks->clock_inf[i].prob,
349-
arch->clocks->clock_inf[i].dens,
350-
arch->clocks->clock_inf[i].period);
348+
arch->clocks[i].prob,
349+
arch->clocks[i].dens,
350+
arch->clocks[i].period);
351351
}
352352
}
353353

libs/libarchfpga/src/physical_types.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include "clock_types.h"
4848

4949
//Forward declarations
50-
struct t_clock_arch;
5150
struct t_clock_network;
5251
struct t_power_arch;
5352
struct t_interconnect_pins;
@@ -411,12 +410,6 @@ struct t_grid_def {
411410

412411
/************************* POWER ***********************************/
413412

414-
/* Global clock architecture */
415-
struct t_clock_arch {
416-
int num_global_clocks;
417-
t_clock_network* clock_inf; /* Details about each clock */
418-
};
419-
420413
/* Architecture information for a single clock */
421414
struct t_clock_network {
422415
bool autosize_buffer; /* autosize clock buffers */
@@ -426,6 +419,8 @@ struct t_clock_network {
426419
float prob; /* Static probability of net assigned to this clock */
427420
float dens; /* Switching density of net assigned to this clock */
428421
float period; /* Period of clock */
422+
423+
t_clock_network() = default;
429424
};
430425

431426
/* Power-related architecture information */
@@ -2202,7 +2197,7 @@ struct t_arch {
22022197
LogicalModels models;
22032198

22042199
t_power_arch* power = nullptr;
2205-
t_clock_arch* clocks = nullptr;
2200+
std::vector<t_clock_network> clocks;
22062201

22072202
//determine which layers in multi-die FPGAs require to build global routing resources
22082203
std::vector<bool> layer_global_routing;

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static void ProcessPower(pugi::xml_node parent,
357357
t_power_arch* power_arch,
358358
const pugiutil::loc_data& loc_data);
359359

360-
static void ProcessClocks(pugi::xml_node Parent, t_clock_arch* clocks, const pugiutil::loc_data& loc_data);
360+
static void ProcessClocks(pugi::xml_node Parent, std::vector<t_clock_network>& clocks, const pugiutil::loc_data& loc_data);
361361

362362
static void ProcessPb_TypePowerEstMethod(pugi::xml_node Parent, t_pb_type* pb_type, const pugiutil::loc_data& loc_data);
363363
static void ProcessPb_TypePort_Power(pugi::xml_node Parent, t_port* port, e_power_estimation_method power_method, const pugiutil::loc_data& loc_data);
@@ -526,16 +526,14 @@ void XmlReadArch(const char* ArchFile,
526526
// Process Clocks
527527
Next = get_single_child(architecture, "clocks", loc_data, POWER_REQD);
528528
if (Next) {
529-
if (arch->clocks) {
529+
if (!arch->clocks.empty()) {
530530
ProcessClocks(Next, arch->clocks, loc_data);
531531
} else {
532532
/* This information still needs to be read, even if it is just
533533
* thrown away.
534534
*/
535-
t_clock_arch* clocks_fake = new t_clock_arch();
535+
std::vector<t_clock_network> clocks_fake;
536536
ProcessClocks(Next, clocks_fake, loc_data);
537-
delete[] clocks_fake->clock_inf;
538-
delete clocks_fake;
539537
}
540538
}
541539

@@ -4712,32 +4710,26 @@ static void ProcessPower(pugi::xml_node parent,
47124710
}
47134711

47144712
/* Get the clock architecture */
4715-
static void ProcessClocks(pugi::xml_node Parent, t_clock_arch* clocks, const pugiutil::loc_data& loc_data) {
4713+
static void ProcessClocks(pugi::xml_node Parent, std::vector<t_clock_network>& clocks, const pugiutil::loc_data& loc_data) {
47164714
pugi::xml_node Node;
47174715
const char* tmp;
47184716

4719-
clocks->num_global_clocks = count_children(Parent, "clock", loc_data, ReqOpt::OPTIONAL);
4717+
int num_global_clocks = count_children(Parent, "clock", loc_data, ReqOpt::OPTIONAL);
47204718

4721-
/* Alloc the clockdetails */
4722-
clocks->clock_inf = nullptr;
4723-
if (clocks->num_global_clocks > 0) {
4724-
clocks->clock_inf = new t_clock_network[clocks->num_global_clocks];
4725-
memset(clocks->clock_inf, 0,
4726-
clocks->num_global_clocks * sizeof(t_clock_network));
4727-
}
4719+
clocks.resize(num_global_clocks);
47284720

47294721
/* Load the clock info. */
47304722
Node = get_first_child(Parent, "clock", loc_data);
4731-
for (int i = 0; i < clocks->num_global_clocks; ++i) {
4723+
for (int i = 0; i < num_global_clocks; ++i) {
47324724
tmp = get_attribute(Node, "buffer_size", loc_data).value();
47334725
if (strcmp(tmp, "auto") == 0) {
4734-
clocks->clock_inf[i].autosize_buffer = true;
4726+
clocks[i].autosize_buffer = true;
47354727
} else {
4736-
clocks->clock_inf[i].autosize_buffer = false;
4737-
clocks->clock_inf[i].buffer_size = (float)atof(tmp);
4728+
clocks[i].autosize_buffer = false;
4729+
clocks[i].buffer_size = (float)atof(tmp);
47384730
}
47394731

4740-
clocks->clock_inf[i].C_wire = get_attribute(Node, "C_wire", loc_data).as_float(0);
4732+
clocks[i].C_wire = get_attribute(Node, "C_wire", loc_data).as_float(0);
47414733

47424734
/* get the next clock item */
47434735
Node = Node.next_sibling(Node.name());

vpr/src/base/SetupVPR.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,9 @@ static void SetupPowerOpts(const t_options& Options, t_power_opts* power_opts, t
730730
if (!Arch->power)
731731
Arch->power = new t_power_arch();
732732

733-
if (!Arch->clocks)
734-
Arch->clocks = new t_clock_arch();
735-
736733
device_ctx.clock_arch = Arch->clocks;
737734
} else {
738735
Arch->power = nullptr;
739-
Arch->clocks = nullptr;
740-
device_ctx.clock_arch = nullptr;
741736
}
742737
}
743738

vpr/src/base/vpr_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct DeviceContext : public Context {
267267
/*******************************************************************
268268
* Clock Network
269269
********************************************************************/
270-
t_clock_arch* clock_arch;
270+
std::vector<t_clock_network> clock_arch;
271271

272272
/// @brief Name of rrgraph file read (if any).
273273
/// Used to determine if the specified rr-graph file is already loaded,

vpr/src/power/power.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void power_usage_local_buffers_and_wires(t_power_usage* power_usage,
8181

8282
/* Clock */
8383
static void power_usage_clock(t_power_usage* power_usage,
84-
t_clock_arch* clock_arch);
84+
std::vector<t_clock_network> clock_arch);
8585
static void power_usage_clock_single(t_power_usage* power_usage,
8686
t_clock_network* clock_inf);
8787

@@ -192,8 +192,8 @@ static void power_usage_primitive(t_power_usage* power_usage, t_pb* pb, t_pb_gra
192192
Q_dens = pin_dens(pb, Q_pin, iblk);
193193
Q_prob = pin_prob(pb, Q_pin, iblk);
194194

195-
clk_prob = device_ctx.clock_arch->clock_inf[0].prob;
196-
clk_dens = device_ctx.clock_arch->clock_inf[0].dens;
195+
clk_prob = device_ctx.clock_arch[0].prob;
196+
clk_dens = device_ctx.clock_arch[0].dens;
197197

198198
power_usage_ff(&sub_power_usage, power_ctx.arch->FF_size, D_prob, D_dens,
199199
Q_prob, Q_dens, clk_prob, clk_dens, power_ctx.solution_inf.T_crit);
@@ -645,7 +645,7 @@ static void power_usage_blocks(t_power_usage* power_usage) {
645645
* Calculates the total power usage from the clock network
646646
*/
647647
static void power_usage_clock(t_power_usage* power_usage,
648-
t_clock_arch* clock_arch) {
648+
std::vector<t_clock_network> clock_arch) {
649649
int clock_idx;
650650
auto& power_ctx = g_vpr_ctx.power();
651651

@@ -654,27 +654,27 @@ static void power_usage_clock(t_power_usage* power_usage,
654654
power_usage->leakage = 0.;
655655

656656
/* if no global clock, then return */
657-
if (clock_arch->num_global_clocks == 0) {
657+
if (clock_arch.empty()) {
658658
return;
659659
}
660660

661-
for (clock_idx = 0; clock_idx < clock_arch->num_global_clocks;
661+
for (clock_idx = 0; clock_idx < static_cast<int>(clock_arch.size());
662662
clock_idx++) {
663663
t_power_usage clock_power;
664664

665665
/* Assume the global clock is active even for combinational circuits */
666-
if (clock_arch->num_global_clocks == 1) {
667-
if (clock_arch->clock_inf[clock_idx].dens == 0) {
668-
clock_arch->clock_inf[clock_idx].dens = 2;
669-
clock_arch->clock_inf[clock_idx].prob = 0.5;
666+
if (clock_arch.size() == 1) {
667+
if (clock_arch[clock_idx].dens == 0) {
668+
clock_arch[clock_idx].dens = 2;
669+
clock_arch[clock_idx].prob = 0.5;
670670

671671
// This will need to change for multi-clock
672-
clock_arch->clock_inf[clock_idx].period = power_ctx.solution_inf.T_crit;
672+
clock_arch[clock_idx].period = power_ctx.solution_inf.T_crit;
673673
}
674674
}
675675
/* find the power dissipated by each clock network */
676676
power_usage_clock_single(&clock_power,
677-
&clock_arch->clock_inf[clock_idx]);
677+
&clock_arch[clock_idx]);
678678
power_add_usage(power_usage, &clock_power);
679679
}
680680

0 commit comments

Comments
 (0)