Closed mahdi259 closed 6 months ago
Hey @mahdi259!
Hmm that's an interesting question! Are we talking about a variable in main memory?
Let's assume you have something like this:
volatile uint32_t some_variable;
This variable will be placed in main memory at a fixed address as it is marked as volatile
. You can use make elf_info
to find out the actual memory address of this variable:
In this example, some_variable
is placed at 0x800000a4. Then, you could connect some VHDL report block to the CPU's data interface (in neorv32_top.vhd
) to track write accesses to this address:
process(clk_i)
begin
if rising_edge(clk_i) then
if (cpu_d_req.stb = '1') and (cpu_d_req.rw = '1') and (cpu_d_req.addr = x"800000a4") then
report "MEM 0x" & to_hstring32_f(cpu_d_req.data) & " -> [0x" & to_hstring32_f(cpu_d_req.addr) & "]" severity note;
end if;
end if;
end process;
Now, when running some C code like this
some_variable = 3;
some_variable = 5;
you'll get the according simulator reports in the console:
Ok I should define it as global variable outside main...
Ok I should define it as global variable outside main...
Right, your variable is just local so it will be put on the stack. Thus, it might not have a static address.
You really solved my question. I wish great success for you in your career and life.
Hi @stnolting . Sorry can you mention how to use this code in testbench with xbus signals? It seems that it changes address on xbus.
Sorry can you mention how to use this code in testbench with xbus signals? It seems that it changes address on xbus.
Just put that somewhere into neorv32_top.vhd
.
I'm not really sure what you want to monitor? What does your processor configuration look like? Do you use internal memories (IMEM / DMEM) or do you use some external memory coupled via XBUS?
Hi. As mentioned above, I monitor value change of volatile int temp_i
variable with address specified in make elf_info
that is 0x80000000. I use neorv32_tb.simple.vhd that utilizes external memories and I disable instruction and data caches.
I wonder why the same writing isn't seen on xbus signals.
codes.zip
For the default testbench setup, address 0x80000000 is mapped to the internal DMEM. Hence, when accessing this variable / address there will be NO activity on the external bus interface (XBUS).
Sorry, you're right.
Hi This is actually a question. I use simple testbench for simulation. What is the best way to capture the value of a variable of C code without using UART to print it?
Describe the solution you'd like I want to know the result of an operation in simulation mode without needing to print it using UART.
Thanks.