EmbDev.net

Forum: FPGA, VHDL & Verilog VHDL error in project


von Fernando .S (Guest)


Rate this post
useful
not useful
So basically I'm trying to read a VHDL file with 3 colors (R,G,B)
with these formats :

image_width = 1666;
image_height = 1267;
Bit depth = 4;

I'm getting a fatal error at line 108 which is
(Sorry for the sudoku code ).
1
--------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------- 
2
3
4
for row_i in 0 to image_height - 1 loop
5
6
      -- Create a new row type in dynamic memory
7
      row := new row_type(0 to image_width - 1);
8
9
      for col_i in 0 to image_width - 1 loop
10
     (=> THIS line) read(bmp_file, char);
11
12
---------------------------------------------------------------------------
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use ieee.numeric_std.all;
16
17
use std.textio.all;
18
use std.env.finish;
19
20
entity read_bmp_tb is
21
end read_bmp_tb;
22
23
architecture sim of read_bmp_tb is
24
25
  type header_type  is array (0 to 117) of character;
26
27
  type pixel_type is record
28
    red : std_logic_vector(7 downto 0);
29
    green : std_logic_vector(7 downto 0);
30
    blue : std_logic_vector(7 downto 0);
31
  end record;
32
33
  type row_type is array (integer range <>) of pixel_type;
34
  type row_pointer is access row_type;
35
  type image_type is array (integer range <>) of row_pointer;
36
  type image_pointer is access image_type;
37
38
  -- DUT signals
39
  signal r_in : std_logic_vector(7 downto 0);
40
  signal g_in : std_logic_vector(7 downto 0);
41
  signal b_in : std_logic_vector(7 downto 0);
42
43
  signal r_out : std_logic_vector(7 downto 0);
44
  signal g_out : std_logic_vector(7 downto 0);
45
  signal b_out : std_logic_vector(7 downto 0);
46
47
begin
48
49
  DUT :entity work.grayscale(rtl)
50
  port map (
51
    r_in => r_in,
52
    g_in => g_in,
53
    b_in => b_in,
54
55
    r_out => r_out,
56
    g_out => g_out,
57
    b_out => b_out
58
  );
59
60
  process
61
    type char_file is file of character;
62
    file bmp_file : char_file open read_mode is "Before.bmp";
63
    file out_file : char_file open write_mode is "After.bmp";
64
    variable header : header_type;
65
    variable image_width : integer;
66
    variable image_height : integer;
67
    variable row : row_pointer;
68
    variable image : image_pointer;
69
    variable padding : integer;
70
    variable char : character;
71
  begin
72
73
    -- Read entire header
74
    for i in header_type'range loop
75
      read(bmp_file, header(i));
76
    end loop;  
77
78
    image_width := 1666;
79
80
    image_height := 1267;
81
82
    -- Number of bytes needed to pad each row to 32 bits
83
    padding := (4 - image_width*3 mod 4) mod 4;
84
    report "padding: " & integer'image(padding);
85
86
    -- Create a new image type in dynamic memory
87
    image := new image_type(0 to image_height - 1);
88
89
    for row_i in 0 to image_height - 1 loop
90
91
      -- Create a new row type in dynamic memory
92
      row := new row_type(0 to image_width - 1);
93
94
      for col_i in 0 to image_width - 1 loop
95
-------------------------------------------------------------------------------------------------------------------------------------------------------------
96
        -- Read blue pixel
97
 --------------------------------------------- --------------------------------------------- ---------------------------------------------   
98
        read(bmp_file, char);//Error starts from here 
99
        row(col_i).blue :=
