转换为 std_logic_vector 并更有效地切片
convert to std_logic_vector and slice more efficiently
在一个进程中,我对 UNSIGNED
向量做了一些工作,我需要在进程结束时对其进行切片并转换回 SLV
。还有比这更nicer/cleaner的方法吗?
out_O : out STD_LOGIC_VECTOR(15 downto 0)
variable o : UNSIGNED(17 downto 0) := (others => '0');
variable outcast_t : STD_LOGIC_VECTOR(17 downto 0) := (others => '0');
...
o := mod_t - div_t + const;
outcast_t := STD_LOGIC_VECTOR(o);
out_O <= outcast_t(15 downto 0);
有
use ieee.numeric_std_unsigned.all;
slv 将作为无符号处理,您可以直接对该类型进行操作,从而避免转换。
你也可以这样做
out_O <= o(out_O'range);
如果修改 out_O
的大小,可能会为您节省一些更改。假设您将 o
重新定义为 slv.
在一个进程中,我对 UNSIGNED
向量做了一些工作,我需要在进程结束时对其进行切片并转换回 SLV
。还有比这更nicer/cleaner的方法吗?
out_O : out STD_LOGIC_VECTOR(15 downto 0)
variable o : UNSIGNED(17 downto 0) := (others => '0');
variable outcast_t : STD_LOGIC_VECTOR(17 downto 0) := (others => '0');
...
o := mod_t - div_t + const;
outcast_t := STD_LOGIC_VECTOR(o);
out_O <= outcast_t(15 downto 0);
有
use ieee.numeric_std_unsigned.all;
slv 将作为无符号处理,您可以直接对该类型进行操作,从而避免转换。
你也可以这样做
out_O <= o(out_O'range);
如果修改 out_O
的大小,可能会为您节省一些更改。假设您将 o
重新定义为 slv.