【问题标题】:VHDL - Phase Accumulator with feedbackVHDL - 带反馈的相位累加器
【发布时间】:2019-06-29 16:23:20
【问题描述】:

我正在尝试使用具有以下特征的 VHDL 创建相位累加器。

输入:

  • D(输入信号)
  • 重置
  • CE
  • 时钟

输出:

  • Q(输出信号 - 反馈)

源代码:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Phase_accu is
port (
    D       : in std_logic_vector(3 downto 0);
    CE      : in std_logic;
    CLK     : in std_logic;
    RESET   : in std_logic;
    Q       : out std_logic_vector(15 downto 0)
);
end Phase_accu;

architecture Behavioral of Phase_accu is
begin

process(D, CE, CLK, RESET)
    begin
        if RESET = '1' then
            Q <= "0000000000000000";
        elsif rising_edge(CLK) then
            if CE = '1' then
                Q <= ("000000000000" & D) + Q;
            end if;
        end if;
end process;

end Behavioral;

我在尝试将 2 个反馈信号合并在一起时遇到错误...

Q <= ("000000000000" & D) + Q;

无法读取输出“Q”。

【问题讨论】:

  • 删除代码第一行 library 之前多余的 use 并使用 VHDL 版本 -2008 分析和详细说明您的代码(在 -2008 中可以评估模式输出端口)。请提供minimal reproducible example,包括完整的错误消息并标识您的工具正在执行的操作,不能保证问题可以按原样重现。

标签: vhdl feedback accumulator phase


【解决方案1】:

在 VHDL-2008 之前的 VHDL 版本中,您无法读取 out 的值。解决此问题的常用方法是拥有输出的内部副本,并在需要获取其值时使用该内部副本:

[...]
Q : out std_logic_vector(15 downto 0);
[...]
signal Q_reg : std_logic_vector(15 downto 0);

process(D, CE, CLK, RES)
    begin

        if RES = '1' then
            Q_reg <= "0000000000000000";
        elsif rising_edge(CLK) then
            if CE = '1' then
                Q_reg <= ("000000000000" & D) + Q_reg;
            end if;
        end if;
end process;

Q <= Q_reg;

【讨论】:

  • 我现在明白了。非常感谢您的帮助。 :)
【解决方案2】:

我建议使用 numeric_std 库而不是 STD_LOGIC_ARITH 和 STD_LOGIC_UNSIGNED。我还建议对向量大小规范进行一些小的优化。

敏感度列表也有两个多条目。您必须删除 D 和 CE 才能描述具有异步复位的有效时钟进程。有关详细信息,请参阅您的综合工具手册。

这使得上面的代码变为

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

entity Phase_accu is
port (
    D       : in std_logic_vector(3 downto 0);
    CE      : in std_logic;
    CLK     : in std_logic;
    RESET   : in std_logic;
    Q       : out std_logic_vector(15 downto 0)
);
end Phase_accu;

architecture Behavioral of Phase_accu is
    signal Q_reg : unsigned(Q'range);
begin

process(CLK, RES)
begin

        if RES = '1' then
            Q_reg <= (others => '0');
        elsif rising_edge(CLK) then
            if CE = '1' then
                Q_reg <= resize(unsigned(D), Q_reg'length) + Q_reg;
            end if;
        end if;

end process;

Q <= std_logic_vector(Q_reg);

end Behavioral;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    相关资源
    最近更新 更多