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.

FPGA CASE When Hex range data syntax

What is the syntax for a range of Hex values e.g. When = X"03" to X"F9"?

  • When = X"03" to X"F9"

    Votes: 0 0.0%
  • or When = X"03 to F9"

    Votes: 0 0.0%

  • Total voters
    0
Status
Not open for further replies.

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
 

I did not understand the question. Specifically how the sentence in English is formulated.
 

Syntax for range of Hex values in the when line of a CASE statement.
e.g. When = X"03" to X"F9" => ....
Thanks
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
 


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;

 

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( )).
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top