-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input_Lfsr_Sel_Halton_tb.py
47 lines (40 loc) · 1.65 KB
/
Input_Lfsr_Sel_Halton_tb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import numpy as np
import matplotlib.pyplot as plt
import inputGen
import weightGen
import test
"""generate input"""
power = 5
num, times = 2**power, 100
para = [-1,1]
samples = inputGen.uniform(para, num, times)
"""generate weight"""
weight = weightGen.lowPassFir(0.2, 31)
"""test effect of sc's length on the precision of filter"""
minLen = 8
maxLen = 20
"""run filter"""
CWAError = test.Test_Input_Lfsr_Sel_Halton('CWA', minLen, maxLen, samples, weight)
HWAError = test.Test_Input_Lfsr_Sel_Halton('HWA', minLen, maxLen, samples, weight)
MWAError = test.Test_Input_Lfsr_Sel_Halton('MWA', minLen, maxLen, samples, weight)
OLMUXError = test.Test_Input_Lfsr_Sel_Halton('OLMUX', minLen, maxLen, samples, weight)
# CWAError = list(range(minLen, maxLen+1))
# HWAError = list(range(minLen, maxLen+1))
# MWAError = list(range(minLen, maxLen+1))
# OLMUXError = list(range(minLen, maxLen+1))
"""plot result"""
xaxis = list(range(minLen, maxLen+1))
plt.plot(xaxis, CWAError, 'b-o', linewidth = 3, label='CWA')
plt.plot(xaxis, HWAError, 'g-o', linewidth = 3, label='HWA')
plt.plot(xaxis, MWAError, 'r-o', linewidth = 3, label='MWA')
plt.plot(xaxis, OLMUXError, 'k-o', linewidth=3, label='OLMUX')
for i in range(len(xaxis)):
plt.text(xaxis[i], CWAError[i], str(round(CWAError[i], 5)))
plt.text(xaxis[i], HWAError[i], str(round(HWAError[i], 5)))
plt.text(xaxis[i], MWAError[i], str(round(MWAError[i], 5)))
plt.text(xaxis[i], OLMUXError[i], str(round(OLMUXError[i], 5)))
plt.title('RMSE of different SC-based FIR filter with Lfsr as input and Halton as Selection', fontsize=20)
plt.legend(fontsize=14)
plt.tick_params(axis='both', which='major', labelsize=14)
plt.show()