bd87659334ae64c2cf74679109bdfe757fae52a5
1 """a Dummy PLL module to be replaced by a real one
4 from nmigen
import (Module
, Signal
, Elaboratable
, Const
, Cat
, Instance
)
5 from nmigen
.cli
import rtlil
7 class DummyPLL(Elaboratable
):
8 def __init__(self
, instance
):
9 self
.instance
= instance
10 self
.clk_24_i
= Signal(reset_less
=True) # external incoming
11 self
.clk_sel_i
= Signal(2, reset_less
=True) # PLL selection
12 self
.sel_a1_i
= Signal(reset_less
=True) # PLL selection
13 self
.clk_pll_o
= Signal(reset_less
=True) # output clock
14 self
.pll_test_o
= Signal(reset_less
=True) # test out
15 self
.pll_vco_o
= Signal(reset_less
=True) # analog
17 def elaborate(self
, platform
):
21 pll
= Instance("pll", i_ref
=self
.clk_24_i
,
22 i_a0
=self
.clk_sel_i
[0],
23 i_a1
=self
.clk_sel_i
[1],
24 o_out_v
=self
.clk_pll_o
,
25 o_div_out_test
=self
.pll_test_o
,
26 o_vco_test_ana
=self
.pll_vco_o
,
28 m
.submodules
['real_pll'] = pll
29 #pll.attrs['blackbox'] = 1
31 m
.d
.comb
+= self
.clk_pll_o
.eq(self
.clk_24_i
) # just pass through
32 # just get something, stops yosys destroying (optimising) these out
33 with m
.If(self
.clk_sel_i
== 0):
34 m
.d
.comb
+= self
.pll_test_o
.eq(self
.clk_24_i
)
35 m
.d
.comb
+= self
.pll_vco_o
.eq(~self
.clk_24_i
)
41 return [self
.clk_24_i
, self
.clk_sel_i
, self
.clk_pll_o
,
42 self
.pll_test_o
, self
.pll_vco_o
]
45 if __name__
== '__main__':
48 vl
= rtlil
.convert(dut
, ports
=dut
.ports())
49 with
open("test_dummy_pll.il", "w") as f
: