首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >对于6输入1输出逻辑来说,Artix-7 LUT的使用率太高了

对于6输入1输出逻辑来说,Artix-7 LUT的使用率太高了
EN

Stack Overflow用户
提问于 2020-08-04 08:51:49
回答 1查看 256关注 0票数 2

在Artix-7上,一个LUT是6位输入,1位输出.想必,任何函数,我有6位输入,1位输出,我可以实现只用一个LUT。

但是,当我合成下面的代码时,我会得到一份报告,其中说7 LUTs已被使用。我想知道为什么?

我正在使用Vivado 2019.2。

代码语言:javascript
运行
复制
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std_unsigned.all;

entity test is
    port(
        d_in    : in std_logic_vector(5 downto 0);
        d_out   : out std_logic
    );
end entity test;

architecture RTL of test is
    
type t_int_array is array (natural range<>) of integer; 
constant primes : t_int_array(0 to 17) := (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61);
    
begin
    
process(d_in)
begin
    
    d_out <= '0';
    for i in 0 to 17 loop
        if (d_in(5 downto 4) * d_in(3 downto 0) - d_in(0) = primes(i)) then
            d_out <= '1';
        end if;
    end loop;
    
end process;

end architecture RTL;

这是合成的原理图。

当我将代码更改为跳过一个减法时:

代码语言:javascript
运行
复制
if (d_in(5 downto 4) * d_in(3 downto 0) = primes(i)) then
    d_out <= '1';
end if;

并进行合成,得到预期的1 LUT

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-05 13:11:08

Vivado可能真的实现了第一个版本中的一些算法。但这在一定程度上是你的错:你把所有这些描述成简单的算术,而你却想要一个固定的查找表。为什么不计算你的常量查找表,然后按原样使用它呢?以下只是一个未经测试的草案,向您展示这个功能等价的解决方案的示例,但在纯粹的综合观点上有很大的不同:

代码语言:javascript
运行
复制
type lut6to1_t is array(0 to 63) of std_ulogic;
function is_prime_f return lut6to1_t is
  variable l: lut6to1_t := (others => '0');
  variable p: natural range 0 to 63;
begin
  for i in l'range loop
    p := ((i / 16) * (i mod 16) - (i mod 2)) mod 64;
    for j in primes'range loop
      if p = primes(j) then
        l(i) := '1';
      end if;
    end loop;
  end loop;
  return l;
end function is_prime_f;
constant is_prime: lut6to1_t := is_prime_f;

begin

  d_out <= is_prime(d_in);

end architecture rtl;

主要的区别是合成器首先像模拟器一样计算is_prime常数,然后使用它推断硬件。因此,简单的6对1 LUT就足够了,而不是一个非常复杂的基于算术的电路.

请注意,任何其他64x1常量,即使是任意复杂的计算,都会导致合成后相同的资源使用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63243309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档