B
Brian Philofsky
Guest
Kevin Neilson wrote:
If all you are planning to do is read in binary or hex data from an
external file, I find the $readmemb and $readmemh command much easier to
use. Since they are Verilog95, most simulators support it and the
reading of the data for these commands can be done in a couple of lines
in the testbench without too much thought. The newer Verilog 2001 file
commands take a bit more thought and more typing to get to work but do
give added flexibility, especially if you want to read something other
than binary/hex, need to parse the file, need to write/update the file
or do anything more advanced than simply reading data and storing in an
array. Also, if you are reading in a lot of data, the new commands can
be more memory efficient since you can read in pieces at a time however
doing so can also slow down simulation since every time you go to the
disk to get or write information can stall the simulation from operating
at full speed (similar to going to swap/paging when you run low on
memory). In general though, anytime you read/write to a file, you can
slow down simulation so I generally try to use sparingly.
In terms of ModelSim support, it depends on which version of simulator
you are using. From the original post, it looks like Chris is using
5.7c which I am fairly sure supports most of the Verilog 2001 file I/O
commands. There is is a section in the new 6.2i Language Templates that
also explains the use of these new commands at: Verilog --> Simulation
Constructs --> System Tasks and Functions --> File I/O --> Read/Write to
a File. There should be enough information to get someone started with
this but may take a little trial and error to get fully working the way
you intend to use it (at least that is how it usually works for me).
On a related but slightly off-topic note, Chris mentions that he is
using 5.2i but using 5.7c of ModelSim-XE. If memory serves, 5.7c was
the version of ModelSim-XE designed to be used with 6.1i. It is
important to keep the MTI-XE release in sync with the ISE version used
because MTI-XE comes with pre-compiled libraries for the version of ISE
it is released with. It is possible problems can arise later when
post-translate, post-map or post-par (timing) simulation is performed as
the simulation netlist will be created by 5.2i but the pre-compiled
libraries are for 6.1i if MTI-XE 5.7c is used. Since updates are
periodically necessary in the timing parameters and interfaces to the
models, it is never suggested to mix netlists generated with one version
of ISE with libraries from another.
Good luck,
-- Brian
"Chris Carlen" <crcarle@BOGUS.sandia.gov> wrote in message
news:cbt2af01rlh@news3.newsguy.com...
Where can I learn about these Verilog 2001 IO commands? Are they
implemented in Modelsim? I have read the documentation a little bit.
I'll have to look in there some more.
Good day!
I don't know if you'll have luck finding help in the Modelsim documentation.
That will tell you what commands are implemented, but not how to use them.
I think the best bet may be to get out a C book and look up 'fscanf' and
'getc' and such. I think the Verilog commands are supposed to operate just
like the C ones. -Kevin
If all you are planning to do is read in binary or hex data from an
external file, I find the $readmemb and $readmemh command much easier to
use. Since they are Verilog95, most simulators support it and the
reading of the data for these commands can be done in a couple of lines
in the testbench without too much thought. The newer Verilog 2001 file
commands take a bit more thought and more typing to get to work but do
give added flexibility, especially if you want to read something other
than binary/hex, need to parse the file, need to write/update the file
or do anything more advanced than simply reading data and storing in an
array. Also, if you are reading in a lot of data, the new commands can
be more memory efficient since you can read in pieces at a time however
doing so can also slow down simulation since every time you go to the
disk to get or write information can stall the simulation from operating
at full speed (similar to going to swap/paging when you run low on
memory). In general though, anytime you read/write to a file, you can
slow down simulation so I generally try to use sparingly.
In terms of ModelSim support, it depends on which version of simulator
you are using. From the original post, it looks like Chris is using
5.7c which I am fairly sure supports most of the Verilog 2001 file I/O
commands. There is is a section in the new 6.2i Language Templates that
also explains the use of these new commands at: Verilog --> Simulation
Constructs --> System Tasks and Functions --> File I/O --> Read/Write to
a File. There should be enough information to get someone started with
this but may take a little trial and error to get fully working the way
you intend to use it (at least that is how it usually works for me).
On a related but slightly off-topic note, Chris mentions that he is
using 5.2i but using 5.7c of ModelSim-XE. If memory serves, 5.7c was
the version of ModelSim-XE designed to be used with 6.1i. It is
important to keep the MTI-XE release in sync with the ISE version used
because MTI-XE comes with pre-compiled libraries for the version of ISE
it is released with. It is possible problems can arise later when
post-translate, post-map or post-par (timing) simulation is performed as
the simulation netlist will be created by 5.2i but the pre-compiled
libraries are for 6.1i if MTI-XE 5.7c is used. Since updates are
periodically necessary in the timing parameters and interfaces to the
models, it is never suggested to mix netlists generated with one version
of ISE with libraries from another.
Good luck,
-- Brian