2012-02-16 12:02:37 -05:00
|
|
|
from fractions import Fraction
|
|
|
|
|
2013-05-22 11:10:13 -04:00
|
|
|
from migen.fhdl.std import *
|
2012-02-16 12:02:37 -05:00
|
|
|
|
2013-09-17 12:15:22 -04:00
|
|
|
class MXCRG(Module):
|
2013-03-26 12:57:17 -04:00
|
|
|
def __init__(self, pads, outfreq1x):
|
2013-03-15 14:17:05 -04:00
|
|
|
self.clock_domains.cd_sys = ClockDomain()
|
2013-07-09 13:41:28 -04:00
|
|
|
self.clock_domains.cd_sdram_half = ClockDomain()
|
|
|
|
self.clock_domains.cd_sdram_full_wr = ClockDomain()
|
|
|
|
self.clock_domains.cd_sdram_full_rd = ClockDomain()
|
2013-09-17 12:15:22 -04:00
|
|
|
self.clock_domains.cd_base50 = ClockDomain(reset_less=True)
|
2013-03-26 12:57:17 -04:00
|
|
|
|
|
|
|
self.clk4x_wr_strb = Signal()
|
|
|
|
self.clk4x_rd_strb = Signal()
|
|
|
|
|
|
|
|
###
|
2014-10-17 05:14:35 -04:00
|
|
|
|
2013-03-26 12:57:17 -04:00
|
|
|
infreq = 50*1000000
|
2012-09-10 17:47:06 -04:00
|
|
|
ratio = Fraction(outfreq1x)/Fraction(infreq)
|
|
|
|
in_period = float(Fraction(1000000000)/Fraction(infreq))
|
|
|
|
|
2013-07-04 13:19:39 -04:00
|
|
|
self.specials += Instance("mxcrg",
|
2012-09-10 17:47:06 -04:00
|
|
|
Instance.Parameter("in_period", in_period),
|
|
|
|
Instance.Parameter("f_mult", ratio.numerator),
|
|
|
|
Instance.Parameter("f_div", ratio.denominator),
|
2013-03-26 12:57:17 -04:00
|
|
|
Instance.Input("clk50_pad", pads.clk50),
|
|
|
|
Instance.Input("trigger_reset", pads.trigger_reset),
|
2014-10-17 05:14:35 -04:00
|
|
|
|
2012-09-10 17:47:06 -04:00
|
|
|
Instance.Output("sys_clk", self.cd_sys.clk),
|
2012-09-10 18:21:07 -04:00
|
|
|
Instance.Output("sys_rst", self.cd_sys.rst),
|
2013-07-09 13:41:28 -04:00
|
|
|
Instance.Output("clk2x_270", self.cd_sdram_half.clk),
|
|
|
|
Instance.Output("clk4x_wr", self.cd_sdram_full_wr.clk),
|
|
|
|
Instance.Output("clk4x_rd", self.cd_sdram_full_rd.clk),
|
2013-09-17 12:15:22 -04:00
|
|
|
Instance.Output("base50_clk", self.cd_base50.clk),
|
2013-03-26 12:57:17 -04:00
|
|
|
|
|
|
|
Instance.Output("clk4x_wr_strb", self.clk4x_wr_strb),
|
|
|
|
Instance.Output("clk4x_rd_strb", self.clk4x_rd_strb),
|
|
|
|
Instance.Output("norflash_rst_n", pads.norflash_rst_n),
|
|
|
|
Instance.Output("ddr_clk_pad_p", pads.ddr_clk_p),
|
2014-11-20 19:47:11 -05:00
|
|
|
Instance.Output("ddr_clk_pad_n", pads.ddr_clk_n))
|