Changing string

A

ALuPin

Hi newsgroup,

I have a function which is called by

ReadFile("image.bmp")


At certain events I want to call that function in the following
manner:

signal image_cnt : integer range 0 to 127;

process(Clk)
begin
if rising_edge(Clk) then

if load_image='1' then
if image_cnt=127 then
image_cnt <= 0;
else
image_cnt <= image_cnt + 1;
end if;

if image_cnt=0 then
ReadFile("image0.bmp");
elsif image_cnt=1 then
ReadFile("image1.bmp");
...
elsif image_cnt=127 then
ReadFile("image127.bmp");
end if;
end if;
end if;
end process;

How can I include the "image_cnt" value
into the string of the image name in an elegant way ?

Thank you for your help.

Rgds
Andre
 
K

KJ

               if image_cnt=0 then
                  ReadFile("image0.bmp");
              elsif image_cnt=1 then
                  ReadFile("image1.bmp");
              ...
              elsif image_cnt=127 then
                  ReadFile("image127.bmp");
              end if;
         end if;
   end if;
end process;

How can I include the "image_cnt" value
into the string of the image name in an elegant way ?

ReadFile("image" & integer'image(127) & ".bmp");

Kevin Jennings
 
J

Jonathan Bromley

How can I include the "image_cnt" value

[an integer]
into the string of the image name in an elegant way ?

ReadFile("image" & integer'image(image_cnt) & ".bmp");

Or, much better:

ReadFile(MakeFilenameFromInteger(image_cnt));

And now you can write a function MakeFilenameFromInteger
that perhaps does exactly what I first suggested:

function MakeFilenameFromInteger(n: integer)
return string
is
begin
return "image" & integer'image(n) & ".bmp";
end;

or, perhaps, does something cleverer.
--
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
(e-mail address removed)
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
K

KJ

if image_cnt=0 then
ReadFile("image0.bmp");
elsif image_cnt=1 then
ReadFile("image1.bmp");
...
elsif image_cnt=127 then
ReadFile("image127.bmp");
end if;
end if;
end if;
end process;
How can I include the "image_cnt" value
into the string of the image name in an elegant way ?



ReadFile("image" & integer'image(image_cnt) & ".bmp");

Kevin Jennings
 
M

Mike Treseler

Mike said:
I would read the file into a testbench
variable or constant array
at initialization time.

Sorry, I missed the point that
there are more than one file.
See the other postings.

-- Mike Treseler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top