我有一个32位的输出(rd_data),应该将'0'与w位信号(mux_out)连接起来,但我不知道如何将两者结合起来。
signal mux_out : std_logic_vector(w-1 downto 0);
signal rd_data : std_logic_vector(31 downto 0);
signal rd : std_logic;
with rd select
rd_data <= (OTHERS => '0') when '0',
**32-BIT CONCATENATION OF ZEROES AND MUX_OUT** when '1';
w永远不会大于32位。
没有VHDL-2008。
rd_data <= (OTHERS => '0') when '0',
(rd_data'length-1 downto MUX_OUT'length => '0') & MUX_OUT when '1',
(others => 'X') when others ; -- since rd is std_logic
注意,如果MUX_OUT'length = rd_data'length,那么"(rd_data'length-1 downto MUX_OUT'length => '0') "仍然是合法的,因为它返回一个NULL数组(value = "")。
随着VHDL-2008。
use ieee.numeric_std_unsigned.all; -- in context clause
. . .
rd_data <= (OTHERS => '0') when '0',
resize(MUX_OUT, rd_data'length) when '1',
(others => 'X') when others ; -- since rd is std_logic