URL
https://opencores.org/ocsvn/cic_core/cic_core/trunk
[/] [cic_core/] [trunk/] [sim/] [cic_d_tb.sv] - Blame information for rev 3
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
3 |
vadimuzzz |
`timescale 1ns / 1ns
|
2 |
|
|
package cmath;
|
3 |
|
|
import "DPI-C" function real sin(input real x);
|
4 |
|
|
endpackage
|
5 |
|
|
module cic_d_tb
|
6 |
|
|
(
|
7 |
|
|
);
|
8 |
|
|
localparam R = 25;
|
9 |
|
|
localparam idw = 16;
|
10 |
|
|
localparam odw = 16;
|
11 |
|
|
localparam M = 4;
|
12 |
|
|
localparam G = 1;
|
13 |
|
|
/*************************************************************/
|
14 |
|
|
localparam real Fs = 100;//MHz
|
15 |
|
|
localparam real T_ns = 10**3/Fs;//ns
|
16 |
|
|
localparam time half_T = T_ns/2;
|
17 |
|
|
localparam real f = 0.5;//MHz
|
18 |
|
|
localparam real f_inc = f/Fs;
|
19 |
|
|
localparam bias = 5;
|
20 |
|
|
real f_n = 0.0;
|
21 |
|
|
/*************************************************************/
|
22 |
|
|
reg clk;
|
23 |
|
|
reg reset_n;
|
24 |
|
|
reg signed[idw-1:0] filter_in;
|
25 |
|
|
wire filter_valid;
|
26 |
|
|
wire signed[odw-1:0] filter_out;
|
27 |
|
|
/*************************************************************/
|
28 |
|
|
import cmath::*;
|
29 |
|
|
/*************************************************************/
|
30 |
|
|
initial begin : clk_gen
|
31 |
|
|
clk <= 1'b0;
|
32 |
|
|
#half_T forever #half_T clk = ~clk;
|
33 |
|
|
end
|
34 |
|
|
/*************************************************************/
|
35 |
|
|
initial begin : reset_gen
|
36 |
|
|
$display($time, " << Starting the Simulation >>");
|
37 |
|
|
reset_n = 1'b0;
|
38 |
|
|
repeat (2) @(negedge clk);
|
39 |
|
|
$display($time, " << Coming out of reset >>");
|
40 |
|
|
reset_n = 1'b1;
|
41 |
|
|
repeat (20) @(posedge clk);
|
42 |
|
|
@(posedge clk);
|
43 |
|
|
end
|
44 |
|
|
/*************************************************************/
|
45 |
|
|
always @(posedge clk)
|
46 |
|
|
begin
|
47 |
|
|
f_n = f_n + f_inc;
|
48 |
|
|
end
|
49 |
|
|
/*************************************************************/
|
50 |
|
|
assign filter_in = $rtoi((2**(idw-1)-1)*($sin(f_n)));
|
51 |
|
|
/*************************************************************/
|
52 |
|
|
cic_d #(idw,odw,R,M,G) dut1
|
53 |
|
|
(
|
54 |
|
|
.clk(clk),
|
55 |
|
|
.reset_n(reset_n),
|
56 |
|
|
.data_in(filter_in),
|
57 |
|
|
.data_out(filter_out),
|
58 |
|
|
.out_dv(filter_valid)
|
59 |
|
|
);
|
60 |
|
|
/*************************************************************/
|
61 |
|
|
endmodule
|
62 |
|
|
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.