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

Subversion Repositories rtftextcontroller

[/] [rtftextcontroller/] [trunk/] [rtl/] [verilog/] [delay.v] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2006-2020  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//
9
//      delay.v
10
//              - delays signals by so many clock cycles
11
//
12
// BSD 3-Clause License
13
// Redistribution and use in source and binary forms, with or without
14
// modification, are permitted provided that the following conditions are met:
15
//
16
// 1. Redistributions of source code must retain the above copyright notice, this
17
//    list of conditions and the following disclaimer.
18
//
19
// 2. Redistributions in binary form must reproduce the above copyright notice,
20
//    this list of conditions and the following disclaimer in the documentation
21
//    and/or other materials provided with the distribution.
22
//
23
// 3. Neither the name of the copyright holder nor the names of its
24
//    contributors may be used to endorse or promote products derived from
25
//    this software without specific prior written permission.
26
//
27
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//                                                                          
38
// ============================================================================
39
//
40
module delay1
41
        #(parameter WID = 1)
42
        (
43
        input clk,
44
        input ce,
45
        input [WID:1] i,
46
        output reg [WID:1] o
47
        );
48
 
49
        always @(posedge clk)
50
                if (ce)
51
                        o <= i;
52
 
53
endmodule
54
 
55
 
56
module delay2
57
        #(parameter WID = 1)
58
        (
59
        input clk,
60
        input ce,
61
        input [WID:1] i,
62
        output reg [WID:1] o
63
        );
64
 
65
 
66
        reg     [WID:1] r1;
67
 
68
        always @(posedge clk)
69
                if (ce)
70
                        r1 <= i;
71
 
72
        always @(posedge clk)
73
                if (ce)
74
                        o <= r1;
75
 
76
endmodule
77
 
78
 
79
module delay3
80
        #(parameter WID = 1)
81
        (
82
        input clk,
83
        input ce,
84
        input [WID:1] i,
85
        output reg [WID:1] o
86
        );
87
 
88
        reg     [WID:1] r1, r2;
89
 
90
        always @(posedge clk)
91
                if (ce)
92
                        r1 <= i;
93
 
94
        always @(posedge clk)
95
                if (ce)
96
                        r2 <= r1;
97
 
98
        always @(posedge clk)
99
                if (ce)
100
                        o <= r2;
101
 
102
endmodule
103
 
104
module delay4
105
        #(parameter WID = 1)
106
        (
107
        input clk,
108
        input ce,
109
        input [WID-1:0] i,
110
        output reg [WID-1:0] o
111
        );
112
 
113
        reg     [WID-1:0] r1, r2, r3;
114
 
115
        always @(posedge clk)
116
                if (ce)
117
                        r1 <= i;
118
 
119
        always @(posedge clk)
120
                if (ce)
121
                        r2 <= r1;
122
 
123
        always @(posedge clk)
124
                if (ce)
125
                        r3 <= r2;
126
 
127
        always @(posedge clk)
128
                if (ce)
129
                        o <= r3;
130
 
131
endmodule
132
 
133
 
134
module delay5
135
#(parameter WID = 1)
136
(
137
        input clk,
138
        input ce,
139
        input [WID:1] i,
140
        output reg [WID:1] o
141
);
142
 
143
        reg     [WID:1] r1, r2, r3, r4;
144
 
145
        always @(posedge clk)
146
                if (ce) r1 <= i;
147
 
148
        always @(posedge clk)
149
                if (ce) r2 <= r1;
150
 
151
        always @(posedge clk)
152
                if (ce) r3 <= r2;
153
 
154
        always @(posedge clk)
155
                if (ce) r4 <= r3;
156
 
157
        always @(posedge clk)
158
                if (ce) o <= r4;
159
 
160
endmodule
161
 
162
module delay6
163
#(parameter WID = 1)
164
(
165
        input clk,
166
        input ce,
167
        input [WID:1] i,
168
        output reg [WID:1] o
169
);
170
 
171
        reg     [WID:1] r1, r2, r3, r4, r5;
172
 
173
        always @(posedge clk)
174
                if (ce) r1 <= i;
175
 
176
        always @(posedge clk)
177
                if (ce) r2 <= r1;
178
 
179
        always @(posedge clk)
180
                if (ce) r3 <= r2;
181
 
182
        always @(posedge clk)
183
                if (ce) r4 <= r3;
184
 
185
        always @(posedge clk)
186
                if (ce) r5 <= r4;
187
 
188
        always @(posedge clk)
189
                if (ce) o <= r5;
190
 
191
endmodule
192
 
193
module delay(clk, ce, i, o);
194
parameter WID = 1;
195
parameter DEP = 1;
196
input clk;
197
input ce;
198
input [WID-1:0] i;
199
output [WID-1:0] o;
200
 
201
reg [WID-1:0] pldreg [0:DEP-1];
202
 
203
genvar g;
204
generate begin : gPipeline
205
  always @(posedge clk)
206
    if (ce) pldreg[0] <= i;
207
  for (g = 0; g < DEP - 1; g = g + 1)
208
    always @(posedge clk)
209
      if (ce) pldreg[g+1] <= pldreg[g];
210
  assign o = pldreg[DEP-1];
211
end
212
endgenerate
213
 
214
endmodule

powered by: WebSVN 2.1.0

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