首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VHDL合成- FF/Latch常量

VHDL合成- FF/Latch常量
EN

Stack Overflow用户
提问于 2013-04-18 15:38:13
回答 2查看 2.6K关注 0票数 0

我试图合成一个vhdl模块,我已经写好了。

守则如下:

代码语言:javascript
复制
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/Latch在块中的恒定值为0。此FF/Latch将在优化过程中被裁剪。警告:Xst:1896年-由于其他FF/舱口修整,FF/Latch在块中的恒定值为0。此FF/Latch将在优化过程中被裁剪。警告:Xst:1896年-由于其他FF/舱口修整,FF/Latch在块中的恒定值为0。此FF/Latch将在优化过程中被裁剪。

修剪一直到最后。

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

这些警告是我可以忽略的吗?

这个模块是我正在研究的一个更大的系统的一部分,当我合成更大的系统时,我得到了很多

为信号找到1位锁存器

因此,我试图做的是消除尽可能多的警告,在较低级别模块之前,修复上层模块。

任何帮助都会很好。谢谢

PS -我正在使用Xilinx 6 sp605评估工具包板和项目导航器.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-04-18 16:12:17

从外观上看,这是在做您想做的事情,但需要进行优化。clkCount被声明为整数或32位,但是一旦它命中多数值或3,即等于"11“或2位,则将其重置为0。因此,clkCount(31下降到2)将被优化,因为它总是0。

我假设Sum应该向下优化,但是合成工具可能没有注意到它也可以得到优化的耦合。

我不太喜欢硬编码值,如果您实例化多个时钟计数器,您可能可以用泛型来扩展它,使其更可定制。

代码语言:javascript
复制
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;
票数 3
EN

Stack Overflow用户

发布于 2013-04-18 17:17:02

最好设置整数的预期范围;这样,合成将首先生成正确的大小,而不是32位,然后发出数百个“修整”警告。

任一种

代码语言:javascript
复制
variable clkCount : integer range 0 to totalBitWidth := 0;

会不会是负面的?不是吗?那么更好..。

代码语言:javascript
复制
variable clkCount : natural range 0 to totalBitWidth := 0;
variable Sum      : natural range 0 to majorityValue := 0;

或者使用类型系统。

例如,如果totalBitWidthmajorityValue之间存在某种关系,那么就直接表达它,而不是让它们独立:当您更改totalBitWidth时,很少跟踪和出错。(我猜在下面的关系中)

代码语言:javascript
复制
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;
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16087307

复制
相关文章

相似问题

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