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

Subversion Repositories gng

[/] [gng/] [trunk/] [rtl/] [gng_ctg.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 guangxi.li
//------------------------------------------------------------------------------
2
//
3
// gng_ctg.v
4
//
5
// This file is part of the Gaussian Noise Generator IP Core
6
//
7
// Description
8
//     Maximally equidistributed combined Tausworthe generator with
9
// (k1,k2,k3) = (63,58,55); (q1,q2,q3) = (5,19,24); (s1,s2,s3) = (24,13,7).
10
// Period is approximately 2^176.
11
//
12
//------------------------------------------------------------------------------
13
//
14
// Copyright (C) 2014, Guangxi Liu <guangxi.liu@opencores.org>
15
//
16
// This source file may be used and distributed without restriction provided
17
// that this copyright statement is not removed from the file and that any
18
// derivative work contains the original copyright notice and the associated
19
// disclaimer.
20
//
21
// This source file is free software; you can redistribute it and/or modify it
22
// under the terms of the GNU Lesser General Public License as published by
23
// the Free Software Foundation; either version 2.1 of the License,
24
// or (at your option) any later version.
25
//
26
// This source is distributed in the hope that it will be useful, but
27
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
28
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
29
// License for more details.
30
//
31
// You should have received a copy of the GNU Lesser General Public License
32
// along with this source; if not, download it from
33
// http://www.opencores.org/lgpl.shtml
34
//
35
//------------------------------------------------------------------------------
36
 
37
 
38
`timescale 1 ns / 1 ps
39
 
40
 
41
module gng_ctg #(
42
    parameter INIT_Z1 = 64'd5030521883283424767,
43
    parameter INIT_Z2 = 64'd18445829279364155008,
44
    parameter INIT_Z3 = 64'd18436106298727503359
45
)
46
(
47
    // System signals
48
    input clk,                    // system clock
49
    input rstn,                   // system synchronous reset, active low
50
 
51
    // Data interface
52
    input ce,                     // clock enable
53
    output reg valid_out,         // output data valid
54
    output reg [63:0] data_out    // output data
55
);
56
 
57
// Local variables
58
reg [63:0] z1, z2, z3;
59
wire [63:0] z1_next, z2_next, z3_next;
60
 
61
 
62
// Update state
63
assign z1_next = {z1[39:1], z1[58:34] ^ z1[63:39]};
64
assign z2_next = {z2[50:6], z2[44:26] ^ z2[63:45]};
65
assign z3_next = {z3[56:9], z3[39:24] ^ z3[63:48]};
66
 
67
always @ (posedge clk) begin
68
    if (!rstn) begin
69
        z1 <= INIT_Z1;
70
        z2 <= INIT_Z2;
71
        z3 <= INIT_Z3;
72
    end
73
    else if (ce) begin
74
        z1 <= z1_next;
75
        z2 <= z2_next;
76
        z3 <= z3_next;
77
    end
78
end
79
 
80
 
81
// Output data
82
always @ (posedge clk) begin
83
    if (!rstn)
84
        valid_out <= 1'b0;
85
    else
86
        valid_out <= ce;
87
end
88
 
89
always @ (posedge clk) begin
90
    if (!rstn)
91
        data_out <= 64'd0;
92
    else
93
        data_out <= z1_next ^ z2_next ^ z3_next;
94
end
95
 
96
 
97
endmodule

powered by: WebSVN 2.1.0

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