【问题标题】:VHDL synax error in state machine状态机中的 VHDL 语法错误
【发布时间】:2017-03-25 03:32:56
【问题描述】:

我很难在编码中找到语法错​​误。任何帮助将不胜感激。我的合成器说错误位于 blowoncompon>= 时的状态,但是我认为错误在其他地方,因为当我提交该代码状态时,错误会移动到下一个状态。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity question4 is
 Port (
 --System Clock Declaration--------------------------
 clk: in std_logic;

 --Button Inputs-------------------------------------
 btnL: in std_logic; --
 btnU: in std_logic; --Clear
 btnD: in std_logic; --Reset

 sw: in std_logic_vector(7 downto 0);
 led: out std_logic_vector(15 downto 0)
 );
 end question4;

 architecture Behavioral of question4 is 

 constant active: std_logic := '1'; 
 constant bloweron: std_logic_vector(15 downto 0) := "000000011111111";
 constant compon: std_logic_vector(15 downto 0) := "1111111000000000";
 signal clear: std_logic := btnU; 
 signal reset: std_logic := btnD; 


 type states is (blowoncompoff, 
                blowoffcompoff, 
                blowoncompon);

 signal CurrentState: states; 
 signal NextState: states; 

begin 

motorstatetrans: process(currentsate)
begin

    if clear = active then 
        currentstate <= blowoffcompoff; 
    end if; 

    case currentstate is

       when blowoncompon>=   --------Why syntax error near here
            led <= bloweron;  
            led <= compon;

            if currenttemp=settemp then
                Nextstate <= blowoncompoff;

            elsif
                currenttemp>settemp then 
                    Nextstate <= bloweroncompon; 
            end if; 

       when blowoncompoff >= 
            led <= bloweron; 

            if currenttemp < settemp then 
                Nextstate <= bloweroncompon; 

            elsif current temp = set temp then 
                Nextstate <= blowoffcompoff; 

      when blowoffcompoff >=

            if current temp < settemp then 
                Nextstate <= blowoncompon; 

    end case; 
end process;      

【问题讨论】:

  • 不,错误就在工具指示的位置。 ` when blowoncompon>= --------Why syntax error near here`。 IEEE Std 1076-2008 10.9 Case 语句,语法为 case_statement_alternative ::= when selections => sequence_of_statements。而不是“>=”,您应该在一系列语句之前使用“=>”(一个或多个顺序语句,10.1)。显示您的错误消息。

标签: syntax vhdl


【解决方案1】:
when blowoncompon>=   --------Why syntax error near here

这不是 VHDL 语法,就像错误所说的那样。谷歌一下:VHDL Case Statement

when blowoncompon =>

但是您的代码缺少很多end if;s,所以它仍然无法工作。

【讨论】:

    【解决方案2】:

    根据其实体声明 (clk),您的状态机可能是一个同步电路。但是你的设计不是同步的:它不使用它的时钟。

    【讨论】:

    • 我还没有添加时钟。当我创建第一个状态时,我注意到错误发生了。我正在创建一个时钟分频器信号,该信号将以 if 语句的形式发送到不同的状态,以减慢速度,以便人眼可以看到它们。我不认为缺少时钟信号会产生错误,但我会继续创建它并将信号插入状态,看看会发生什么。
    • 不是我的反对票,但您确实不正确恕我直言:状态机根本不必是同步电路。实际上,在异步设计中,状态机通常是指导电路行为的最佳方式。
    • 在状态机的 VHDL 模型中,输入端口被命名为 clk 并被注释为 系统时钟声明,我们大概可以假设设计的目标类是不是异步的,但您在技术上是正确的,J.H.,状态机也可以是异步的。相应地编辑了我的答案。而且我不介意投反对票,即使我不理解它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-23
    • 2015-08-10
    • 1970-01-01
    • 2012-10-16
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多