![]() |
|
|
|||||||
![]() |
VHDL - select file soorce/destination at simulation start |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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) |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |