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 05:48:43 -04:00
|
|
|
class CRG(Module):
|
2013-02-07 16:07:30 -05:00
|
|
|
def get_clock_domains(self):
|
|
|
|
r = dict()
|
|
|
|
for k, v in self.__dict__.items():
|
|
|
|
if isinstance(v, ClockDomain):
|
|
|
|
r[v.name] = v
|
|
|
|
return r
|
|
|
|
|
|
|
|
class SimpleCRG(CRG):
|
2013-03-15 05:49:18 -04:00
|
|
|
def __init__(self, platform, clk_name, rst_name, rst_invert=False):
|
2013-02-07 16:07:30 -05:00
|
|
|
self.cd = ClockDomain("sys")
|
|
|
|
platform.request(clk_name, None, self.cd.clk)
|
2013-03-15 05:49:18 -04:00
|
|
|
if rst_invert:
|
|
|
|
rst_n = platform.request(rst_name)
|
|
|
|
self.comb += self.cd.rst.eq(~rst_n)
|
|
|
|
else:
|
|
|
|
platform.request(rst_name, None, self.cd.rst)
|