Counter simulation proper but giving trouble in DFT

N

nisheethg

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity su_pixel_counter is
Port ( CLK : in STD_LOGIC;
RESET : in STD_LOGIC;
EN : in STD_LOGIC;
CNTR_INCR : in STD_LOGIC;
LOAD_PIXEL : in STD_LOGIC;
TC : in STD_LOGIC_VECTOR( 3 downto 0);
COUNT_ONE : out STD_LOGIC;
COUNT_ONE_IF_INCR : out STD_LOGIC;-- First Count i.e. zero
CNTR : out STD_LOGIC_VECTOR ( 3 downto 0);
TC_MINUS_CNTR : out STD_LOGIC_VECTOR ( 3 downto 0);
SUM_OF_CNTR_AND_TC_MINUS_CNTR: out STD_LOGIC_VECTOR ( 3 downto 0);
PIXEL_CNTR_COUNT_OVER : out STD_LOGIC

--test
);
end su_pixel_counter;

architecture Behavioral of su_pixel_counter is

SIGNAL CNTR_IN : STD_LOGIC_VECTOR(3 downto 0); -- original value 1

--SIGNAL iCNTR : STD_LOGIC_VECTOR(3 downto 0);
--SIGNAL iTC_MINUS_CNTR : STD_LOGIC_VECTOR(3 downto 0);
--SIGNAL iSUM_OF_CNTR_AND_TC_MINUS_CNTR : STD_LOGIC_VECTOR(3 downto
0);

begin

process(CLK, RESET)
begin

if ( RESET ='1') then
CNTR_IN <= b"0000";
PIXEL_CNTR_COUNT_OVER <= '0';
COUNT_ONE_IF_INCR <= '0';


elsif(CLK'event and CLK ='1') then
if ( EN ='1') then
if (CNTR_INCR = '1') then

-- CNTR_IN <= CNTR_IN + 1;

if ( CNTR_IN = "0000") then
COUNT_ONE_IF_INCR<= '1';
PIXEL_CNTR_COUNT_OVER <= '0';
CNTR_IN <= CNTR_IN + 1;

elsif ( CNTR_IN = TC) then
COUNT_ONE_IF_INCR<= '0';
PIXEL_CNTR_COUNT_OVER <= '1';
CNTR_IN <= CNTR_IN + 1;

elsif ( CNTR_IN = TC + 1 ) then
COUNT_ONE_IF_INCR<= '0';
PIXEL_CNTR_COUNT_OVER <= '0';
CNTR_IN <= b"0000";
else
CNTR_IN <= CNTR_IN + 1;

end if;


--if ( CNTR_IN = TC + 1) then
-- CNTR_IN <= b"0000"; -- original value 0001
-- end if;


-- for generating counter count over when TC is greater than 1
-- if ( CNTR_IN = TC) then -- original tc -1
-- PIXEL_CNTR_COUNT_OVER<='1';
-- end if;

--
-- if (CNTR_IN = b"0000") then -- chnaged from 1 to 0
-- COUNT_ONE_IF_INCR<= '1';
-- else
-- COUNT_ONE_IF_INCR<= '0';
-- end if;
end if;

else
PIXEL_CNTR_COUNT_OVER<= '0';
COUNT_ONE_IF_INCR<= '0';
end if;

CNTR<= CNTR_IN;
TC_MINUS_CNTR<= (TC + 2) - CNTR_IN;
SUM_OF_CNTR_AND_TC_MINUS_CNTR <= TC + 2;


end if;
end process;




--- COunter intitial value flag
process( CLK, RESET)
begin
if (RESET ='1') then
COUNT_ONE<= '0';
elsif (CLK ='1' and CLK'event) then
if (CNTR_IN = b"0001") then
COUNT_ONE<= '1';
else
COUNT_ONE<= '0';
end if;
end if;
end process;



--process(CLK, RESET)
--begin
-- if (RESET ='1') then


-- elsif ( CLK ='1' and CLK'event) then


-- -end if;
--end process;

--CNTR <= iCNTR;
--TC_MINUS_CNTR <= iTC_MINUS_CNTR;
--SUM_OF_CNTR_AND_TC_MINUS_CNTR <= iSUM_OF_CNTR_AND_TC_MINUS_CNTR;

end Behavioral;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top