Question

I have the below VHDL file, where i am facing problem. The final sum is getting the value undefined always.

CL_Adder is the Carry lookahead adder and is check as individual component and is working fine. Regstr module is also working fine.

The problem is with the reslt, reslt_out1, reslt_out2 variables usage ..!

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use work.CS_Adder_Package.all;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity movingaverage is
    Port ( sin : in  STD_LOGIC_VECTOR (10 downto 0);
       clk : in  STD_LOGIC;
       rst : in  STD_LOGIC;
          --reslt_in: in std_logic_vector(14 downto 0);
       sout : out  STD_LOGIC_VECTOR (10 downto 0)
          --reslt_out: out std_logic_vector(14 downto 0)
          ); 
end movingaverage;

architecture Structural of movingaverage is

component Regstr is
port ( d : in STD_LOGIC_VECTOR (10 downto 0);
clk : in STD_LOGIC;
rst : in STD_LOGIC;
q : out STD_LOGIC_VECTOR (10 downto 0));
end component;


component CL_Adder is
Port ( x : in  STD_LOGIC_VECTOR (14 downto 0);
       y : in  STD_LOGIC_VECTOR (14 downto 0);
       cin : in  STD_LOGIC;
       s : out  STD_LOGIC_VECTOR (14 downto 0);
       cout : out  STD_LOGIC);
end component;

signal s: input_array;
signal s_se :std_logic_vector(14 downto 0):=  (others =>'0');
signal s_se1 :std_logic_vector(14 downto 0):=  (others =>'0');
signal s_se2 : std_logic_vector(14 downto 0):=  (others =>'0');
signal reslt : std_logic_vector(14 downto 0):=  (others =>'0');
signal reslt_out1: std_logic_vector(14 downto 0):=  (others =>'0');
signal reslt_out2: std_logic_vector(14 downto 0):=  (others =>'0');
signal c1,c2: std_logic;

begin


u0: for i in 15 downto 1 generate
    u1:regstr port map(s(i-1)(10 downto 0),clk,rst,s(i)(10 downto 0));
end generate u0;

u7:regstr port map(sin,clk,rst,s(0)(10 downto 0));



s_se(14 downto 0) <= sin(10) & sin(10) & sin(10) & sin(10) & sin(10 downto 0);

reslt<= reslt_out2;

u8:CL_Adder port map(s_se,reslt,'0',reslt_out1,c1);

s_se1<= s(15)(10) & s(15)(10) & s(15)(10) & s(15)(10) & s(15)(10 downto 0);
s_se2 <= not(s_se1);

u9:CL_Adder port map(reslt_out1,s_se2,'1',reslt_out2,c2);





Sout <= reslt(14 downto 4); --divide by 16


end Structural;
Était-ce utile?

La solution

Without more code I must add a little guessing, but could look like there is a loop in the design in reslt => reslt_out1 => reslt_out2 => reslt, since there is no clock (clk) on CL_Adder in the code:

reslt <= reslt_out2;
...
u8:CL_Adder port map(s_se, reslt, '0', reslt_out1, c1);
...
u9:CL_Adder port map(reslt_out1, s_se2, '1', reslt_out2, c2);

Whether this is the reason for the problem depends on how you see the "undefined". In simulation the loop itself should not result in X (unknown), or similar, but the loop hints a problem. Btw, you mention "variables usage", but there are no variables in the shown code; only signals.

Addition:

If the purpose is to accumulate the value, then a sequential process (clocked process to make flip flops) may be used to capture the result of each iteration, and present as argument in next iteration. The reslt <= reslt_out2; may then be replaced with a process like:

process (clk, rst) is
begin
  if rst = '1' then  -- Reset if required
    reslt <= (others => '0');
  elsif rising_edge(clk) then  -- Clock
    reslt <= reslt_out2;
  end if;
end process;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top