Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[VHDL] Case-When or If-Then? Both can be nested?

Status
Not open for further replies.

mountain

Member level 2
Member level 2
Joined
May 22, 2004
Messages
49
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
649
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;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top