superhet
Junior Member level 3
Code:
module fir_srg (clk, x, y); //----> Interface
input clk;
input [3:0] x;
output [3:0] y;
reg [3:0] y;
// Tapped delay line array of bytes
reg [3:0] tap0, tap1, tap2, tap3;
// For bit access use single vectors in Verilog
always @(posedge clk) //----> Behavioral Style
begin : p1
// Compute output y with the filter coefficients weight.
// The coefficients are [-1 3.75 3.75 -1].
// Multiplication and division for Altera MaxPlusII can
// be done in Verilog with sign extensions and shifts!
y <= (tap1<<1) + tap1 + {tap1[3],tap1[3:1]}
+ {tap1[3],tap1[3],tap1[3:2]} + (tap2<<1) + tap2
+ {tap2[3],tap2[3:1]}
+ {tap2[3],tap2[3],tap2[3:2]} - tap3 - tap0;
tap3 <= tap2; // Tapped delay line: shift one
tap2 <= tap1;
tap1 <= tap0;
tap0 <= x; // Input in register 0
end
endmodule
this is basically a 4 tap FIR filter. it was taken from the book "Digital Signal Processing with Field Programmable Gate Arrays" by Uwe Meyer.
the difficulty that i am having in understanding this code is in the always block. i understand the non-blocking assignments tap3 <= tap2 etc but i dont understand how y is calculated.
please help