forked from M-Labs/artiq
1
0
Fork 0

wrpll: clean up matlab comparison test

This commit is contained in:
Sebastien Bourdeauducq 2020-10-08 15:40:15 +08:00
parent cd8c2ce713
commit 6248970ef8
1 changed files with 25 additions and 22 deletions

View File

@ -152,31 +152,34 @@ class WRPLL(Module, AutoCSR):
]
def helper_sim(N=15):
class WRPLL(Module):
def __init__(self, N):
self.tag_ref = Signal(N)
self.input_stb = Signal()
self.adpll = Signal((24, True))
self.out_stb = Signal()
class HelperTB(Module):
def __init__(self, N):
self.tag_ref = Signal(N)
self.input_stb = Signal()
self.adpll = Signal((24, True))
self.out_stb = Signal()
# # # #
loop_filter = thls.make(filters.helper, data_width=48)
self.submodules.loop_filter = loop_filter
self.submodules.collector = collector = Collector(N)
###
self.comb += [
self.collector.tag_ref.eq(self.tag_ref),
self.collector.ref_stb.eq(self.input_stb),
self.collector.main_stb.eq(self.input_stb),
self.loop_filter.input.eq(self.collector.out_helper << 22),
self.loop_filter.input_stb.eq(self.collector.out_stb),
self.adpll.eq(self.loop_filter.output),
self.out_stb.eq(self.loop_filter.output_stb),
]
pll = WRPLL(N=N)
loop_filter = thls.make(filters.helper, data_width=48)
self.submodules.loop_filter = loop_filter
self.submodules.collector = collector = Collector(N)
self.comb += [
self.collector.tag_ref.eq(self.tag_ref),
self.collector.ref_stb.eq(self.input_stb),
self.collector.main_stb.eq(self.input_stb),
self.loop_filter.input.eq(self.collector.out_helper << 22),
self.loop_filter.input_stb.eq(self.collector.out_stb),
self.adpll.eq(self.loop_filter.output),
self.out_stb.eq(self.loop_filter.output_stb),
]
# check filter against output from MatLab model
def helper_sim():
pll = HelperTB(15)
# check filter against output from MatLab model
initial_helper_out = -8000
ref_tags = np.array([
24778, 16789, 8801, 814, 25596, 17612, 9628, 1646,