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?
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?