If statement 使用vhdl的If语句

If statement 使用vhdl的If语句,if-statement,vhdl,fpga,xilinx,If Statement,Vhdl,Fpga,Xilinx,我正在使用vhdl和planahead软件设计计数器,不管怎样,我正在使用if语句,但它给出了许多错误。计数器的用途是从1递增/递减到10,反之亦然。在升序的情况下,当它到达9时,我重置out以从0开始再次计数。在这种情况下,当它得到0时,重置输出,并给出9作为新值。我用板上的开关按钮在上升/下降计数之间切换。低于if状态和错误。我不知道我是否在书写表格上使用它。如果有人有主意,那就太好了 Line:27- if(inc_dec='1') then Line:28 if (r_re

我正在使用vhdl和planahead软件设计计数器,不管怎样,我正在使用if语句,但它给出了许多错误。计数器的用途是从1递增/递减到10,反之亦然。在升序的情况下,当它到达9时,我重置out以从0开始再次计数。在这种情况下,当它得到0时,重置输出,并给出9作为新值。我用板上的开关按钮在上升/下降计数之间切换。低于if状态和错误。我不知道我是否在书写表格上使用它。如果有人有主意,那就太好了

 Line:27-   if(inc_dec='1') then
 Line:28    if (r_reg=M-1) then
            r_next<=(others=>'0')
 Line:30    else r_reg+1;
 Line: 31   elsif (inc_dec='0')then
 Line:32    if (r_reg=M-10) then
            r_next<=(others=>'9')
 Line:34    else
            r_reg-1;

           end if;
           end if;
           end if;
正如所指出的,您需要使用end if终止if/else。此外,还缺少一些分号。下面的代码应该可以工作

if (inc_dec='1') then
   if (r_reg=(M-1)) then
        r_next <= (others=>'0');
   else 
        r_reg+1;
   end if; 
elsif (inc_dec='0') then
   if (r_reg=(M-10)) then
        r_next <=  to_unsigned(9, r_next'length);
   else
        r_reg-1;
   end if;
end if;
如果(inc_dec='1'),则
如果(r_reg=(M-1)),那么
r_next“0”);
其他的
r_reg+1;
如果结束;
elsif(inc_dec='0')然后
如果(r_reg=(M-10)),那么

r\u下一步,对于
else
,如果没有
end if
,则不能将
else
后跟
elsif
。但从错误消息来看,您似乎试图在错误的位置使用
if
语句,可能是在进程之外。请发布原始源代码。正确格式化此代码,错误可能会很明显。下一行r_'9')是错误的。正确的表达式是r_next是的,我怎么忘记了(其他=>'9');。完全不正确。谢谢你,我要试试这个密码
if (inc_dec='1') then
   if (r_reg=(M-1)) then
        r_next <= (others=>'0');
   else 
        r_reg+1;
   end if; 
elsif (inc_dec='0') then
   if (r_reg=(M-10)) then
        r_next <=  to_unsigned(9, r_next'length);
   else
        r_reg-1;
   end if;
end if;
r_next <= (others=>'9');
r_next <=  to_unsigned(9, r_next'length)