depanwita
Newbie level 4
- Joined
- Jan 18, 2011
- Messages
- 6
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,362
I need to design DNF(Digital Noise Filter) using VHDL, which is able to eliminate glitches by calculating pulse width. that is is a pulse width is less than a specified value it will not come in output but if more than specified value it will come in output. for pulsewidth calculation I am using this following code
here the pulse width is coming properly but not getting the proper noise eliminated output.
Please I need urgent help for this
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 library IEEE; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity Pulse_Measure is generic ( Pulse_Measure_Polarity : STD_ULOGIC := '1' -- 0=Measure Low Time 1=Measure High Time ); port ( i_Rst : in STD_ULOGIC; -- Active high reset i_Clk : in STD_ULOGIC; -- Measurement Clock i_Pulse : in STD_ULOGIC; -- Pulse to be measured -- o_Pulse_Width : out UNSIGNED(15 downto 0); -- Measurement o_Overflow : out STD_ULOGIC; -- Overflow flag o_Measurement_Valid : out BOOLEAN; -- True if measurement was successful Pulse_out : out STD_ULOGIC); end Pulse_Measure; architecture arc_Pulse_Measure of Pulse_Measure is signal Pulse : STD_ULOGIC; signal Pulse_Counter : UNSIGNED(15 downto 0); signal Pulse_Count : UNSIGNED(15 downto 0); signal Overflow : STD_ULOGIC; signal Measurement_Valid : BOOLEAN; type state is ( s_Reset, s_Signal_Inactive, s_Counting, s_Done ); signal Measurement_State : state; begin -- Set polarity so that "Pulse" is always high for measurement Pulse <= i_Pulse xor not Pulse_Measure_Polarity; process(i_Rst,i_Clk) begin if i_Rst = '1' then Pulse_Counter <= X"0000"; Pulse_Count <= X"0000"; Overflow <= '0'; Measurement_Valid <= FALSE; Measurement_State <= s_Reset; elsif rising_edge(i_Clk) then case Measurement_State is when s_Reset => -- Wait here for signal to become inactive so we don't measure a partial pulse if Pulse = '0' then Measurement_State <= s_Signal_Inactive; else null; -- Stay here end if; when s_Signal_Inactive => if Pulse = '1' then Pulse_Counter <= Pulse_Counter + 1; -- Start counting here Measurement_State <= s_Counting; else -- Pulse = '0' Pulse_Counter <= X"0000"; -- Hold cleared while not in use end if; when s_Counting => if Pulse = '1' then -- Actively counting if Pulse_Counter = X"FFFF" then -- We have overflowed the count Overflow <= '1'; -- Set flag Measurement_Valid <= False; -- Clear Flag Measurement_State <= s_Reset; -- Start over else Pulse_Counter <= Pulse_Counter + 1; -- All is good, keep counting end if; else --Pulse = '0' -- Pulse is over Measurement_State <= s_Done; end if; when s_Done => Pulse_Count <= Pulse_Counter; -- Capture count Measurement_Valid <= TRUE; -- Set Flag Measurement_State <= s_Reset; -- And return to start if(Pulse_Counter< 5) then Pulse_out <= i_Pulse; else Pulse_out <= '0'; end if; when others => null; end case; end if; -- Connect signals to output pins. o_Pulse_Width <= Pulse_Count; o_Overflow <= Overflow; o_Measurement_Valid <= Measurement_Valid; end process; end arc_Pulse_Measure;
here the pulse width is coming properly but not getting the proper noise eliminated output.
Please I need urgent help for this
Last edited by a moderator: