On Thu, 19 Jun 2008 03:05:15 -0700 (PDT), koyel.aphy@[EMAIL PROTECTED]
wrote:
>I have to write another test bench for a unit that takes on 8 inputs
>(each of 10 bits)parallely. There will be an array of minimum of 1024
>such elements(integer number of 1024 in general) in the data file.
>What should be the format of the data file and how should be the
>reading operation in VHDL.
Choose a format that's easy to handle with VHDL's rather limited
string functions, but also can be easily manipulated by external
software. Comma-separated values (CSV) are a good choice, since
they are fairly easy to handle in VHDL but also work nicely with
spreadsheets and other programs - and they're human-readable.
Since your data are only 10 bits wide, it seems natural to
represent them as simple (decimal) integers. Each line
of your CSV file then looks like
25,1021,42,0,1000,58,1,76
You can simply work through the input file in VHDL until you
reach end-of-file.
It will also be OK if you permit spaces before the integers:
25, 1021, 42, 0, 1000, 58, 1, 76
since read() automatically skips over these spaces. Don't allow
spaces before the comma, though - that would need extra work.
Here's a piece of VHDL code that should be able to read such
data into a signal that's an array of 10-bit std_logic_vector.
Testing and debugging is left as an exercise :-)
In the real world you would also want a great deal more
error checking than I have provided. Note that both
file_open() and read() have options to check for success;
if you don't use these options, then they will simply
fail with a fatal error if anything goes wrong.
use ieee.std_logic_1164.all, ieee.numeric_std.all;
...
subtype slv10 is std_logic_vector(9 downto 0);
type arr_slv10 is array(natural range <>) of slv10;
...
signal stimulus: arr_slv10(0 to 7);
file StimCSV: text;
...
process ReadAndApply;
variable c: character;
variable i: integer;
variable L: line;
begin
file_open(StimCSV, "my/file/name.csv", READ_MODE);
while not endfile(StimCSV) loop
wait until .... you need some more stimulus ....
readline(StimCSV, L); -- Get the next stimulus line
for j in s'range loop
read(L, i); -- Get the next integer
if j /= s'right then
-- it's not the last item; skip the next comma
read(L, c);
assert c = ',' re****t "Oops, bad separator";
end if;
stimulus(j) <= std_logic_vector(
to_unsigned(i, slv10'length));
end loop;
end loop;
file_close(StimCSV);
wait;
end process;
hth
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@[EMAIL PROTECTED]
contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


|