Hi I am trying to write a code in VHDL and I get syntax error near "end" / "if". I am not very good at nested if statements and have not figured out how to close those if statements in what order due to lack of internet sources. I am pretty sure that errors I receive are due to if statements, especially due to those which are not properly closed. How can I overcome this problem and continue my project? Here is a code segment I am getting error from. I wrote //ERROR HERE// to denote where an error occurs.
SHOW : process (clk, rst) is
begin -- process SHOW
if rst = '1' then
processed_pic <= def_pic;
cursor_pos_x <= 0;
cursor_pos_y <= 0;
elsif clk'event and clk = '1' then
if (visible = '1') and ( pos_x < 250) and (pos_y <250) and (pos_x > -1)
and (pos_y > -1) then
if((pos_y = cursor_pos_y) and ((pos_x > cursor_pos_x -1) or (pos_x <
cursor_pos_x + height ))) or ((pos_y = cursor_pos_y + height -1) and
((pos_x > cursor_pos_x -1) or (pos_x < cursor_pos_x + height))) then
vgaData <= "00000000000";
data_r <= vgaData(3*COLOR_BIT-1 downto 2*COLOR_BIT);
data_g <= vgaData(2*COLOR_BIT-1 downto COLOR_BIT);
data_b <= vgaData(COLOR_BIT-1 downto 0)
//ERROR HERE// if ((pos_x = cursor_pos_x) and ((pos_y > cursor_pos_y - 1) or (pos_y <
cursor_pos_y + height))) or ((pos_x = cursor_pos_x + height -1) and
((pos_y > cursor_pos_y - 1) or (pos_y < cursor_pos_y + height))) then
vgaData <= "00000000000";
data_r <= vgaData(3*COLOR_BIT-1 downto 2*COLOR_BIT);
data_g <= vgaData(2*COLOR_BIT-1 downto COLOR_BIT);
data_b <= vgaData(COLOR_BIT-1 downto 0)
//ERROR HERE //end if;
else
vgaData <= processed_pic(pos_x,pos_y);
data_r <= vgaData(3*COLOR_BIT-1 downto 2*COLOR_BIT);
data_g <= vgaData(2*COLOR_BIT-1 downto COLOR_BIT);
data_b <= vgaData(COLOR_BIT-1 downto 0)
//ERROR HERE //if ((pos_x > 249) and (pos_y > -1)) or ((pos_y > 249) and ((pos_x > -1)
or (pos_x < 250))) then
vgaData <= "000000001111"; -- mavi
data_r <= vgaData(3*COLOR_BIT-1 downto 2*COLOR_BIT);
data_g <= vgaData(2*COLOR_BIT-1 downto COLOR_BIT);
data_b <= vgaData(COLOR_BIT-1 downto 0);
end if;
end if;
end if;
end process SHOW;
-
\$\begingroup\$ // is not a comment, and there are some missing semicolons. Apart from that, this isn't a complete compilable file and you've not told us what the error messages actually say. \$\endgroup\$user16324– user163242018年04月17日 19:30:48 +00:00Commented Apr 17, 2018 at 19:30
-
\$\begingroup\$ //ERROR HERE// is what I wrote above. It is not in the code. Error message says syntax error near "if". I added some semicolons and I kind of got rid of errors. However, now I am getting "expecting type void for SHOW" error. \$\endgroup\$OnurTR– OnurTR2018年04月17日 19:35:33 +00:00Commented Apr 17, 2018 at 19:35
-
\$\begingroup\$ Use proper indentation, of which there is plenty about on the Internet. Good presentation will help you spot errors in your design more easily. And those that have to use and maintain it after you. I recommend setting your Tabs to inserting two spaces, enough spacing to show structure without wasting screen space. Keep lines to 100 characters or less, which ensures they can be seen on screen easily and printed on A4 in 9pt. With good indentation showing structure, you'll see the unbalanced 'if's. \$\endgroup\$TonyM– TonyM2018年04月17日 19:36:18 +00:00Commented Apr 17, 2018 at 19:36
1 Answer 1
Each of the lines preceding an error is missing a semicolon at the end, e.g.
data_b <= vgaData(COLOR_BIT-1 downto 0)
^^^