EDAboard.com | EDAboard.eu | EDAboard.de | EDAboard.co.uk | RTV forum PL | NewsGroups PL

generic to 0 or 1

elektroda.net NewsGroups Forum Index - VHDL Language - generic to 0 or 1

Goto page Previous  1, 2

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

Goto page Previous  1, 2

elektroda.net NewsGroups Forum Index - VHDL Language - generic to 0 or 1

Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
RTV map EDAboard.com map News map EDAboard.eu map EDAboard.de map EDAboard.co.uk map Opony