1

我正在尝试使用 VHDL 2008 在 Vivado 2020.2 中创建一个七段显示控制器。实体需要通过系统时钟速率和时间进行参数化,以在显示器中显示每个数字(有 8 个数字)。这是我到目前为止的代码:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std_unsigned.all;

entity SevenSeg is
    generic (
        -- Rate in HZ
        CLK_RT          : integer := 100000000;
        -- Time in ms
        DISPLAY_TIME    : integer := 20
    );
    port (
        clk             : in std_logic;
        rst             : in std_logic;
        dataIn          : in std_logic_vector(31 downto 0);
        digitDisplay    : in std_logic_vector(7 downto 0);
        digitPoint      : in std_logic_vector(7 downto 0);
        anode           : out std_logic_vector(7 downto 0);
        segment         : out std_logic_vector(7 downto 0)
    );
end SevenSeg;

architecture rtl of SevenSeg is
    constant ROLL_OVER : unsigned := to_unsigned(20 * 1000000 / (1000000000 / CLK_RT), 32);
    signal cnt       : std_logic_vector(31 downto 0);
    signal anode_sel : std_logic_vector(2 downto 0);
begin

     process (clk)
     begin
         if (clk'EVENT AND clk = '1') then      
             if rst = '1' then 
                 anode_sel <= (others => '0');
             else if cnt = std_logic_vector(ROLL_OVER) then
                 anode_sel <= anode_sel + 1;
             end if;
         end if;
     end process;
end rtl;

在代码的当前状态下,Vivado 正在标记语法错误“近端进程”。我很确定出了点问题,cnt = std_logic_vector(ROLL_OVER)因为当我将 if 子句的那部分注释掉时,不再有任何语法错误。我一直在研究 vhdl 以及常量无符号/向量类型的比较,但似乎没有任何效果。我希望能深入了解导致此错误的原因。

4

2 回答 2

0

您没有遵循标准的 VHDL。else if 引入了一个新的 if 条件,它需要一个额外的 end if 是正确的语法。您可以改用 elsif 并且您的代码不会产生错误。

于 2021-11-05T14:23:59.327 回答
0

有两种选择,或者使用elsif

if rst = '1' then 
   anode_sel <= (others => '0');
elsif cnt = std_logic_vector(ROLL_OVER) then
   anode_sel <= anode_sel + 1;
end if;

或:否则如果

if rst = '1' then 
   anode_sel <= (others => '0');
else
   if cnt = std_logic_vector(ROLL_OVER) then
      anode_sel <= anode_sel + 1;
   end if;
end if;
于 2021-11-02T09:11:44.437 回答