If statement VHDL-嵌套if语句
我在vhdl中定义了这样一个进程(我知道if语句中的一些条件是不必要的,但我现在忽略了这些条件):If statement VHDL-嵌套if语句,if-statement,process,nested,vhdl,If Statement,Process,Nested,Vhdl,我在vhdl中定义了这样一个进程(我知道if语句中的一些条件是不必要的,但我现在忽略了这些条件): LSPflag:process(xcolumn、yrow、picture_q_______________________________ 变量RGB:RGB_type;——输出颜色 变量x,y,zx,zy:integer;——重命名为xcolumn和yrow 变量i图片:布尔; 开始 x:=到_整数(xcolumn);y:=到_整数(yrow);--转换为整数 zy:=到_整数(无符号(xyof
LSPflag:process(xcolumn、yrow、picture_q_______________________________
变量RGB:RGB_type;——输出颜色
变量x,y,zx,zy:integer;——重命名为xcolumn和yrow
变量i图片:布尔;
开始
x:=到_整数(xcolumn);y:=到_整数(yrow);--转换为整数
zy:=到_整数(无符号(xyoffset));
zx:=(到_整数(无符号(xyoffset))*XSIZE)/YSIZE;
RGB:=黑色;
如果zy>360,则
--使用if语句进行填充1
如果结束;
如果zy>240,则
--使用if语句执行stuff2
如果结束;
如果zy>120,则
--使用if语句执行stuff3
其他的
i图片:=x>=EMBORGX+centerx zx和x=EMBORGY+centery+zy和y=centerx+zx和x=centery+zx和x=centery+zy和yYSIZE*x然后--右下角
RGB:=蓝色或RGB;
如果结束;
如果是我画的话
图片地址正如BrianDrummond提醒我的那样,问题是我写的是'else-if'而不是elsif。这在我看来更像是C代码,而不是VHDL。请给出一个例子。我不想在这里展示它,因为我认为它与这个问题并不相关,但我在帖子中编辑了它。你的编辑没有提供一个最小的、完整的和可验证的例子:它既不是最小的、完整的,也不是可验证的。您的帖子现在将三次显示相同的代码片段。我们无法模拟它,因此无法看到您的问题。您只是要求我们调试高度集成的代码,而无需任何注释。很抱歉,这会占用我太多时间。您有很多else if
行,它们打开了新的嵌套if
语句。您可能打算使用elsif
,但实际上并非如此。这样做的结果是大量缺少end if
语句,因此解析器发现end process
位于错误的位置(嵌套if
s的深处),这正是错误消息(如果您费心发布)试图说的。那个版本,加上正确的语法,很可能就是你们想要达到的。@JHBonarius嗯,好吧,我会尝试用另一种方式来表达我自己
LSPflag : process(xcolumn, yrow, picture_q_s) -- output of process depends on xcolumn and yrow
variable RGB : RGB_type; -- output colors
variable x, y, zx,zy : integer; -- renamed xcolumn and yrow
variable isPicture:boolean;
begin
x:=to_integer(xcolumn); y:=to_integer(yrow); -- convert to integer
zy:= To_integer(unsigned(xyoffset));
zx:= (To_integer(unsigned(xyoffset))*XSIZE)/YSIZE;
RGB:=BLACK;
if zy>360 then
--do stuff1 with if statements
end if;
if zy>240 then
--do stuff2 with if statements
end if;
if zy>120 then
--do stuff3 with if statements
else
isPicture:= x>=EMBORGX+centerx-zx and x<EMBORGX+MEMROWSIZE+centerx-zx and y>=EMBORGY+centery+zy and y<EMBORGY+MEMROWCOUNT+centery+zy;
if isPicture and picture_q_s = '1' then--bottomleft corner
RGB:=YELLOW or RGB;
end if;
if y*XSIZE<=-YSIZE*x+YSIZE*XSIZE+(centery-zy)*XSIZE+(centerx-zx)*YSIZE and x>=centerx-zx and x<=XSIZE+centerx-zx and y>=centery-zy and y<=YSIZE+centery-zy then--upperleft corner
RGB:=WHITE or RGB;
end if;
if y*XSIZE>-YSIZE*x+YSIZE*XSIZE+(centery-zy)*XSIZE+(centerx+zx)*YSIZE and x>=centerx+zx and x<=XSIZE+centerx+zx and y>=centery-zy and y<=YSIZE+centery-zy and y*XSIZE<YSIZE*x-(2*zy)*XSIZE then--upperright corner
RGB:=RED or RGB;
end if;
if y*XSIZE>-YSIZE*x+YSIZE*XSIZE+(centery+zy)*XSIZE+(centerx+zx)*YSIZE and x>=centerx+zx and x<=XSIZE+centerx+zx and y>=centery+zy and y<=YSIZE+centery+zy and y*XSIZE>YSIZE*x then--bottomright corner
RGB:=BLUE or RGB;
end if;
if isPicture then
picture_address_s <= std_logic_vector(to_unsigned((y-EMBORGY-centery-zy)*MEMROWSIZE + (x-EMBORGX-centerx+zx), picture_address_s'LENGTH));
else
picture_address_s <=(others=>'0');
end if;
end if;
VGA_R<=RGB.R; VGA_G<=RGB.G; VGA_B<=RGB.B;
end process;
if zy>360 then
--do stuff with if statements1
else if zy>240 then
--do stuff with if statements2
else if zy>120 then
--do stuff with if statements3
else
isPicture:= x>=EMBORGX+centerx-zx and x<EMBORGX+MEMROWSIZE+centerx-zx and y>=EMBORGY+centery+zy and y<EMBORGY+MEMROWCOUNT+centery+zy;
if isPicture and picture_q_s = '1' then--bottomleft corner
RGB:=YELLOW or RGB;
end if;
if y*XSIZE<=-YSIZE*x+YSIZE*XSIZE+(centery-zy)*XSIZE+(centerx-zx)*YSIZE and x>=centerx-zx and x<=XSIZE+centerx-zx and y>=centery-zy and y<=YSIZE+centery-zy then--upperleft corner
RGB:=WHITE or RGB;
end if;
if y*XSIZE>-YSIZE*x+YSIZE*XSIZE+(centery-zy)*XSIZE+(centerx+zx)*YSIZE and x>=centerx+zx and x<=XSIZE+centerx+zx and y>=centery-zy and y<=YSIZE+centery-zy and y*XSIZE<YSIZE*x-(2*zy)*XSIZE then--upperright corner
RGB:=RED or RGB;
end if;
if y*XSIZE>-YSIZE*x+YSIZE*XSIZE+(centery+zy)*XSIZE+(centerx+zx)*YSIZE and x>=centerx+zx and x<=XSIZE+centerx+zx and y>=centery+zy and y<=YSIZE+centery+zy and y*XSIZE>YSIZE*x then--bottomright corner
RGB:=BLUE or RGB;
end if;
if isPicture then
picture_address_s <= std_logic_vector(to_unsigned((y-EMBORGY-centery-zy)*MEMROWSIZE + (x-EMBORGX-centerx+zx), picture_address_s'LENGTH));
else
picture_address_s <=(others=>'0');
end if;
end if;