2013-02-07 16:07:30 -05:00
|
|
|
from migen.fhdl.structure import *
|
2013-03-15 05:48:43 -04:00
|
|
|
from migen.fhdl.module import Module
|
2013-02-07 16:07:30 -05:00
|
|
|
|
2013-03-15 13:46:11 -04:00
|
|
|
class SimpleCRG(Module):
|
2013-03-15 05:49:18 -04:00
|
|
|
def __init__(self, platform, clk_name, rst_name, rst_invert=False):
|
2013-04-08 14:28:11 -04:00
|
|
|
self._clk = platform.request(clk_name)
|
|
|
|
self._rst = platform.request(rst_name)
|
2013-03-15 13:46:11 -04:00
|
|
|
self.clock_domains.cd_sys = ClockDomain()
|
2013-04-08 14:28:11 -04:00
|
|
|
self.comb += self.cd_sys.clk.eq(self._clk)
|
2013-03-15 05:49:18 -04:00
|
|
|
if rst_invert:
|
2013-04-08 14:28:11 -04:00
|
|
|
self.comb += self.cd_sys.rst.eq(~self._rst)
|
2013-03-15 05:49:18 -04:00
|
|
|
else:
|
2013-04-08 14:28:11 -04:00
|
|
|
self.comb += self.cd_sys.rst.eq(self._rst)
|