当尝试用除法器合成行为VHDL代码时,需要无限长的时间
我有一个很难解决的问题: 我正在尝试合成VHDL行为代码,如本问题末尾所示 当我用电话线的时候 m1Low:=m1Low/m0Low 电路正在合成并产生正确的结果。但是,这是针对给定输入的,在代码中固定为常量。当输入信号来自电路外部时,特别是输入hist,它是一个std_逻辑_向量数组,它不再合成。我必须用除法函数替换/: m1Low:=to_integerdivideto_unsignedm1Low,32;to_unsignedm0Low,32 电路需要大量的时间进行合成。我把它放了一夜,它没有完成合成 你建议我做什么 多谢各位 哈里斯 试验台如下所示:当尝试用除法器合成行为VHDL代码时,需要无限长的时间,vhdl,Vhdl,我有一个很难解决的问题: 我正在尝试合成VHDL行为代码,如本问题末尾所示 当我用电话线的时候 m1Low:=m1Low/m0Low 电路正在合成并产生正确的结果。但是,这是针对给定输入的,在代码中固定为常量。当输入信号来自电路外部时,特别是输入hist,它是一个std_逻辑_向量数组,它不再合成。我必须用除法函数替换/: m1Low:=to_integerdivideto_unsignedm1Low,32;to_unsignedm0Low,32 电路需要大量的时间进行合成。我把它放了一夜,它没
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use ieee.std_logic_arith.ALL;
use IEEE.std_logic_unsigned.ALL;
use IEEE.NUMERIC_STD.ALL;
package declarations is
--generic ( NHIST : integer := 6 );
type vector_array is array (23 downto 0) of std_logic_vector(7 downto 0);
function divide (a : UNSIGNED; b : UNSIGNED) return UNSIGNED;
end package declarations;
package body declarations is
function divide (a : UNSIGNED; b : UNSIGNED) return UNSIGNED is
variable a1 : unsigned(a'length-1 downto 0):=a;
variable b1 : unsigned(b'length-1 downto 0):=b;
variable p1 : unsigned(b'length downto 0):= (others => '0');
variable i : integer:=0;
begin
for i in 0 to b'length-1 loop
p1(b'length-1 downto 1) := p1(b'length-2 downto 0);
p1(0) := a1(a'length-1);
a1(a'length-1 downto 1) := a1(a'length-2 downto 0);
p1 := p1-b1;
if(p1(b'length-1) ='1') then
a1(0) :='0';
p1 := p1+b1;
else
a1(0) :='1';
end if;
end loop;
return a1;
end divide;
end package body;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY testbench1 IS
END testbench1;
ARCHITECTURE behavior OF testbench1 IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT behavioral_code
port ( clk : in std_logic;
en : in std_logic;
hist : in vector_array;
--debug1 : out std_logic_vector ( 31 downto 0);
--debug10 : out std_logic_vector ( 31 downto 0);
--debug11 : out std_logic_vector ( 31 downto 0);
--debug2 : out std_logic_vector ( 31 downto 0);
--debug3 : out std_logic_vector ( 31 downto 0);
--debug4 : out std_logic_vector ( 31 downto 0);
--debug5 : out std_logic_vector ( 31 downto 0);
--debug6 : out std_logic_vector ( 31 downto 0);
--debug7 : out std_logic_vector ( 31 downto 0);
--debug8 : out std_logic_vector ( 31 downto 0);
--debug50 : out std_logic_vector ( 31 downto 0);
-- debug60 : out std_logic_vector ( 31 downto 0);
thres : out std_logic_vector ( 31 downto 0) );
end component;
--Inputs
signal en : std_logic := '0';
signal hist : vector_array := (others => '0');
signal clk: std_logic := '0';
--Outputs
signal thres : std_logic_vector(31 downto 0);
--signal debug1 : std_logic_vector(31 downto 0);
--signal debug10 : std_logic_vector(31 downto 0);
--signal debug11 : std_logic_vector(31 downto 0);
--signal debug2 : std_logic_vector ( 31 downto 0);
-- signal debug3 : std_logic_vector ( 31 downto 0);
--signal debug4 : std_logic_vector ( 31 downto 0);
--signal debug5 : std_logic_vector ( 31 downto 0);
--signal debug6 : std_logic_vector ( 31 downto 0);
-- signal debug7 : std_logic_vector ( 31 downto 0);
--signal debug8 : std_logic_vector ( 31 downto 0);
--signal debug50 : std_logic_vector ( 31 downto 0);
--signal debug60 : std_logic_vector ( 31 downto 0);
-- No clks detected in port list. Replace <clk> below with
-- appropriate port name
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: behavioral_code PORT MAP (
en => en,
clk => clk,
-- debug1 => debug1,
-- debug10 => debug10,
-- debug11 => debug11,
-- debug2 => debug2,
--debug3 => debug3,
--debug4 => debug4,
--debug5 => debug5,
--debug6 => debug6,
--debug7 => debug7,
--debug8 => debug8,
--debug50 => debug50,
--debug60 => debug60,
hist => hist,
thres => thres
);
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 10 ns;
en<='1';
--wait for <clk>_period*10;
-- insert stimulus here
wait;
end process;
END;
请注意,合成将从代码中生成硬件。代码看起来似乎只是软件编程,而不是用于合成- e、 g.VHDL for循环在块内多次生成代码。因此,您的代码会产生非常大的设计。考虑以更连续的方式重新编写代码。使用 如果上升,那么 在使用FF阶段的过程中
顺便说一句:如果你用常量测试它,你的合成器工具很可能为你做了除法,并且只是实现了结果;这就是为什么它使用常量 根据Baldy回答中的建议,提供缺失的时钟边缘语句,并猜测缺失包的内容,我发现您忽略了提供除法函数 那么,恢复固有的划分,让我们看看综合报告:
=========================================================================
Advanced HDL Synthesis Report
Macro Statistics
# Multipliers : 2072
31x2-bit multiplier : 1
31x3-bit multiplier : 3
31x4-bit multiplier : 7
31x5-bit multiplier : 15
32x32-bit multiplier : 1986
33x32-bit multiplier : 60
# Adders/Subtractors : 4349
32-bit adder : 1373
32-bit adder carry in : 1984
32-bit subtractor : 992
# Adder Trees : 88
32-bit / 10-inputs adder tree : 1
...
32-bit / 7-inputs adder tree : 1
32-bit / 8-inputs adder tree : 1
32-bit / 9-inputs adder tree : 1
# Registers : 96
Flip-Flops : 96
# Comparators : 2077
32-bit comparator greater : 31
32-bit comparator lessequal : 62
...
64-bit comparator lessequal : 62
# Multiplexers : 61721
1-bit 2-to-1 multiplexer : 61536
32-bit 2-to-1 multiplexer : 185
=========================================================================
然后,尝试优化需要相当长的时间。但实际上,合成已经走得够远,足以告诉你你需要知道的:这确实是一个非常大的设计;远远超过了任务的要求
我只能同意他的建议,即必须跨多个时钟周期重新组织计算,直到其大小可以接受为止。然后,合成时间也将减少到可接受的限度
还有。。。所有的逻辑只有96个触发器?这是一个非常不平衡的设计,可能会像糖蜜一样慢。管道寄存器——很多——需要达到可接受的性能。什么芯片?什么编译器/合成器工具?列表中最后一个是Virtex 5。Xilinxe ise 11.1版升级这些工具可能会有所帮助,因为合成器已经变得更好了。但你要求的是逻辑,所以你可能会挣扎。如果你已经有了C,看看XilinxC-to-gates工具。这个工具是免费的吗?它附带Xilinx ISE?我不认为它是Webpack的一部分,不。在创建高端设计时,FPGA仍然需要昂贵的软件。在代码生成器旁使用除法器怎么样?我认为xilinx ise不支持if rising_Edgeck inside for loops。唯一支持这一点的工具是synplify。rising_edge语句将在流程的最开始实现:processclk。。。开始如果上升的话。。。;这样,流程中的代码可以用FFs实现。尝试将算法分为几个步骤和几个时钟周期。这就是我所说的更有顺序的方式。。。不是所有的环路->大设计的并行逻辑,而是按顺序的步骤进行小设计如果使用ip核心生成器中的xilinx ise除法器,您会看到它需要几个时钟周期,直到计算出结果。循环数与向量大小相关,并由工具报告。我的代码来自一个进行颜色二值化的c代码。关键是要尝试在VHDL中快速完成一些在c中缓慢完成的事情。如果你观察,几乎所有的代码都在一个大的for循环中。因此,在和平时期不可能破译密码。此外,除了beggining之外,不可能在代码中的任何位置放置ifu_edgeck。放置时钟的唯一方法是使用synplify在for循环中放置wait-until-clk'event和clk='1'语句。但那永远合成。我真的很沮丧!我写vhdl已经4年了,但我从来没有见过这样的东西!非常感谢你的想法。我很快就会回来发表评论
=========================================================================
Advanced HDL Synthesis Report
Macro Statistics
# Multipliers : 2072
31x2-bit multiplier : 1
31x3-bit multiplier : 3
31x4-bit multiplier : 7
31x5-bit multiplier : 15
32x32-bit multiplier : 1986
33x32-bit multiplier : 60
# Adders/Subtractors : 4349
32-bit adder : 1373
32-bit adder carry in : 1984
32-bit subtractor : 992
# Adder Trees : 88
32-bit / 10-inputs adder tree : 1
...
32-bit / 7-inputs adder tree : 1
32-bit / 8-inputs adder tree : 1
32-bit / 9-inputs adder tree : 1
# Registers : 96
Flip-Flops : 96
# Comparators : 2077
32-bit comparator greater : 31
32-bit comparator lessequal : 62
...
64-bit comparator lessequal : 62
# Multiplexers : 61721
1-bit 2-to-1 multiplexer : 61536
32-bit 2-to-1 multiplexer : 185
=========================================================================