Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - select file soorce/destination at simulation start

 
Thread Tools Search this Thread
Old 11-07-2008, 07:59 AM   #1
Default select file soorce/destination at simulation start


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.


Niv (KP)
  Reply With Quote
Old 11-07-2008, 09:11 AM   #2
Tricky
 
Posts: n/a
Default Re: select file soorce/destination at simulation start
On 7 Nov, 07:59, "Niv (KP)" <kev.pars...@mbda-systems.com> 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.


Tricky
  Reply With Quote
Old 11-13-2008, 03:31 PM   #3
jtw
 
Posts: n/a
Default Re: select file soorce/destination at simulation start
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)" <> wrote in message
news:2d5032fa-5e37-4dc9-856c-...
> 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.





jtw
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cisco 2600 - Inbound NAT translation/Port-forwarding not working Greg Hardware 0 11-20-2008 07:33 PM
How to Rip DVD and Convert Video on Mac OS dave345 Media 12 07-07-2008 09:32 AM
DVD Copy for Mac OS Users reallyone Software 2 03-22-2008 01:38 AM
How To: Convert (rip) DVD movies to iPhone(iPod)? zbusoft@gmail.com DVD Video 5 12-25-2007 02:42 PM
simulation Tom MCITP 0 04-05-2007 01:40 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46