---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 16:20:51 03/03/2010 -- Design Name: -- Module Name: pw_checker - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity pw_checker is generic( lower_pw : natural := 2; upper_pw : natural := 4); Port ( input : in STD_LOGIC; rst : in STD_LOGIC; clk : in STD_LOGIC; output : out STD_LOGIC); end pw_checker; architecture Behavioral of pw_checker is signal cnt : natural; --signal pw : natural; --signal test : std_logic; signal start : std_logic; begin count_pw: process(clk,input) begin if( clk'event and clk = '1' ) then if ( start = '1' ) then cnt <= cnt + 1; -- pw <= cnt+1; else cnt <= 0; -- pw <= cnt; end if; end if; end process count_pw; --do_out: process(input) --begin -- if( input'event and input = '0' ) then -- if( cnt <= upper_pw and cnt >= lower_pw ) then -- output <= '1'; -- else -- output <= '0'; -- end if; -- else -- if(input'event and input = '1') then -- start <= '1'; -- end if; -- end if; --end process; do_out: process(input) begin if(input'event and input = '0' ) then if( cnt <= upper_pw and cnt >= lower_pw ) then output <= '1'; else output <= '0'; end if; end if; end process do_out; do_start: process(input) begin if( input = '0' ) then start <= '0'; else start <= '1'; end if; end process; --do_out: process(input) --begin -- if( input'event and input = '0' ) then -- if( clk'event and clk = '1' ) then -- if( pw <= upper_pw and pw >= lower_pw ) then -- output <= '1'; -- else -- output <= '0'; -- end if; -- end if; --end process do_out; end Behavioral;