【问题标题】:VHDL Place and route path analysisVHDL 布局布线路径分析
【发布时间】:2015-12-02 16:21:23
【问题描述】:

我的问题是,当我使用 Xilinx ISE 14.7 + XPS 实现我的设计时,我经常在静态时序分析中获得非常不同数量的分析路径,在 .vhd 文件中也几乎没有差异。 特别是,我更改(或我认为更改...)的唯一文件是:

entity my_entity is(
    ...
    data_in : in std_logic_vector(N*B-1 downto 0);
    ...
);
end entity my_entity;

architecture bhv of my_entity is
    signal data : std_logic_vector(B-1 downto 0);
    signal idx_vect : std_logic_vector(log2(N)-1 downto 0);
    signal idx : integer range 0 to N-1;
    ...
begin
    process(clk)
    begin
        if(rising_edge(clk))then
            idx_vect <= idx_vect + 1;
        end if;
    end process;

    idx <= to_integer(unsigned(idx_vect));

    data <= data_in((idx+1)*B-1 downto idx*B);

end architecture bhv;

我不确定问题出在此处,但我没有找到任何其他可能导致分析路径数量减少五倍的原因。为了获得正确的实现,是否有一些必须避免的语法?是否有可能使用整数索引数组(如在示例编解码器中)以某种方式破坏路径,使它们不被分析?

代码更改类似于:

process(shift_reg, data_in)
    for i in range 0 to N-1 loop
        if(shift_reg(i) = '1')then
            data <= data_in((i+1)*B-1 downto i*B);
        end if;
    end loop;
end process;

其中我有一个 N 位的循环单热移位寄存器,而不是递增 idx_vect。 提前致谢。

【问题讨论】:

  • 你在这段代码中实际改变了什么?时序分析器报告每个时序约束的“分析路径数”。你在这里指的是哪一个?只要 XST 没有发出(有害的)警告,代码就会按预期合成。
  • 更改是关于我索引数组的方式,似乎当我不使用整数时(但是,例如,for 循环检查条件,所以没有“直接索引” ),分析路径的数量增加。 XST 不会发出警告。可能问题出在其他地方,但我只想确认语法正确并且没有已知问题...
  • 请编辑您的问题并附加for loop。如果 XST 没有错误地接受该语法,则该语法是正确的。如果模拟显示所需的输出并且 XST 不发出警告,则语义是正确的。你没有回答我的第二个问题。答案对我很重要,可能会解决您的问题。
  • 谢谢@MartinZabel。该约束是由 XPS 生成的派生约束。我的周期约束是指锁定到某个引脚并进入时钟发生器的差分时钟的 P 侧,它传播到一些新的派生约束(这对我来说看起来是正确的,除了其中一个的分析路径的高度可变数量,我几乎所有的设计都用这个)。
  • 如果(由于编码错误,例如省略将结果连接到输出)您的大部分硬件都可以优化掉,那么就没有太多需要分析的东西了。值得检查综合报告以获得比以前更多的“修剪逻辑”报告,或者 LUT/FF 使用量的可疑减少。

标签: vhdl xilinx synthesis


【解决方案1】:

本行多路复用器的编码风格

data <= data_in((idx+1)*B-1 downto idx*B);

会严重影响逻辑综合。这会导致用于时序分析的路径数量非常不同。

原来的多路复用器

我首先使用这个小例子检查了上述行的合成:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity mux1 is
    generic (
        B : positive := 32;
        M : positive := 7); -- M := ceil(log_2 N)
    port (
        d : in  STD_LOGIC_VECTOR ((2**M)*B-1 downto 0); -- input data
        s : in  STD_LOGIC_VECTOR (M-1 downto 0);        -- selector
        y : out  STD_LOGIC_VECTOR(B-1 downto 0));       -- result
end mux1;

architecture Behavioral of mux1 is
    constant N : positive := 2**M;
    signal idx : integer range 0 to N-1;
begin
    idx <= to_integer(unsigned(s));
    y <= d((idx+1)*B-1 downto idx*B);
end Behavioral;

如果有人为 Spartan-6 合成了这个,XST 会报告这个(摘录):

Macro Statistics
# Adders/Subtractors                                   : 2
 13-bit subtractor                                     : 1
 8-bit adder                                           : 1
