Skip to content

Commit 038ee51

Browse files
authored
Merge pull request #1 from jeanlego/tested
Tested
2 parents 16f3731 + 923d3d3 commit 038ee51

File tree

129 files changed

+60701
-2633
lines changed

Some content is hidden

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

129 files changed

+60701
-2633
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Possible values:
1616
# release
1717
# debug
18-
BUILD_TYPE = release
18+
BUILD_TYPE = debug
1919

2020
#Allows users to pass parameters to cmake
2121
# e.g. make CMAKE_PARAMS="-DVTR_ENABLE_SANITIZE=true"

ODIN_II/SRC/ace.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE.
2727
#include "ace.h"
2828
#include "st.h"
2929

30+
3031
#define ACE_P0TO1(P1,PS) ((P1)==0.0)?0.0:(((P1)==1.0)?1.0:0.5*PS/(1.0-(P1)))
3132
#define ACE_P1TO0(P1,PS) ((P1)==0.0)?1.0:(((P1)==0.0)?0.0:0.5*PS/(P1))
3233

@@ -59,7 +60,7 @@ OTHER DEALINGS IN THE SOFTWARE.
5960

6061
typedef unsigned int *pset;
6162

62-
#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
63+
#define ALLOC(type, num) (type*)calloc(num,sizeof(type))
6364

6465
#define set_remove(set, e) (set[WHICH_WORD(e)] &= ~ (1 << WHICH_BIT(e)))
6566
#define set_insert(set, e) (set[WHICH_WORD(e)] |= 1 << WHICH_BIT(e))
@@ -332,6 +333,8 @@ void compute_switching_activities ( netlist_t *net ) {
332333
}
333334
}
334335
}
336+
Cudd_RecursiveDeref(dd,Cudd_ReadOne(dd));
337+
Cudd_Quit(dd);
335338
}
336339

337340

