OpenCores
URL https://opencores.org/ocsvn/gng/gng/trunk

Subversion Repositories gng

[/] [gng/] [trunk/] [tb/] [tb_gng.sv] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 guangxi.li
//------------------------------------------------------------------------------
2
//
3
// tb_gng.sv
4
//
5
// This file is part of the Gaussian Noise Generator IP Core
6
//
7
// Description
8
//     Systemverilog testbench for module gng. Generate noise sequences of
9
// length N and output to file.
10
//
11
//------------------------------------------------------------------------------
12
//
13
// Copyright (C) 2014, Guangxi Liu 
14
//
15
// This source file may be used and distributed without restriction provided
16
// that this copyright statement is not removed from the file and that any
17
// derivative work contains the original copyright notice and the associated
18
// disclaimer.
19
//
20
// This source file is free software; you can redistribute it and/or modify it
21
// under the terms of the GNU Lesser General Public License as published by
22
// the Free Software Foundation; either version 2.1 of the License,
23
// or (at your option) any later version.
24
//
25
// This source is distributed in the hope that it will be useful, but
26
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
28
// License for more details.
29
//
30
// You should have received a copy of the GNU Lesser General Public License
31
// along with this source; if not, download it from
32
// http://www.opencores.org/lgpl.shtml
33
//
34
//------------------------------------------------------------------------------
35
 
36
 
37
`timescale 1 ns / 1 ps
38
 
39
 
40
module tb_gng;
41
 
42
// Parameters
43
parameter ClkPeriod = 10.0;
44 13 guangxi.li
parameter Dly = 1.0;
45 3 guangxi.li
parameter N = 1000000;
46 2 guangxi.li
 
47
 
48
// Local variables
49
logic clk;
50
logic rstn;
51
logic ce;
52
logic valid_out;
53
logic [15:0] data_out;
54
 
55
 
56
// Instances
57
gng #(
58
   .INIT_Z1(64'd5030521883283424767),
59
   .INIT_Z2(64'd18445829279364155008),
60
   .INIT_Z3(64'd18436106298727503359)
61
)
62
u_gng (.*);
63
 
64
 
65
// System signals
66
initial begin
67
    clk <= 1'b0;
68
    forever #(ClkPeriod/2) clk = ~clk;
69
end
70
 
71
initial begin
72
    rstn <= 1'b0;
73
    #(ClkPeriod*2) rstn = 1'b1;
74
end
75
 
76
 
77
// Main process
78
int fpOut;
79
 
80
initial begin
81
    fpOut = $fopen("gng_data_out.txt", "w");
82
 
83
    ce = 0;
84
 
85
    #(ClkPeriod*10)
86
    repeat (N) begin
87
        @(posedge clk);
88 13 guangxi.li
        #(Dly);
89 2 guangxi.li
        ce = 1;
90
    end
91
    @(posedge clk);
92 13 guangxi.li
    #(Dly);
93 2 guangxi.li
    ce = 0;
94
 
95
    #(ClkPeriod*20)
96
    $fclose(fpOut);
97
    $stop;
98
end
99
 
100
 
101
// Record data
102
always_ff @ (negedge clk) begin
103
    if (valid_out)
104
        $fwrite(fpOut, "%0d\n", $signed(data_out));
105
end
106
 
107
 
108
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.