Skip to content

Commit

Permalink
Removed fixed arithmetic as it's been badly supported
Browse files Browse the repository at this point in the history
  • Loading branch information
berndporr committed Apr 15, 2024
1 parent 6e7e606 commit b9258f7
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 362 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.8.0)

project(fir VERSION 1.8.0 LANGUAGES CXX)

Expand All @@ -14,9 +14,6 @@ include(GNUInstallDirs)
add_subdirectory(demo)
add_subdirectory(test)

cmake_policy(SET CMP0048 NEW) # set VERSION in project()
cmake_policy(SET CMP0042 NEW) # enable MACOSX_RPATH by default

enable_testing()

if (MSVC)
Expand All @@ -27,11 +24,9 @@ endif()

set(LIBSRC
Fir1.cpp
Fir1fixed.cpp
)

set(LIBINCLUDE
Fir1fixed.h
Fir1.h
)

Expand Down
104 changes: 0 additions & 104 deletions Fir1fixed.cpp

This file was deleted.

130 changes: 0 additions & 130 deletions Fir1fixed.h

This file was deleted.

28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ f1 = 45
f2 = 55
b = signal.firwin(999,[f1/fs*2,f2/fs*2])
```
For fixed point you need to scale up the coefficients,
for example by 15 bits: b*32768.

#### octave/MATLAB:
```
Expand All @@ -125,8 +123,6 @@ octave:1> h=fir1(100,0.1);
which creates the coefficients of a lowpass filter with 100 taps
and normalised cutoff 0.1 to Nyquist.

Again, for fixed point "h" needs to be scaled.

### Initialisation

#### C++ floating point FIR filter:
Expand All @@ -145,14 +141,6 @@ with a constant value:
Fir1 moving_average(100,1.0/100);
```

#### C++ integer FIR filter:
```
Fir1fixed fir("h_fixed.dat",12);
```
where the coefficients have been scaled up by 2^12 and the
filter will scale them down by this amount (with the help of
a bitshift operation).

#### JAVA:
```
Fir1 fir = new Fir1(coeff);
Expand All @@ -172,11 +160,6 @@ f = fir1.Fir1(coeff)
double b = fir.filter(a);
```

#### C++ integer:
```
int b = fir.filter(a);
```

#### JAVA:
```
double b = fir.filter(a)
Expand Down Expand Up @@ -291,19 +274,16 @@ The commands under JAVA and Python are identical to C++.

## Demos
Demo programs are in the "demo" directory which show how to use the
filters for both floating point and fixed point.
filter.
1. `firdemo` sends an impulse into the filter and you should see the impulse
response at its output.
2. `fixeddemo` filters an example ECG with 50Hz noise. The coefficients
are 12 bit and you can generate them either with OCTAVE/MATLAB or Python.
The scripts are also provided.
3. `lmsdemo` filters out 50Hz noise from an ECG with the help of
2. `lmsdemo` filters out 50Hz noise from an ECG with the help of
adaptive filtering by using the 50Hz powerline frequency as the input
to the filter. This can be replaced by any reference artefact signal
or signal which is correlated with the artefact.
4. JAVA has an `InstrumentedTest` which filters both a delta pulse and
3. JAVA has an `InstrumentedTest` which filters both a delta pulse and
a step function.
5. filter_ecg.py performs the filtering of an ECG in python using
4. filter_ecg.py performs the filtering of an ECG in python using
the fir1 python module which in turn calls internally the C++ functions.

## C++ documentation
Expand Down
6 changes: 1 addition & 5 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.8.0)

project(FIRdemo)

Expand All @@ -17,10 +17,6 @@ add_executable (coeffarraydemo coeffarraydemo.cpp)
target_link_libraries(coeffarraydemo fir_static)
target_include_directories(coeffarraydemo PRIVATE ..)

add_executable (fixeddemo fixeddemo.cpp)
target_link_libraries(fixeddemo fir_static)
target_include_directories(fixeddemo PRIVATE ..)

add_executable (lmsdemo lmsdemo.cpp)
target_link_libraries(lmsdemo fir_static)
target_include_directories(lmsdemo PRIVATE ..)
1 change: 0 additions & 1 deletion demo/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
firdemo: sends an impulse response through the filter (floating point)
fixeddemo: sends an ECG with 50Hz noise through the fixed point filter
lmsdemo: removes 50Hz with the help of adaptive filter using LMS
filter_ecg.py: Pure python program which loads the fir1 module to filter 50Hz
Loading

0 comments on commit b9258f7

Please sign in to comment.