W
Weng Tianxiang
Guest
Hi Lewis,
I have a suggestion on VHDL function interface.
Here is a point: ('-' is used to simplify the 'downto')
R(63-0) <= a0*b0(63-0) + a1*b1(63-0) + ... + an*bn(63-0);
To finish the output data bus, I have to add function:
BitAndVector(a, b), then the above equation becomes:
R(63-0) <= BitAndVector(a0, b0) + BitAndVector(a1, b1) + ... +
BitAndVector(an, bn);
If we have a new interface like this:
BitAndVectorThenOR(a, b, ...);
The above function can be called like this:
R(63-0) <= BitAndVectorThenOR(a0, b0, a1, b1, a2, b2);
or
R(63-0) <= BitAndVectorThenOR(a0, b0, a1, b1, a2, b2, a3, b3, a4, b3);
The big advantages are: it makes compiler easier to do the best
optimization about the coding and VHDL programmers are easier to call
routine functions.
The compiler will check if a0, a1, ... are the same type of inputs and
if b0, b1, ... are the same type of inputs as R. There must be even
number of input signals and so on.
Another example:
Function XOR(a0, a1, ...);
The following calls are all valid:
XOR(a0, a1, a2);
XOR(a0, a1, a2, a3, a4, a5);
The compiler will check if a0, a1, ... are the same type of inputs.
Any number of input signals more than 1 are allowed and the function
will do the specified XOR operation and so on.
Here is an example of my code to generate a XOR equation from 32 input
signals:
y_xor(0) <= (x(1) xor x(2) xor x(3) xor x(5) xor x(8) xor x(9)
xor x(11) xor x(14) xor x(17) xor x(18) xor x(19) xor x(21) xor x(24)
xor x(25) xor x(27) xor x(30) xor x(32) xor x(36) xor x(38) xor x(39)
xor x(42) xor x(44) xor x(45) xor x(47) xor x(48) xor x(52) xor x(54)
xor x(55) xor x(58) xor x(60) xor x(61) xor x(63));
If there is a new function interface:
y_xor(0) <= XOR(x(1), x(2), x(3), x(5), x(8), x(9), x(11), x(14),
x(17), x(18), x(19), x(21), x(24), x(25), x(27), x(30), x(32), x(36),
x(38), x(39), x(42), x(44), x(45), x(47), x(48), x(52), x(54), x(55),
x(58), x(60), x(61), x(63));
Any comments are welcome.
Weng
I have a suggestion on VHDL function interface.
Here is a point: ('-' is used to simplify the 'downto')
R(63-0) <= a0*b0(63-0) + a1*b1(63-0) + ... + an*bn(63-0);
To finish the output data bus, I have to add function:
BitAndVector(a, b), then the above equation becomes:
R(63-0) <= BitAndVector(a0, b0) + BitAndVector(a1, b1) + ... +
BitAndVector(an, bn);
If we have a new interface like this:
BitAndVectorThenOR(a, b, ...);
The above function can be called like this:
R(63-0) <= BitAndVectorThenOR(a0, b0, a1, b1, a2, b2);
or
R(63-0) <= BitAndVectorThenOR(a0, b0, a1, b1, a2, b2, a3, b3, a4, b3);
The big advantages are: it makes compiler easier to do the best
optimization about the coding and VHDL programmers are easier to call
routine functions.
The compiler will check if a0, a1, ... are the same type of inputs and
if b0, b1, ... are the same type of inputs as R. There must be even
number of input signals and so on.
Another example:
Function XOR(a0, a1, ...);
The following calls are all valid:
XOR(a0, a1, a2);
XOR(a0, a1, a2, a3, a4, a5);
The compiler will check if a0, a1, ... are the same type of inputs.
Any number of input signals more than 1 are allowed and the function
will do the specified XOR operation and so on.
Here is an example of my code to generate a XOR equation from 32 input
signals:
y_xor(0) <= (x(1) xor x(2) xor x(3) xor x(5) xor x(8) xor x(9)
xor x(11) xor x(14) xor x(17) xor x(18) xor x(19) xor x(21) xor x(24)
xor x(25) xor x(27) xor x(30) xor x(32) xor x(36) xor x(38) xor x(39)
xor x(42) xor x(44) xor x(45) xor x(47) xor x(48) xor x(52) xor x(54)
xor x(55) xor x(58) xor x(60) xor x(61) xor x(63));
If there is a new function interface:
y_xor(0) <= XOR(x(1), x(2), x(3), x(5), x(8), x(9), x(11), x(14),
x(17), x(18), x(19), x(21), x(24), x(25), x(27), x(30), x(32), x(36),
x(38), x(39), x(42), x(44), x(45), x(47), x(48), x(52), x(54), x(55),
x(58), x(60), x(61), x(63));
Any comments are welcome.
Weng