Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Selecting generic at simulation time.

Thread Tools

Selecting generic at simulation time.

Niv (KP)
Posts: n/a
I have a testbench which reads data from a memory, which is
initialised with data from a file, the file name is a generic in the
memory model.

Is there some way to start the simulation which then asks which file
I'd like to use to initialise the memory before the sim progresses?
TIA, Niv.
Reply With Quote
Posts: n/a
You can also use environment variables when opening a file.
I've succeded both with aldecs and mentors vhdl simulators,
use $$MY_ENV_VAR for riviera, use $MY_ENV_VAR for modelsim.

So something similar to this should work (can' test my self right now)
file_open(status, "$$MY_PATH/my_file.ext", L.all, READ_MODE);

HTH -- Pontus
Reply With Quote
Posts: n/a
If the file is opened/read dynamically in a process, then you cannot
initialize the memory array via its declaration. With a generic, you
can initialize the array declaration with a function call that uses
the generic, opens the file, reads the data and returns an initialized
array. This initialization is done during the VHDL elaboration phase,
which is "hidden" at the beginning of many simulators (before the
actual simulation starts), but is an explicit step on others (e.g.

Reply With Quote
Posts: n/a
I've also written testbenches that pause and wait for the user to source
a tcl script. The tcl script sets a VHDL variable (using the "change"
command in Modelsim), issues a "force" command on a signal to trigger an
event, and that starts a process that does some massaging of the
variable (mainly to determine to number of non-blank characters) and
feeds that to a VHDL open statement to open the requested file.

Charles Bailey

Reply With Quote

Thread Tools

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 Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Post-synthesis simulation errors at generic map KJ VHDL 3 06-15-2011 01:14 PM
Changing the value of a generic during simulation time Bert Böhne VHDL 1 05-26-2010 04:02 PM
Generic-default : simulation vs. synthesis VHDL 3 04-01-2009 07:24 AM
generic interfaces with generic methods Murat Tasan Java 1 02-03-2009 12:17 PM
Problem with post-route simulation / timing simulation jasperng VHDL 0 11-27-2008 06:23 AM