module polyfilter(clk,clk2,reset,x_in,y_out);
parameter even = 0,odd =1;
input clk;
input clk2;
input reset;
input [7:0] x_in;
output [8:0] y_out;
reg [16:0] m0,m1,m2,m3,r0,r1,r2,r3;
reg [16:0] x33,x99,x107;
reg [16:0] y;
reg [7:0] x_odd,x_even,x_wait;
wire [16:0] x_odd_sxt,x_even_sxt;
reg state;
always @(posedge clk ) begin
if(!reset) begin
state <= odd;
x_even <= 0;
x_odd <= 0;
x_wait <= 0;
end
else begin
case(state)
even:begin
x_even <= x_in;
x_odd <= x_wait;
state <= odd;
end
odd: begin
x_wait <= x_in;
state <= even;
end
endcase
end
end
assign x_odd_sxt = {{9{x_odd[7]}},x_odd};
assign x_even_sxt = {{9{x_even[7]}},x_even};
always @(posedge clk) begin
if(!reset) begin
x33 =0;
x99 = 0;
x107 = 0;
m0 =0;
m1 = 0;
m2 =0;
m3 =0;
end
else begin
x33 = (x_odd_sxt << 5) + x_odd_sxt;
x99 = (x33 << 1) + x33;
x107 = x99 + (x_odd_sxt <<3);
m0 = (x_even_sxt << 7) - (x_even_sxt <<2);
m1 = x107 << 1;
m2 = (x_even_sxt << 6);
m3 = x33;
end
end
always @(posedge clk2) begin
if(!reset) begin
r0 <= 0 ;
r1 <= 0;
r2 <= 0;
r3 <= 0;
end
else begin
r0 <= r2 + m0;
r2 <= m2;
r1 <= -r3 + m1;
r3 <= m3;
y <= r0 + r1;
end
end
assign y_out = y[16:8];
endmodule
用户1069018 2015-9-28 16:47
自做自受 2014-1-17 22:56
用户377235 2014-1-6 09:11