Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > select file soorce/destination at simulation start

Reply
Thread Tools

select file soorce/destination at simulation start

 
 
Niv (KP)
Guest
Posts: n/a
 
      11-07-2008
Hi, I currently set a generic to select between two groups of files,
as below:

ARCHITECTURE behave OF mystuff IS
-----------------------------------------------------------------------------------------------------
FUNCTION assign_rd_file(select : BOOLEAN) RETURN STRING IS
BEGIN
IF select THEN
RETURN "../file1.txt";
ELSE
RETURN "../file2.txt";
END IF;
END assign_rd_file;
----------------------------------------------------------------------------------------------------------

BEGIN -- The Architecture

main : PROCESS
FILE f_rd : TEXT OPEN read_mode IS
assign_rd_file(select ) ;
BEGIN

-- do stuff with read file here

END PROCESS main;

END ARCHITECTURE behave;

All well and good, but I would prefer to make the selection after i've
invoked ModelSim, rather than compile with different generic each time
I want different file choice.

I can use something like:

-----------------------------------------------------------------------------------------------
simulation_type_proc : PROCESS

VARIABLE line_out : LINE;
VARIABLE line_in : LINE;
VARIABLE key_press : CHARACTER;
CONSTANT question : STRING := "Enter 'y' for file set 1, anything
else for file set 2";

BEGIN
write(line_out, question); -- ask the question
writeline(output, line_out);
readline(input, line_in); -- get the answer
read(line_in, key_press);
IF key_press = 'y' THEN
select <= TRUE;
ELSE
select <= FALSE;
END IF;
WAIT;
END PROCESS simulation_type_proc;
-------------------------------------------------------------------------------------

which will set a "select" variable, but this obviously wont overwrite
the generic.

Any ideas please?

TIA, Niv.
 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      11-07-2008
On 7 Nov, 07:59, "Niv (KP)" <(E-Mail Removed)> wrote:
> Hi, *I currently set a generic to select between two groups of files,
> as below:
>
> ARCHITECTURE behave OF mystuff IS
> -----------------------------------------------------------------------------------------------------
> FUNCTION assign_rd_file(select : BOOLEAN) RETURN STRING IS
> * BEGIN
> * * IF select THEN
> * * * RETURN "../file1.txt";
> * * ELSE
> * * * RETURN "../file2.txt";
> * * END IF;
> END assign_rd_file;
> ----------------------------------------------------------------------------------------------------------
>
> BEGIN -- The Architecture
>
> main : PROCESS
> * FILE f_rd * * * * * : TEXT OPEN read_mode *IS
> assign_rd_file(select ) ;
> BEGIN
>
> -- do stuff with read file here
>
> END PROCESS main;
>
> END ARCHITECTURE behave;
>
> All well and good, but I would prefer to make the selection after i've
> invoked ModelSim, rather than compile with different generic each time
> I want different file choice.
>
> I can use something like:
>
> -----------------------------------------------------------------------------------------------
> simulation_type_proc : PROCESS
>
> * * * * VARIABLE line_out : LINE;
> * * * * VARIABLE line_in : LINE;
> * * * * VARIABLE key_press : CHARACTER;
> * * * * CONSTANT question : STRING := "Enter 'y' for file set 1, anything
> else for file set 2";
>
> * * * * BEGIN
> * * * * write(line_out, question); * * *-- ask the question
> * * * * writeline(output, line_out);
> * * * * readline(input, line_in); * * * -- get the answer
> * * * * read(line_in, key_press);
> * * * * IF key_press = 'y' THEN
> * * * * * * * * select <= TRUE;
> * * * * ELSE
> * * * * * * * * select *<= FALSE;
> * * * * END IF;
> * * * * WAIT;
> END PROCESS simulation_type_proc;
> -------------------------------------------------------------------------------------
>
> which will set a "select" variable, but this obviously wont overwrite
> the generic.
>
> Any ideas please?
>
> TIA, Niv.



