On Jun 26, 1:40=A0pm, Jonathan Bromley <jonathan.brom...@[EMAIL PROTECTED]
>
wrote:
> On Thu, 26 Jun 2008 05:18:42 -0700 (PDT), koyel.a...@[EMAIL PROTECTED]
wrote:
> >Here is what I am able to edit when I got few errors though there seem
> >to be no reason for those.
>
> I have no idea what you mean. =A0When I tried out my own code
> just now I found a few silly errors that prevented it from
> compiling; it took me about a minute to fix them. =A0
> What's the problem?
>
> >But now I am getting undefined values [...]
> > I don't want to change this code much
>
> Why not? =A0You'll learn far more if you *do* change it.
> Hack around, add plenty of diagnostics, try things out,
> see what happens, until you are confident that you
> know how to do it all for yourself.
>
>
>
> >ReadAndApply:process
> > =A0 =A0variable c: character;
> > =A0 =A0variable i: integer;
> > =A0 =A0variable L: line;
> > =A0begin
> > =A0 =A0file_open(StimCSV, "StimCSV.csv", READ_MODE);
> > =A0 =A0 wait until (clk'event and clk =3D '1');
> [...]
> > =A0 =A0 =A0 =A0 =A0 =A0din <=3D stimulus;
> > =A0 =A0 =A0 =A0 =A0 =A0end if;
> > =A0 =A0file_close(StimCSV);
> > =A0 =A0wait;
>
> You're OK with just getting exactly one line of stimulus
> from the file? =A0Doesn't sound very interesting to me.
>
> Since you don't seem to want to debug for yourself,
> here's my code fully debugged and working. =A0I didn't
> need to change very much. =A0I've put in some fixed
> time delays so that you can see the values on signal
> "stimulus" in a wave viewer.
>
> entity read_csv_test is end;
>
> library ieee;
> use ieee.std_logic_1164.all;
> use ieee.numeric_std.all;
> use std.textio.all;
>
> architecture A of read_csv_test is
>
> =A0 subtype slv10 is std_logic_vector(9 downto 0);
> =A0 type arr_slv10 is array(natural range <>) of slv10;
>
> =A0 signal stimulus: arr_slv10(0 to 7);
> =A0 file StimCSV: text;
>
> begin
>
> =A0 ReadAndApply: process
> =A0 =A0 variable c: character;
> =A0 =A0 variable i: integer;
> =A0 =A0 variable L: line;
> =A0 begin
> =A0 =A0 file_open(StimCSV, "test.csv", READ_MODE);
> =A0 =A0 while not endfile(StimCSV) loop
> =A0 =A0 =A0 wait for 10 ns;
> =A0 =A0 =A0 readline(StimCSV, L); =A0 -- Get the next stimulus line
> =A0 =A0 =A0 for j in stimulus'range loop
> =A0 =A0 =A0 =A0 read(L, i); =A0 =A0-- Get the next integer
> =A0 =A0 =A0 =A0 if j /=3D stimulus'right then
> =A0 =A0 =A0 =A0 =A0 -- it's not the last item; skip the next comma
> =A0 =A0 =A0 =A0 =A0 read(L, c);
> =A0 =A0 =A0 =A0 =A0 assert c =3D ',' re****t "Oops, bad separator";
> =A0 =A0 =A0 =A0 end if;
> =A0 =A0 =A0 =A0 stimulus(j) <=3D std_logic_vector(
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 to_unsigned(i,
slv10'=
length));
> =A0 =A0 =A0 end loop;
> =A0 =A0 end loop;
> =A0 =A0 file_close(StimCSV);
> =A0 =A0 wait for 20 ns;
> =A0 =A0 wait;
> =A0 end process;
>
> end;
Okay, the test bench has more than this part so that can also be the
reason for my wrong outputs. No I am not interested to read one line.
Sorry I forgot to include the count to be incremented for not using a
loop. However, I will now use the loop instead. I was not sure if I
can use the clock'event statement under loop and if all the statements
for one line in the input file will be executed for one clock pulse
then. That's all.


|