我正在尝试合成我写过的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 / Latch有一个常数 块中的值为0。这个FF / Latch将被修剪 在优化过程中。警告:Xst:1896 - 由于其他原因 FF / Latch修整,FF / Latch有一个常数 块中的值为0。这个FF / Latch将被修剪 在优化过程中。警告:Xst:1896 - 由于其他原因 FF / Latch修整,FF / Latch有一个常数 块中的值为0。这个FF / Latch将被修剪 在优化过程中。
修剪一直到下去。
我得不到的是clkCount变量是一个最多增量为6的整数,然后重置为0.
这些警告是否可以忽略?
这个模块是我正在研究的更大系统的一部分,当我合成更大的系统时,我得到了很多
找到信号的1位锁存器
所以我要做的是在修复上层模块之前在较低级别的模块中消除尽可能多的警告。
任何帮助都会很棒。 感谢
PS - 我正在使用Xilinx spartan 6 sp605评估套件板和Project Navigator。
答案 0 :(得分:3)
从它的外观来看,是在做你想要的但是有优化。 clkCount声明为整数或32位,但是一旦它达到多数值或3,它就会重置为0,这相当于“11”或2位。因此clkCount(31 downto 2)将被优化,因为它始终为0。
我认为Sum应该优化下来,但综合工具可能不会注意到它可以优化的耦合。
我不是硬编码值的忠实粉丝,如果您实例化多个时钟计数器,您可以使用泛型扩展它以使其更具可定制性。
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;
答案 1 :(得分:3)
最好设置整数的预期范围;这样合成将首先生成正确的大小,而不是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;
或使用类型系统。
例如,如果totalBitWidth
和majorityValue
之间存在关系,则直接表达它而不是使它们独立:更改跟踪并在更改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;