使用 with-select 语句的 VHDL 语法错误

VHDL syntax error using with-select statement

我正在为一个项目编写七段解码器的代码,但当我检查语法错误时,它向我显示了这些:

Error (10500): VHDL syntax error at sevenseg.vhd(16) near text "with"; expecting "end", or "(", or an identifier ("with" is a reserved keyword), or a sequential statement

Error (10500): VHDL syntax error at sevenseg.vhd(17) near text "when"; expecting ";"

我的代码:

library IEEE;
use IEEE.std_logic_1164.all;

entity sevenseg is
    port (m3, m2, m1, m0:in std_logic;
            out7 : out std_logic_vector (6 downto 0));
end sevenseg;

architecture ssdec of sevenseg is
    signal min : std_logic_vector (3 downto 0);
begin
    process(m0, m1, m2, m3)
begin
    min <= m3 & m2 & m1 & m0; --concatenate m0, m1, m2, m3 into vector min
    
    with min select                                 --here is where the error specify
    out7    <=  "0111111"   when "0000" | "1010",   -- 0 
                "0000110"   when "0001" | "1011",   -- 1
                "1010111"   when "0010" | "1100",   -- 2
                "1001111"   when "0011" | "1101",   -- 3
                "1100110"   when "0100" | "1110",   -- 4
                "1101101"   when "0101" | "1111",   -- 5
                "1111100"   when "0110",            -- 6
                "0000111"   when "0111",            -- 7
                "1111111"   when "1000",            -- 8
                "1100111"   when "1001";            -- 9

end process;
end ssdec;

有什么错误,我是如何改正的,谢谢。

在 2008 之前的 VHDL 版本中,with..select 语句只能在进程外使用。因此,要修复错误,可以:

  1. 将 with..select 移出进程
  2. 使用 VHDL 2008 或更高版本

如果您选择上面的 2.,您还需要将 min 添加到过程敏感度列表中。

您还有一个问题,在with..select中没有“其他”选项。 with..select 中必须包含所有案例。因为 min 是 std_logic_vector,所以您必须涵盖所有 9 种独立状态类型的所有组合。因此 when others 通常是涵盖所有内容的最佳方式。