1 |
2 |
vladimirar |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Low Pass Filter FIR IP Core ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the LPFFIR project ////
|
6 |
|
|
//// https://opencores.org/projects/lpffir ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// Implementation of LPFFIR IP core according to ////
|
10 |
|
|
//// LPFFIR IP core specification document. ////
|
11 |
|
|
//// ////
|
12 |
|
|
//// To Do: ////
|
13 |
|
|
//// - ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// Author: ////
|
16 |
|
|
//// - Vladimir Armstrong, vladimirarmstrong@opencores.org ////
|
17 |
|
|
//// ////
|
18 |
|
|
//////////////////////////////////////////////////////////////////////
|
19 |
|
|
//// ////
|
20 |
|
|
//// Copyright (C) 2019 Authors and OPENCORES.ORG ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// This source file may be used and distributed without ////
|
23 |
|
|
//// restriction provided that this copyright statement is not ////
|
24 |
|
|
//// removed from the file and that any derivative work contains ////
|
25 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source file is free software; you can redistribute it ////
|
28 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
29 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
30 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
31 |
|
|
//// later version. ////
|
32 |
|
|
//// ////
|
33 |
|
|
//// This source is distributed in the hope that it will be ////
|
34 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
35 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
36 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
37 |
|
|
//// details. ////
|
38 |
|
|
//// ////
|
39 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
40 |
|
|
//// Public License along with this source; if not, download it ////
|
41 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
42 |
|
|
//// ////
|
43 |
|
|
//////////////////////////////////////////////////////////////////////
|
44 |
|
|
|
45 |
|
|
// Verilog test bench
|
46 |
|
|
module bench (
|
47 |
|
|
input clk,
|
48 |
|
|
input rst
|
49 |
|
|
);
|
50 |
|
|
|
51 |
|
|
// Test case #1: check impulse response of low-pass filter.
|
52 |
|
|
logic [15:0] in = (count == 1) ? 1:0;
|
53 |
|
|
logic [15:0] out;
|
54 |
|
|
reg [31:0] count;
|
55 |
|
|
|
56 |
|
|
always_ff @(posedge clk or posedge rst)
|
57 |
|
|
if (rst)
|
58 |
|
|
count <= 0;
|
59 |
|
|
else
|
60 |
|
|
count <= count + 1;
|
61 |
|
|
|
62 |
|
|
// unit under test(UUT)
|
63 |
|
|
lpffir_core lpffir_core(.x_i(in),.clk_i(clk),.y_o(out));
|
64 |
|
|
|
65 |
|
|
// Test case log
|
66 |
|
|
initial begin
|
67 |
|
|
$display("Test Case #1:");
|
68 |
|
|
$display("Check impulse response of low-pass filter.");
|
69 |
|
|
$display("RTL simulation results:");
|
70 |
|
|
$display("Input Output");
|
71 |
|
|
$display("----- ------");
|
72 |
|
|
end
|
73 |
|
|
|
74 |
|
|
always_ff @(posedge clk or posedge rst)
|
75 |
|
|
if(!rst)
|
76 |
|
|
$display(" %0d %0d", in, out);
|
77 |
|
|
|
78 |
|
|
endmodule
|