OK, I'va managed to control the ModelSim flow by invoking a "do" macro,
which
sets a signal in the test bench called "sim_time" as follows:
force -deposit sim:/proto_test_tb/i1/sim_time 1 0
However, this still means I have to edit the .do file, I really want
ModelSim
to ask the user to type in something like a "Y" or "N" response to
cause the
appropriate branch control.
hi again Kevin,
see my original response; the key question here is where you
want the user interaction to take place. It can be done either
from within VHDL itself, or from the Tcl "do" script.
Getting user input from VHDL is easy enough, and it makes your
code completely portable across different simulation
environments, but the user interface will be rubbish.
Getting user input from Tcl is probably even easier, but you
then have to work out how to get that input to influence the
simulation - as Mike Treseler pointed out, you could use it
to patch up some generics, or you could use a force command
to put the appropriate value on to a signal that's otherwise
floating in your testbench.
Anyways, for what it's worth here's the "user Y/N" thing,
worked through in detail for both VHDL and Tcl.
In VHDL, it's easiest to add a little procedure to your
test bench. THe procedure is sufficiently useful that
it's probably worth putting into a package, along with
any other string manipulation utilities that you create.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
use std.textio.all;
....
procedure UserYN(
prompt: in string;
yes : out boolean
) is
variable L, user: line;
variable response: character;
variable OK: boolean;
variable dontknow: boolean := true;
begin
-- first prompt is polite
write (L, prompt & " Enter Y/N");
writeline (output, L);
while dontknow loop
-- get user input
readline(input, user);
read(user, response, OK);
if OK then -- there was at least one char on the line
case response is
when 'Y' | 'y' => yes := true; dontknow := false;
when 'N' | 'n' => yes := false; dontknow := false;
when others =>
write(L, prompt & " Bad input: use Y=yes, N=no");
end case;
else -- user gave us a blank line!
write(L, prompt & " Please enter SOMETHING");
end if; -- if OK
-- spit out second, stroppier prompt
writeline(output, L);
end loop; -- while dontknow
-- Get rid of any storage still in use for line "user"
deallocate(user);
end;
Now you can just call the procedure with a suitable prompt:
signal green: std_logic;
....
process Test_Control is
variable Choice: boolean;
begin
UserYN("Do you want it green?", Choice);
if Choice then
green <= '1';
else
green <= '0';
end if;
wait;
end process;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Tcl it's easy, too...
# Display prompt; push the partial line of text to the console
puts -nonewline "Do you want it green (enter Y/N)? "
flush stdout
# Loop until we have satisfactory input
set dontknow 1
while {$dontknow} {
# Read user input into a variable
gets stdin user_line
# Check user input - only the first character
switch -- [string index $user_line 0] {
y -
Y {
set dontknow 0
set yes 1
}
n -
N {
set dontknow 0
set yes 0
}
default {
puts -nonewline "Try again: Green (Y/N)? "
flush stdout
}
}
}
# use the result - yes is either 1 or 0
force -deposit sim:/tb_top/green $yes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Even more fun can be had by adding a GUI using Tcl/Tk, but
we'll save that for another day...
HTH
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
[email protected]
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.