100
          std_logic_vector(to_unsigned(character'pos(char), 8));
101
102
        -- Read green pixel
103
        read(bmp_file, char);
104
        row(col_i).green :=
105
          std_logic_vector(to_unsigned(character'pos(char), 8));
106
107
        -- Read red pixel
108
        read(bmp_file, char);
109
        row(col_i).red :=
110
          std_logic_vector(to_unsigned(character'pos(char), 8));
111
112
      end loop;
113
114
      -- Read and discard padding
115
      for i in 1 to padding loop
116
        read(bmp_file, char);
117
      end loop;
118
119
      -- Assign the row pointer to the image vector of rows
120
      image(row_i) := row;
121
122
    end loop;
123
124
    -- DUT test
125
    for row_i in 0 to image_height - 1 loop
126
      row := image(row_i);
127
128
      for col_i in 0 to image_width - 1 loop
129
130
        r_in <= row(col_i).red;
131
        g_in <= row(col_i).green;
132
        b_in <= row(col_i).blue;
133
        wait for 10 ns;
134
135
        row(col_i).red := r_out;
136
        row(col_i).green := g_out;
137
        row(col_i).blue := b_out;
138
139
      end loop;
140
    end loop;
141
142
    -- Write header to output file
143
    for i in header_type'range loop
144
      write(out_file, header(i));
145
    end loop;
146
147
    for row_i in 0 to image_height - 1 loop
148
      row := image(row_i);
149
150
      for col_i in 0 to image_width - 1 loop
151
152
        -- Write blue pixel
153
        write(out_file,
154
          character'val(to_integer(unsigned(row(col_i).blue))));
155
156
        -- Write green pixel
157
        write(out_file,
158
          character'val(to_integer(unsigned(row(col_i).green))));
159
160
        -- Write red pixel
161
        write(out_file,
162
          character'val(to_integer(unsigned(row(col_i).red))));
163
164
      end loop;
165
166
      deallocate(row);
167
168
      -- Write padding
169
      for i in 1 to padding loop
170
        write(out_file, character'val(0));
171
      end loop;
172
173
    end loop;
174
175
    deallocate(image);
176
177
    file_close(bmp_file);
178
    file_close(out_file);
179
180
    report "Simulation done. Check ""out.bmp"" image.";
181
    finish;
182
  end process;
183
184
end architecture;
185
186
----------------------------------------------------------------------------------------------------------------------------------------
I appreciate any help on the code thanks

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Fernando .S wrote:
1
        read(bmp_file, char);    // Error starts from here --> is that really the problem?
2
3
        row(col_i).blue := std_logic_vector(to_unsigned(character'pos(char), 8));  -->  or is it here?
Did you single step through the source code?


> I appreciate any help
Pls use the [vhdl] tags to wrap your code. See "Formatting options" a 
few lines over each text input box.

: Edited by Moderator
von Fernando .S (Guest)


Attached files:

Rate this post
useful
not useful
I tried a smaller code to check if read function is working correctly or 
not .

When I run the simulation I keep getting this :

# Loading std.standard
# Loading std.textio(body)
# Loading ieee.std_logic_1164(body)
# Loading ieee.numeric_std(body)
# Loading std.env(body)
# Loading work.readbmp(reading)

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Fernando .S wrote:
> When I run the simulation I keep getting this :
Nothing else? On which simulator? Can you do single stepping on that 
simulator?

> vhdl.png
> I tried a smaller code
Pls. post that CODE in ASCII as a *.vhd odr a *.vhdl file. Its simply 
impossible to copy&past some test out of a picture.

Or do it as I already wrote:
> Pls use the [vhdl] tags to wrap your code. See "Formatting options" a
> few lines over each text input box.

von Fernando .S (Guest)


Attached files:

Rate this post
useful
not useful
Yes nothing else showed up .

I tried to wait for half an hour thinking that the data that I wrote may 
too big but it's actually not .

What do you mean by single stepping on the simulator ? I don't know 
that.

It just keeps showing these messages
# Loading std.standard
# Loading std.textio(body)
# Loading ieee.std_logic_1164(body)
# Loading ieee.numeric_std(body)
# Loading std.env(body)
# Loading work.readbmp(reading)

von Fernando .S (Guest)


Rate this post
useful
not useful
I'm Using modelsim

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.