@@ -682,6 +682,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
682
682
fold_expressions = true ;
683
683
break ;
684
684
}
685
+ case TASK: // fallthrough
686
+ case STATEMENT: // fallthough
685
687
case FUNCTION: // fallthrough
686
688
case INITIAL: // fallthrough
687
689
case ALWAYS:
@@ -863,6 +865,59 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
863
865
vtr::free (temp_instance_name);
864
866
}
865
867
868
+ for (i = 0 ; i < node->types .task .size_task_instantiations ; i++)
869
+ {
870
+
871
+ /* make the stringed up module instance name - instance name is
872
+ * MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
873
+ * module name is MODULE_INSTANCE->IDENTIFIER(child[0])
874
+ */
875
+ ast_node_t *temp_instance = node->types .task .task_instantiations_instance [i];
876
+ char *instance_name_prefix = local_ref->instance_name_prefix ;
877
+
878
+ char *temp_instance_name = make_full_ref_name (instance_name_prefix,
879
+ temp_instance->children [0 ]->types .identifier ,
880
+ temp_instance->children [1 ]->children [0 ]->types .identifier ,
881
+ NULL , -1 );
882
+
883
+ long sc_spot;
884
+ /* lookup the name of the task associated with this instantiated point */
885
+ if ((sc_spot = sc_lookup_string (module_names_to_idx, temp_instance->children [0 ]->types .identifier )) == -1 )
886
+ {
887
+ error_message (NETLIST_ERROR, node->line_number , node->file_number ,
888
+ " Can't find task name %s\n " , temp_instance->children [0 ]->types .identifier );
889
+ }
890
+
891
+ /* make a unique copy of this task */
892
+ ast_node_t *instance = ast_node_deep_copy ((ast_node_t *)module_names_to_idx->data [sc_spot]);
893
+
894
+ long sc_spot_2 = sc_add_string (module_names_to_idx, temp_instance_name);
895
+ oassert (sc_spot_2 > -1 && module_names_to_idx->data [sc_spot_2] == NULL );
896
+ module_names_to_idx->data [sc_spot_2] = (void *)instance;
897
+
898
+ ast_modules = (ast_node_t **)vtr::realloc (ast_modules, sizeof (ast_node_t *)*(sc_spot_2 + 1 ));
899
+ ast_modules[sc_spot_2] = instance;
900
+
901
+ /* create the string cache list for the instantiated module */
902
+ sc_hierarchy *original_sc_hierarchy = ((ast_node_t *)module_names_to_idx->data [sc_spot])->types .hierarchy ;
903
+ sc_hierarchy *task_sc_hierarchy = copy_sc_hierarchy (original_sc_hierarchy);
904
+ task_sc_hierarchy->parent = local_ref;
905
+ task_sc_hierarchy->instance_name_prefix = vtr::strdup (temp_instance_name);
906
+ task_sc_hierarchy->scope_id = vtr::strdup (temp_instance->children [1 ]->children [0 ]->types .identifier );
907
+
908
+ /* update parent string cache list */
909
+ int num_task_children = local_ref->num_task_children ;
910
+ local_ref->task_children = (sc_hierarchy **)vtr::realloc (local_ref->task_children , sizeof (sc_hierarchy *)*(num_task_children + 1 ));
911
+ local_ref->task_children [i] = task_sc_hierarchy;
912
+ local_ref->num_task_children ++;
913
+
914
+ /* elaboration */
915
+ instance = build_hierarchy (instance, NULL , -1 , task_sc_hierarchy, false , true , data);
916
+
917
+ /* clean up */
918
+ vtr::free (temp_instance_name);
919
+ }
920
+
866
921
break ;
867
922
}
868
923
case MODULE_INSTANCE:
@@ -1098,6 +1153,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
1098
1153
1099
1154
break ;
1100
1155
}
1156
+ case STATEMENT: // fallthrough
1157
+ case TASK: // fallthrough
1101
1158
case FUNCTION: // fallthrough
1102
1159
case INITIAL: // fallthrough
1103
1160
case ALWAYS:
@@ -1192,6 +1249,44 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1192
1249
1193
1250
break ;
1194
1251
}
1252
+ case TASK:
1253
+ {
1254
+ if (parent != NULL )
1255
+ {
1256
+ skip_children = true ;
1257
+ }
1258
+ break ;
1259
+ }
1260
+ case TASK_INSTANCE:
1261
+ {
1262
+ // check ports
1263
+ ast_node_t *connect_list = node->children [1 ]->children [1 ];
1264
+ bool is_ordered_list;
1265
+ if (connect_list->children [1 ]->children [0 ]) // skip first connection
1266
+ {
1267
+ is_ordered_list = false ; // name was specified
1268
+ }
1269
+ else
1270
+ {
1271
+ is_ordered_list = true ;
1272
+ }
1273
+
1274
+ for (int i = 1 ; i < connect_list->num_children ; i++)
1275
+ {
1276
+ if ((connect_list->children [i]
1277
+ && connect_list->children [i]->children )
1278
+ && (( connect_list->children [i]->children [0 ] && is_ordered_list)
1279
+ || (!connect_list->children [i]->children [0 ] && !is_ordered_list)))
1280
+ {
1281
+ error_message (PARSE_ERROR, node->line_number , node->file_number ,
1282
+ " %s" , " Cannot mix port connections by name and port connections by ordered list\n " );
1283
+ }
1284
+ }
1285
+
1286
+ skip_children = true ;
1287
+
1288
+ break ;
1289
+ }
1195
1290
case MODULE_ITEMS:
1196
1291
{
1197
1292
/* look in the string cache for in-line continuous assignments */
@@ -1299,6 +1394,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1299
1394
node = unroll_for_loop (node, parent, &num_unrolled, local_ref, is_generate_region);
1300
1395
break ;
1301
1396
}
1397
+ case STATEMENT: // fallthrough
1302
1398
case ALWAYS: // fallthrough
1303
1399
case INITIAL:
1304
1400
{
@@ -1547,6 +1643,40 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1547
1643
vtr::free (temp_instance_name);
1548
1644
}
1549
1645
1646
+ for (i = 0 ; i < node->types .task .size_task_instantiations ; i++)
1647
+ {
1648
+
1649
+ /* make the stringed up module instance name - instance name is
1650
+ * MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
1651
+ * module name is MODULE_INSTANCE->IDENTIFIER(child[0])
1652
+ */
1653
+ ast_node_t *temp_instance = node->types .task .task_instantiations_instance [i];
1654
+ char *instance_name_prefix = local_ref->instance_name_prefix ;
1655
+
1656
+ char *temp_instance_name = make_full_ref_name (instance_name_prefix,
1657
+ temp_instance->children [0 ]->types .identifier ,
1658
+ temp_instance->children [1 ]->children [0 ]->types .identifier ,
1659
+ NULL , -1 );
1660
+
1661
+ /* lookup the name of the task associated with this instantiated point */
1662
+ long sc_spot = sc_lookup_string (module_names_to_idx, temp_instance->children [0 ]->types .identifier );
1663
+ oassert (sc_spot > -1 && module_names_to_idx->data [sc_spot] != NULL );
1664
+ ast_node_t *instance = (ast_node_t *)module_names_to_idx->data [sc_spot];
1665
+
1666
+ sc_hierarchy *task_sc_hierarchy = local_ref->task_children [i];
1667
+
1668
+ /* update the parameter table for the instantiated module */
1669
+ STRING_CACHE *instance_param_table_sc = task_sc_hierarchy->local_param_table_sc ;
1670
+ update_instance_parameter_table (temp_instance, instance_param_table_sc);
1671
+
1672
+ /* elaboration */
1673
+ update_string_caches (task_sc_hierarchy);
1674
+ instance = finalize_ast (instance, NULL , task_sc_hierarchy, false , true );
1675
+
1676
+ /* clean up */
1677
+ vtr::free (temp_instance_name);
1678
+ }
1679
+
1550
1680
break ;
1551
1681
}
1552
1682
case MODULE_INSTANCE:
@@ -1777,6 +1907,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
1777
1907
if (node->num_children == 3 ) convert_2D_to_1D_array_ref (&node, local_ref);
1778
1908
break ;
1779
1909
}
1910
+ case STATEMENT: // fallthrough
1780
1911
case ALWAYS: // fallthrough
1781
1912
case INITIAL:
1782
1913
{
@@ -1834,6 +1965,11 @@ ast_node_t *reduce_expressions(ast_node_t *node, sc_hierarchy *local_ref, long *
1834
1965
skip_children = true ;
1835
1966
break ;
1836
1967
}
1968
+ case TASK:
1969
+ {
1970
+ skip_children = true ;
1971
+ break ;
1972
+ }
1837
1973
case MODULE_INSTANCE:
1838
1974
{
1839
1975
skip_children = true ;
0 commit comments