Recognize string as a signal name

  • Thread starter Kenneth Brun Nielsen
  • Start date
K

Kenneth Brun Nielsen

Guest
I'm developing a testbench in order to create real-life test vectors.

The testbench is reading commands from a command file and interprets
them to perform a given desired behaviour.

E.g. I want to implement a command "VERIFY [SIGNALNAME]" that enables
any output to be compared with its expected value (as a default
outputs are "don't care" )

The testbench reads the command file in a while loop. Here is a
summary:

reg [100*8-1:0] textline;
fd = $fopen("test1.cmd","r");

while (!$feof(fd))
begin
r = $fgets(textline,fd);

if ($sscanf(textline," %1b %1b %1b %1b\n",SS,MOSI,SCK,MISOcmp,INTcmp)
$display("Stimuli data read succesfully");
#10
end
else if ($sscanf(textline,"* %s \n",comment) > 0)
$display("Comment read: %s", comment);
else if ($sscanf(textline,"VERIFY %s \n",signalName) > 0)
begin
// In the section I would like to assign a signal
// with a name equal to the signalName string
end

end

Is this possible?

Best regards,
Kenneth
 
On Fri, 11 Sep 2009 02:42:29 -0700 (PDT), Kenneth Brun Nielsen wrote:

" that enables
any output to be compared with its expected value

Is this possible?
I'm pretty sure it can't be done in pure Verilog
or SystemVerilog.

It is certainly possible using the Verilog PLI/VPI,
and that's precisely how verification tools like Specman,
and high-end debuggers such as Novas tools, achieve
that kind of result. But it is not trivial to write
PLI/VPI code to explore the design hierarchy looking
for signal names.

It's more likely that a simulator script, or special
tools in the simulator such as "SignalSpy" in ModelSim,
will do what you need.

If you want to go the VPI route, you'll need a good
book - the two well-known ones, by Stuart Sutherland
and Swapnajit Mittra, are both excellent - and reasonably
slick C skills.

Alternatively the Teal tool from www.trusster.com may
provide you with a useful framework; they've done most
of the PLI hard work for you already. Again, though,
you'll need reasonable C/C++ skills to be able to
use it effectively.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
On Fri, 11 Sep 2009 11:08:01 +0100, Jonathan Bromley wrote:
(assorted musings on accessing signals by string name)

Postscript:

Whatever way you do it, identifying signals by
their string name at runtime is sure to be SLOW.
It is vitally important that you should perform
the string-to-signal mapping just once, and then
cache it somehow for faster future lookup.

It is unlikely that this requirement would fit
successfully into a simple framework where you
just use the signal's string name to identify it.
Instead, you probably ought to be thinking about
building a table of pointers/handles/references/...
to all the signals you will need. Or perhaps
do on-demand cacheing of a reference. For example,
I could imagine building a PLI application that
worked like this:

... When I want to sample signal "SIGNAME":

integer sig_handle;
// Use my custom PLI function to locate
// the signal by name
sig_handle = $lookup_signal("SIGNAME");
// Now the PLI app has an internal reference
// to the signal, and I can use the integer
// value to get at it later:
signal_value = $read_using_handle(sig_handle);

Now the string lookup is done just once; the result
is cached inside your PLI application, and you can
locate the signal at any time in the future with
comparatively low overhead by using the integer
handle number that was returned by the PLI lookup.

Like I said, though, doing a good job on this is
not something I would take on as my first PLI project...
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
On Sep 11, 12:20 pm, Jonathan Bromley <jonathan.brom...@MYCOMPANY.com>
wrote:
On Fri, 11 Sep 2009 11:08:01 +0100, Jonathan Bromley wrote:

Like I said, though, doing a good job on this is
not something I would take on as my first PLI project...
Thank you, Jonathan. I will find another solution :)

Best regards,
Kenneth
 

Welcome to EDABoard.com

Sponsor

Back
Top