@@ -682,6 +682,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
682682 fold_expressions = true ;
683683 break ;
684684 }
685+ case TASK: // fallthrough
686+ case STATEMENT: // fallthough
685687 case FUNCTION: // fallthrough
686688 case INITIAL: // fallthrough
687689 case ALWAYS:
@@ -863,6 +865,59 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
863865 vtr::free (temp_instance_name);
864866 }
865867
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+
866921 break ;
867922 }
868923 case MODULE_INSTANCE:
@@ -1098,6 +1153,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
10981153
10991154 break ;
11001155 }
1156+ case STATEMENT: // fallthrough
1157+ case TASK: // fallthrough
11011158 case FUNCTION: // fallthrough
11021159 case INITIAL: // fallthrough
11031160 case ALWAYS:
@@ -1192,6 +1249,44 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
11921249
11931250 break ;
11941251 }
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+ }
11951290 case MODULE_ITEMS:
11961291 {
11971292 /* 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
12991394 node = unroll_for_loop (node, parent, &num_unrolled, local_ref, is_generate_region);
13001395 break ;
13011396 }
1397+ case STATEMENT: // fallthrough
13021398 case ALWAYS: // fallthrough
13031399 case INITIAL:
13041400 {
@@ -1547,6 +1643,40 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
15471643 vtr::free (temp_instance_name);
15481644 }
15491645
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+
15501680 break ;
15511681 }
15521682 case MODULE_INSTANCE:
@@ -1777,6 +1907,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
17771907 if (node->num_children == 3 ) convert_2D_to_1D_array_ref (&node, local_ref);
17781908 break ;
17791909 }
1910+ case STATEMENT: // fallthrough
17801911 case ALWAYS: // fallthrough
17811912 case INITIAL:
17821913 {
@@ -1834,6 +1965,11 @@ ast_node_t *reduce_expressions(ast_node_t *node, sc_hierarchy *local_ref, long *
18341965 skip_children = true ;
18351966 break ;
18361967 }
1968+ case TASK:
1969+ {
1970+ skip_children = true ;
1971+ break ;
1972+ }
18371973 case MODULE_INSTANCE:
18381974 {
18391975 skip_children = true ;
0 commit comments