B
Brad Smallridge
Guest
The code below is cut from a testbench I wrote that reads the header of a
BMP file, and writes another BMP file as output. I have tried to shorten
this code by putting the file reading, file writing, multiply and add in a
separate function, however I get an error saying that the read / write are
not somehow doable in a "pure" function. Obviously something is not going
on the way I expect a VHDL function to run like a string of operations like
in C.
Can somebody show me a readable and concise way of doing this?
Thanks,
Brad Smallridge
-- the next 4 bytes are the file size
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := character'pos(my_char_v);
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*(character'pos(my_char_v));
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*256*(character'pos(my_char_v));
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*256*256*(character'pos(my_char_v));
ETC. ETC. ETC. Very verbose.
BMP file, and writes another BMP file as output. I have tried to shorten
this code by putting the file reading, file writing, multiply and add in a
separate function, however I get an error saying that the read / write are
not somehow doable in a "pure" function. Obviously something is not going
on the way I expect a VHDL function to run like a string of operations like
in C.
Can somebody show me a readable and concise way of doing this?
Thanks,
Brad Smallridge
-- the next 4 bytes are the file size
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := character'pos(my_char_v);
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*(character'pos(my_char_v));
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*256*(character'pos(my_char_v));
read (my_file, my_char_v);
write(my_file2,my_char_v);
file_size := file_size+ 256*256*256*(character'pos(my_char_v));
ETC. ETC. ETC. Very verbose.