Can we log internal signals from a testbench in VHDL?

P

py

Hi,

At the end of a test, I would like to collect some stat in the following manner:

assert false report "Max counter is " & str(counter_value) severity note

This syntax won't work if counter_value is embedded inside DUT and is not a IO port. Is there any way to "peak" inside the inner layer? I heard that for verilog, it is possible to reference internal signal like outer_layer.inner_layer.signal_name


Thanks
 
R

Ralf Hildebrandt

Hi py!
This syntax won't work if counter_value is embedded inside DUT and is not a IO port. Is there any way to "peak" inside the inner layer?

Declare a signal in a package - a "global" signal. Write to this signal
inside your subcomponent, read this signal wherever you want. All you
need is to include this package in all components where you read/write
this signal.

To make this subcomponent synthesizeable use
-- pragma translate_off
.... your problemativ VHDL code here ...
-- pragma translate_off

As an alternative you can use a "shared variable". This can be written
from several locations while the signal should be written only from one
location.

Ralf
 
P

py

Hi py!






Declare a signal in a package - a "global" signal. Write to this signal

inside your subcomponent, read this signal wherever you want. All you

need is to include this package in all components where you read/write

this signal.



To make this subcomponent synthesizeable use

-- pragma translate_off

... your problemativ VHDL code here ...

-- pragma translate_off



As an alternative you can use a "shared variable". This can be written

from several locations while the signal should be written only from one

location.



Ralf

Wow that's fast, thanks!
 
S

Sean Durkin

Hi,
Hi,

At the end of a test, I would like to collect some stat in the
following manner:

assert false report "Max counter is " & str(counter_value) severity
note

This syntax won't work if counter_value is embedded inside DUT and is
not a IO port. Is there any way to "peak" inside the inner layer? I
heard that for verilog, it is possible to reference internal signal
like outer_layer.inner_layer.signal_name

if you use Modelsim, there's the "modelsim_util" package with functions
for that purpose. You can use it like this:

library modelsim_lib;
use modelsim_lib.util.all;

-- entity, architecture, signal declarations skipped

-----------------------------------------------------------------------------
-- spy process
-----------------------------------------------------------------------------
sig_spy : process is
begin
init_signal_spy("/DUT/submodule1/submodule2/interesting_sig",
"tb_sig", 1);
wait;
end process sig_spy;

Here, you connect a signal from somewhere inside your DUT to another
signal in your test bench and can then use it there for whatever you need.

Also, in VHDL2008 hierarchical references are supported, so you can do
stuff like this (taken from the Modelsim documentation):

REPORT "Test Pin = " & integer'image(<<SIGNAL .tb.dut.i0.tp : natural>>)
SEVERITY note;

The test bench has to be compiled as VHDL2008, obviously (by calling the
compiler with a corresponding option).

This is part of the VHDL2008 standard, so should work with every
simulator that supports it. But at the moment not every tool vendor has
implemented all of VHDL2008, so this specific feature might not be
supported by your simulator.

Greetings,
Sean
 
P

py

Hi Sean,

I tried the hierachical referenece method and ran into an issue. It does work if I could reference a signal in an instantiated module. However, what should the syntax be if a module is generated? ie:

gen_counter : for idx in 0 to max-1 generate

counter: entity work.counter
....
....

end generate gen_counter;

The signal I want to reference inside the counter module.


Thank you
 
A

Andy

Each counter label will have the generate index appended to it. You should be able to see this in the name of the signal if you trace it.

Andy
 
S

Sean Durkin

py said:
Hi Sean,

I tried the hierachical referenece method and ran into an issue. It
does work if I could reference a signal in an instantiated module.
However, what should the syntax be if a module is generated? ie:

gen_counter : for idx in 0 to max-1 generate

counter: entity work.counter ... ...

end generate gen_counter;

The signal I want to reference inside the counter module.

Yeah, I'm always unclear about that, too. :)

