Background
With the rapid development of large-scale integrated circuits and computer technologies, digital signal processing techniques have been widely used in the fields of communications, radars, earthquake prediction, biomedicine, control systems, hydraulic engineering, fault detection, instruments and meters for faults, and the like. In a digital signal processing system, a signal at a wireless communication receiving end is derived from an analog signal, is sampled to form a discrete time signal, and then is converted into a digital signal form with a limited word length. Since the received signal is often mixed with noise and various frequency components, digital filtering of the received signal is required and filters may remove signal noise and other unwanted signal components. The filter is divided into an analog filter and a digital filter according to the processed signals, and is divided into a low-pass filter, a high-pass filter, a band-pass filter and a band-stop filter according to the frequency band of the passed signals. The band-pass filter is a filter which only allows signals in a specified frequency band to pass through and suppresses signals of other frequencies, such as signals, interference and noise below or above the frequency band; the band-stop filter is a filter for suppressing signals of a specific frequency band and passing signals of other frequencies. An ideal bandpass filter should have a completely flat passband with no amplification or attenuation within the passband and with all frequencies outside the passband completely attenuated, and with transitions inside and outside the passband being completed over a very small frequency range. In practice, there is no ideal band-pass filter, and a practical filter cannot completely attenuate all frequencies outside the desired frequency range, especially outside the desired pass-band, there is also an attenuated but not isolated range, which is commonly referred to as the roll-off phenomenon of the filter, and is expressed in dB per decade of attenuation magnitude. In general, filters are designed to ensure that the narrower the roll-off range, the better the filter will perform, and thus the performance of the filter will be closer to that of the design, however, as the roll-off range becomes smaller, the pass band becomes flatter and "ripples" begin to appear, which is particularly noticeable at the edges of the pass band, and this effect is known as the gibbs phenomenon.
In the field of signal processing, the requirements for real-time performance and rapidity of signal processing are increasing, and filters are widely used in many information processing processes, such as filtering, detecting, predicting, etc. of signals. The digital filter has the outstanding advantages of high stability, high precision, flexible design, convenient implementation and the like, and the problems of voltage drift, temperature drift, noise and the like which cannot be overcome by an analog filter are avoided. The digital filter is a digital device or program that converts an input sequence into an output sequence through a certain operation, both inputs and outputs are digital signals, and changes the relative proportion of frequency components contained in the input signals through numerical operation processing, or filters some frequency components. Therefore, the concept of digital filtering is the same as that of analog filtering, only the form of a signal is different from that of the method for realizing the filtering, and the digital filtering realizes the filtering through numerical operation, so that the digital filter has the advantages of high processing precision, stability, small volume, light weight, flexibility, no impedance matching problem and capability of realizing the special filtering function which cannot be realized by the analog filter. If analog signals are to be processed, matched conversion of the signal form can be performed by the ADC and DAC, and the analog signals can also be filtered using digital filters. The digital filter is a device composed of digital multiplier, adder and delay unit, and is a digital signal processor, which is a discrete time system and has the function of operating the digital code of the input discrete signal to change the signal spectrum. In practice, a digital computer is mainly used for correspondingly calculating digital signals according to a pre-programmed program, and if a general computer is adopted, the signal processing can be completed by writing the program at any time, but the speed is low; if a special computer is adopted, the chip of the special computer is an integrated circuit manufactured according to a fixed calculation method, the signal can be processed after the signal is connected, the speed is high, but the processing mode cannot be changed; if a programmable computer chip is adopted, different programs can be programmed to achieve diversification of processing modes, and the processing speed is higher, so that the programmable computer chip is most widely applied in the current market.
The fir (finite Impulse response) filter is a finite single-bit Impulse response filter, is the most basic element in a digital signal processing system, can have strict linear phase-frequency characteristics while ensuring arbitrary amplitude-frequency characteristics, and has finite unit sampling response, so that the filter is a stable system. Therefore, FIR filters are widely used in the fields of communications, image processing, pattern recognition, and the like. The digital filter is carried out in the time domain, receives a discrete sequence with a finite length, allows useful frequency signal components to pass, suppresses useless frequency signal components, and finally outputs a sequence, which is essentially a linear time-invariant discrete system realized by a finite-precision algorithm and can be realized in FPGA hardware. Nowadays, FIR filters, which are widely used in practice, are causal, their impulse response is zero before the impulse signal is applied, and the output sequence is undistorted and time-shiftable.
The design method of the FIR digital filter mainly comprises a window function method, a frequency sampling method, a Chebyshev approximation method and the like. The main mathematical tool for window function digital signal processing is Boyle transform, Fourier transform is to study the relation of the whole time domain and frequency domain, however, when the engineering test signal processing is realized by using a computer, the infinite signal cannot be measured and operated, but the finite time segment is taken for analysis, the specific method is to intercept a time segment from the signal, then carry out periodic extension processing by using the observed signal time segment to obtain a virtual infinite signal, and then carry out mathematical processing such as Fourier transform, correlation analysis and the like on the signal. After the signal with no line length is cut off, the spectrum is distorted, and the energy originally concentrated at the zero point is dispersed into two wider frequency bands, which is called spectrum energy leakage. To reduce spectral energy leakage, the signal may be truncated using different truncation functions, called window functions, or simply windows. The energy leakage phenomenon generated after the signal is truncated is inevitable, because the window function is an infinite function of a frequency band, even if the original signal is a limited bandwidth signal, the window function is inevitably a function of an infinite bandwidth after the signal is truncated, namely, the energy and the distribution of the signal in a frequency domain are expanded. The basic idea of window function design is as follows: according to the technical index requirement, selecting a proper order N and a type of a window function to enable the amplitude-frequency characteristic to approach the amplitude-frequency characteristic of an ideal filter, and correspondingly selecting the window function, considering the property and the processing requirement of the analyzed signal. The window function can influence not only the transition bandwidth but also the magnitude of the shoulder and the ripple (attenuation of the stop band), and is therefore chosen such that its frequency spectrum: the width of the main lobe is as small as possible to make the transition zone as steep as possible, the side lobes are as small as possible relative to the main lobe, so that the shoulder and the ripple are reduced, i.e. the energy is concentrated as much as possible in the main lobe, these two requirements are contradictory for the window function, and a compromise is selected as required. The rectangular window has centralized main lobes, high frequency identification precision and higher side lobes, and is the most used window function; the Hanning window is a cosine window, the main lobe is widened but reduced, the side lobe is low, the frequency resolution is reduced, and the Hanning window is suitable for filtering signals with complex frequency points and multiple frequency components; the Hanming window is an improved raised cosine window, and the side lobe is smaller; the second-order raised cosine window has wider main lobe, lower side lobe, high amplitude identification precision and better signal selectivity.
The window function design method of the filter is to provide a filter window coefficient approximate to the frequency response function of an ideal filter, the impulse response of the ideal filter is an infinite sequence, the impulse response of the designed filter is finite, the infinite impulse response is truncated left and right and then shifted right to form a causal system, and therefore, the FIR filter shows oscillation phenomena in a pass band and a stop band, when the order M of the filter is increased, the number of oscillation ripples is increased, and the width of the ripples is reduced. Alternative window function types can be divided into
Second-order raised cosine window

