在 vhdl 中具有相同输入向量的位到位异或 [英] bit to bit xor with same input vector in vhdl

查看:39
本文介绍了在 vhdl 中具有相同输入向量的位到位异或的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对相同的输入向量进行一点一点的异或,例如:

I want to do bit by bit xor with same input vector like:

input(0) xor input(2) xor input(3) 直到 input(187).

我得到的答案是:

输出(0)到输出(94)

这意味着我必须连续执行 xor.如果我有 10 位输入,我得到的最后一个答案是 5 位输出.编写整个向量非常困难,也不是一个好方法.

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.

有谁知道如何在 vhdl 中编写有效的代码?

Does anyone knows how to write a efficient code of this in vhdl?

我有一个想法.首先提取偶数索引位,然后是奇数索引位并执行 xor 但没有运气请帮助我.

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.

推荐答案

听起来你需要一个 生成语句for 循环一>.

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;

注意事项

在任一版本中,我们都可以将 94 替换为 output'length.

这篇关于在 vhdl 中具有相同输入向量的位到位异或的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