Aug 30, 2022 #1 R ralphLunt Newbie Joined Aug 29, 2022 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 18 Syntax for range of Hex values in the when line of a CASE statement. e.g. When = X"03" to X"F9" => .... Thanks
Syntax for range of Hex values in the when line of a CASE statement. e.g. When = X"03" to X"F9" => .... Thanks
Aug 30, 2022 #2 dpaul Advanced Member level 5 Joined Jan 16, 2008 Messages 1,802 Helped 317 Reputation 635 Reaction score 343 Trophy points 1,373 Location Germany Activity points 13,096 I did not understand the question. Specifically how the sentence in English is formulated.
Aug 30, 2022 #3 R ralphLunt Newbie Joined Aug 29, 2022 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 Activity points 18 ralphLunt said: Syntax for range of Hex values in the when line of a CASE statement. e.g. When = X"03" to X"F9" => .... Thanks Click to expand... This is the code I'm evaluating for syntax Case Sel is When = X"03" to X"F9 => code to execute When others ..... What is the correct syntax for the line above X"03" to X"F" , or X("03 to F9", or another format
ralphLunt said: Syntax for range of Hex values in the when line of a CASE statement. e.g. When = X"03" to X"F9" => .... Thanks Click to expand... This is the code I'm evaluating for syntax Case Sel is When = X"03" to X"F9 => code to execute When others ..... What is the correct syntax for the line above X"03" to X"F" , or X("03 to F9", or another format
Sep 3, 2022 #4 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,822 Reputation 3,654 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,207 Code VHDL - [expand]1 2 3 case sel is when X"03" | X"04" | X"05" | X"06" | X"07" | X"08" | X"09" | X"0A" ......etc when others ..... If you have such a huge range of values you are testing against it is probably better if you use an if statement Code VHDL - [expand]1 2 3 if sel >= X"03" and sel <= X"F9" then .... end if;
Code VHDL - [expand]1 2 3 case sel is when X"03" | X"04" | X"05" | X"06" | X"07" | X"08" | X"09" | X"0A" ......etc when others ..... If you have such a huge range of values you are testing against it is probably better if you use an if statement Code VHDL - [expand]1 2 3 if sel >= X"03" and sel <= X"F9" then .... end if;
Sep 3, 2022 #5 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,455 Helped 14,754 Reputation 29,790 Reaction score 14,112 Trophy points 1,393 Location Bochum, Germany Activity points 298,244 You didn't mention the type of sel. The case statement can use discrete ranges with "to" in the choice, but only for integer case expressions. If sel is e.g. an unsigned type, you can write Code: case to_integer(sel) is when 16#03# to 16#f9# => when others => end case; Similarly, you can cast std_logic_vector case expressions to_integer(unsigned( )).
You didn't mention the type of sel. The case statement can use discrete ranges with "to" in the choice, but only for integer case expressions. If sel is e.g. an unsigned type, you can write Code: case to_integer(sel) is when 16#03# to 16#f9# => when others => end case; Similarly, you can cast std_logic_vector case expressions to_integer(unsigned( )).