error "choice must be discrete range" with CASE

Discussion in 'VHDL' started by Manfred Balik, Apr 25, 2005.

  1. I want to do something, if the signal "address" is in the used address
    range. I don't want to list all of this adresses (128!!!) in the case
    structure.
    Compiling this structure, I'm getting the error "choice must be discrete
    range":

    SIGNAL address : STD_LOGIC_VECTOR(14 downto 0);
    ....
    CASE address IS
    WHEN "000010000000000" TO "000010001111111" =>
    ....

    What is my mistake?
    How can I realize this functionality by an other structure?

    Thanks, Manfred
    Manfred Balik, Apr 25, 2005
    #1
    1. Advertising

  2. Hi Manfred,

    The choices in case statement must be of discrete range , that is
    case expression ( here address) must be either of Enumeration or
    integer type . The other way doing this is given below

    SIGNAL address : STD_LOGIC_VECTOR(14 downto 0);
    process
    variable address_int : integer;
    begin

    address_int := TO_INTEGER(unsigned(address));
    CASE address_int IS
    WHEN 1024 to 1279 =>
    ...........


    Use unsigned and signed types. since address is considered as unsigned
    number hence prefer to declare it as

    SIGNAL address : unsigned(14 downto 0);

    Moreover packages numeric_std has many relavent arithmetic and
    conversion functions.

    -- Mohammed A Khader.
    Mohammed A khader, Apr 25, 2005
    #2
    1. Advertising

  3. Manfred Balik

    Jerry Guest

    To use the range following a when, a scaler type must be used (natural,
    integer). So if you convert the address to an natural type first, then use
    a natural range it should work.

    signal address_natural : natural range 0 to 16535;


    address_natural <= conv_integer(address);

    case address_natural is
    when 1024 to 1151 =>



    "Manfred Balik" <> wrote in message
    news:426cd2d2$0$10578$...
    >I want to do something, if the signal "address" is in the used address
    >range. I don't want to list all of this adresses (128!!!) in the case
    >structure.
    > Compiling this structure, I'm getting the error "choice must be discrete
    > range":
    >
    > SIGNAL address : STD_LOGIC_VECTOR(14 downto 0);
    > ...
    > CASE address IS
    > WHEN "000010000000000" TO "000010001111111" =>
    > ....
    >
    > What is my mistake?
    > How can I realize this functionality by an other structure?
    >
    > Thanks, Manfred
    >
    Jerry, Apr 26, 2005
    #3
  4. On Mon, 25 Apr 2005 13:21:54 +0200, "Manfred Balik"
    <> wrote:

    >I want to do something, if the signal "address" is in the used address
    >range. I don't want to list all of this adresses (128!!!) in the case
    >structure.
    >Compiling this structure, I'm getting the error "choice must be discrete
    >range":
    >
    >SIGNAL address : STD_LOGIC_VECTOR(14 downto 0);
    >...
    >CASE address IS
    > WHEN "000010000000000" TO "000010001111111" =>
    > ....
    >
    >What is my mistake?
    >How can I realize this functionality by an other structure?
    >


    If you have many similar ranges, try something like

    CASE address(13 downto 7) IS
    WHEN "00001000" =>

    If you have different size ranges, you can embed further CASE or IF
    clauses in the arms of this one.

    - Brian
    Brian Drummond, Apr 30, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Franks
    Replies:
    2
    Views:
    1,237
    Steve Franks
    Jun 10, 2004
  2. Tee
    Replies:
    3
    Views:
    7,768
    Herfried K. Wagner [MVP]
    Jun 23, 2004
  3. Janice

    lower case to upper case

    Janice, Dec 10, 2004, in forum: C Programming
    Replies:
    17
    Views:
    1,156
    Richard Bos
    Dec 14, 2004
  4. Replies:
    1
    Views:
    2,457
    Mark P
    Apr 6, 2007
  5. Lakshmi Narayanan.R

    "Case 1 To 5" in Select case, giving Error!!. Why?

    Lakshmi Narayanan.R, Mar 2, 2005, in forum: ASP General
    Replies:
    10
    Views:
    333
    Bob Barrows [MVP]
    Mar 4, 2005
Loading...

Share This Page