解析错误:意外的 WHEN,期望分号

发布于 2025-01-10 23:08:57 字数 1929 浏览 1 评论 0原文

我正在尝试在 VHDL 中实现此 when else 语句,但由于某种原因,我收到此错误:

Line 48. parse error, unexpected WHEN, expecting SEMICOLON

第 48 行是这个:LED<= "1111001" when count_temp = "0001" else

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity SOURCE is
    Port (clk_in,RST : in  STD_LOGIC;
          COUNT : inout  STD_LOGIC_VECTOR (3 downto 0);
             AN: out std_logic_vector(3 downto 0);
             LED: out std_logic_vector(6 downto 0));
end SOURCE;

architecture Behavioral of SOURCE is

signal count_temp: std_logic_vector(3 downto 0);
signal CLK: std_logic;

component clk_div is
port (clk_in: in std_logic;
        clk_out: out std_logic);
end component;


begin
CL: clk_div port map (clk_in, CLK);

counter: process (CLK,RST,count_temp) 

begin
if (RST = '1')then
count_temp <= "0000";
elsif(rising_edge(CLK))then

    if (count_temp <= "1111") then
    count_temp <= count_temp +1;
    else count_temp <= "0000";
    end if;
end if;
end process;

COUNT <= count_temp;
AN <= "1110";

process(count_temp)

begin

LED<= "1111001" when count_temp = "0001" else
        "0100100" when count_temp = "0010" else
        "1111001" when count_temp = "0011" else
        "0100100" when count_temp = "0100" else
        "1111001" when count_temp = "0101" else
        "0100100" when count_temp = "0110" else
        "0100100" when count_temp = "0111" else
        "1111001" when count_temp = "1000" else
        "0100100" when count_temp = "1001" else
        "1111001" when count_temp = "1010" else
        "0100100" when count_temp = "1011" else
        "1111001" when count_temp = "1100" else
        "0100100" when count_temp = "1101" else
        "1111001" when count_temp = "1110" else
        "0100100" when count_temp = "1111" else
        "0100111" when others;
    
end process;

I am trying to implement this when else statement in VHDL but for some reason, I get this error:

Line 48. parse error, unexpected WHEN, expecting SEMICOLON

Line 48 is this one: LED<= "1111001" when count_temp = "0001" else

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity SOURCE is
    Port (clk_in,RST : in  STD_LOGIC;
          COUNT : inout  STD_LOGIC_VECTOR (3 downto 0);
             AN: out std_logic_vector(3 downto 0);
             LED: out std_logic_vector(6 downto 0));
end SOURCE;

architecture Behavioral of SOURCE is

signal count_temp: std_logic_vector(3 downto 0);
signal CLK: std_logic;

component clk_div is
port (clk_in: in std_logic;
        clk_out: out std_logic);
end component;


begin
CL: clk_div port map (clk_in, CLK);

counter: process (CLK,RST,count_temp) 

begin
if (RST = '1')then
count_temp <= "0000";
elsif(rising_edge(CLK))then

    if (count_temp <= "1111") then
    count_temp <= count_temp +1;
    else count_temp <= "0000";
    end if;
end if;
end process;

COUNT <= count_temp;
AN <= "1110";

process(count_temp)

begin

LED<= "1111001" when count_temp = "0001" else
        "0100100" when count_temp = "0010" else
        "1111001" when count_temp = "0011" else
        "0100100" when count_temp = "0100" else
        "1111001" when count_temp = "0101" else
        "0100100" when count_temp = "0110" else
        "0100100" when count_temp = "0111" else
        "1111001" when count_temp = "1000" else
        "0100100" when count_temp = "1001" else
        "1111001" when count_temp = "1010" else
        "0100100" when count_temp = "1011" else
        "1111001" when count_temp = "1100" else
        "0100100" when count_temp = "1101" else
        "1111001" when count_temp = "1110" else
        "0100100" when count_temp = "1111" else
        "0100111" when others;
    
end process;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是我以为 2025-01-17 23:08:57

看起来可能有两件事:

  1. 不确定您是否可以在像您这样的进程中使用条件信号分配。尝试移动到进程之外?
    2)。根据此页面 https://www.ics.uci.edu/~jmoorkan /vhdlref/cond_s_a.html。您编写 else 部分的方式看起来像是一些语法错误?也许只需要 else "0100111" (其他时候不需要)

It looks like perhaps two things:

  1. Not sure if you can use conditional signal assignment in a process like you are. Try moving outside process?
    2). Per this page https://www.ics.uci.edu/~jmoorkan/vhdlref/cond_s_a.html. It looks like some syntax error for how you wrote the else part? Maybe just need else "0100111" (no when others)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文