Skip to content

Instantly share code, notes, and snippets.

@XMPPwocky
Created August 20, 2020 06:59
Show Gist options
  • Save XMPPwocky/305fc65481f02f6f51c65a0523d5c23a to your computer and use it in GitHub Desktop.
Save XMPPwocky/305fc65481f02f6f51c65a0523d5c23a to your computer and use it in GitHub Desktop.
prev_input = Signal(signed(self.in_width))
m.d.sync += prev_input.eq(self.input)
slope = self.input - prev_input
with m.If(self.output):
with m.If(slope <= -self.threshold):
m.d.sync += self.output.eq(False)
with m.Else():
with m.If(slope >= self.threshold):
m.d.sync += self.output.eq(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment