@@ -214,6 +214,44 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, STRING_CACHE_LIST
214
214
215
215
break ;
216
216
}
217
+ case TASK:
218
+ {
219
+ if (parent != NULL )
220
+ {
221
+ skip_children = true ;
222
+ }
223
+ break ;
224
+ }
225
+ case TASK_INSTANCE:
226
+ {
227
+ // check ports
228
+ ast_node_t *connect_list = node->children [1 ]->children [1 ];
229
+ bool is_ordered_list;
230
+ if (connect_list->children [1 ]->children [0 ]) // skip first connection
231
+ {
232
+ is_ordered_list = false ; // name was specified
233
+ }
234
+ else
235
+ {
236
+ is_ordered_list = true ;
237
+ }
238
+
239
+ for (int i = 1 ; i < connect_list->num_children ; i++)
240
+ {
241
+ if ((connect_list->children [i]
242
+ && connect_list->children [i]->children )
243
+ && (( connect_list->children [i]->children [0 ] && is_ordered_list)
244
+ || (!connect_list->children [i]->children [0 ] && !is_ordered_list)))
245
+ {
246
+ error_message (PARSE_ERROR, node->line_number , node->file_number ,
247
+ " %s" , " Cannot mix port connections by name and port connections by ordered list\n " );
248
+ }
249
+ }
250
+
251
+ skip_children = true ;
252
+
253
+ break ;
254
+ }
217
255
case MODULE_ITEMS:
218
256
{
219
257
/* look in the string cache for in-line continuous assignments */
@@ -761,6 +799,65 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, STRING_CACHE_LIST
761
799
vtr::free (temp_instance_name);
762
800
}
763
801
802
+ int task_offset = function_offset + i;
803
+ for (i = 0 ; i < node->types .task .size_task_instantiations ; i++)
804
+ {
805
+
806
+ /* make the stringed up module instance name - instance name is
807
+ * MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
808
+ * module name is MODULE_INSTANCE->IDENTIFIER(child[0])
809
+ */
810
+ ast_node_t *temp_instance = node->types .task .task_instantiations_instance [i];
811
+ char *instance_name_prefix = local_string_cache_list->instance_name_prefix ;
812
+
813
+ char *temp_instance_name = make_full_ref_name (instance_name_prefix,
814
+ temp_instance->children [0 ]->types .identifier ,
815
+ temp_instance->children [1 ]->children [0 ]->types .identifier ,
816
+ NULL , -1 );
817
+
818
+ long sc_spot;
819
+ /* lookup the name of the task associated with this instantiated point */
820
+ if ((sc_spot = sc_lookup_string (module_names_to_idx, temp_instance->children [0 ]->types .identifier )) == -1 )
821
+ {
822
+ error_message (NETLIST_ERROR, node->line_number , node->file_number ,
823
+ " Can't find task name %s\n " , temp_instance->children [0 ]->types .identifier );
824
+ }
825
+
826
+ /* make a unique copy of this task */
827
+ ast_node_t *instance = ast_node_deep_copy ((ast_node_t *)module_names_to_idx->data [sc_spot]);
828
+
829
+ long sc_spot_2 = sc_add_string (module_names_to_idx, temp_instance_name);
830
+ oassert (sc_spot_2 > -1 && module_names_to_idx->data [sc_spot_2] == NULL );
831
+ module_names_to_idx->data [sc_spot_2] = (void *)instance;
832
+
833
+ ast_modules = (ast_node_t **)vtr::realloc (ast_modules, sizeof (ast_node_t *)*(sc_spot_2 + 1 ));
834
+ ast_modules[sc_spot_2] = instance;
835
+
836
+ /* create the string cache list for the instantiated task */
837
+ STRING_CACHE_LIST *task_string_cache_list = (STRING_CACHE_LIST*)vtr::calloc (1 , sizeof (STRING_CACHE_LIST));
838
+ task_string_cache_list->parent = local_string_cache_list;
839
+
840
+ int num_children = local_string_cache_list->num_children ;
841
+ local_string_cache_list->children = (STRING_CACHE_LIST **)vtr::realloc (local_string_cache_list->children , sizeof (STRING_CACHE_LIST *)*(num_children + 1 ));
842
+ local_string_cache_list->children [task_offset + i] = task_string_cache_list;
843
+ local_string_cache_list->num_children ++;
844
+
845
+ task_string_cache_list->instance_name_prefix = vtr::strdup (temp_instance_name);
846
+ task_string_cache_list->scope_id = vtr::strdup (temp_instance->children [1 ]->children [0 ]->types .identifier );
847
+
848
+ /* create the symbol table for the instantiated module */
849
+ task_string_cache_list->local_symbol_table_sc = sc_new_string_cache ();
850
+ task_string_cache_list->num_local_symbol_table = 0 ;
851
+ task_string_cache_list->local_symbol_table = NULL ;
852
+ create_symbol_table_for_scope (instance->children [2 ], task_string_cache_list);
853
+
854
+ /* elaboration */
855
+ simplify_ast_module (&instance, task_string_cache_list);
856
+
857
+ /* clean up */
858
+ vtr::free (temp_instance_name);
859
+ }
860
+
764
861
break ;
765
862
}
766
863
case MODULE_PARAMETER:
@@ -1131,6 +1228,11 @@ ast_node_t *reduce_expressions(ast_node_t *node, STRING_CACHE_LIST *local_string
1131
1228
skip_children = true ;
1132
1229
break ;
1133
1230
}
1231
+ case TASK:
1232
+ {
1233
+ skip_children = true ;
1234
+ break ;
1235
+ }
1134
1236
case BLOCKING_STATEMENT:
1135
1237
case NON_BLOCKING_STATEMENT:
1136
1238
{
0 commit comments