ireon
Junior Member level 2
- Joined
- Mar 28, 2013
- Messages
- 21
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Activity points
- 1,455
VHDL warnings using loop with signal
I have a problem with VHDL language about the use of loop instruction with signals. If I write the following code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter_bit_1 is
port(a: in std_logic_vector(3 downto 0);
y: out std_logic_vector(2 downto 0));
end counter_bit_1;
architecture Behavioral of counter_bit_1 is
begin
process(a)
variable p: integer;
begin
p:=0;
for i in 3 downto 0 loop
if (a(i)='1') then p:=p+1;
end if;
end loop;
if p=0
then y<="000";
elsif p=1
then y<="001";
elsif p=2
then y<="010";
elsif p=3
then y<="011";
else y<="100";
end if;
end process;
end Behavioral;
It works perfectly and there aren't errors or warning.
While if I use the following code with a signal instead of a variable:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter_bit_1 is
port(a: in std_logic_vector(3 downto 0);
y: out std_logic_vector(2 downto 0));
end counter_bit_1;
architecture Behavioral of counter_bit_1 is
signal p: std_logic_vector(2 downto 0);
begin
process(a)
begin
p<=(others=>'0');
for i in 3 downto 0 loop
if a(i)='1' then p<=p+"001";
end if;
end loop;
end process;
y<=p;
end Behavioral;
It doesn't work. The block should count the number of 1 bit in input. I get the following warnings:
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: Madd_p_share0000_lut<2>, p_share0000<2>.
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: p_share0000<1>, Madd_p_share0000_lut<1>.
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: Madd_p_share0000_cy<0>.
How can I implement the block using a signal?
I have a problem with VHDL language about the use of loop instruction with signals. If I write the following code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter_bit_1 is
port(a: in std_logic_vector(3 downto 0);
y: out std_logic_vector(2 downto 0));
end counter_bit_1;
architecture Behavioral of counter_bit_1 is
begin
process(a)
variable p: integer;
begin
p:=0;
for i in 3 downto 0 loop
if (a(i)='1') then p:=p+1;
end if;
end loop;
if p=0
then y<="000";
elsif p=1
then y<="001";
elsif p=2
then y<="010";
elsif p=3
then y<="011";
else y<="100";
end if;
end process;
end Behavioral;
It works perfectly and there aren't errors or warning.
While if I use the following code with a signal instead of a variable:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter_bit_1 is
port(a: in std_logic_vector(3 downto 0);
y: out std_logic_vector(2 downto 0));
end counter_bit_1;
architecture Behavioral of counter_bit_1 is
signal p: std_logic_vector(2 downto 0);
begin
process(a)
begin
p<=(others=>'0');
for i in 3 downto 0 loop
if a(i)='1' then p<=p+"001";
end if;
end loop;
end process;
y<=p;
end Behavioral;
It doesn't work. The block should count the number of 1 bit in input. I get the following warnings:
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: Madd_p_share0000_lut<2>, p_share0000<2>.
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: p_share0000<1>, Madd_p_share0000_lut<1>.
WARNING:Xst:2170 - Unit counter_bit_1 : the following signal(s) form a combinatorial loop: Madd_p_share0000_cy<0>.
How can I implement the block using a signal?