...
 Number of Slice LUTs:                 1516  out of   5720    26%  
...
Timing constraint: Default path analysis
  Total number of paths / destination ports: 139264 / 32

因此,没有检测到多路复用器,时序分析器必须分析大量路径。 逻辑利用率还可以。

优化实现

可以通过以下方式实现相同的多路复用:(EDIT:错误修复和简化)

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity mux2 is
    generic (
        B : positive := 32;
        M : positive := 7); -- M := ceil(log_2 N)
    port (
        d : in  STD_LOGIC_VECTOR ((2**M)*B-1 downto 0);
        s : in  STD_LOGIC_VECTOR (M-1 downto 0);
        y : out  STD_LOGIC_VECTOR(B-1 downto 0));
end mux2;

-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-- !! The entire architecture has been FIXED and simplified. !!
-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
architecture Behavioral of mux2 is
    constant N : positive := 2**M;
    type matrix is array (N-1 downto 0) of std_logic_vector(B-1 downto 0);
    signal dd : matrix;
begin
    -- reinterpret 1D vector 'd' as 2D matrix, i.e.
    -- row 0 holds d(B-1 downto 0) which is selected in case s = 0
    row_loop: for row in 0 to N-1 generate
        dd(row) <= d((row+1)*B-1 downto row*B);
    end generate;

    -- select the requested row
    y <= dd(to_integer(unsigned(s)));
end Behavioral;

现在,XST 报告看起来好多了:

Macro Statistics
# Multiplexers                                         : 1
 32-bit 128-to-1 multiplexer                           : 1
...
 Number of Slice LUTs:                 1344  out of   5720    23%  
...
Timing constraint: Default path analysis
  Total number of paths / destination ports: 6816 / 32

它检测到每个输出位都需要一个 128 对 1 多路复用器。这种宽多路复用器的优化综合内置于综合工具中。 LUT 的数量仅略有减少。但是,时序分析器要处理的路径数量显着减少了 20 倍!

使用 one-hot 选择器实现

以上示例使用二进制编码的选择器信号。 我还检查了带有 one-hot 编码的变体:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity mux3 is
    generic (
        B : positive := 32;
        N : positive := 128);
    port ( d : in  STD_LOGIC_VECTOR (N*B-1 downto 0);
           s : in  STD_LOGIC_VECTOR (N-1 downto 0);
           y : out  STD_LOGIC_VECTOR(B-1 downto 0));
end mux3;

architecture Behavioral of mux3 is

begin
    process(d, s)
    begin
        y <= (others => '0'); -- avoid latch!
        for i in 0 to N-1 loop
            if s(i) = '1' then
                y <= d((i+1)*B-1 downto i*B);
            end if;
        end loop;
    end process;

end Behavioral;

现在,XST 报告又不一样了:

Macro Statistics
# Multiplexers                                         : 128
 32-bit 2-to-1 multiplexer                             : 128
...
Number of Slice LUTs:                 2070  out of   5720    36%  
...
Timing constraint: Default path analysis
  Total number of paths / destination ports: 13376 / 32

检测到 2 对 1 多路复用器,因为描述了与此方案类似的优先多路复用器:

if s(127) = '1' then
  y <= d(128*B-1 downto 127*B);
else
  if s(126) = '1' then
    y <= d(127*B-1 downto 126*B);
  else
    ...
                             if s(0) = '1' then
                               y <= d(B-1 downto 0);
                             else
                               y <= (others => '0');
                             end if;
  end if; -- s(126)
end if; -- s(127)

出于教学原因,我没有在这里使用elsif。每个if-else 级都是一个 32 位宽的 2 对 1 多路复用器。这里的问题是,合成不知道s 是一个单热编码信号。因此,在我的优化实现中需要更多的逻辑。

用于分析时序变化的路径数量再次显着变化。 这个数字比原始实现低 10 倍,但比我优化的高 2 倍。

【讨论】:

  • 难以置信!非常感谢您的解释!
  • @Alessandro 如果你打算使用我的优化实现,请查看我的错误修复mux2。现在更简单了。对不起。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-17
  • 2015-04-28
  • 2012-03-31
  • 2013-08-14
  • 1970-01-01
相关资源
最近更新 更多