And the like. The FIR filter forms it by a weighted sum of the current and past input valuesSince the response of the FIR filter depends only on a limited number of input values, it has a finite non-zero response to a discrete impulse, i.e. the response of an M-order FIR filter to an impulse is zero after M clock cycles, and its output at any point in time is only related to a window containing the latest M input values, and is therefore also called a moving average filter. Each arithmetic unit of the structure of the FIR filter is assigned a finite word length, its data path is adapted to the outputs of the multipliers and adders and manages the data flow during operation. The limited word length of the data limits the resolution and dynamic range that the filter can represent and introduces quantization errors; at the same time, the filter coefficients are also of finite word length, which results in additional quantization and truncation errors. The filter has to select a higher order M to achieve higher data resolution and selectivity, but the higher the order, the more multipliers and adders required in the filtering calculation, and the more FPGA hardware resources are occupied. Therefore, the digital filter needs to be designed with consideration of data resolution, filtering selectivity, dynamic range, quantization error, hardware resource consumption, computation time, and other balance.
In the traditional digital filter implementation method in FPGA, the filter coefficient is fixed, i.e. the characteristic indexes of the filter, such as frequency response characteristic, passband type, filter bandwidth, cut-off frequency, in-band fluctuation and the like, are not changeable, and if a certain characteristic index of the filter needs to be changed, the filter coefficient needs to be redesigned and the FPGA program needs to be compiled. Under the condition that the received signal mode is complex and variable, the traditional digital filter implementation method cannot meet the requirement that the filtering characteristic is variable.
Disclosure of Invention
The invention provides a passband-selectable digital filter implementation method which has the advantages of strong flexibility, good stability, high filtering precision and small calculation amount and can adapt to various signals with different requirements, in order to overcome the defect that the filtering characteristics of the traditional digital filter implementation method are invariable.
The above object of the present invention can be achieved by the following scheme, and a method for implementing a digital filter with a selectable passband has the following technical features: a window function type selection module, a filter frequency response characteristic selection module, a filtering bandwidth selection module, a filter coefficient reading module, a data folding module and a filtering calculation module are adopted to establish a filter model with selectable pass band; firstly, selecting different filter window function types through control parameters of a window function type selection module, determining the window function length N according to requirements on attenuation of a transition band and a stop band, selecting different filter frequency response characteristics through a filter frequency response characteristic selection module, selecting different filter characteristic indexes such as filter bandwidth through a filter bandwidth selection module, determining filter coefficients meeting design indexes by utilizing a Matlab tool, and designing an FIR filter with M-order symmetric coefficients; selecting filter system digital length, filter signal word length and technical indexes according to hardware resource capacity to obtain the order M of the FIR digital filter, storing M-order symmetric coefficients of the FIR digital filter at the relative position in a ROM group, reading the filter coefficients in the ROM group by a filter coefficient reading module according to address mapping, multiplying and accumulating the input signals and the filter coefficients, performing data folding calculation by a data folding module, performing filter calculation on the folded data and the filter coefficients by a filter calculation module, and outputting filtered signals with selectable pass bands.
Compared with the traditional digital filter implementation method, the invention has the following beneficial effects:
the flexibility is strong. The invention adopts a window function type selection module, a filter frequency response characteristic selection module, a filtering bandwidth selection module, a filter coefficient reading module, a data folding module and a filtering calculation module to establish a filter model with selectable pass band; different filter window function types, different filter frequency response characteristics, different filter bandwidths and other filter characteristic indexes can be selected through control parameters.
The filtering precision is high. The invention utilizes Matlab tool to determine the filter coefficient meeting the design index, designs the FIR filter with M-order symmetric coefficient, can ensure that the phase characteristic is linear in the filter response passband, the output of any time point is only related to the latest M input values, the order of the filter is 128, the filter coefficient length and the filter signal word length can be selected correspondingly according to the hardware resource capacity, compared with the traditional digital filter implementation method, the invention has higher filtering precision.
The stability is good. The M-order symmetric coefficient of the FIR digital filter is stored in the ROM group, and when filtering calculation is carried out, the filter coefficient in the ROM group is read only according to address mapping, and the input signal and the filter coefficient are multiplied and accumulated to complete filtering and output signals.
The calculation amount is small. The filter with symmetrical coefficient is designed, the input signal is multiplied by the symmetrical coefficient, and the result has symmetry, so that the filter coefficient stored in ROM memory bank only needs to be the M-order filter
Firstly, the data folding calculation is carried out on the input signal, and finally, the folded data sum is carried out
Compared with the traditional digital filter implementation method, the invention has the advantages that the number of the multipliers and adders used is less, the calculated amount is smaller, and compared with a direct filter structure, the number of the multipliers used is reduced by half, the direct filter is multiplied before added, and the invention is added before multiplied.
The invention selects different filter window function types through control parameters. The filtering characteristics of various window functions are different, and the window functions can be flexibly selected according to the signal filtering requirement. Different filter frequency response characteristics, such as low-pass, band-pass, high-pass, band-stop, etc., are selected by controlling parameters. Different filter bandwidths are selected through control parameters, a low-pass filter and a high-pass filter need to determine the cut-off frequency of a pass band, a band-pass filter and a band-stop filter need to determine the cut-off frequency of the pass band/stop band and the bandwidth of the pass band/stop band, and an FIR filter with symmetrical coefficients is designed, so that the phase characteristics of the FIR filter can be ensured to be linear in the response pass band of the filter, the filter coefficients meeting the design indexes can be determined by utilizing tools such as Matlab and the like in advance, and under the condition that the filter requirements are different, the structure and other coefficients of the whole filter do not need to be changed, and the filters.
Detailed Description
See fig. 1. According to the invention, a filter model with a selectable passband is established by adopting a window function type selection module, a filter frequency response characteristic selection module, a filtering bandwidth selection module, a filter coefficient reading module, a data folding module and a filtering calculation module; firstly, selecting different filter window function types through control parameters of a window function type selection module, determining the window function length N according to requirements on attenuation of a transition band and a stop band, selecting different filter frequency response characteristics through a filter frequency response characteristic selection module, selecting different filter characteristic indexes such as filter bandwidth through a filter bandwidth selection module, determining filter coefficients meeting design indexes by utilizing a Matlab tool, and designing an FIR filter with M-order symmetric coefficients; selecting a filter coefficient word length and a filter signal word length according to hardware resource capacity, solving the order M of the FIR digital filter according to technical indexes, storing M-order symmetric coefficients of the FIR digital filter at the relative position in a ROM (read only memory) group, reading the filter coefficients in the ROM group according to address mapping by a filter coefficient reading module, multiplying and accumulating the input signals and the filter coefficients, performing data folding calculation by a data folding module, performing filter calculation on the folded data and the filter coefficients by a filter calculating module, and outputting filtered signals with selectable pass bands.
The filter coefficient meeting the design index can be determined by utilizing tools such as Matlab and the like, and for an M-order filter, only the coefficient is required to be determined
Symmetrical filter coefficients are stored in ROM memory bank in sequence, each group of coefficients occupying
A memory address. The filter coefficients are finite word lengths that determine the quantization error during filtering, and the filter coefficient word length in this embodiment is a 12-bit binary number. According to the filter window function type, the pass band type, the bandwidth and other filter characteristic indexes determined by the control parameters, D is inquired through address mapping
coefReading the front of a ROM bank
The coefficients of the M order filter window function.
See fig. 2. The M-order filter forms its output by a weighted sum of current and past input values, the output at any point in time being associated with only one window containing the latest M input values, which for a sampled data stream need to be stored first in a memory of depth M, respectively data D
0、D
1、D
2… …, up to D
126、D
127Until now. Because the window function coefficient is symmetrical, the input value and the symmetrical coefficient are multiplied, and the result also has symmetry, the M input values can be firstly subjected to data folding calculation, the data folding module is subjected to data folding calculation according to the input signal, and the filtering calculation module is used for carrying out data folding calculation on the folded input values
Data sum
The filter coefficients are subjected to filter calculation. After the calculation of the data folding, the data folding is performed,data folding module output data y
0:
Wherein A is
iBefore the M-order filter
The ith coefficient, S, of the coefficients
iRepresenting the ith fold value obtained after the data folding calculation. As shown in FIG. 2, when the order M is 128, the data folding module firstly inputs the 1 st input data D
0And 128 th input data D
127Adding to obtain data S
0Then, the 2 nd input data D is inputted
1And 127 th input data D
126Adding to obtain data S
1And so on, and finally the 64 th input data D
63And 65 th input data D
64Adding to obtain data S
63And completing the data folding calculation. When the filtering calculation of the output signal of the latest point is finished, reading a new data sampling value delayed by one sampling period, namely data D in the memory with the depth of M
0、D
1、D
2……D
126、D
127Shifting one bit, performing data folding calculation of the next output signal to obtain data S
0、S
1、S
2……S
62、S
63And the step is circulated.
See fig. 3. The filtering calculation module carries out filtering calculation on the folded data and the filtering coefficient, outputs a filtered signal, and for an M-order filter with symmetrical coefficients, folds the data after the data folding module
Data sum
And carrying out filtering calculation on the filter coefficients, and outputting the product accumulated value of M data stream sampling values and M symmetrical filter coefficients at the current moment:
wherein A is
iRepresenting the ith coefficient of the M order filter coefficients, where x [ n-i ]]Representing the M input signal sample values prior to the delay of i sample periods. The adder and multiplier of the filter have a fast enough operation speed to complete the calculation of the current output signal before the next sample data, that is, the calculation of the current filter value is completed within a delay of one sampling period, and the data is truncated in the middle of each stage of calculation to adapt to the balance of data resolution, dynamic range, hardware resource consumption, calculation time and the like.
The following is a concrete analysis by way of example: storing filter coefficients of different bandwidths of a 128-order symmetric rectangular window low-pass FIR filter in advance in a filter coefficient ROM, and the intermediate frequency carrier frequency f of an input signalcarry20MHz, a spreading frequency Rc of 10.23MHz, a sampling frequency fadAt 90MHz, the signal-to-noise ratio C/N0 was 20 dB. After down-conversion and frequency mixing, the filter designed by the invention is used for low-pass filtering, and the program control parameters select a rectangular window function, the low-pass filter and the filtering bandwidth is 11 MHz. Through experiments, the example finally obtains correct filtered data.
While the present invention has been described in detail with reference to the embodiments, it will be apparent to one skilled in the art that various changes can be made in the embodiments without departing from the spirit and scope of the invention.