forked from xcore/sc_dsp_filters
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
540ad8f
commit 11caa90
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# The TARGET variable determines what target system the application is | ||
# compiled for. It either refers to an XN file in the source directories | ||
# or a valid argument for the --target option when compiling. | ||
|
||
TARGET = XDK | ||
|
||
# The APP_NAME variable determines the name of the final .xe file. It should | ||
# not include the .xe postfix. If left blank the name will default to | ||
# the project name | ||
|
||
APP_NAME = app_example_singel_fir | ||
|
||
# The flags passed to xcc when building the application | ||
# You can also set the following to override flags for a particular language: | ||
# | ||
# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS | ||
# | ||
# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to | ||
# xcc for the final link (mapping) stage. | ||
|
||
XCC_FLAGS = -O2 | ||
|
||
# The USED_MODULES variable lists other module used by the application. | ||
|
||
USED_MODULES = module_fir | ||
|
||
#============================================================================= | ||
# The following part of the Makefile includes the common build infrastructure | ||
# for compiling XMOS applications. You should not need to edit below here. | ||
|
||
|
||
# Use the main Makefile from module_xcommon | ||
-include ../module_xcommon/build/Makefile.common | ||
-include ../../xcommon/module_xcommon/build/Makefile.common | ||
|
||
# The final target of the build. This is usually dependent on a binary file | ||
# in the $(BIN_DIR) directory e.g. | ||
# | ||
# all : $(BIN_DIR)/my_app.xe | ||
|
||
all: $(BIN_DIR)/$(APP_NAME).xe | ||
@echo Build Complete | ||
|
||
clean: clean_common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* main.xc | ||
* | ||
* Created on: 14 okt 2011 | ||
* Author: Mikael Bohman | ||
*/ | ||
//FIR filter using a channel as Inut and Ouput running on 1 trhrad. Uses the double data method and Q8.24 | ||
|
||
#include <platform.h> | ||
#include <print.h> | ||
#include <xs1.h> | ||
#include <fir.h> | ||
|
||
#define sec XS1_TIMER_HZ | ||
#define ntaps 3000 //Number of FIT filter taps | ||
#define POLYNOMIAL 0xEDB88320 //Used for crc32 checksum | ||
|
||
|
||
|
||
int test_performance(streaming chanend c) { | ||
timer t; | ||
int time; | ||
unsigned crc = 0; | ||
int ans = 0, i = 1; | ||
printstrln("Testing performance, Running FIR-filter for 1 sec on a single thread with 3000 filter taps"); | ||
t:> time; | ||
c<:i; //Send first sample directly after the timing started | ||
time+=sec; | ||
while(1) { | ||
select { | ||
default: | ||
i++; | ||
c<:i; | ||
c:>ans; | ||
crc32(crc, ans, POLYNOMIAL); | ||
break; | ||
case t when timerafter (time) :> void: | ||
printstr("Filtered "); | ||
printint(i); | ||
printstrln(" samples during 1 second"); | ||
printint(i*3); | ||
printstrln(" kTaps per sec."); | ||
printstr("CRC32 checksum for all filtered samples was: 0x"); | ||
printhex(crc); | ||
soutct(c,10); //end FIR thread | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
int main() { | ||
streaming chan c; | ||
|
||
//Init the arrays | ||
int ans; | ||
|
||
unsigned crc = 0; | ||
unsigned samples; | ||
int x[2 * ntaps]; | ||
int h[ntaps]; | ||
for (int i = 0; i < ntaps; i++) { | ||
h[i] = (i + 1)<<24; | ||
x[i] = 0; | ||
x[i + ntaps] = 0; | ||
}par { | ||
firASM_DoubleData_singleThread(c, h, x, ntaps); | ||
samples = test_performance(c); | ||
} | ||
for (int i = 0; i < ntaps; i++) { | ||
x[i] = 0; | ||
} | ||
printstrln( | ||
"\nCalculating the CRC32 checksum from the XC implementation, this might take some time"); | ||
for (int i = 1; i < samples; i++) { | ||
ans = fir(i, h, x, ntaps); | ||
crc32(crc, ans, POLYNOMIAL); | ||
} | ||
printstr("Correct Checksum for filtered datasequence is: 0x"); | ||
printhex(crc); | ||
while (1); // Program doesn't halt correctly ?? | ||
|
||
return 0; | ||
} |