目前的流程似乎可以解决:
process(sel, X)
begin
-- set all to 0
mux_out <= (others => zero);
-- Set input in correct line
mux_out(to_integer(unsigned(sel))) <= X;
end process;
Run Code Online (Sandbox Code Playgroud)
我将使用 TestBench 测试更多案例并将结果写在这里,再次感谢大家的帮助:)
==== 上一篇文章 ======= 我已经通过以下 Paebbles 示例实现了 DEMUX:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.MATH_REAL.ALL;
use IEEE.NUMERIC_STD.ALL;
entity DeMUX_1toX_N_bits is
generic (
PORTS : POSITIVE := 4;
BITS : POSITIVE := 8 );
port (
sel : in STD_LOGIC_VECTOR(integer(ceil(log2(real(PORTS)))) - 1 downto 0);
X : in STD_LOGIC_VECTOR(BITS - 1 downto 0);
Y : out …Run Code Online (Sandbox Code Playgroud)