vhdl nested case
In my project, there is a nested selection. The outer selection adopts "Case Sel Is...". The inner selection accords to "Status(1 Dowto 0)" to make decision. Here, firstly I used "Case Status(1 Downto 0) Is...When...", but it did not work in simulation! But when I switch to "If Status(1 Downto 0) Then...ElsIf...", it worked!
Codes is below.
Can the "Case-When" not be nested?
Thank you!
Process(Sel, Status, RD, A, B)
Begin
If RD = '0' Then --Read form Ports to D
Case Sel Is
When "0000" => --Read From A to D If permit, or from Ain if not
If Status(3) = '1' Then
Dout <= Ain;
Else
Dout <= Aout;
End If;
When "0001" => --Read From B to D If permit, or from Bin if not
If Status(2) = '1' Then
Dout <= Bin;
Else
Dout <= Bout;
End If;
When "0010" => --Read From C to D If permit, or from Bin if not
-- Case Status(1 Downto 0) Is --Case When
-- When "11" =>
If Status(1 Downto 0) = "11" Then -- If Then
Dout(7 Downto 4) <= Cinup;
Dout(3 Downto 0) <= Cindn;
-- When "10" =>
ElsIf Status(1 Downto 0) = "10" Then
Dout(7 Downto 4) <= Cinup;
Dout(3 Downto 0) <= Coutdn;
-- When "01" =>
ElsIf Status(1 Downto 0) = "01" Then
Dout(7 Downto 4) <= Coutup;
Dout(3 Downto 0) <= Cindn;
-- When "00" =>
ElsIf Status(1 Downto 0) = "00" Then
Dout(7 Downto 4) <= Coutup;
Dout(3 Downto 0) <= Coutdn;
-- When Others =>
-- Null;
-- End Case;
End if;
When "0100" => --Read From Eout to D
Dout <= Eout;
When "0101" => --Read From Fout to D
Dout <= Fout;
When "0011" => --Read From G to D If permit
Dout(3 Downto 0) <= Gin;
When Others =>
Null;
End Case;
End If;
End Process;