@@ -465,7 +468,7 @@ ace_cube_t * ace_cube_dup(ace_cube_t * cube) {
465468
int i;
466469
ace_cube_t * cube_copy;
467470

468-
cube_copy = (ace_cube_t * ) malloc(sizeof(ace_cube_t));
471+
cube_copy = (ace_cube_t * ) calloc(1,sizeof(ace_cube_t));
469472
cube_copy->static_prob = cube->static_prob;
470473
cube_copy->num_literals = cube->num_literals;
471474
cube_copy->cube = set_new (2 * cube->num_literals);
@@ -499,7 +502,7 @@ ace_cube_t * ace_cube_new_dc(int num_literals) {
499502
int i;
500503
ace_cube_t * new_cube;
501504

502-
new_cube = (ace_cube_t * ) malloc(sizeof(ace_cube_t));
505+
new_cube = (ace_cube_t * ) calloc(1,sizeof(ace_cube_t));
503506
new_cube->num_literals = num_literals;
504507
new_cube->static_prob = 1.0;
505508
new_cube->cube = set_new (2 * num_literals);
@@ -616,7 +619,7 @@ double calc_cube_switch_prob_recur(DdManager * mgr, DdNode * bdd, ace_cube_t * c
616619

617620
i = Cudd_Regular(bdd)->index;
618621

619-
current_prob = ( double * ) malloc(sizeof(double));
622+
current_prob = ( double * ) calloc(1,sizeof(double));
620623

621624
if (Cudd_IsComplement(bdd)) {
622625
bdd_if1 = Cudd_E(bdd);

ODIN_II/SRC/activity_estimation.c

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ OTHER DEALINGS IN THE SOFTWARE.
3333
#include "activity_estimation.h"
3434
#include "netlist_check.h"
3535

36+
3637
#define DEFAULT_STATIC_PROBABILITY .5
3738
#define DEFAULT_TRANSITION_DENSITY .5
3839

@@ -102,7 +103,7 @@ void calc_transition_density(netlist_t *netlist)
102103
if (current_node->type == BLIF_FUNCTION)
103104
{
104105
/* only one output */
105-
act_data->transition_density = (double*)malloc(sizeof(double)); // only one output
106+
act_data->transition_density = (double*)calloc(1,sizeof(double)); // only one output
106107

107108
if (current_node->num_input_pins == 1)
108109
{
@@ -155,7 +156,7 @@ void calc_transition_density(netlist_t *netlist)
155156
oassert(input_node->unique_node_data_id == ACTIVATION);
156157

157158
/* just store since allocated in the initialization */
158-
act_data->transition_density = (double*)malloc(sizeof(double));
159+
act_data->transition_density = (double*)calloc(1,sizeof(double));
159160
act_data->transition_density[0] = 2 * (input_data->static_probability[input_node_pin] * (1-input_data->static_probability[input_node_pin]));
160161
}
161162
else if (current_node->type == OUTPUT_NODE)
@@ -166,7 +167,7 @@ void calc_transition_density(netlist_t *netlist)
166167
oassert(input_node->unique_node_data_id == ACTIVATION);
167168

168169
/* allocate and stre through */
169-
act_data->transition_density = (double*)malloc(sizeof(double));
170+
act_data->transition_density = (double*)calloc(1,sizeof(double));
170171
act_data->transition_density[0] = input_data->static_probability[input_node_pin];
171172
}
172173
else if ((current_node->type == INPUT_NODE) || (current_node->type == VCC_NODE) || (current_node->type == GND_NODE))
@@ -198,7 +199,7 @@ void initialize_probabilities(char *input_file, netlist_t *netlist)
198199
oassert(current_node->unique_node_data_id == RESET);
199200

200201
current_node->unique_node_data_id = ACTIVATION;
201-
act_data = (activation_t*)malloc(sizeof(activation_t));
202+
act_data = (activation_t*)calloc(1,sizeof(activation_t));
202203
current_node->node_data = (void*)act_data;
203204

204205
if (current_node->type == INPUT_NODE)
@@ -218,9 +219,9 @@ void initialize_probabilities(char *input_file, netlist_t *netlist)
218219
else
219220
{
220221
/* initialize all the initial probabilities */
221-
act_data->static_probability = (double*)malloc(sizeof(double));
222-
act_data->transition_probability = (double*)malloc(sizeof(double));
223-
act_data->transition_density = (double*)malloc(sizeof(double));
222+
act_data->static_probability = (double*)calloc(1,sizeof(double));
223+
act_data->transition_probability = (double*)calloc(1,sizeof(double));
224+
act_data->transition_density = (double*)calloc(1,sizeof(double));
224225

225226
act_data->static_probability[0] = DEFAULT_STATIC_PROBABILITY;
226227
act_data->transition_probability[0] = -1;
@@ -230,9 +231,9 @@ void initialize_probabilities(char *input_file, netlist_t *netlist)
230231
else if (current_node->type == GND_NODE)
231232
{
232233
/* initialize all the initial probabilities */
233-
act_data->static_probability = (double*)malloc(sizeof(double));
234-
act_data->transition_probability = (double*)malloc(sizeof(double));
235-
act_data->transition_density = (double*)malloc(sizeof(double));
234+
act_data->static_probability = (double*)calloc(1,sizeof(double));
235+
act_data->transition_probability = (double*)calloc(1,sizeof(double));
236+
act_data->transition_density = (double*)calloc(1,sizeof(double));
236237

237238
act_data->static_probability[0] = 0.0;
238239
act_data->transition_probability[0] = -1;
@@ -242,9 +243,9 @@ void initialize_probabilities(char *input_file, netlist_t *netlist)
242243
else if (current_node->type == VCC_NODE)
243244
{
244245
/* initialize all the initial probabilities */
245-
act_data->static_probability = (double*)malloc(sizeof(double));
246-
act_data->transition_probability = (double*)malloc(sizeof(double));
247-
act_data->transition_density = (double*)malloc(sizeof(double));
246+
act_data->static_probability = (double*)calloc(1,sizeof(double));
247+
act_data->transition_probability = (double*)calloc(1,sizeof(double));
248+
act_data->transition_density = (double*)calloc(1,sizeof(double));
248249

249250
act_data->static_probability[0] = 1.0;
250251
act_data->transition_probability[0] = -1;
@@ -254,9 +255,9 @@ void initialize_probabilities(char *input_file, netlist_t *netlist)
254255
else if (current_node->type == FF_NODE)
255256
{
256257
/* initialize all the initial probabilities */
257-
act_data->static_probability = (double*)malloc(sizeof(double));
258-
act_data->transition_probability = (double*)malloc(sizeof(double));
259-
act_data->transition_density = (double*)malloc(sizeof(double));
258+
act_data->static_probability = (double*)calloc(1,sizeof(double));
259+
act_data->transition_probability = (double*)calloc(1,sizeof(double));
260+
act_data->transition_density = (double*)calloc(1,sizeof(double));
260261

261262
act_data->static_probability[0] = DEFAULT_STATIC_PROBABILITY;
262263
act_data->transition_probability[0] = -1;
@@ -296,7 +297,7 @@ void calc_probabilities_and_init_act_data(netlist_t *netlist)
296297
if (rep == 0)
297298
{
298299
/* only one output */
299-
act_data->static_probability = (double*)malloc(sizeof(double));
300+
act_data->static_probability = (double*)calloc(1,sizeof(double));
300301
}
301302

302303
for (k = 0; k < function_size; k++)
@@ -356,7 +357,7 @@ void calc_probabilities_and_init_act_data(netlist_t *netlist)
356357
if (rep == 0)
357358
{
358359
/* only one output */
359-
act_data->static_probability = (double*)malloc(sizeof(double));
360+
act_data->static_probability = (double*)calloc(1,sizeof(double));
360361
}
361362

362363
act_data->static_probability[0] = input_data->static_probability[input_node_pin];
@@ -374,7 +375,7 @@ void calc_probabilities_and_init_act_data(netlist_t *netlist)
374375
if (rep == 0)
375376
{
376377
/* calculate transition probability */
377-
act_data->transition_probability = (double*)malloc(sizeof(double)*current_node->num_output_pins);
378+
act_data->transition_probability = (double*)calloc(current_node->num_output_pins,sizeof(double));
378379
}
379380

380381
for (k = 0; k < current_node->num_output_pins; k++)
@@ -404,7 +405,7 @@ short *boolean_difference(nnode_t *node, int variable_spot)
404405
/* calculate the size of the boolean difference */
405406
function_size = pow2(node->num_input_pins-1);
406407

407-
return_function = (short*)calloc(sizeof(short), function_size);
408+
return_function = (short*)calloc(function_size,sizeof(short));
408409

409410
for (i = 0; i < function_size; i++)
410411
{
@@ -529,9 +530,9 @@ double calc_density(nnode_t *node, int variable_spot, short *boolean_difference)
529530
*-------------------------------------------------------------------------------------------*/
530531
void output_activation_file_ace_and_function_file(char *output_filename, int lut_size, netlist_t *LUT_netlist, netlist_t *CLUSTER_netlist)
531532
{
532-
char *ace_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1));
533-
char *ac2_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1));
534-
char *function_file_name = (char*)malloc(sizeof(char)*(strlen(output_filename)+4+1));
533+
char *ace_file_name = (char*)calloc((strlen(output_filename)+4+1),sizeof(char));
534+
char *ac2_file_name = (char*)calloc((strlen(output_filename)+4+1),sizeof(char));
535+
char *function_file_name = (char*)calloc((strlen(output_filename)+4+1),sizeof(char));
535536
int i, j, k, l;
536537
FILE *ace_out;
537538
FILE *ac2_out;
@@ -545,20 +546,22 @@ void output_activation_file_ace_and_function_file(char *output_filename, int lut
545546
sprintf(function_file_name, "%s.fun", output_filename);
546547

547548
ace_out = fopen(ace_file_name, "w");
548-
if (ace_out == NULL)
549-
{
549+
if (!ace_out){
550550
error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", ace_file_name);
551551
}
552+
free(ace_out);
553+
552554
ac2_out = fopen(ac2_file_name, "w");
553-
if (ac2_out == NULL)
554-
{
555+
if (!ac2_out){
555556
error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", ac2_file_name);
556557
}
558+
free(ac2_out);
559+
557560
function_out = fopen(function_file_name, "w");
558-
if (function_out == NULL)
559-
{
561+
if (!function_out){
560562
error_message(ACTIVATION_ERROR, -1, -1, "Could not open output file %s\n", function_file_name);
561563
}
564+
free(function_out);
562565

563566
/* Go through the LUT netlist and print out the ace files */
564567
for (i = 0; i < LUT_netlist->num_forward_levels; i++)
@@ -658,7 +661,7 @@ void output_activation_file_ace_and_function_file(char *output_filename, int lut
658661
for (k = 0; k < internal_subblocks->num_internal_nodes; k++)
659662
{
660663
nnode_t *current_subblock = internal_subblocks->internal_nodes[k];
661-
char *output_search_name = (char*)malloc(sizeof(char)*(strlen(current_subblock->name)+1+4));
664+
char *output_search_name = (char*)calloc((strlen(current_subblock->name)+1+4),sizeof(char));
662665
sprintf(output_search_name, "out:%s", current_subblock->name);
663666

664667
if ((sc_spot = sc_lookup_string(internal_subblocks->nodes_sc, output_search_name)) != -1)

ODIN_II/SRC/activity_estimation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
void activity_estimation(char *input_filename, char *output_filename, int lut_size, netlist_t *LUT_netlist, netlist_t *CLUSTER_netlist);

0 commit comments

Comments
 (0)