首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Xilinx分区IP核

如何使用Xilinx分区IP核
EN

Stack Overflow用户
提问于 2016-12-20 11:33:24
回答 1查看 2.2K关注 0票数 1

我正在用VHDL编写代码,将其合成到XilinX FPGA上。我通常使用GHDL来模拟我的测试台。为了除以变量,我需要使用XilinX除法核心,但是我不知道如何做到这一点,因为在XilinX文档中似乎没有示例。我是否必须使用XilinX软件来为除法器生成VHDL组件?还是XilinX隐式地理解除法器意味着使用IP核?如果我的第二句话是真的,我将如何使用GHDL进行模拟,或者我是否需要使用XilinX模拟工具?我真的可以用一个最小的例子来使用XilinX除法器核心来通过变量来实现除法,例如:

代码语言:javascript
复制
library ieee;      
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;

entity DividingExample is
  port (
    clk : in std_logic;
    reset : in std_logic;
    InputSignal : in std_logic_vector(15 downto 0);
    OutputSignal : out std_logic_vector(15 downto 0)
    );
end DividingExample;

architecture behaviour of DividingExample is
-- declarations
  signal numerator : integer;
begin
-- behaviour
  process(clk)
  begin
    if(rising_edge(clk)) then
      if(reset = '1') then
        -- reset values
        numerator <= 1000;  
      else
        -- calculate value to be output
        OutputSignal <= numerator/to_integer(signed(InputSignal))
    end if;
  end if;
end process;
end behaviour;

这个示例代码显然不工作,因为除法( '/‘操作符)不是为整数数据类型定义的。我该怎么做?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-18 10:33:30

最后,我编写了自己的部门代码,这比使用XilinX的IP Core要快得多,实现起来也容易得多。我使用了二进制除法算法详细的这里,并为一个签名的32位除法编写了以下VHDL代码:

代码语言:javascript
复制
  function Divide(N : signed(31 downto 0); D : signed(31 downto 0)) return signed is                                                                                                                    
    variable Q : signed(31 downto 0) := to_signed(0, 32);                                                      
    variable R : signed(31 downto 0) := to_signed(0, 32);                                                      
    variable l : line;                                                                                           
    constant N_Abs : signed(31 downto 0) := abs(N);                                                             
    constant D_Abs : signed(31 downto 0) := abs(D);                                                             
  begin                                                                                                          
    -- behaviour                                                                                                 
    for i in N_Abs'high downto 0 loop                                                                            
      R := shift_left(R, 1);                                                                                     
      R(0) := N_Abs(i);                                                                                          
      if R >= D_Abs then                                                                                         
        R := R - D;                                                                                              
        Q(i) := '1';                                                                                             
      end if;                                                                                                    
    end loop;                                                                                                    

    if ((N < 0 and D > 0) or (N > 0 and D < 0)) then                                                             
      return -Q;                                                                                                 
    else                                                                                                         
      return Q;                                                                                                  
    end if;                                                                                                      
  end function;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41241377

复制
相关文章

相似问题

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