@@ -40,6 +40,7 @@ OTHER DEALINGS IN THE SOFTWARE.
40
40
char **get_name_of_pins_number (ast_node_t *var_node, int start, int width);
41
41
char *get_name_of_pin_number (ast_node_t *var_node, int bit);
42
42
void update_tree_tag (ast_node_t *node, int cases, int tagged);
43
+ STRING_CACHE *copy_param_table_sc (STRING_CACHE *to_copy);
43
44
44
45
// HIGH LEVEL AST TAG
45
46
static int high_level_id;
@@ -344,6 +345,10 @@ void remove_child_from_node_at_index(ast_node_t* node, int index)
344
345
{
345
346
node->children [index] = free_whole_tree (node->children [index]);
346
347
node->children [index] = NULL ;
348
+
349
+ // ast_node_t *child = node->children[index];
350
+ // child = free_whole_tree(child);
351
+ // child = NULL;
347
352
}
348
353
349
354
for (int i = index; i < (node->num_children - 1 ); i++)
@@ -379,13 +384,13 @@ ast_node_t **expand_node_list_at(ast_node_t **list, long old_size, long to_add,
379
384
* (function: make_concat_into_list_of_strings)
380
385
* 0th idx will be the MSbit
381
386
*-------------------------------------------------------------------------------------------*/
382
- void make_concat_into_list_of_strings (ast_node_t *concat_top, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
387
+ void make_concat_into_list_of_strings (ast_node_t *concat_top, char *instance_name_prefix, sc_hierarchy *local_ref )
383
388
{
384
389
long i;
385
390
int j;
386
391
ast_node_t *rnode[3 ] = { 0 };
387
392
388
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
393
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
389
394
390
395
concat_top->types .concat .num_bit_strings = 0 ;
391
396
concat_top->types .concat .bit_strings = NULL ;
@@ -395,7 +400,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
395
400
{
396
401
if (concat_top->children [i]->type == CONCATENATE)
397
402
{
398
- make_concat_into_list_of_strings (concat_top->children [i], instance_name_prefix, local_string_cache_list );
403
+ make_concat_into_list_of_strings (concat_top->children [i], instance_name_prefix, local_ref );
399
404
}
400
405
}
401
406
@@ -416,7 +421,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
416
421
{
417
422
concat_top->types .concat .num_bit_strings ++;
418
423
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
419
- concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], -1 , instance_name_prefix, local_string_cache_list );
424
+ concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], -1 , instance_name_prefix, local_ref );
420
425
}
421
426
else if (var_declare->children [3 ] == NULL )
422
427
{
@@ -429,7 +434,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
429
434
{
430
435
concat_top->types .concat .num_bit_strings ++;
431
436
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
432
- concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_string_cache_list );
437
+ concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_ref );
433
438
}
434
439
}
435
440
else if (var_declare->children [3 ] != NULL )
@@ -443,7 +448,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
443
448
{
444
449
concat_top->types .concat .num_bit_strings ++;
445
450
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
446
- concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], 0 , instance_name_prefix, local_string_cache_list );
451
+ concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], 0 , instance_name_prefix, local_ref );
447
452
}
448
453
else if (concat_top->children [i]->type == RANGE_REF)
449
454
{
@@ -460,7 +465,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
460
465
concat_top->types .concat .num_bit_strings ++;
461
466
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
462
467
concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] =
463
- get_name_of_pin_at_bit (concat_top->children [i], ((rnode[1 ]->types .vnumber ->get_value () - rnode[2 ]->types .vnumber ->get_value ()))-j, instance_name_prefix, local_string_cache_list );
468
+ get_name_of_pin_at_bit (concat_top->children [i], ((rnode[1 ]->types .vnumber ->get_value () - rnode[2 ]->types .vnumber ->get_value ()))-j, instance_name_prefix, local_ref );
464
469
}
465
470
}
466
471
else if (concat_top->children [i]->type == NUMBERS)
@@ -472,7 +477,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
472
477
{
473
478
concat_top->types .concat .num_bit_strings ++;
474
479
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
475
- concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_string_cache_list );
480
+ concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_ref );
476
481
477
482
}
478
483
}
@@ -488,7 +493,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
488
493
{
489
494
concat_top->types .concat .num_bit_strings ++;
490
495
concat_top->types .concat .bit_strings = (char **)vtr::realloc (concat_top->types .concat .bit_strings , sizeof (char *)*(concat_top->types .concat .num_bit_strings ));
491
- concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_string_cache_list );
496
+ concat_top->types .concat .bit_strings [concat_top->types .concat .num_bit_strings -1 ] = get_name_of_pin_at_bit (concat_top->children [i], j, instance_name_prefix, local_ref );
492
497
}
493
498
}
494
499
else
@@ -560,12 +565,12 @@ char *get_name_of_var_declare_at_bit(ast_node_t *var_declare, int bit)
560
565
* (function: get_name of_port_at_bit)
561
566
* Assume module connections can be one of: Array entry, Concat, Signal, Array range reference
562
567
*-------------------------------------------------------------------------------------------*/
563
- char *get_name_of_pin_at_bit (ast_node_t *var_node, int bit, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
568
+ char *get_name_of_pin_at_bit (ast_node_t *var_node, int bit, char *instance_name_prefix, sc_hierarchy *local_ref )
564
569
{
565
570
char *return_string = NULL ;
566
571
ast_node_t *rnode[3 ] = { 0 };
567
572
568
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
573
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
569
574
570
575
if (var_node->type == ARRAY_REF)
571
576
{
@@ -632,7 +637,7 @@ char *get_name_of_pin_at_bit(ast_node_t *var_node, int bit, char *instance_name_
632
637
if (var_node->types .concat .num_bit_strings == -1 )
633
638
{
634
639
/* If this hasn't been made into a string list then do it */
635
- make_concat_into_list_of_strings (var_node, instance_name_prefix, local_string_cache_list );
640
+ make_concat_into_list_of_strings (var_node, instance_name_prefix, local_ref );
636
641
}
637
642
638
643
return_string = (char *)vtr::malloc (sizeof (char )*strlen (var_node->types .concat .bit_strings [bit])+1 );
@@ -695,15 +700,15 @@ char *get_name_of_pin_number(ast_node_t *var_node, int bit)
695
700
* Assume module connections can be one of: Array entry, Concat, Signal, Array range reference
696
701
* Return a list of strings
697
702
*-------------------------------------------------------------------------------------------*/
698
- char_list_t *get_name_of_pins (ast_node_t *var_node, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
703
+ char_list_t *get_name_of_pins (ast_node_t *var_node, char *instance_name_prefix, sc_hierarchy *local_ref )
699
704
{
700
705
char **return_string = NULL ;
701
706
char_list_t *return_list = (char_list_t *)vtr::malloc (sizeof (char_list_t ));
702
707
ast_node_t *rnode[3 ] = { 0 };
703
708
int i;
704
709
int width = 0 ;
705
710
706
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
711
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
707
712
708
713
if (var_node->type == ARRAY_REF)
709
714
{
@@ -803,7 +808,7 @@ char_list_t *get_name_of_pins(ast_node_t *var_node, char *instance_name_prefix,
803
808
{
804
809
if (var_node->types .concat .num_bit_strings == -1 )
805
810
{
806
- make_concat_into_list_of_strings (var_node, instance_name_prefix, local_string_cache_list );
811
+ make_concat_into_list_of_strings (var_node, instance_name_prefix, local_ref );
807
812
}
808
813
809
814
width = var_node->types .concat .num_bit_strings ;
@@ -829,14 +834,14 @@ char_list_t *get_name_of_pins(ast_node_t *var_node, char *instance_name_prefix,
829
834
/* ---------------------------------------------------------------------------------------------
830
835
* (function: get_name_of_pins_with_prefix
831
836
*-------------------------------------------------------------------------------------------*/
832
- char_list_t *get_name_of_pins_with_prefix (ast_node_t *var_node, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
837
+ char_list_t *get_name_of_pins_with_prefix (ast_node_t *var_node, char *instance_name_prefix, sc_hierarchy *local_ref )
833
838
{
834
839
int i;
835
840
char_list_t *return_list;
836
841
char *temp_str;
837
842
838
843
/* get the list */
839
- return_list = get_name_of_pins (var_node, instance_name_prefix, local_string_cache_list );
844
+ return_list = get_name_of_pins (var_node, instance_name_prefix, local_ref );
840
845
841
846
for (i = 0 ; i < return_list->num_strings ; i++)
842
847
{
@@ -852,14 +857,14 @@ char_list_t *get_name_of_pins_with_prefix(ast_node_t *var_node, char *instance_n
852
857
/* ----------------------------------------------------------------------------
853
858
* (function: get_size_of_variable)
854
859
*--------------------------------------------------------------------------*/
855
- long get_size_of_variable (ast_node_t *node, STRING_CACHE_LIST *local_string_cache_list )
860
+ long get_size_of_variable (ast_node_t *node, sc_hierarchy *local_ref )
856
861
{
857
862
long assignment_size = 0 ;
858
863
long sc_spot = 0 ;
859
864
ast_node_t *var_declare = NULL ;
860
865
861
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
862
- STRING_CACHE *local_param_table_sc = local_string_cache_list ->local_param_table_sc ;
866
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
867
+ STRING_CACHE *local_param_table_sc = local_ref ->local_param_table_sc ;
863
868
864
869
switch (node->type )
865
870
{
@@ -915,7 +920,7 @@ long get_size_of_variable(ast_node_t *node, STRING_CACHE_LIST *local_string_cach
915
920
916
921
case CONCATENATE:
917
922
{
918
- assignment_size = resolve_concat_sizes (node, local_string_cache_list );
923
+ assignment_size = resolve_concat_sizes (node, local_ref );
919
924
return assignment_size;
920
925
}
921
926
@@ -1452,7 +1457,7 @@ long clog2(long value_in, int length)
1452
1457
/* ---------------------------------------------------------------------------
1453
1458
* (function: resolve_concat_sizes)
1454
1459
*-------------------------------------------------------------------------*/
1455
- long resolve_concat_sizes (ast_node_t *node_top, STRING_CACHE_LIST *local_string_cache_list )
1460
+ long resolve_concat_sizes (ast_node_t *node_top, sc_hierarchy *local_ref )
1456
1461
{
1457
1462
long concatenation_size = 0 ;
1458
1463
@@ -1464,7 +1469,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1464
1469
{
1465
1470
for (int i = 0 ; i < node_top->num_children ; i++)
1466
1471
{
1467
- concatenation_size += resolve_concat_sizes (node_top->children [i], local_string_cache_list );
1472
+ concatenation_size += resolve_concat_sizes (node_top->children [i], local_ref );
1468
1473
}
1469
1474
}
1470
1475
break ;
@@ -1473,7 +1478,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1473
1478
case ARRAY_REF:
1474
1479
case RANGE_REF:
1475
1480
{
1476
- concatenation_size += get_size_of_variable (node_top, local_string_cache_list );
1481
+ concatenation_size += get_size_of_variable (node_top, local_ref );
1477
1482
}
1478
1483
break ;
1479
1484
@@ -1483,7 +1488,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1483
1488
long max_size = 0 ;
1484
1489
for (int i = 0 ; i < node_top->num_children ; i++)
1485
1490
{
1486
- long this_size = resolve_concat_sizes (node_top->children [i], local_string_cache_list );
1491
+ long this_size = resolve_concat_sizes (node_top->children [i], local_ref );
1487
1492
if (this_size > max_size) max_size = this_size;
1488
1493
}
1489
1494
concatenation_size += max_size;
@@ -1493,8 +1498,8 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1493
1498
case IF_Q:
1494
1499
{
1495
1500
/* check true/false expressions */
1496
- long true_length = resolve_concat_sizes (node_top->children [1 ], local_string_cache_list );
1497
- long false_length = resolve_concat_sizes (node_top->children [2 ], local_string_cache_list );
1501
+ long true_length = resolve_concat_sizes (node_top->children [1 ], local_ref );
1502
+ long false_length = resolve_concat_sizes (node_top->children [2 ], local_ref );
1498
1503
concatenation_size += (true_length > false_length) ? true_length : false_length;
1499
1504
}
1500
1505
break ;
@@ -1519,59 +1524,3 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1519
1524
1520
1525
return concatenation_size;
1521
1526
}
1522
-
1523
- /* ---------------------------------------------------------------------------
1524
- * (function: copy_param_table_sc)
1525
- *-------------------------------------------------------------------------*/
1526
- STRING_CACHE *copy_param_table_sc (STRING_CACHE *to_copy)
1527
- {
1528
- STRING_CACHE *sc;
1529
-
1530
- sc = sc_new_string_cache ();
1531
-
1532
- for (long i = 0 ; i < to_copy->free ; i++)
1533
- {
1534
- long sc_spot = sc_add_string (sc, to_copy->string [i]);
1535
- sc->data [sc_spot] = (void *)ast_node_deep_copy ((ast_node_t *)to_copy->data [i]);
1536
- }
1537
-
1538
- return sc;
1539
- }
1540
-
1541
- /* ---------------------------------------------------------------------------
1542
- * (function: free_string_cache_list)
1543
- *-------------------------------------------------------------------------*/
1544
- void free_string_cache_list (STRING_CACHE_LIST *to_free)
1545
- {
1546
- int i;
1547
-
1548
- for (i = 0 ; i < to_free->num_children ; i++)
1549
- {
1550
- free_string_cache_list (to_free->children [i]);
1551
- }
1552
- to_free->children = (STRING_CACHE_LIST **)vtr::free (to_free->children );
1553
-
1554
- if (to_free->local_param_table_sc )
1555
- {
1556
- for (i = 0 ; i < to_free->local_param_table_sc ->free ; i++)
1557
- {
1558
- free_whole_tree ((ast_node_t *)to_free->local_param_table_sc ->data [i]);
1559
- }
1560
- to_free->local_param_table_sc = sc_free_string_cache (to_free->local_param_table_sc );
1561
- }
1562
-
1563
- for (i = 0 ; i < to_free->num_local_symbol_table ; i++)
1564
- {
1565
- free_whole_tree (to_free->local_symbol_table [i]);
1566
- }
1567
- to_free->num_local_symbol_table = 0 ;
1568
- to_free->local_symbol_table = (ast_node_t **)vtr::free (to_free->local_symbol_table );
1569
- to_free->local_symbol_table_sc = sc_free_string_cache (to_free->local_symbol_table_sc );
1570
-
1571
- to_free->instance_name_prefix = (char *)vtr::free (to_free->instance_name_prefix );
1572
- to_free->scope_id = (char *)vtr::free (to_free->scope_id );
1573
-
1574
- to_free->num_children = 0 ;
1575
-
1576
- vtr::free (to_free);
1577
- }
0 commit comments