If you're running from the modelsim GUI, you dont need to re-run vsim
every time you recompile. just use the "restart" command and it re-
initialises any recompiled files (picking up your new file choice).
THis is the method I use - A whole bunch of generics on the testbench
set for that given simulation.

As for you're second method - you will need to go about the file
selection differently. Scrap the generic, as you can use that for the
method above. What you'll have is:

architecture sim of my_ent is
begin

process
variable select : boolean;
file myfile : text;


VARIABLE line_out : LINE;
VARIABLE line_in : LINE;
VARIABLE key_press : CHARACTER;
CONSTANT question : STRING := "Enter 'y' for file set 1, anything
else for file set 2";
begin

write(line_out, question); -- ask the question
writeline(output, line_out);
readline(input, line_in); -- get the answer
read(line_in, key_press);
IF key_press = 'y' THEN
select := TRUE;
ELSE
select := FALSE;
END IF;

FILE_OPEN( f => myfile,
external_name => assign_rd_file(select),
open_kind => READ_MODE);

..
--Do whatever you want with the file
..


FILE_CLOSE(myfile); --Important, otherwise you may lock the file as
opened in the OS (sim should clear up after itself, but best be
careful)
wait;
end process;


but you have to restart the simulation to get a different file choice
every time anyway, so I dont see how this method would be any better.
 
Reply With Quote
 
 
 
 
jtw
Guest
Posts: n/a
 
      11-13-2008
Use the form: vsim -g[generic name]=[generic value]

Of course, use all other necessary parameters.

You can only change the value of the generics at the start of a
simulation--not to be confused with when you start the simulator (Modelsim.)

JTW


"Niv (KP)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, I currently set a generic to select between two groups of files,
> as below:
>
> ARCHITECTURE behave OF mystuff IS
> -----------------------------------------------------------------------------------------------------
> FUNCTION assign_rd_file(select : BOOLEAN) RETURN STRING IS
> BEGIN
> IF select THEN
> RETURN "../file1.txt";
> ELSE
> RETURN "../file2.txt";
> END IF;
> END assign_rd_file;
> ----------------------------------------------------------------------------------------------------------
>
> BEGIN -- The Architecture
>
> main : PROCESS
> FILE f_rd : TEXT OPEN read_mode IS
> assign_rd_file(select ) ;
> BEGIN
>
> -- do stuff with read file here
>
> END PROCESS main;
>
> END ARCHITECTURE behave;
>
> All well and good, but I would prefer to make the selection after i've
> invoked ModelSim, rather than compile with different generic each time
> I want different file choice.
>
> I can use something like:
>
> -----------------------------------------------------------------------------------------------
> simulation_type_proc : PROCESS
>
> VARIABLE line_out : LINE;
> VARIABLE line_in : LINE;
> VARIABLE key_press : CHARACTER;
> CONSTANT question : STRING := "Enter 'y' for file set 1, anything
> else for file set 2";
>
> BEGIN
> write(line_out, question); -- ask the question
> writeline(output, line_out);
> readline(input, line_in); -- get the answer
> read(line_in, key_press);
> IF key_press = 'y' THEN
> select <= TRUE;
> ELSE
> select <= FALSE;
> END IF;
> WAIT;
> END PROCESS simulation_type_proc;
> -------------------------------------------------------------------------------------
>
> which will set a "select" variable, but this obviously wont overwrite
> the generic.
>
> Any ideas please?
>
> TIA, Niv.



 
Reply With Quote
 
 
 
Reply

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
how to start post synthesis simulation sagar g VHDL 1 09-12-2012 08:38 PM
select gridview row without using select button? =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 5 02-27-2009 02:56 AM
Problem with post-route simulation / timing simulation jasperng VHDL 0 11-27-2008 06:23 AM
Question: Writing text file based TestBenches vs. Waveform file based simulation. BLF VHDL 4 08-07-2004 12:44 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments