courteous
Junior Member level 1
Hello!
How would you write 3/8 demux with the WITH signal SELECT statement?
I've already done it with a CASE signal IS statement, like so (any tips for improving the code welcomed:wink:
Now, how about WITH signal SELECT statement? This is, of course, wrong:
How would you write 3/8 demux with the WITH signal SELECT statement?
I've already done it with a CASE signal IS statement, like so (any tips for improving the code welcomed:wink:
Code:
-- [COLOR="blue"]"4"[/COLOR] as the 4th way of writing the [I]3/8 demux[/I] (1st and 2nd are IF versions)
entity demux[COLOR="blue"][B]4[/B][/COLOR]_3v8 is
Port ( a_i : in STD_LOGIC_VECTOR (2 downto 0); -- address signal
y1_o : out STD_LOGIC;
y2_o : out STD_LOGIC;
y3_o : out STD_LOGIC;
y4_o : out STD_LOGIC;
y5_o : out STD_LOGIC;
y6_o : out STD_LOGIC;
y7_o : out STD_LOGIC;
y8_o : out STD_LOGIC);
end demux4_3v8;
architecture Behavioral of demux4_3v8 is
begin
DEMUX: process(a_i)
begin
case a_i is
when "000" =>
y1_o <= '1';
when "001" =>
y2_o <= '1';
when "010" =>
y3_o <= '1';
when "011" =>
y4_o <= '1';
when "100" =>
y5_o <= '1';
when "101" =>
y6_o <= '1';
when "110" =>
y7_o <= '1';
when others =>
y8_o <= '1';
end case;
end process;
end Behavioral;
Now, how about WITH signal SELECT statement? This is, of course, wrong:
Code:
entity demux[COLOR="blue"][B]3[/B][/COLOR]_3v8 is
Port ( a_i : in STD_LOGIC_VECTOR (2 downto 0); -- address signal
y1_o : out STD_LOGIC;
y2_o : out STD_LOGIC;
y3_o : out STD_LOGIC;
y4_o : out STD_LOGIC;
y5_o : out STD_LOGIC;
y6_o : out STD_LOGIC;
y7_o : out STD_LOGIC;
y8_o : out STD_LOGIC);
end demux3_3v8;
architecture Behavioral of demux3_3v8 is
begin
with a_i select
y1_o <= '1' when "000",
y2_o <= '1' when "001",
y3_o <= '1' when "001",
-- etc.
end Behavioral;