Created
August 4, 2013 11:18
-
-
Save cryptix/6150074 to your computer and use it in GitHub Desktop.
PSHDL 4-tap Fir Filter
This file contains hidden or 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
// simple 4 tap fir | |
// coeff's are power of two | |
package de.tuhh.hbubert.noiseCancel; | |
module simpleFir { | |
param uint Width = 8; | |
@clock in bit clk; | |
@reset in bit rst; | |
in int<Width> x; | |
out register int<Width> y; | |
register(resetValue = {0,0,0,0}) int<Width> tap[4]; | |
// write output | |
// [1, 1, 1, 1] | |
y = tap[0] | |
+ tap[1] | |
+ tap[2] | |
+ tap[3]; | |
// how to const array? | |
//register(resetValue = {-1, 3.75, 3.75, -1}) int<Width> coeff[4]; | |
//y = coeff[0] * tap[0] | |
// + coeff[1] * tap[1] | |
// + coeff[2] * tap[2] | |
// + coeff[3] * tap[3]; | |
// low pass | |
// [-1, 3.75, 3.75, -1] | |
// y = | |
// -1 * tap[0] // -1 | |
// + 2* tap[1] + tap[1] + tap[1]/2 + tap[1]/4 // +3.75 | |
// + 2* tap[2] + tap[2] + tap[2]/2 + tap[2]/4 // +3.75 | |
// -1 * tap[3]; // -1 | |
// shift! | |
for (I={1:3}) { | |
tap[I] = tap[I-1]; | |
} | |
// read input | |
tap[0] = x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment