Reputation: 119
I want to do bit by bit xor with same input vector like:
input(0) xor input(2) xor input(3)
up to input(187)
.
The answer I get is like:
output(0) downto output (94)
This means I have to do xor
successively. If I have 10
input bits, the last answer I get is 5
bit output. Its very difficult and not a good approach to write the whole vector.
Does anyone knows how to write a efficient code of this in vhdl?
I have a idea how to do it. First extract even index bits, then odd index bits and do xor
but no luck please help me.
Upvotes: 1
Views: 14473
Reputation: 82026
It sounds like you need either a generate statement or a for loop.
lots_of_xor: for i in 0 to 94 generate
output(i) <= input(2*i + 0) xor input(2*i + 1);
end generate;
for i in 0 to 94 loop
output(i) <= input(2*i + 0) xor input(2*i + 1);
end loop;
In either version, we can replace 94 with output'length
as well.
Upvotes: 2