23
23
#include < cstring>
24
24
#include < cmath>
25
25
#include < map>
26
+ #include < string>
26
27
27
28
#include " vtr_assert.h"
28
29
#include " vtr_memory.h"
@@ -211,19 +212,16 @@ float calc_buffer_stage_effort(int N, float final_stage_size) {
211
212
* - LUT_size: The number of LUT inputs
212
213
* - truth_table: The logic terms saved from the BLIF file
213
214
*/
214
- char * alloc_SRAM_values_from_truth_table (int LUT_size,
215
- const AtomNetlist::TruthTable& truth_table) {
216
- int num_SRAM_bits = 1 << LUT_size;
215
+ std::string alloc_SRAM_values_from_truth_table (int LUT_size,
216
+ const AtomNetlist::TruthTable& truth_table) {
217
+ size_t num_SRAM_bits = 1 << LUT_size;
217
218
218
219
// SRAM value stored as a string of '0' and '1' characters
219
220
// Initialize to all zeros
220
- char * SRAM_values = new char [num_SRAM_bits + 1 ];
221
- for (int i = 0 ; i < num_SRAM_bits + 1 ; i++)
222
- SRAM_values[i] = ' 0' ;
223
- SRAM_values[num_SRAM_bits] = ' \0 ' ;
221
+ std::string SRAM_values (num_SRAM_bits, ' 0' );
224
222
225
223
if (truth_table.empty ()) {
226
- for (int i = 0 ; i < num_SRAM_bits; i++) {
224
+ for (size_t i = 0 ; i < num_SRAM_bits; i++) {
227
225
SRAM_values[i] = ' 1' ;
228
226
}
229
227
return SRAM_values;
@@ -237,7 +235,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size,
237
235
if (truth_table[0 ].size () == 1 ) {
238
236
if (truth_table[0 ][0 ] == vtr::LogicValue::TRUE ) {
239
237
// Mark all the SRAM values as ON
240
- for (int i = 0 ; i < num_SRAM_bits; i++) {
238
+ for (size_t i = 0 ; i < num_SRAM_bits; i++) {
241
239
SRAM_values[i] = ' 1' ;
242
240
}
243
241
return SRAM_values;
@@ -250,7 +248,7 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size,
250
248
auto expanded_truth_table = expand_truth_table (truth_table, LUT_size);
251
249
std::vector<vtr::LogicValue> lut_mask = truth_table_to_lut_mask (expanded_truth_table, LUT_size);
252
250
253
- VTR_ASSERT (lut_mask.size () == ( size_t ) num_SRAM_bits);
251
+ VTR_ASSERT (lut_mask.size () == num_SRAM_bits);
254
252
255
253
// Convert to string
256
254
for (size_t i = 0 ; i < lut_mask.size (); ++i) {
0 commit comments