@@ -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;
@@ -379,13 +380,13 @@ ast_node_t **expand_node_list_at(ast_node_t **list, long old_size, long to_add,
379
380
* (function: make_concat_into_list_of_strings)
380
381
* 0th idx will be the MSbit
381
382
*-------------------------------------------------------------------------------------------*/
382
- void make_concat_into_list_of_strings (ast_node_t *concat_top, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
383
+ void make_concat_into_list_of_strings (ast_node_t *concat_top, char *instance_name_prefix, sc_hierarchy *local_ref )
383
384
{
384
385
long i;
385
386
int j;
386
387
ast_node_t *rnode[3 ] = { 0 };
387
388
388
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
389
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
389
390
390
391
concat_top->types .concat .num_bit_strings = 0 ;
391
392
concat_top->types .concat .bit_strings = NULL ;
@@ -395,7 +396,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
395
396
{
396
397
if (concat_top->children [i]->type == CONCATENATE)
397
398
{
398
- make_concat_into_list_of_strings (concat_top->children [i], instance_name_prefix, local_string_cache_list );
399
+ make_concat_into_list_of_strings (concat_top->children [i], instance_name_prefix, local_ref );
399
400
}
400
401
}
401
402
@@ -416,7 +417,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
416
417
{
417
418
concat_top->types .concat .num_bit_strings ++;
418
419
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 );
420
+ 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
421
}
421
422
else if (var_declare->children [3 ] == NULL )
422
423
{
@@ -429,7 +430,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
429
430
{
430
431
concat_top->types .concat .num_bit_strings ++;
431
432
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 );
433
+ 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
434
}
434
435
}
435
436
else if (var_declare->children [3 ] != NULL )
@@ -443,7 +444,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
443
444
{
444
445
concat_top->types .concat .num_bit_strings ++;
445
446
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 );
447
+ 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
448
}
448
449
else if (concat_top->children [i]->type == RANGE_REF)
449
450
{
@@ -460,7 +461,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
460
461
concat_top->types .concat .num_bit_strings ++;
461
462
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
463
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 );
464
+ 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
465
}
465
466
}
466
467
else if (concat_top->children [i]->type == NUMBERS)
@@ -472,7 +473,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
472
473
{
473
474
concat_top->types .concat .num_bit_strings ++;
474
475
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 );
476
+ 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
477
477
478
}
478
479
}
@@ -488,7 +489,7 @@ void make_concat_into_list_of_strings(ast_node_t *concat_top, char *instance_nam
488
489
{
489
490
concat_top->types .concat .num_bit_strings ++;
490
491
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 );
492
+ 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
493
}
493
494
}
494
495
else
@@ -560,12 +561,12 @@ char *get_name_of_var_declare_at_bit(ast_node_t *var_declare, int bit)
560
561
* (function: get_name of_port_at_bit)
561
562
* Assume module connections can be one of: Array entry, Concat, Signal, Array range reference
562
563
*-------------------------------------------------------------------------------------------*/
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 )
564
+ char *get_name_of_pin_at_bit (ast_node_t *var_node, int bit, char *instance_name_prefix, sc_hierarchy *local_ref )
564
565
{
565
566
char *return_string = NULL ;
566
567
ast_node_t *rnode[3 ] = { 0 };
567
568
568
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
569
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
569
570
570
571
if (var_node->type == ARRAY_REF)
571
572
{
@@ -632,7 +633,7 @@ char *get_name_of_pin_at_bit(ast_node_t *var_node, int bit, char *instance_name_
632
633
if (var_node->types .concat .num_bit_strings == -1 )
633
634
{
634
635
/* 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 );
636
+ make_concat_into_list_of_strings (var_node, instance_name_prefix, local_ref );
636
637
}
637
638
638
639
return_string = (char *)vtr::malloc (sizeof (char )*strlen (var_node->types .concat .bit_strings [bit])+1 );
@@ -695,15 +696,15 @@ char *get_name_of_pin_number(ast_node_t *var_node, int bit)
695
696
* Assume module connections can be one of: Array entry, Concat, Signal, Array range reference
696
697
* Return a list of strings
697
698
*-------------------------------------------------------------------------------------------*/
698
- char_list_t *get_name_of_pins (ast_node_t *var_node, char *instance_name_prefix, STRING_CACHE_LIST *local_string_cache_list )
699
+ char_list_t *get_name_of_pins (ast_node_t *var_node, char *instance_name_prefix, sc_hierarchy *local_ref )
699
700
{
700
701
char **return_string = NULL ;
701
702
char_list_t *return_list = (char_list_t *)vtr::malloc (sizeof (char_list_t ));
702
703
ast_node_t *rnode[3 ] = { 0 };
703
704
int i;
704
705
int width = 0 ;
705
706
706
- STRING_CACHE *local_symbol_table_sc = local_string_cache_list ->local_symbol_table_sc ;
707
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
707
708
708
709
if (var_node->type == ARRAY_REF)
709
710
{
@@ -803,7 +804,7 @@ char_list_t *get_name_of_pins(ast_node_t *var_node, char *instance_name_prefix,
803
804
{
804
805
if (var_node->types .concat .num_bit_strings == -1 )
805
806
{
806
- make_concat_into_list_of_strings (var_node, instance_name_prefix, local_string_cache_list );
807
+ make_concat_into_list_of_strings (var_node, instance_name_prefix, local_ref );
807
808
}
808
809
809
810
width = var_node->types .concat .num_bit_strings ;
@@ -829,14 +830,14 @@ char_list_t *get_name_of_pins(ast_node_t *var_node, char *instance_name_prefix,
829
830
/* ---------------------------------------------------------------------------------------------
830
831
* (function: get_name_of_pins_with_prefix
831
832
*-------------------------------------------------------------------------------------------*/
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 )
833
+ char_list_t *get_name_of_pins_with_prefix (ast_node_t *var_node, char *instance_name_prefix, sc_hierarchy *local_ref )
833
834
{
834
835
int i;
835
836
char_list_t *return_list;
836
837
char *temp_str;
837
838
838
839
/* get the list */
839
- return_list = get_name_of_pins (var_node, instance_name_prefix, local_string_cache_list );
840
+ return_list = get_name_of_pins (var_node, instance_name_prefix, local_ref );
840
841
841
842
for (i = 0 ; i < return_list->num_strings ; i++)
842
843
{
@@ -852,14 +853,14 @@ char_list_t *get_name_of_pins_with_prefix(ast_node_t *var_node, char *instance_n
852
853
/* ----------------------------------------------------------------------------
853
854
* (function: get_size_of_variable)
854
855
*--------------------------------------------------------------------------*/
855
- long get_size_of_variable (ast_node_t *node, STRING_CACHE_LIST *local_string_cache_list )
856
+ long get_size_of_variable (ast_node_t *node, sc_hierarchy *local_ref )
856
857
{
857
858
long assignment_size = 0 ;
858
859
long sc_spot = 0 ;
859
860
ast_node_t *var_declare = NULL ;
860
861
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 ;
862
+ STRING_CACHE *local_symbol_table_sc = local_ref ->local_symbol_table_sc ;
863
+ STRING_CACHE *local_param_table_sc = local_ref ->local_param_table_sc ;
863
864
864
865
switch (node->type )
865
866
{
@@ -915,7 +916,7 @@ long get_size_of_variable(ast_node_t *node, STRING_CACHE_LIST *local_string_cach
915
916
916
917
case CONCATENATE:
917
918
{
918
- assignment_size = resolve_concat_sizes (node, local_string_cache_list );
919
+ assignment_size = resolve_concat_sizes (node, local_ref );
919
920
return assignment_size;
920
921
}
921
922
@@ -1452,7 +1453,7 @@ long clog2(long value_in, int length)
1452
1453
/* ---------------------------------------------------------------------------
1453
1454
* (function: resolve_concat_sizes)
1454
1455
*-------------------------------------------------------------------------*/
1455
- long resolve_concat_sizes (ast_node_t *node_top, STRING_CACHE_LIST *local_string_cache_list )
1456
+ long resolve_concat_sizes (ast_node_t *node_top, sc_hierarchy *local_ref )
1456
1457
{
1457
1458
long concatenation_size = 0 ;
1458
1459
@@ -1464,7 +1465,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1464
1465
{
1465
1466
for (int i = 0 ; i < node_top->num_children ; i++)
1466
1467
{
1467
- concatenation_size += resolve_concat_sizes (node_top->children [i], local_string_cache_list );
1468
+ concatenation_size += resolve_concat_sizes (node_top->children [i], local_ref );
1468
1469
}
1469
1470
}
1470
1471
break ;
@@ -1473,7 +1474,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1473
1474
case ARRAY_REF:
1474
1475
case RANGE_REF:
1475
1476
{
1476
- concatenation_size += get_size_of_variable (node_top, local_string_cache_list );
1477
+ concatenation_size += get_size_of_variable (node_top, local_ref );
1477
1478
}
1478
1479
break ;
1479
1480
@@ -1483,7 +1484,7 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1483
1484
long max_size = 0 ;
1484
1485
for (int i = 0 ; i < node_top->num_children ; i++)
1485
1486
{
1486
- long this_size = resolve_concat_sizes (node_top->children [i], local_string_cache_list );
1487
+ long this_size = resolve_concat_sizes (node_top->children [i], local_ref );
1487
1488
if (this_size > max_size) max_size = this_size;
1488
1489
}
1489
1490
concatenation_size += max_size;
@@ -1493,8 +1494,8 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1493
1494
case IF_Q:
1494
1495
{
1495
1496
/* 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 );
1497
+ long true_length = resolve_concat_sizes (node_top->children [1 ], local_ref );
1498
+ long false_length = resolve_concat_sizes (node_top->children [2 ], local_ref );
1498
1499
concatenation_size += (true_length > false_length) ? true_length : false_length;
1499
1500
}
1500
1501
break ;
@@ -1519,59 +1520,3 @@ long resolve_concat_sizes(ast_node_t *node_top, STRING_CACHE_LIST *local_string_
1519
1520
1520
1521
return concatenation_size;
1521
1522
}
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