Vhdl Artix-7 LUT使用量对于6输入1输出逻辑来说过高

Vhdl Artix-7 LUT使用量对于6输入1输出逻辑来说过高,vhdl,fpga,xilinx,Vhdl,Fpga,Xilinx,在Artix-7上,一个LUT是6位输入,1位输出。据推测,我拥有的任何6位输入、1位输出的函数都可以通过使用一个LUT来实现 然而,当我综合下面的代码时,我得到一个报告说已经使用了7个LUT。我想知道为什么 我正在使用Vivado 2019.2 library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.numeric_std_unsigned.all; entity test is po

在Artix-7上,一个LUT是6位输入,1位输出。据推测,我拥有的任何6位输入、1位输出的函数都可以通过使用一个LUT来实现

然而,当我综合下面的代码时,我得到一个报告说已经使用了7个LUT。我想知道为什么

我正在使用Vivado 2019.2

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;
ieee库;
使用ieee.std_logic_1164.all;
使用ieee.numeric_std.all;
使用ieee.numeric\u std\u unsigned.all;
实体测试是
港口(
d_in:标准逻辑向量(5到0);
d_out:输出标准逻辑
);
终端实体测试;
测试的体系结构RTL是
类型t_int_数组是整数的数组(自然范围);
常量素数:t_int_数组(0到17):=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61);
开始
过程(d_in)
开始

d_outVivado可能真的实现了您的第一个版本中的一些算法。但这在一定程度上是你的错:你把这一切描述为简单的算术,而你想要一个恒定的查找表。为什么不计算常量查找表,然后按原样使用呢?以下只是一个未经测试的草案,向您展示了此功能等效解决方案的一个示例,但从纯合成的角度来看,它有着显著的不同:

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;
类型lut6to1是标准逻辑的数组(0到63);
函数为返回lut6to1的素数
变量l:lut6to1_t:=(其他=>“0”);
变量p:自然范围0至63;
开始
对于l'range循环中的i
p:=((i/16)*(i mod 16)-(i mod 2))mod 64;
对于素数范围循环中的j
如果p=素数(j),那么
l(i):=“1”;
如果结束;
端环;
端环;
返回l;
端函数为素数;
常数是素数:lut6to1\u t:=是素数;
开始
出去
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;