@@ -611,6 +611,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
611
611
fold_expressions = true ;
612
612
break ;
613
613
}
614
+ case TASK: // fallthrough
615
+ case STATEMENT: // fallthough
614
616
case FUNCTION: // fallthrough
615
617
case INITIAL: // fallthrough
616
618
case ALWAYS:
@@ -831,6 +833,59 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
831
833
vtr::free (temp_instance_name);
832
834
}
833
835
836
+ for (i = 0 ; i < node->types .task .size_task_instantiations ; i++)
837
+ {
838
+
839
+ /* make the stringed up module instance name - instance name is
840
+ * MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
841
+ * module name is MODULE_INSTANCE->IDENTIFIER(child[0])
842
+ */
843
+ ast_node_t *temp_instance = node->types .task .task_instantiations_instance [i];
844
+ char *instance_name_prefix = local_ref->instance_name_prefix ;
845
+
846
+ char *temp_instance_name = make_full_ref_name (instance_name_prefix,
847
+ temp_instance->children [0 ]->types .identifier ,
848
+ temp_instance->children [1 ]->children [0 ]->types .identifier ,
849
+ NULL , -1 );
850
+
851
+ long sc_spot;
852
+ /* lookup the name of the task associated with this instantiated point */
853
+ if ((sc_spot = sc_lookup_string (module_names_to_idx, temp_instance->children [0 ]->types .identifier )) == -1 )
854
+ {
855
+ error_message (NETLIST_ERROR, node->line_number , node->file_number ,
856
+ " Can't find task name %s\n " , temp_instance->children [0 ]->types .identifier );
857
+ }
858
+
859
+ /* make a unique copy of this task */
860
+ ast_node_t *instance = ast_node_deep_copy ((ast_node_t *)module_names_to_idx->data [sc_spot]);
861
+
862
+ long sc_spot_2 = sc_add_string (module_names_to_idx, temp_instance_name);
863
+ oassert (sc_spot_2 > -1 && module_names_to_idx->data [sc_spot_2] == NULL );
864
+ module_names_to_idx->data [sc_spot_2] = (void *)instance;
865
+
866
+ ast_modules = (ast_node_t **)vtr::realloc (ast_modules, sizeof (ast_node_t *)*(sc_spot_2 + 1 ));
867
+ ast_modules[sc_spot_2] = instance;
868
+
869
+ /* create the string cache list for the instantiated module */
870
+ sc_hierarchy *original_sc_hierarchy = ((ast_node_t *)module_names_to_idx->data [sc_spot])->types .task .string_cache_list ;
871
+ sc_hierarchy *task_sc_hierarchy = copy_sc_hierarchy (original_sc_hierarchy);
872
+ task_sc_hierarchy->parent = local_ref;
873
+ task_sc_hierarchy->instance_name_prefix = vtr::strdup (temp_instance_name);
874
+ task_sc_hierarchy->scope_id = vtr::strdup (temp_instance->children [1 ]->children [0 ]->types .identifier );
875
+
876
+ /* update parent string cache list */
877
+ int num_task_children = local_ref->num_task_children ;
878
+ local_ref->task_children = (sc_hierarchy **)vtr::realloc (local_ref->task_children , sizeof (sc_hierarchy *)*(num_task_children + 1 ));
879
+ local_ref->task_children [i] = task_sc_hierarchy;
880
+ local_ref->num_task_children ++;
881
+
882
+ /* elaboration */
883
+ instance = build_hierarchy (instance, NULL , -1 , task_sc_hierarchy, false , true , data);
884
+
885
+ /* clean up */
886
+ vtr::free (temp_instance_name);
887
+ }
888
+
834
889
break ;
835
890
}
836
891
case MODULE_INSTANCE:
@@ -1009,6 +1064,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
1009
1064
1010
1065
break ;
1011
1066
}
1067
+ case STATEMENT: // fallthrough
1068
+ case TASK: // fallthrough
1012
1069
case FUNCTION: // fallthrough
1013
1070
case INITIAL: // fallthrough
1014
1071
case ALWAYS:
@@ -1103,6 +1160,44 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1103
1160
1104
1161
break ;
1105
1162
}
1163
+ case TASK:
1164
+ {
1165
+ if (parent != NULL )
1166
+ {
1167
+ skip_children = true ;
1168
+ }
1169
+ break ;
1170
+ }
1171
+ case TASK_INSTANCE:
1172
+ {
1173
+ // check ports
1174
+ ast_node_t *connect_list = node->children [1 ]->children [1 ];
1175
+ bool is_ordered_list;
1176
+ if (connect_list->children [1 ]->children [0 ]) // skip first connection
1177
+ {
1178
+ is_ordered_list = false ; // name was specified
1179
+ }
1180
+ else
1181
+ {
1182
+ is_ordered_list = true ;
1183
+ }
1184
+
1185
+ for (int i = 1 ; i < connect_list->num_children ; i++)
1186
+ {
1187
+ if ((connect_list->children [i]
1188
+ && connect_list->children [i]->children )
1189
+ && (( connect_list->children [i]->children [0 ] && is_ordered_list)
1190
+ || (!connect_list->children [i]->children [0 ] && !is_ordered_list)))
1191
+ {
1192
+ error_message (PARSE_ERROR, node->line_number , node->file_number ,
1193
+ " %s" , " Cannot mix port connections by name and port connections by ordered list\n " );
1194
+ }
1195
+ }
1196
+
1197
+ skip_children = true ;
1198
+
1199
+ break ;
1200
+ }
1106
1201
case MODULE_ITEMS:
1107
1202
{
1108
1203
/* look in the string cache for in-line continuous assignments */
@@ -1322,6 +1417,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1322
1417
1323
1418
break ;
1324
1419
}
1420
+ case STATEMENT: // fallthrough
1325
1421
case ALWAYS: // fallthrough
1326
1422
case INITIAL:
1327
1423
{
@@ -1556,6 +1652,40 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1556
1652
vtr::free (temp_instance_name);
1557
1653
}
1558
1654
1655
+ for (i = 0 ; i < node->types .task .size_task_instantiations ; i++)
1656
+ {
1657
+
1658
+ /* make the stringed up module instance name - instance name is
1659
+ * MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
1660
+ * module name is MODULE_INSTANCE->IDENTIFIER(child[0])
1661
+ */
1662
+ ast_node_t *temp_instance = node->types .task .task_instantiations_instance [i];
1663
+ char *instance_name_prefix = local_ref->instance_name_prefix ;
1664
+
1665
+ char *temp_instance_name = make_full_ref_name (instance_name_prefix,
1666
+ temp_instance->children [0 ]->types .identifier ,
1667
+ temp_instance->children [1 ]->children [0 ]->types .identifier ,
1668
+ NULL , -1 );
1669
+
1670
+ /* lookup the name of the task associated with this instantiated point */
1671
+ long sc_spot = sc_lookup_string (module_names_to_idx, temp_instance->children [0 ]->types .identifier );
1672
+ oassert (sc_spot > -1 && module_names_to_idx->data [sc_spot] != NULL );
1673
+ ast_node_t *instance = (ast_node_t *)module_names_to_idx->data [sc_spot];
1674
+
1675
+ sc_hierarchy *task_sc_hierarchy = local_ref->task_children [i];
1676
+
1677
+ /* update the parameter table for the instantiated module */
1678
+ STRING_CACHE *instance_param_table_sc = task_sc_hierarchy->local_param_table_sc ;
1679
+ update_instance_parameter_table (temp_instance, instance_param_table_sc);
1680
+
1681
+ /* elaboration */
1682
+ update_string_caches (task_sc_hierarchy);
1683
+ instance = finalize_ast (instance, NULL , task_sc_hierarchy, false , true , data);
1684
+
1685
+ /* clean up */
1686
+ vtr::free (temp_instance_name);
1687
+ }
1688
+
1559
1689
break ;
1560
1690
}
1561
1691
case MODULE_INSTANCE:
@@ -1779,6 +1909,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1779
1909
if (node->num_children == 3 ) convert_2D_to_1D_array_ref (&node, local_ref);
1780
1910
break ;
1781
1911
}
1912
+ case STATEMENT: // fallthrough
1782
1913
case ALWAYS: // fallthrough
1783
1914
case INITIAL:
1784
1915
{
@@ -1836,6 +1967,11 @@ ast_node_t *reduce_expressions(ast_node_t *node, sc_hierarchy *local_ref, long *
1836
1967
skip_children = true ;
1837
1968
break ;
1838
1969
}
1970
+ case TASK:
1971
+ {
1972
+ skip_children = true ;
1973
+ break ;
1974
+ }
1839
1975
case MODULE_INSTANCE:
1840
1976
{
1841
1977
skip_children = true ;
0 commit comments