gpt4 book ai didi

vhdl - 签名到 std_logic_vector,切片结果

转载 作者:行者123 更新时间:2023-12-02 20:58:22 25 4
gpt4 key购买 nike

我需要取结果的绝对值,并且我只对最高有效位感兴趣。这就是我所做的:

data_ram_h <= std_logic_vector(abs(signed(resize(r4(calc_cnt - 2), data_ram_h'length) + r4(calc_cnt - 1) +
r4(calc_cnt) + r4(calc_cnt + 1) + r4(calc_cnt + 2) -
r2(calc_cnt - 2) - r2(calc_cnt - 1) - r2(calc_cnt) -
r2(calc_cnt + 1) - r2(calc_cnt + 2))))(11 downto 4);

我尝试检查语法,但收到此错误:

type conversion std_logic_vector is not allowed as a prefix for an slice name.

data_ram_h是一个正确维度的std_logic_vector,并且abs函数返回一个有符号的,因此转换为std_logic_vector应该不会有问题。我正在使用的库是使用ieee.numeric_std.all

我哪里错了?提前致谢 c:

最佳答案

类型转换是一种基本操作,恰好需要在其操作数表达式周围使用括号。还有一个问题,它的使用不是函数调用,因此它不能用作切片名称的前缀。

切片名称的前缀可以是 function_call 或名称。(IEEE Std 1076-2008,5 种类型,5.1 常规,显式类型转换,8 种名称,8.1 常规,8.5 切片名称)。

如果是函数调用,您可以对结果进行切片。

另一方面,您可以对“abs”进行切片,因此对其进行切片,然后进行类型转换:

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

entity slice is
end entity;

architecture foo of slice is
signal h_tmp: signed (11 downto 0);
signal h_tmp_vec: std_logic_vector (11 downto 0);
signal data_ram_h: std_logic_vector(7 downto 0);
signal calc_cnt: integer := 3;
type r_array is array (0 to 15) of unsigned(15 downto 0);
signal r2, r4: r_array := (others => (others => '0'));
begin


data_ram_h<= std_logic_vector (
"abs"(signed(resize(r4(calc_cnt - 2), data_ram_h'length) + r4(calc_cnt - 1) +
r4(calc_cnt) + r4(calc_cnt + 1) + r4(calc_cnt + 2) -
r2(calc_cnt - 2) - r2(calc_cnt - 1) - r2(calc_cnt) -
r2(calc_cnt + 1) - r2(calc_cnt + 2)))(11 downto 4)
);

end architecture;

使用 abs 作为函数调用需要使用它的声明名称,即 "abs"

我只是猜测这里的一些声明,所以我不能保证这在您的代码中有效。上面的示例确实进行了分析、详细说明和运行,这表明子类型范围是兼容的。

关于vhdl - 签名到 std_logic_vector,切片结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28448701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com