On Jun 24, 11:54*am, Alan Fitch <a...@invalid.invalid> wrote:
> On 24/06/11 17:24, Colin Beighley wrote:
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > I'd like to declare a type like this
>
> > type mytype is (-1,1);
>
> > However, it appears that enumerated types aren't allowed to be
> > integers.
>
> > Is there a way to create an integer subtype where the values of the
> > type are constrained to certain hand-picked values, rather than a
> > range? The workaround for this is to use std_logic and convert it to
> > signed when you need to, but it seems an integer subtype would work
> > better.
>
> > Colin
>
> Enumerated types can be a mixture of character literals and identifiers.
>
> What you probably want is an integer subtype, e.g.
>
> subtype mytype is integer range -1 to 1;
>
> Because this is a subtype of integer, it can be assigned to and from
> integers and other integer subtypes.
>
> regards
> Alan
>
> --
> Alan Fitch
My problem is that I want this type to only be able to assume the
values of -1 and 1, not 0. However, I suppose the declaration of a new
type for this is inconvenient because if I want to do any math with
the type I have to convert to a new integer type if the result assumes
a value that is not (-1,1)?
|