FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2007, 01:48 AM
[email protected]
Guest
 
Posts: n/a
Default Reading text files.

I am looking for the easiest way possible to read a text file into
SystemVerilog.

First, a little background:

I have six years of experience with VHDL, which I used to use to make
command-driven testbenches. I could write testbenches that looked
like this:

RESET 10
IDLE 12
WRITE ABCD1234 DEADBEEF
IDLE 6
READ 1234ABCD FEEDFEED

etc. etc. etc.

I would now like to do the same thing in Verilog and/or SystemVerilog,
but cannot find an easy way to read and parse a simple text file. So
far, the ONLY thing that I have found is: http://www.chris.spear.net/pli/fileio.htm
which uses PLI (which seems like a bit of a hack). I would prefer
something built-in to the language itself.

And, of course, if VHDL can do it, then Verilog must be at least as
good, right

I have done pretty well at learning Verilog, so my next hurdle is to
learn SystemVerilog, get into assertions, formal verification, etc.
(nothing like a drink from the firehose)

Reply With Quote
  #2 (permalink)  
Old 07-19-2007, 10:55 PM
Kevin Neilson
Guest
 
Posts: n/a
Default Re: Reading text files.

[email protected] wrote:
> I am looking for the easiest way possible to read a text file into
> SystemVerilog.
>
> First, a little background:
>
> I have six years of experience with VHDL, which I used to use to make
> command-driven testbenches. I could write testbenches that looked
> like this:
>
> RESET 10
> IDLE 12
> WRITE ABCD1234 DEADBEEF
> IDLE 6
> READ 1234ABCD FEEDFEED
>
> etc. etc. etc.
>
> I would now like to do the same thing in Verilog and/or SystemVerilog,
> but cannot find an easy way to read and parse a simple text file. So
> far, the ONLY thing that I have found is: http://www.chris.spear.net/pli/fileio.htm
> which uses PLI (which seems like a bit of a hack). I would prefer
> something built-in to the language itself.
>
> And, of course, if VHDL can do it, then Verilog must be at least as
> good, right
>
> I have done pretty well at learning Verilog, so my next hurdle is to
> learn SystemVerilog, get into assertions, formal verification, etc.
> (nothing like a drink from the firehose)
>


Sure, you can do that in Verilog testbenches. You shouldn't even need
SystemVerilog. Verilog-2005 supports a lot of C-style file i/o, such as
$fscanf, which you can use to parse files. I'm sure Modelsim supports
this (I think I've used this myself), although some simulators might
not. (Synthesizers surely won't.) But you might want to do what I
usually do and just declare functions or tasks for RESET, WRITE, etc.,
and call those with the arguments, like this:

initial
begin
RESET(10);
IDLE(15);
WRITE(1234, 5678);
..
end

If you wanted the "script" in a separate file you could still do that
and just `include it.
-Kevin
Reply With Quote
  #3 (permalink)  
Old 07-20-2007, 05:45 PM
[email protected]
Guest
 
Posts: n/a
Default Re: Reading text files.

On Jul 18, 7:48 pm, kevin.harrel...@gmail.com wrote:
>
> I would now like to do the same thing in Verilog and/or SystemVerilog,
> but cannot find an easy way to read and parse a simple text file. So
> far, the ONLY thing that I have found is:http://www.chris.spear.net/pli/fileio.htm
> which uses PLI (which seems like a bit of a hack). I would prefer
> something built-in to the language itself.


Verilog-2001 added similar C-like file I/O system tasks and functions
built-in. Any tool that is remotely up-to-date should support them.

Reply With Quote
  #4 (permalink)  
Old 07-21-2007, 05:43 PM
Ajeetha (www.noveldv.com)
Guest
 
Posts: n/a
Default Re: Reading text files.

On Jul 19, 4:48 am, kevin.harrel...@gmail.com wrote:
> I am looking for the easiest way possible to read a text file into
> SystemVerilog.
>
> First, a little background:
>
> I have six years of experience with VHDL, which I used to use to make
> command-driven testbenches. I could write testbenches that looked
> like this:
>
> RESET 10
> IDLE 12
> WRITE ABCD1234 DEADBEEF
> IDLE 6
> READ 1234ABCD FEEDFEED
>
> etc. etc. etc.
>
> I would now like to do the same thing in Verilog and/or SystemVerilog,
> but cannot find an easy way to read and parse a simple text file. So
> far, the ONLY thing that I have found is:http://www.chris.spear.net/pli/fileio.htm
> which uses PLI (which seems like a bit of a hack). I would prefer
> something built-in to the language itself.
>
> And, of course, if VHDL can do it, then Verilog must be at least as
> good, right
>
> I have done pretty well at learning Verilog, so my next hurdle is to
> learn SystemVerilog, get into assertions, formal verification, etc.
> (nothing like a drink from the firehose)


As other posters noted, it is equally easier/tougher to do it in
Verilog-2001 without the PLI. Since SystemVerilog is superset of V2K,
same applies. However this would mean your "test generation" is done
outside the testbench and you are not fully exploiting the power of
SystemVerilog. It is understandable if you have lot of legacy command
files of this type that you would like to reuse. Even in that case
there are additional benefits of SV - such as functional coverage etc.
In our SNUG 2007 India paper/poster we showed how to reuse a file
based setup in a SystemVerilog-VMM based environment thereby
leveraging on the legacy tests and moving new tests to constrained
random testing. Look for it in snug-universal.org if interested.

Good Luck
Ajeetha, CVC
www.noveldv.com

Reply With Quote
  #5 (permalink)  
Old 07-23-2007, 03:05 PM
[email protected]
Guest
 
Posts: n/a
Default Re: Reading text files.

Hi Kevin,

I have some open source Systemverilog examples that might be useful
( trusster <> com ). The files to look at are teal_dictionary.sv and
teal_dirctionary.svh. They read a file and create a name, value
dictionary pair. Not exactly what you need, but the file IO muck is
there.

Fell free to contact me privately if you have any questions.

Take Care,
Mike <> trusster.com

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text-based stimulus in AMS Jake Verilog 0 05-16-2007 02:48 AM
text to binary raghu Verilog 5 10-02-2006 06:39 AM
Reading Large Files Using $readmemh Ganesh Verilog 2 04-04-2006 08:51 PM
Reading files in multiple instances of a ROM model [email protected] Verilog 5 06-13-2005 09:04 AM
Text Editor for Verilog (also C, PERL, VHDL) A Verilog 12 04-29-2005 12:02 AM


All times are GMT +1. The time now is 03:16 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved