Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

variable pulse detection

Status
Not open for further replies.

digi001

Full Member level 5
Joined
Apr 5, 2011
Messages
244
Helped
22
Reputation
44
Reaction score
21
Trophy points
1,298
Activity points
2,904
I am looking to write verilog to detect either a 20us or 40us pulse (with some tolerance) and do 2 different actions accordingly.

What would be a good way to approach this? State machine?

State 0:
Idle

State 1:
Start Count on Rising Edge of Pulse
If Count > 19uS : State 2
If Pulse Falling Edge :State 0
else :State 1

State 2:
If Pulse Faling Edge within 2us then take action 1
else State 3

State 3:
If Count > 39uS : State 4
else If Pulse Falling edge State 0

State 4:
If Pulse Faling Edge within 2us then take action 2
else State 0


Something like this?
 

This would be one approach if you like sequential logic design. Another one is taking a fast microcontroller or DSP with onboard window timer. Key question is what tolerance you want to achieve(1us or less?).

Enjoy your design work!
 

I would try something like this

psuedo code for 20 us pulse detection:

if ( (count > 19 us || count < 21 us) && pulse_falling_edge_detect ) state <= do_action_1
else if (count > 21 us) state <= check_4_40us_pulse
else state <= stay_in_this_state

This would wait for a falling edge pulse during the state in a 2 us window and would exit the state when the count exceeds the window without a falling edge pulse. You could use something similar at the 40 us pulse count.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top