-->

VHDL合成 - FF /锁存常数值(VHDL Synthesis - FF/Latch Cons

2019-08-31 11:34发布

我试图合成自己编写的VHDL模块。

代码如下:

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 ClockCounter is
    port(
        clk         : in std_logic;
        input       : in std_logic;
        enable      : in std_logic;
        output      : out std_logic := '0';
        bitReady    : out std_logic := '0';
        countError  : out std_logic := '0'
    );
end ClockCounter;

architecture Behavioral of ClockCounter is

signal totalBitWidth     : integer := 4;
signal majorityValue     : integer := 3;

begin

totalBitWidth <= 4;
majorityValue <= 3;

-- Process for recognizing a single input value from a  clock cycle
-- wide input signal
majority_proc: process(clk, input, enable)

    variable clkCount : integer := 0;
    variable Sum      : integer := 0;

    begin

    if rising_edge(clk) And enable = '1' then
        -- Reset bitReady after one clock cycle
        bitReady <= '0';

        -- Check the input value and add it to the Sum variable
        if input = '1' then
            Sum := Sum + 1;
        else
            Sum := Sum + 0;
        end if;

        -- Increment the clock counter variable
        clkCount := clkCount + 1;

        -- Check if the clock count has reached the specified number of cycles
        if clkCount >= totalBitWidth then
            -- Determine if the Sum variable has met the threshold for
            -- value of 1, set the output accordingly
            if Sum >= majorityValue then
                output <= '1';
            else
                output <= '0';
            end if;

            -- This checks if the value for all clock cycles was the same and
            -- sets an error flag if not
            if Sum = totalBitWidth Or Sum = 0 then
                countError <= '0';
            else
                countError <= '1';
            end if;

            -- Reset the clock counter and sum value
            clkCount := 0;
            Sum := 0;
            -- Set the bit counter high to alert other midules that a new bit
            -- has been received
            bitReady <= '1';
        end if;
        elsif enable = '0' then
        clkCount := 0;
        Sum := 0;
    end if;

    end process;

    end Behavioral;

我得到的问题是这样的尝试合成时:

警告:XST:1293 - FF /锁存器具有0在块的恒定值。 这FF /锁存器将在优化过程中进行修整。 警告:XST:1896 - 由于其它FF /锁存修整,FF /闩锁具有0在块的恒定值。 这FF /锁存器将在优化过程中进行修整。 警告:XST:1896 - 由于其它FF /锁存修整,FF /闩锁具有0在块的恒定值。 这FF /锁存器将在优化过程中进行修整。

修整去一路下跌到。

我不明白的是,clkCount变量是最多增加高达6的整数,然后重置为0。

难道这些警告的东西我可以忽略?

该模块是分开更大的系统的我的工作,当我合成更大的系统我得到了很多的

结果1位锁存器信号

所以,我试图做的是固定的上层模块之前消除低级模块尽可能多的警告越好。

任何帮助将是巨大的。 谢谢

PS - 我使用赛灵思Spartan 6 SP605评估套件板,并在Project Navigator。

Answer 1:

从外观上来看,是在做什么,你打算而是优化。 所述clkCount被声明为一个整数或者32位,但你必须将其重置为0,一旦它击中多数值或3,这相当于“11”或2位。 因此,因此clkCount(31 DOWNTO 2)将得到优化掉,因为它总是0。

我假设总和必须得到优化回落,但综合工具可能没有注意到,它可以得到优化,以及耦合。

我不是硬编码值的大风扇,你可能会扩大这个泛型,使其更加个性化,如果你实例化多个时钟计数器。

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 ClockCounter is
  generic (
    totalBitWidth : integer := 4;
    majorityValue : integer := 3);
  port(
    clk        : in  std_logic;
    input      : in  std_logic;
    enable     : in  std_logic;
    output     : out std_logic := '0';
    bitReady   : out std_logic := '0';
    countError : out std_logic := '0');
end ClockCounter;

architecture Behavioral of ClockCounter is


begin

-- Process for recognizing a single input value from a clock cycle -- wide input     signal 
  majority_proc : process(clk, input, enable)

    variable clkCount : integer := 0;
    variable Sum      : integer := 0;

  begin

    if rising_edge(clk) and enable = '1' then
                                        -- Reset bitReady after one clock cycle
      bitReady <= '0';
                                        -- Check the input value and add it to the Sum     variable
      if input = '1' then
        Sum := Sum + 1;
      else
        Sum := Sum + 0;
      end if;

                                        -- Increment the clock counter variable
      clkCount := clkCount + 1;

                                        -- Check if the clock count has reached the     specified number of cycles
       if clkCount >= totalBitWidth then
                                        -- Determine if the Sum variable has met the threshold for
                                        -- value of 1, set the output accordingly
        if Sum >= majorityValue then
          output <= '1';
        else
          output <= '0';
        end if;

                                        -- This checks if the value for all clock cycles was the same and
                                        -- sets an error flag if not
        if Sum = totalBitWidth or Sum = 0 then
          countError <= '0';
        else
          countError <= '1';
        end if;

                                        -- Reset the clock counter and sum value
        clkCount := 0;
        Sum      := 0;
                                        -- Set the bit counter high to alert other midules that a new bit
                                        -- has been received
        bitReady <= '1';
      end if;
    elsif enable = '0' then
      clkCount := 0;
      Sum      := 0;
    end if;

  end process;

end Behavioral;


Answer 2:

这是更好地设置您的整数的预期范围内; 这样合成将生成它们在第一位置正确的尺寸,而不是32位,然后发射数百“微调”的警告。

variable clkCount : integer range 0 to totalBitWidth := 0;

它可以永远是负面的? 没有? 然后更好的...

variable clkCount : natural range 0 to totalBitWidth := 0;
variable Sum      : natural range 0 to majorityValue := 0;

或使用的类型系统。

例如,如果有之间的关系totalBitWidthmajorityValue ,那么它表达出来,而不是直接让他们独立的:不跟踪,当你改变totalBitWidth得到错误的。 (我在预期的关系如下猜测)

type counttype is new integer range 0 to totalBitWidth;
subtype sumtype is counttype range 0 to totalBitWidth / 2 + 1;

    variable clkCount : counttype := 0;
    variable Sum      : sumtype   := 0;


文章来源: VHDL Synthesis - FF/Latch Constant Value