1 from fractions
import Fraction
3 from migen
.fhdl
.structure
import *
6 def __init__(self
, infreq
, outfreq1x
):
8 self
.trigger_reset
= Signal()
10 self
.cd_sys
= ClockDomain("sys")
12 ratio
= Fraction(outfreq1x
)/Fraction(infreq
)
13 in_period
= float(Fraction(1000000000)/Fraction(infreq
))
16 Instance
.Parameter("in_period", in_period
),
17 Instance
.Parameter("f_mult", ratio
.numerator
),
18 Instance
.Parameter("f_div", ratio
.denominator
),
19 Instance
.Input("clkin", self
.clkin
),
20 Instance
.Input("trigger_reset", self
.trigger_reset
),
22 Instance
.Output("sys_clk", self
.cd_sys
.clk
),
23 Instance
.Output("sys_rst", self
.cd_sys
.rst
)
40 setattr(self
, name
, s
)
41 inst_items
.append(Instance
.Output(name
, s
))
43 self
._inst
= Instance("m1crg", *inst_items
)
46 def get_fragment(self
):
47 return Fragment(instances
=[self
._inst
])