Currently, pyeda uses the following operators for the following purposes:
Variables and Functions:
-a : unary NOT
a + b : binary OR
a * b : binary AND
p >> q : binary IMPLIES (p => q)
q << p : binary reverse IMPLIES (p => q)
BitVectors:
~A : bitwise NOT
A | B : bitwise OR
A & B : bitwise AND
A ^ B : bitwise XOR
Problems:
No symbolic XOR operator for Boolean variables
Cannot use -+* for arithmetic on Boolean vectors
Cannot use >> and << for shift on Boolean vectors
pyeda so far has an emphasis on Boolean algebra, and not higher-level arithmetic. If you decide to use the + operator for addition between two vectors, there isn't enough information to decide what type of adder (ie RCA, LCA, etc) you want to use. I can envision creating some kind of "black box" object that behaves like a Bitvector, but requires you to define the behavior abstractly. That might be useful for RTL simulation purposes, because you really only care about the correctness of the arithmetic, and not whether it's implemented using Brent-Kung. Doing this will make it obvious that the -+*% symbols can only be used for abstract arithmetic.
Python has only >> and <<, because integers do not have a fixed size, and all shifts are arithmetic. For Bitvectors, if you want to use symbols at all, you really need to differentiate between right shift (rsh) and arithmetic right shift (arsh). So until Python grows an overloadable "right arrow" operator, using them for implication seems reasonable.
The biggest issue by far is the lack of a symbol for binary XOR on functions. Even though you only need NOT/OR/AND for a complete Boolean algebra, XOR is extremely useful. Writing (~a&b|a&~b) is very verbose, and other data structures like DDs should have more convenient ways for XOR. So until Python grows another operator that is sufficient, I am afraid the only reasonable solution is to use ~|*^ for both Boolean Function and VectorFunction types. The only thing you lose is the ability to type a - b as a short-hand for a + -b, since a ~ b is not valid Python.
Another possible use for + and * operators is concatenation and repetition of BitVector types, respectively. This might seem counter-intuitive, but is probably more useful than arithmetic.
Currently,
pyeda
uses the following operators for the following purposes:Variables and Functions:
-a
: unary NOTa + b
: binary ORa * b
: binary ANDp >> q
: binary IMPLIES (p => q)q << p
: binary reverse IMPLIES (p => q)BitVectors:
~A
: bitwise NOTA | B
: bitwise ORA & B
: bitwise ANDA ^ B
: bitwise XORProblems:
-+*
for arithmetic on Boolean vectors>>
and<<
for shift on Boolean vectorspyeda
so far has an emphasis on Boolean algebra, and not higher-level arithmetic. If you decide to use the+
operator for addition between two vectors, there isn't enough information to decide what type of adder (ie RCA, LCA, etc) you want to use. I can envision creating some kind of "black box" object that behaves like a Bitvector, but requires you to define the behavior abstractly. That might be useful for RTL simulation purposes, because you really only care about the correctness of the arithmetic, and not whether it's implemented using Brent-Kung. Doing this will make it obvious that the-+*%
symbols can only be used for abstract arithmetic.Python has only
>>
and<<
, because integers do not have a fixed size, and all shifts are arithmetic. For Bitvectors, if you want to use symbols at all, you really need to differentiate between right shift (rsh) and arithmetic right shift (arsh). So until Python grows an overloadable "right arrow" operator, using them for implication seems reasonable.The biggest issue by far is the lack of a symbol for binary XOR on functions. Even though you only need NOT/OR/AND for a complete Boolean algebra, XOR is extremely useful. Writing (~a&b|a&~b) is very verbose, and other data structures like DDs should have more convenient ways for XOR. So until Python grows another operator that is sufficient, I am afraid the only reasonable solution is to use
~|*^
for both Boolean Function and VectorFunction types. The only thing you lose is the ability to typea - b
as a short-hand fora + -b
, sincea ~ b
is not valid Python.