diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index ca838a8fb..cfc9d8551 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -650,7 +650,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) "previously scanned scope %s.\n", fullname); } else { vcd_names_add(&fst_tab, fullname); - vcd_names_sort(&fst_tab); } name = vpi_get_str(vpiName, item); @@ -781,6 +780,8 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name) dep = draw_scope(item, callh); scan_item(depth, item, 0); + /* The scope list must be sorted after we scan an item. */ + vcd_names_sort(&fst_tab); while (dep--) fstWriterSetUpscope(dump_file); diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index ca20de692..efb88b42d 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -757,8 +757,9 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name) int dep = draw_scope(item); - vcd_names_sort(&lxt_tab); scan_item(depth, item, 0); + /* The scope list must be sorted after we scan an item. */ + vcd_names_sort(&lxt_tab); while (dep--) pop_scope(); } diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 559445cdb..0717d4858 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -690,7 +690,6 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) "previously scanned scope %s.\n", fullname); } else { vcd_names_add(&vcd_tab, fullname); - vcd_names_sort(&vcd_tab); } name = vpi_get_str(vpiName, item); @@ -821,6 +820,8 @@ static PLI_INT32 sys_dumpvars_calltf(PLI_BYTE8*name) dep = draw_scope(item, callh); scan_item(depth, item, 0); + /* The scope list must be sorted after we scan an item. */ + vcd_names_sort(&vcd_tab); while (dep--) fprintf(dump_file, "$upscope $end\n");