Usually I just click through the hierarchy in the simulator GUI and then
copy&paste the displayed hierarchy name.

HTH,
Sean
 
P

py

Sorry guys, still can't get this to work :(

TB code:
assert(false) report "Maximum FIFO depth: " & to_string(<<signal .tb.dut.gen_module__0.module.fifo_depth : std_logic_vector>>) severity note;

Copy and Paste from sim environment
sim:/tb/dut/gen_module__0/module/fifo_depth

For some reason, I would get the following compile error from Riviera Pro:

COMP96 ERROR COMP96_0010: "Invalid literal." "../tb.vhd" 675 98
COMP96 ERROR COMP96_0018: "Identifier expected expected." "../tb.vhd" 675 98

The 98th character position is right at the beginning of 'gen_module__0', so it looks like from the compiler's POV, the module is not yet generated.

Note that if I have something other than gen_module__0 in place, then the code would actually compiled, but would then fail at elaboration. So I do think we are moving at the right direction.
 
S

Sean Durkin

Hi,
Sorry guys, still can't get this to work :(

TB code: assert(false) report "Maximum FIFO depth: " &
to_string(<<signal .tb.dut.gen_module__0.module.fifo_depth :
std_logic_vector>>) severity note;

Copy and Paste from sim environment
sim:/tb/dut/gen_module__0/module/fifo_depth

For some reason, I would get the following compile error from Riviera
Pro:

COMP96 ERROR COMP96_0010: "Invalid literal." "../tb.vhd" 675 98
COMP96 ERROR COMP96_0018: "Identifier expected expected." "../tb.vhd"
675 98

The 98th character position is right at the beginning of
'gen_module__0', so it looks like from the compiler's POV, the module
is not yet generated.

Note that if I have something other than gen_module__0 in place, then
the code would actually compiled, but would then fail at elaboration.
So I do think we are moving at the right direction.

hmm, can't help you on that one, I'm afraid. I guess we need one of the
VHDL gurus now... :)

Is "fifo_depth" an unconstrained std_logic_vector? If not, maybe you
need to specify the actual range for it so the tool can find it. Just
guessing...

Bye,
Sean
 
P

py

Hi, py wrote: > Sorry guys, still can't get this to work :( > > TB code: assert(false) report "Maximum FIFO depth: " & > to_string(<<signal .tb.dut.gen_module__0.module.fifo_depth : > std_logic_vector>>) severity note; > > Copy and Paste from sim environment > sim:/tb/dut/gen_module__0/module/fifo_depth > > For some reason, I would get the following compile error from Riviera > Pro: > > COMP96 ERROR COMP96_0010: "Invalid literal." "../tb.vhd" 675 98 > COMP96 ERROR COMP96_0018: "Identifier expected expected." "../tb.vhd" > 675 98 > > The 98th character position is right at the beginning of > 'gen_module__0', so it looks like from the compiler's POV, the module > is not yet generated. > > Note that if I have something other than gen_module__0 in place, then > the code would actually compiled, but would then fail at elaboration. > So I do think we are moving at the right direction. hmm, can't help you on that one, I'm afraid. I guess we need one of the VHDL gurus now... :) Is "fifo_depth" an unconstrained std_logic_vector? If not, maybe you need to specify the actual range for it so the tool can find it. Justguessing... Bye, Sean


fifo_depth has a fixed range
signal fifo_depth : std_logic_vector(8 downto 0);

Thanks for your time, we are getting there :)
 
P

py

Hi,

Thanks for the tip. I certainly had tried the LRM naming convention you suggest, and in return, I would see the following Riviera elaboration error:

