Brad Smallridge
Guest
Wed Feb 24, 2010 10:34 pm
Quote:
OK, what I'm hearing is that I need a function
to make the conversion.
I do need a natural because I use it
as an argument in various arrays. I believe,
that a boolean wouldn't work as an argument
for an array.
Why not? Not if you're trying to index into
a std_logic_vector, of course, but if you can
make a custom array type then it's perfectly
OK for the subscript to be a boolean. Suppose,
for example, you wanted to have an array of
two integers indexed by boolean.
type my_array_type is
array (boolean) of integer;
signal chooser: my_array_type;
signal result: integer;
...
chooser(TRUE) <= 55;
chooser(FALSE) <= 100;
...
result <= chooser(A >= B);
-- result=55 if A>=B, result=100 if not.
Any boolean expression will do as the subscript.
Nice, or what?
--
Jonathan Bromley
Hmm. Indexing arrays with enums seems odd to me,
but I do find it in my reference books. So I could
redefine my arrays as array(boolean) and write
chooser(sim>0)? That's pretty clean.
Brad Smallridge