Question

This question has been asked before but still I am unable to fix the problem in my code. What is wrong in my code, which is giving these warnings?

use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.all;

use work.switch_param.all;


entity fault_gen is
port (
  clk           : in  std_logic;
  rst           : in  std_logic;
  buff_free     : in  std_logic;
  i_fault_gen   : in  std_logic_vector(NUM_PORTS -1 downto 0);
  o_sel         : out std_logic_vector(NUM_PORTS -1 downto 0);
  o_valid       : out std_logic;
  o_fault_gen   : out flit_t
  );
end fault_gen;

architecture Behavioral of fault_gen is
type ftgen_state is (idle, compt, final);
signal current_state, next_state : ftgen_state;
signal ft_current, ft_next : flit_t;
signal temp_gen : std_logic_vector(FT_INFO_BITS - 1 downto 0);
signal enable : std_logic;

begin
proc_state: process(clk, rst)
begin 
    if (rst = '1') then
        current_state <= idle;
        ft_current <= (others => '0');
    elsif (clk'event and clk='1') then
        current_state <= next_state;
        ft_current <= ft_next;
    end if;
end process proc_state;


proc_fault: process(current_state, ft_current, i_fault_gen, buff_free)
begin
    temp_gen <= (others => '0');
    o_sel <= (others => '0');
    o_valid <= '0';
    enable <= '0';
    ft_next <= ft_current;

    case current_state is

      when idle     =>
        if (buff_free = '1')  then
            if (i_fault_gen = (i_fault_gen'range => '0')) then
                next_state <= idle;
            else
                next_state <= compt;
            end if;
        else
          next_state <= idle;
        end if;

      when compt    =>
        next_state <= final;
        ftgen_inst: for i in NUM_PORTS -1 downto 0 loop
            if (i_fault_gen(i) = '1')  then
              temp_gen <= std_logic_vector(to_unsigned(i,FT_INFO_BITS));
              o_sel(i) <= '1';
              enable <= '1';
              exit ftgen_inst;
            end if;
        end loop;  -- i

      when final    =>
        next_state <= idle;
        if (enable = '1') then
            ft_next <= FT_INFO & link_fault & temp_gen & switch_ID & reserved_bits;
            o_valid <= '1';
        else
            next_state <= idle;
        end if;

      when others   =>
        next_state <= idle;

    end case;
end process proc_fault;

o_fault_gen <= ft_current;    

end Behavioral;

In this program, the value of signal temp_gen is changing and rest of parameters are constant.

switch parameters are:

package switch_param is
constant NUM_PORTS    : natural       := 5;
constant FLIT_WIDTH   : natural:= 36;
subtype flit_t is std_logic_vector(FLIT_WIDTH - 1 downto 0);
constant FT_INFO : std_logic_vector(3 downto 0) := "0011";
constant link_fault : std_logic_vector(2 downto 0) := "000";
constant reserved_bits : std_logic_vector(17 downto 0) := (others => '0');
constant FT_INFO_BITS : integer := 3;
constant switch_ID : std_logic_vector(7 downto 0)       := "11111111";    -- switch ID

end switch_param;

warnings are:

WARNING:Xst:2404 -  FFs/Latches <ft_current<35:34>> (without init value) have a constant value of 0 in block <fault_gen>.
WARNING:Xst:1710 - FF/Latch <ft_current_31> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_30> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_29> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_17> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_16> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_15> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_14> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_13> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_12> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_11> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_10> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_9> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_8> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_7> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_6> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_5> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_4> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_3> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_2> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_1> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_0> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1710 - FF/Latch <ft_current_18> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_26> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_27> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_28> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1710 - FF/Latch <ft_current_18> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_26> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_27> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_28> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1710 - FF/Latch <ft_current_18> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_26> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_27> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_28> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1710 - FF/Latch <ft_current_18> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_26> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_27> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
WARNING:Xst:1895 - Due to other FF/Latch trimming, FF/Latch <ft_current_28> (without init value) has a constant value of 0 in block <fault_gen>. This FF/Latch will be trimmed during the optimization process.
Was it helpful?

Solution

From you package values I generated this:

    -- Field      Size              Contents         ft_next range   static?
    ------------------------------------------------------------------------
    -- FT_INFO    (3 downto 0)      "0011"            35 downto 32 static
    -- link_fault (2 downto 0)      "000"             31 downto 29 static
    -- temp_gen   (2 downto 0)      "011"             28 downto 26 changeable
    -- switch_ID  (7 downto 0)      "11111111"        25 downto 18 static
    -- reserved_bits (17 downto 0)  (other s=> '0')   17 downto 0  static


       ft_next <= FT_INFO & link_fault & temp_gen & switch_ID & reserved_bits;

There are only three non-static bits assigned to ft_next (temp_gen - possible values "100", "011" ,"010", "001" and "000").

All the rest of the locally static (known at analysis time), meaning they don't need flip flops. You ended up with three.

I'd originally gotten the order of the arguments to TO_UNISIGNED backward, but after getting that straight (and it tells you to verify everything you rely on in an answer) you notice the loop:

  when compt    =>
    next_state <= final;
    ftgen_inst: for i in NUM_PORTS -1 downto 0 loop
        if (i_fault_gen(i) = '1')  then
          temp_gen <= std_logic_vector(to_unsigned(i,FT_INFO_BITS));
          o_sel(i) <= '1';
          enable <= '1';
          exit ftgen_inst;
        end if;
    end loop;  -- i

One of the characteristics of assigning signals in a process statement is that there is only one future value for a signal. It means the last fault_gen(i) with a '1' is the one that actually gets reported, with ascending priority downto 0. You might consider having temp_gen replaced by i_fault_gen should that be unacceptable.

Anyway, the way you have defined ft_next, there are only three flip flops needed, the rest of the bits are all static.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top