微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VHDL可以合成clk'event吗?

如何解决VHDL可以合成clk'event吗?

我正在尝试用 VHDL 编写一个 4 位乘法器。这是我写的代码

-r

它可以在模拟中执行并且可以工作,但是当我尝试合成它时,我得到: 不受支持的 Clock 语句。

解决方法

如果你只想要一个带有 4 位参数的乘法器,那么不带 clk 的代码如下。您不需要 a'event 或 b'event。

process(A,B)
    variable sum_result : unsigned(8 downto 0) := (others => '0');
begin
    sum_result:=(others => '0');
    for i in 0 to 3 loop
        if B(i)='1' then
           sum_result:=sum_result+shift_left(b"00000"&unsigned(A),i);
        end if;
    end loop;
    Y<=STD_LOGIC_VECTOR(sum_result(7 downto 0));
end process;

OTOH,如果您想要乘法器和触发器,请编写以下代码。您不需要敏感列表中的 A 或 B。

process(clk)
    variable sum_result : unsigned(8 downto 0) := (others => '0');
begin
    if clk = '1' and clk'event then
        sum_result:=(others => '0');
        for i in 0 to 3 loop
            if B(i)='1' then
                sum_result:=sum_result+shift_left(b"00000"&unsigned(A),i);
            end if;
        end loop;
        Y<=STD_LOGIC_VECTOR(sum_result(7 downto 0));
    end if;
end process;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。