【问题标题】:VHDL: error when using "With Select When" StatementVHDL:使用“With Select When”语句时出错
【发布时间】:2017-05-03 06:14:50
【问题描述】:

我正在使用 Altera Max V 和 Quartus 学习 VHDL 来做一些示例,但在使用“With Select when”语句时遇到了麻烦。我有一个简单的 2-4 解码器,如下所示:

library ieee;
use ieee.std_logic_1164.all;

entity lesson9 is
    port(
        x: in std_logic_vector(1 downto 0);
        en: in std_logic;
        y: out std_logic_vector(3 downto 0)
    );
end lesson9;

architecture rtl of lesson9 is

signal outputBuff: std_logic_vector(3 downto 0);

begin
    decoder2to4: process(x)
    begin
        with x select
            outputBuff <= "0001" when "00",
                          "0010" when "01",
                          "0100" when "10",
                          "1000" when "11";
    end process decoder2to4;

    y <= outputBuff;
end rtl;

我收到了错误消息:

靠近文本“with”;期望“end”,或“(”,或标识符(“with”是保留关键字),pr是顺序语句

我试图检查我的代码但找不到问题?

【问题讨论】:

  • 您使用的是哪个版本的 Quartus? With-select it VHDL-2008 结构,旧工具版本不支持。此外,如果使用更新的 Quartus 版本,请确保为文件启用 VHDL-2008。
  • with ... select 不是 VHDL-2008 构造,但在顺序代码(例如进程)中允许 with ... select 是新的。如果您的工具支持这些功能,您需要删除使with ... select 并发的进程或启用使用 2008 功能进行编译。

标签: vhdl quartus


【解决方案1】:

with ... select 语句是在进程外部使用的并发信号赋值语句:

architecture rtl of lesson9 is

signal outputBuff: std_logic_vector(3 downto 0);

begin
    with x select
        outputBuff <= "0001" when "00",
                      "0010" when "01",
                      "0100" when "10",
                      "1000" when "11";

    y <= outputBuff when en='1' else (others=>'0');
end rtl;

我还在输出赋值语句中添加了en 信号。

注意:我没有模拟那个代码 sn-p。

【讨论】:

  • VHDL 2008 中还有一个顺序选择的信号分配语句。参见 IEEE Std 1076-2008 10.5 信号分配语句和 10.5.4 选择的信号分配。不幸的是,Quartus® Prime 不支持用于综合的功能。
  • 为什么要在输出语句中添加en 信号?问题中没有任何内容表明这是必要的。
  • 嗯,端口列表中有一个en 输入端口,很容易猜出它的用途。声明架构中未使用的输入端口当然不是错误,但综合/linting 工具可能会抱怨它。所以我建议要么使用该端口,要么将其从端口列表中删除。
  • @Juergen 如果不使用声明的信号,则信号将在合成过程中被优化(即删除)而不会产生任何抱怨。
  • 谢谢@Juergen。我会测试一下。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-20
  • 1970-01-01
  • 1970-01-01
  • 2020-04-16
  • 1970-01-01
相关资源
最近更新 更多