# ELBREAD: Elaboration time 5.4 .
# KERNEL: Main thread initiated.
# KERNEL: Kernel process initialization phase.
# KERNEL: Time resolution set to 1ps.
# ELAB2: Elaboration final pass...
# KERNEL: PLI/VHPI kernel's engine initialization done.
# PLI: Loading library '/usr/local/riviera-pro-2012.02-x86_64/bin/libsystf.so'
# VHPI: Loading library 'systf.so'
# ELAB2: Create instances ...
# ELAB2: Fatal Error: ELAB2_0135 tb.vhd (519): Subtype indication of external name that denotes an unelaborated object is not fully constrained or external name does not exist.
# KERNEL: Error: E8005 : Kernel process initialization failed.
# VSIM: Error: Simulation initialization failed.

The total number of instances generated in the generate statement is set to a constant (and I also tried just force it to a number), so I'm guessing it's not about instances being fully constraint?


Thanks
 
P

py

Hi,

Sorry, was busy this week so this reply comes a bit late. The code I tried is

assert(false) report "Maximum FIFO depth: " & to_string(<<signal .tb.dut.gen_sample_reader__0.sample_reader.request_fifo_depth_wr_max : std_logic_vector>>) severity note;
-> fails during compile

assert(false) report "Maximum FIFO depth: " & to_string(<<signal .tb.dut.gen_sample_reader(0).sample_reader.request_fifo_depth_wr_max : std_logic_vector>>) severity note;
-> fails during elaboration

instance_name looks like it could be useful. Is there any quick way to convert the output to a string so that I can display it?

assert(i_req = '0') report "DEBUG: " & to_string(req_fifo_depth_wr_max'instance_name);

VHDL2008 was enabled via the -hdl_version 2008 compile flag.


Thanks!


Hi,
Thanks for the tip. I certainly had tried the LRM naming convention you suggest, and in return, I would see the following Riviera elaboration error:
# ELBREAD: Elaboration time 5.4 .

# KERNEL: Main thread initiated.
# KERNEL: Kernel process initialization phase.
# KERNEL: Time resolution set to 1ps.
# ELAB2: Elaboration final pass...
# KERNEL: PLI/VHPI kernel's engine initialization done.
# PLI: Loading library '/usr/local/riviera-pro-2012.02-x86_64/bin/libsystf.so'
# VHPI: Loading library 'systf.so'
# ELAB2: Create instances ...
# ELAB2: Fatal Error: ELAB2_0135 tb.vhd (519): Subtype indication of external name that denotes an unelaborated object is not fully constrained or external name does not exist.
# KERNEL: Error: E8005 : Kernel process initialization failed.
# VSIM: Error: Simulation initialization failed.

The total number of instances generated in the generate statement is set to a constant (and I also tried just force it to a number), so I'm guessing it's not about instances being fully constraint?

Oh.



Can you post the exact path you typed in to the code?



Also have you tried using 'instance_name to print out the path?



Finally (probably a stupid question) have you enabled VHDL-2008 when

compiling?



regards

Alan
 
M

Martin Thompson

py said:
instance_name looks like it could be useful. Is there any quick way to convert
the output to a string so that I can display it?

assert(i_req = '0') report "DEBUG: " &
to_string(req_fifo_depth_wr_max'instance_name);

I may be missing something, but isn't the instance_name property already
a string?

assert(i_req = '0') report "DEBUG: " & req_fifo_depth_wr_max'instance_name;

should be fine.
 
P

py

Opps, you are right! Here is the output on the console

tb(struct):dut@module(rtl):gen_sample_reader(0):sample_reader@module(rtl):req_fifo_depth_wr_max

so according to this, this should had work right? But Riviera elaboration process complained about it. I guess it is time to email support.

.tb.dut.gen_sample_reader(0).sample_reader.request_fifo_depth_wr_max
 
J

Jim Lewis

With external names, instance order is important. Make sure to instance the DUT before other testbench code. This will make sure the DUT has been elaborated before you try to access the signal. Aliases in the architecture will be problematic for this same reason.

Good luck,
Jim
 
P

py

Sorry for the late update. I ended up contacting Riviera on this issue and it looks like the culprit is a compiler bug. The correct format was shown by the simulator all along

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top