Signal assignments - tomas-fryza/vhdl-labs GitHub Wiki
Outside process
The following two assignments can only be written outside a process. Assignment With
-Select
is so called selected signal assignment:
with addr_i select
y_o <= a_i when "000", -- If addr_i = "000" then y_o = a_i
b_i when "001",
c_i when "010",
d_i when others; -- All other combinations
Assignment When
-Else
is called conditional signal assignment:
y_o <= a_i when (addr_i = "000" and en_i = '1') else
b_i when (addr_i = "001" and en_i = '1') else
c_i when (addr_i = "010" and en_i = '1') else
d_i; -- All other combinations
Inside process
The following two assignments can only be written inside a process. Assignment If
-Then
-Else
:
p_label : process (a)
begin
if (a = '0') then
q <= '0';
else
q <= '1';
end if;
end process p_label;
Assignment Case
-When
:
p_label : process (a)
begin
case a is
when '0' =>
q <= '0';
when others =>
q <= '1';
end case;
end process p_label;