Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Writing nul character to file

Hi!

I'm currently developing a small test bench where a bitmap file is read (using std.textio.all). I have managed to read the bmp file and I can write all characters to a new bmp file except 0 (nul character). By opening the input bmp file in notepad++ I can see the nul characters and by using the attribute image on the read variable in the test bench I can see that the nul character has been read properly. The nul characters can, however, not be found in the new bmp file I write to. Here is my simple test bench:


test_proc: process (clk)
variable line_read    :    line; 
variable line_write   :    line;
variable char_buf     :    character;
file input_file       :    text OPEN read_mode IS "input_image.bmp"; -- Image to read from
file output_file      :    text OPEN write_mode IS "output_image.bmp"; -- Image to write to
    
begin
    if rising_edge(clk) then
        readline(input_file, line_read); -- Bitmap only consists of one line.
        while line_read'length > 0 loop
            read(line_read, char_buf);    
            write(line_write, char_buf);
        end loop;
        writeline(output_file, line_write);
        assert false report "NONE! Simulation Finished" severity failure;            
    end if;
end process;

Is it possible to write the nul character to a file using VHDL?

11 Replies