Skip to content

Commit 3909a9f

Browse files
[Warnings] Converted an int into a size_t
This code previously used an int to calculate the size of an allocation, which was done by shifting a bit; however, this is technically ill-formed since this could generate a negative value. This was causing a warning to appear in the most recent version of GCC. Although this is technically ok, its best that this properly uses size_t instead.
1 parent dc9c6a9 commit 3909a9f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vpr/src/power/power_util.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ float calc_buffer_stage_effort(int N, float final_stage_size) {
213213
*/
214214
char* alloc_SRAM_values_from_truth_table(int LUT_size,
215215
const AtomNetlist::TruthTable& truth_table) {
216-
int num_SRAM_bits = 1 << LUT_size;
216+
size_t num_SRAM_bits = 1 << LUT_size;
217217

218218
//SRAM value stored as a string of '0' and '1' characters
219219
// Initialize to all zeros
220220
char* SRAM_values = new char[num_SRAM_bits + 1];
221-
for (int i = 0; i < num_SRAM_bits + 1; i++)
221+
for (size_t i = 0; i < num_SRAM_bits + 1; i++)
222222
SRAM_values[i] = '0';
223223
SRAM_values[num_SRAM_bits] = '\0';
224224

225225
if (truth_table.empty()) {
226-
for (int i = 0; i < num_SRAM_bits; i++) {
226+
for (size_t i = 0; i < num_SRAM_bits; i++) {
227227
SRAM_values[i] = '1';
228228
}
229229
return SRAM_values;
@@ -237,7 +237,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size,
237237
if (truth_table[0].size() == 1) {
238238
if (truth_table[0][0] == vtr::LogicValue::TRUE) {
239239
//Mark all the SRAM values as ON
240-
for (int i = 0; i < num_SRAM_bits; i++) {
240+
for (size_t i = 0; i < num_SRAM_bits; i++) {
241241
SRAM_values[i] = '1';
242242
}
243243
return SRAM_values;
@@ -250,7 +250,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size,
250250
auto expanded_truth_table = expand_truth_table(truth_table, LUT_size);
251251
std::vector<vtr::LogicValue> lut_mask = truth_table_to_lut_mask(expanded_truth_table, LUT_size);
252252

253-
VTR_ASSERT(lut_mask.size() == (size_t)num_SRAM_bits);
253+
VTR_ASSERT(lut_mask.size() == num_SRAM_bits);
254254

255255
//Convert to string
256256
for (size_t i = 0; i < lut_mask.size(); ++i) {

0 commit comments

Comments
 (0)