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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [scenario/] [3d/] [rand_delay_r.v] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 specular
//=======================================================================
2
// Project Monophony
3
//   Wire-Frame 3D Graphics Accelerator IP Core
4
//
5
// File:
6
//   rand_delay_r.v
7
//
8
// Abstract:
9
//   Pipeline delay module with reset
10
//       parameters :
11
//                WIDTH      data width (default value is 8)
12
//                NUM_DELAY  number of delay cycle  (default value is 8)
13
//
14
// Author:
15 4 specular
//   Kenji Ishimaru (info.wf3d@gmail.com)
16 2 specular
//
17
//======================================================================
18
//
19
// Copyright (c) 2015, Kenji Ishimaru
20
// All rights reserved.
21
//
22
// Redistribution and use in source and binary forms, with or without
23
// modification, are permitted provided that the following conditions are met:
24
//
25
//  -Redistributions of source code must retain the above copyright notice,
26
//   this list of conditions and the following disclaimer.
27
//  -Redistributions in binary form must reproduce the above copyright notice,
28
//   this list of conditions and the following disclaimer in the documentation
29
//   and/or other materials provided with the distribution.
30
//
31
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
33
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
35
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
38
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
40
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
41
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
//
43
// Revision History
44
 
45
module rand_delay_r (
46
    clk_core,
47
    rst_x,
48
    i_en,
49
    i_delay,
50
    i_data,
51
    o_data
52
);
53
 
54
////////////////////////////
55
// parameter
56
////////////////////////////
57
    parameter P_WIDTH     = 8;
58
    parameter P_NUM_DELAY = 8;
59
////////////////////////////
60
// I/O definition
61
////////////////////////////
62
    input                clk_core;
63
    input                rst_x;
64
    input                i_en;
65
    input  [7:0]          i_delay;
66
    input  [P_WIDTH-1:0] i_data;
67
    output [P_WIDTH-1:0] o_data;
68
 
69
 
70
////////////////////////////
71
// reg
72
////////////////////////////
73
    reg   [P_WIDTH-1:0] r_delay[0:P_NUM_DELAY-1];
74
 
75
////////////////////////////
76
// assign
77
////////////////////////////
78
    // in/out port connection
79
    assign o_data =  (i_delay < P_NUM_DELAY) ? r_delay[i_delay] :
80
                                               r_delay[P_NUM_DELAY-1];
81
////////////////////////////
82
// always
83
////////////////////////////
84
    always @(posedge clk_core) begin
85
        if (i_en) r_delay[0] <= i_data;
86
    end
87
 
88
    // delay register connection
89
    integer i;
90
    always @(posedge clk_core or negedge rst_x) begin
91
        if (!rst_x) begin
92
            if ( P_NUM_DELAY > 1 ) begin
93
                for ( i = 1; i < P_NUM_DELAY; i = i + 1) begin
94
                    r_delay[i] <= 0;
95
                end
96
            end
97
        end else begin
98
            if ( P_NUM_DELAY > 1 ) begin
99
                for ( i = 1; i < P_NUM_DELAY; i = i + 1) begin
100
                    if (i_en) r_delay[i] <= r_delay[i-1];
101
                end
102
            end
103
        end
104
    end
105
 
106
endmodule

powered by: WebSVN 2.1.0

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