The \"when/else\" conditional signal assignment offers an alternative to the IF
ID: 2265879 • Letter: T
Question
The "when/else" conditional signal assignment offers an alternative to the IF statement. Unlike IF, when/else does not go in a process, so it is quicker to write. Being outside the process it must be kept simple (no nesting for example). The code below makes Z = "101" when ADDR = "O1" or "10", Z = "111" when ADDR = "11" and Z = "000" for all other ADDR values (ADDR "00").Rewrite the VHDL code replacing the "when/else" with a IF statement. Just like IF, the "when/else" can be handle more complicated expressions than the CASE or "with/select" 3) library IEEE use IEEE.STD LOGIC 1164 ALL entity hw12 p3 is Port (signal ADDR: in STD LOGIC VECTOR(1 DOWNTO 0) signal Z :out STD LOGIC VECTOR(2 DOWNTO O)) end hw12 p3 architecture behavioral of hw12_p3 is begin outside all processes ZExplanation / Answer
CODE:
library IEEE;
entity hw12_p3 is
Port( signal ADDR: in STD_LOGIC_VECTOR(1 DOWNTO 0);
signal Z : out STD_LOGIC_VECTOR(2 DOWNTO 0);
end hw12_p3;
architecture behavioral of hw12_p3 is
process(ADDR)
begin
if ( ADDR = "01") or (ADDR = "10") then
Z<= "101";
elsif( ADDR = "11") then
Z<= "111";
else
Z<= "000";
end if;
end process;
end behavioral;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.