计算 15 位输入中设置位数的电路

发布于 2024-07-27 04:41:30 字数 95 浏览 4 评论 0原文

如何构建一个节省面积的电路,使用 4 输入 LUT(查找表)来计算 15 位输入中设置位的数量。 输出显然是 4 位(计数 0-15)。 有人声称可以使用 9 个 LUT。

How to build an area-efficient circuit that counts the number of set bits in 15-bit input using 4-input LUTs (look-up tables). The output is obviously 4-bit (counts 0-15). Some claim that it's possible to do using 9 LUTs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮倦 2024-08-03 04:41:30

好吧,我会让你开始的。 您的第一层查找表将如下所示:

0 0 0 0 = 00
0 0 0 1 = 01
0 0 1 0 = 01
0 0 1 1 = 10
0 1 0 0 = 01
0 1 0 1 = 10
0 1 1 0 = 10
0 1 1 1 = 11
1 0 0 0 = 01
1 0 0 1 = 10
1 0 1 0 = 10
1 0 1 1 = 11
1 1 0 0 = 10
1 1 0 1 = 11
1 1 1 0 = 11
1 1 1 1 = 00

将其中的四个分布在您的十五位输入上,获取输出并将它们传递给两个新的查找表,如下所示:

0 0 0 0 = 000
0 0 0 1 = 001
0 0 1 0 = 010
0 0 1 1 = 011
0 1 0 0 = 001
0 1 0 1 = 010
0 1 1 0 = 011
0 1 1 1 = 100
1 0 0 0 = 010
1 0 0 1 = 011
1 0 1 0 = 100
1 0 1 1 = 101
1 1 0 0 = 011
1 1 0 1 = 100
1 1 1 0 = 101
1 1 1 1 = 110

...等等。 当然,您必须解决第一层中所有零和所有产生相同输出的问题。

我可能完全错了。

Well, I'll get you started. Your first layer of lookup tables will look like this:

0 0 0 0 = 00
0 0 0 1 = 01
0 0 1 0 = 01
0 0 1 1 = 10
0 1 0 0 = 01
0 1 0 1 = 10
0 1 1 0 = 10
0 1 1 1 = 11
1 0 0 0 = 01
1 0 0 1 = 10
1 0 1 0 = 10
1 0 1 1 = 11
1 1 0 0 = 10
1 1 0 1 = 11
1 1 1 0 = 11
1 1 1 1 = 00

Spread four of them across your fifteen-bit input, take the outputs and pass them through two new lookup tables that look like this:

0 0 0 0 = 000
0 0 0 1 = 001
0 0 1 0 = 010
0 0 1 1 = 011
0 1 0 0 = 001
0 1 0 1 = 010
0 1 1 0 = 011
0 1 1 1 = 100
1 0 0 0 = 010
1 0 0 1 = 011
1 0 1 0 = 100
1 0 1 1 = 101
1 1 0 0 = 011
1 1 0 1 = 100
1 1 1 0 = 101
1 1 1 1 = 110

... and so on. Of course, you're going to have to solve the problem of all zeroes and all ones producing the same output in the first layer.

And I may be totally wrong.

海拔太高太耀眼 2024-08-03 04:41:30

我可以在 10 时间内完成。它是第一个计数器级(4 个表),然后是带进位的 2 级加法器(3 和 3 个表)。

我怀疑有一种方法可以做得更好,因为我没有完全使用每个 LUT,但有时简单的设计值得额外的成本。 我尝试了其他方法,但仍然需要 10。

祝你作业顺利。 (:

I can do it in 10. It’s a first counter stage (4 tables), then a 2 stage adder with carry (3 and 3 tables).

I suspect there is a way to do better because I didn’t use each LUT completely, but sometimes a simple design is worth the extra cost. I tried other approaches and still needed 10.

Good luck on your homework. (:

贩梦商人 2024-08-03 04:41:30

下面是一些计算位数的 C 代码:
C 代码计算“1”位的数量。 您必须将其转换为您的硬件。

Here some C code that counts the number of bits:
C code to count the number of '1' bits. You'll have to convert this into your hardware.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文