1

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.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
hassan anwar
  • 119
  • 1
  • 2
  • 11
  • 2
    Can you give some sample data and expected outputs? I'm not sure why `input(1)` is skipped in your example and yet inputs 0,2 and 3 are involved together. And why the result is 95 outputs. Maybe simplify the example and (again) give inputs and expected outputs. – Damien_The_Unbeliever Aug 18 '14 at 17:05
  • I guess he means parallel 2-input XOR gates for a long vector input – Garp Aug 18 '14 at 17:09
  • @Damien_The_Unbeliever: I imagine that `input(1)` being skipped is a typo. – Bill Lynch Aug 18 '14 at 17:13
  • 2
    @sharth - if it's what Garp's suggesting, there are so many fencepost errors *and* typographical errors that if you can devine the original intent, go into fortune telling. – Damien_The_Unbeliever Aug 18 '14 at 17:15
  • Having re-read the question a few more times (it really does need work) - are you trying to compute *parity*? – Damien_The_Unbeliever Aug 18 '14 at 17:54
  • See [this previous question](http://stackoverflow.com/questions/20296276/and-all-elements-of-an-n-bit-array-in-vhdl)? – fru1tbat Aug 18 '14 at 18:32
  • first i want to extract the values that are on odd index than those that are on even index so if i have std_logic_vector(9 downto 0) it means i have 10 indexes first i want to extract 5 even index values than 5 odd index values than do xor. – hassan anwar Aug 19 '14 at 15:00
  • @hassananwar: You're going to need to do what Damien asked 21 hours ago. It's difficult to understand exactly what you are asking for, and a great way to help us understand is to use __examples__. – Bill Lynch Aug 19 '14 at 15:02

1 Answers1

2

It sounds like you need either a generate statement or a for loop.

Concurrent Statement

lots_of_xor: for i in 0 to 94 generate
    output(i) <= input(2*i + 0) xor input(2*i + 1);
end generate;

Sequential Statement

for i in 0 to 94 loop
    output(i) <= input(2*i + 0) xor input(2*i + 1);
end loop;

Notes

In either version, we can replace 94 with output'length as well.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
  • first i want to extract the values that are on odd index than those that are on even index so if i have std_logic_vector(9 downto 0) it means i have 10 indexes first i want to extract 5 even index values than 5 odd index values than do xor. – hassan anwar Aug 19 '14 at 15:00