Selecting generic at simulation time.

N

Niv (KP)

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.
 
P

Pontus

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
 
A

Andy

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.
Cadence).

Andy
 
L

logic_guy

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
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top