3.Object Viewer

Automatic variables or dynamic variables can not be viewed by waveform viewer since they are not static objects.
Then, how we debug those objects?

Object Viewer is for it. It is just debugger like other standard language's. It displays;

In usual case, we use Object viewer with Step.
Let's look at this by following examples.

Recursive Function
First example is recursive function. Note n in Function Factorial2 is automatic variable since function property is automatic.

program recursive_function_test;

	function automatic int Factorial2(int n);// we need automatic property for recursive function

		if (n == 0 || n == 1)
			return (1);
		else
			return (n * Factorial2(n -1));//recursive function call
	endfunction

	initial begin
		$display("Fatorial2(4)=%d",Factorial2(3));
		$display("Fctorial2(5)=%d",Factorial2(4));

	end

endprogram

The simulation results are shown as below.

***** Veritak SV6464 Engine Version 444 Build Apr 23 2013*****

Fatorial2(4)=          6
Fctorial2(5)=         24

---------- Simulation finished. time=0ns


3.1 Use Object Viewer

Check Enable Object Viewer in Project Setting.

Then load the project and proceed 3 steps , and select "n", to display "n" as tooltip.

Call stack shows call history. We can go jump on editor if we click any row of call stack.
Tooltip history shows n's values which is the same value as tooltip below.
We can confirm n==3 is passed as argument of first function call.



We make further steps for second function call, and and select "n", to display "n" as tooltip.
Note n shows 2 in this time and (internal) address shows different from each other. This is because n is dynamic object.

Finally we come statement line 6.



Now we understand how recursive function works by using step and tooltips. Object viewer will help you for such debugging.

Tips:
To clear tooltip history, click "History of Tooltips".


3.2 Use Scope Object

We view objects using Scope Objects.

class C;
	int i1;
	function new();
		i1=100;
	endfunction
endclass

class B;
	C c1;
	function new();
		c1=new;
	endfunction
endclass

class A;
	B b1;
	function new();
		b1=new;
	endfunction
endclass


program test_top;
	A a1;

	initial begin
		a1=new;
		$display("hi");
	end

endprogram

We break at line 4.

Click Scope on bottom of call stack as below.

+test_top should be shown in Scope Objects.

Clicking + extracts objects.

However, we have no objects from a1. This is caused by that a1 constructor is not finished yet.
If we move as below, constructor should be finished.



We can confirm class A has class B that has Class C that has i1 variable with value of 100(64hex).


Scope Object can stack plural objects. Complex object is extracted by clicking+ .
Note life of the objects are at current step only.



3.3 Memory Viewer

How we view contents of large memory? We can view it partially using waveform viewer if we know the indexes at compile time.
In this topic, we overview runtime-method to view raw physical memory.
program memory_test;
        byte mem[2_500_000_000];
  longint i;
        initial begin

                mem[64'd2_499_999_990]=8'h12;
                mem[64'd2_499_999_991]=8'h34;
                mem[64'd2_499_999_992]=8'h56;
                mem[64'd2_499_999_993]=8'h78;

        for (i=0;i<2_500_000_000;i++) begin
            if (mem[i]) $display("mem[%d]=%x",i,mem[i]);
        end
        $display("Finished");

        end

endprogram


We placed the breakpoint at line14 below and run.
Then select mem to view tooltip in Text3.

However, since mem is not simple object, only "mem" is displayed in tooltip dialog. The object description is also sent to object viewer. So we can view them by pressing + mark for first 50000 (it depends on object size ) items. In other words, we can view them all if mem items are less than 50000( it depends on object size.) However, note object size is around 2.5GB.

We know address of mem is 0xe000_00c0 by Object Viewer. The address we are interested in is 0xe000_000+ 2_499_999_990 now is around 0x17502F9B0

(Yes,this is not smart method, but may be useful when you do reverse engineering for complex object in DPI development without asking to author.)

Press memory on Object Viewer

We select size of bytes and *enter 17502F9B0 at address field on Memory Viewer. (Note Keyboard's enter )

We can confirm the address 0x17502F9B has 0x12, 0x17502F9C has 0x34..

Another example is "i" in longint.
We know longint i's address is 0x17502F9e0 by object viewer. Tooltip value shows 2_500_000_000, that is 9502f900 in hexformat, is also shown at the address in memory view. (Note x64 architecture is little endian.)

Note:

This example needs specific verition VeritakSV6464 (>=445A). SV32 or SV6432 should not be run because 32bit addressing is too short.
Please take care your machine has adequate memory to avoid using virtual memory
..