| 1 |
2 |
vladimirar |
#!/usr/bin/python3
|
| 2 |
|
|
# Python version: 3.6.7
|
| 3 |
|
|
import re
|
| 4 |
|
|
|
| 5 |
|
|
# //////////////////////////////////////////////////////////////////////
|
| 6 |
|
|
# //// ////
|
| 7 |
|
|
# //// Low Pass Filter FIR IP Core ////
|
| 8 |
|
|
# //// ////
|
| 9 |
|
|
# //// This file is part of the LPFFIR project ////
|
| 10 |
|
|
# //// https://opencores.org/projects/lpffir ////
|
| 11 |
|
|
# //// ////
|
| 12 |
|
|
# //// Description ////
|
| 13 |
|
|
# //// Implementation of LPFFIR IP core according to ////
|
| 14 |
|
|
# //// LPFFIR IP core specification document. ////
|
| 15 |
|
|
# //// ////
|
| 16 |
|
|
# //// To Do: ////
|
| 17 |
|
|
# //// - ////
|
| 18 |
|
|
# //// ////
|
| 19 |
|
|
# //// Author: ////
|
| 20 |
|
|
# //// - Vladimir Armstrong, vladimirarmstrong@opencores.org ////
|
| 21 |
|
|
# //// ////
|
| 22 |
|
|
# //////////////////////////////////////////////////////////////////////
|
| 23 |
|
|
# //// ////
|
| 24 |
|
|
# //// Copyright (C) 2019 Authors and OPENCORES.ORG ////
|
| 25 |
|
|
# //// ////
|
| 26 |
|
|
# //// This source file may be used and distributed without ////
|
| 27 |
|
|
# //// restriction provided that this copyright statement is not ////
|
| 28 |
|
|
# //// removed from the file and that any derivative work contains ////
|
| 29 |
|
|
# //// the original copyright notice and the associated disclaimer. ////
|
| 30 |
|
|
# //// ////
|
| 31 |
|
|
# //// This source file is free software; you can redistribute it ////
|
| 32 |
|
|
# //// and/or modify it under the terms of the GNU Lesser General ////
|
| 33 |
|
|
# //// Public License as published by the Free Software Foundation; ////
|
| 34 |
|
|
# //// either version 2.1 of the License, or (at your option) any ////
|
| 35 |
|
|
# //// later version. ////
|
| 36 |
|
|
# //// ////
|
| 37 |
|
|
# //// This source is distributed in the hope that it will be ////
|
| 38 |
|
|
# //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 39 |
|
|
# //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 40 |
|
|
# //// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 41 |
|
|
# //// details. ////
|
| 42 |
|
|
# //// ////
|
| 43 |
|
|
# //// You should have received a copy of the GNU Lesser General ////
|
| 44 |
|
|
# //// Public License along with this source; if not, download it ////
|
| 45 |
|
|
# //// from http://www.opencores.org/lgpl.shtml ////
|
| 46 |
|
|
# //// ////
|
| 47 |
|
|
# //////////////////////////////////////////////////////////////////////
|
| 48 |
|
|
|
| 49 |
|
|
# path
|
| 50 |
|
|
rtl_path = '../../sim/rtl_sim/out/rtl_impulseResponse.txt'
|
| 51 |
|
|
check_path = '../out/check_impulseResponse.txt'
|
| 52 |
|
|
|
| 53 |
|
|
# open
|
| 54 |
|
|
rtl_file = open(rtl_path,'r')
|
| 55 |
|
|
check_file = open(check_path,'w')
|
| 56 |
|
|
|
| 57 |
|
|
# read
|
| 58 |
|
|
rtl_list = rtl_file.readlines()
|
| 59 |
|
|
|
| 60 |
|
|
# remove header text
|
| 61 |
|
|
del rtl_list[0:9]
|
| 62 |
|
|
|
| 63 |
|
|
# remove newlines
|
| 64 |
|
|
rtl_list2 = [x.replace('\n', '') for x in rtl_list]
|
| 65 |
|
|
|
| 66 |
|
|
# Expected from MATLAB, first 0:5 index is one
|
| 67 |
|
|
oneCount = 0
|
| 68 |
|
|
for index in range(6):
|
| 69 |
|
|
searchObj = re.search( r'1$', rtl_list2[index])
|
| 70 |
|
|
if searchObj:
|
| 71 |
|
|
oneCount += 1
|
| 72 |
|
|
|
| 73 |
|
|
# Expected from MATLAB, last 6:$ index is zero
|
| 74 |
|
|
zeroCount = 0
|
| 75 |
|
|
for index in range(6,len(rtl_list2)):
|
| 76 |
|
|
searchObj = re.search( r'0$', rtl_list2[index])
|
| 77 |
|
|
if searchObj:
|
| 78 |
|
|
zeroCount += 1
|
| 79 |
|
|
|
| 80 |
|
|
# check RTL match MATLAB expected
|
| 81 |
|
|
if oneCount == 6 and zeroCount == 7:
|
| 82 |
|
|
checkResult = "Impulse Response Test: PASS";
|
| 83 |
|
|
else:
|
| 84 |
|
|
checkResult = "Impulse Response Test: FAIL";
|
| 85 |
|
|
|
| 86 |
|
|
# Log
|
| 87 |
|
|
print (checkResult);
|
| 88 |
|
|
check_file.write(checkResult)
|
| 89 |
|
|
|
| 90 |
|
|
# close
|
| 91 |
|
|
rtl_file.close()
|
| 92 |
|
|
check_file.close()
|