I'm guessing here, but this looks like the Verilog/VHDL logic
states which you can comfortably encode into a unsigned
char. Why are you using a -1 value, this is a bad choice since
you can do some very nice bit-wise operations to compute logical
expressions of these values which takes into account the "solid"
0,1 values and the undefined/unknown values U & X.
VHDL adopts the rule that the "Leftmost" value is the default (unassigned)
value for a enumeration type, so if you made U = 0, this would be convenient
to implement in C++, (especially with arrays of these babies)
Here's what I'd suggest, so that is in "Binary" you enum type would take
these values.
"U" = 00
"X" = 01
"0" = 00
"1" = 10
As you can see, this makes the logical evaluation of expressions of signals
relatively
easy, you can evaluate the expression using the "known" values ( its a bit
too much
to go into here, but you probably should evaluate the "unknown" part first
to see if
its worth evaluating the "known" part ).
Also in VHDL, an "U" value trumps other values when combined in expressions
( which means you have to do two pairs of bit wise ops on the two sets of
bit positions).
dave
<ma******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
i'd like to store values of a signal into a variable called signal.
signal can take 0, 1, -1, U (where u = undefined, -1 = uninitialized)
is there a way i can store this without making the signal a string or
an int (in which case, i have to change the U to another number)
right now i am going with string, but i was wondering what you pros do
in such cases.
by the way, i am going to use these values to do some basic and/or/xor
type operations. (if i use string, i have to keep converting that stuff
before i do anything)
thanks.