In reply to dave_59:
I tried the second method as you suggested but getting this error:
# ** Error (suppressible): testbench.sv(7): (vopt-7063) Failed to find 'D1' in hierarchical name '$root.D1.sum'.
# Region: testbench_sv_unit
# ** Error (suppressible): testbench.sv(7): (vopt-7063) Failed to find 'D1' in hierarchical name 'D1.sum.$$'.
how should D1 declared and initialized with ?