error "choice must be discrete range" with CASE

M

Manfred Balik

Guest
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
 
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" <manfred.balik@tuwien.ac.at> wrote in message
news:426cd2d2$0$10578$3b214f66@tunews.univie.ac.at...
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
 
On Mon, 25 Apr 2005 13:21:54 +0200, "Manfred Balik"
<manfred.balik@tuwien.ac.at> 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
 
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top