Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. class FrequencyMeasurement(Module, AutoCSR):
  2.     def __init__(self, pulse):
  3.         self._period = CSRStatus(32)
  4.  
  5.         # # #
  6.  
  7.         # compute period (unit = sys_clk ticks)
  8.         self.submodules.counter = counter = Counter(32)
  9.         self.comb += [
  10.             counter.ce.eq(1),
  11.             counter.reset.eq(pulse)
  12.         ]
  13.         self.sync += [
  14.             If(counter.reset,
  15.                 self._period.status.eq(counter.value)
  16.             )
  17.         ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement