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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [registers.v] - Blame information for rev 22

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

Line No. Rev Author Line
1 3 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Versatile library, registers                                ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Different type of registers                                 ////
7
////                                                              ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   - add more different registers                             ////
11
////                                                              ////
12
////  Author(s):                                                  ////
13
////      - Michael Unneback, unneback@opencores.org              ////
14
////        ORSoC AB                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2010 Authors and OPENCORES.ORG                 ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
 
43 18 unneback
module vl_dff ( d, q, clk, rst);
44 3 unneback
 
45
        parameter width = 1;
46
        parameter reset_value = 0;
47
 
48
        input [width-1:0] d;
49
        input clk, rst;
50
        output reg [width-1:0] q;
51
 
52
        always @ (posedge clk or posedge rst)
53
        if (rst)
54
                q <= reset_value;
55
        else
56
                q <= d;
57
 
58
endmodule
59
 
60 18 unneback
module vl_dff_array ( d, q, clk, rst);
61 5 unneback
 
62
        parameter width = 1;
63
        parameter depth = 2;
64
        parameter reset_value = 1'b0;
65
 
66
        input [width-1:0] d;
67
        input clk, rst;
68
        output [width-1:0] q;
69
        reg  [0:depth-1] q_tmp [width-1:0];
70
        integer i;
71
        always @ (posedge clk or posedge rst)
72
        if (rst) begin
73
            for (i=0;i<depth;i=i+1)
74
                q_tmp[i] <= {width{reset_value}};
75
        end else begin
76
            q_tmp[0] <= d;
77
            for (i=1;i<depth;i=i+1)
78
                q_tmp[i] <= q_tmp[i-1];
79
        end
80
 
81
    assign q = q_tmp[depth-1];
82
 
83
endmodule
84
 
85 18 unneback
module vl_dff_ce ( d, ce, q, clk, rst);
86 3 unneback
 
87
        parameter width = 1;
88
        parameter reset_value = 0;
89
 
90
        input [width-1:0] d;
91
        input ce, clk, rst;
92
        output reg [width-1:0] q;
93
 
94
        always @ (posedge clk or posedge rst)
95
        if (rst)
96
                q <= reset_value;
97
        else
98
                if (ce)
99
                        q <= d;
100
 
101
endmodule
102
 
103 18 unneback
module vl_dff_ce_clear ( d, ce, clear, q, clk, rst);
104 8 unneback
 
105
        parameter width = 1;
106
        parameter reset_value = 0;
107
 
108
        input [width-1:0] d;
109 10 unneback
        input ce, clear, clk, rst;
110 8 unneback
        output reg [width-1:0] q;
111
 
112
        always @ (posedge clk or posedge rst)
113
        if (rst)
114
            q <= reset_value;
115
        else
116
            if (ce)
117
                if (clear)
118
                    q <= {width{1'b0}};
119
                else
120
                    q <= d;
121
 
122
endmodule
123
 
124 3 unneback
`ifdef ALTERA
125
// megafunction wizard: %LPM_FF%
126
// GENERATION: STANDARD
127
// VERSION: WM1.0
128
// MODULE: lpm_ff 
129
 
130
// ============================================================
131
// File Name: dff_sr.v
132
// Megafunction Name(s):
133
//                      lpm_ff
134
//
135
// Simulation Library Files(s):
136
//                      lpm
137
// ============================================================
138
// ************************************************************
139
// THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE!
140
//
141
// 9.1 Build 304 01/25/2010 SP 1 SJ Full Version
142
// ************************************************************
143
 
144
 
145
//Copyright (C) 1991-2010 Altera Corporation
146
//Your use of Altera Corporation's design tools, logic functions 
147
//and other software and tools, and its AMPP partner logic 
148
//functions, and any output files from any of the foregoing 
149
//(including device programming or simulation files), and any 
150
//associated documentation or information are expressly subject 
151
//to the terms and conditions of the Altera Program License 
152
//Subscription Agreement, Altera MegaCore Function License 
153
//Agreement, or other applicable license agreement, including, 
154
//without limitation, that your use is for the sole purpose of 
155
//programming logic devices manufactured by Altera and sold by 
156
//Altera or its authorized distributors.  Please refer to the 
157
//applicable agreement for further details.
158
 
159
 
160
// synopsys translate_off
161
`timescale 1 ps / 1 ps
162
// synopsys translate_on
163 18 unneback
module vl_dff_sr (
164 3 unneback
        aclr,
165
        aset,
166
        clock,
167
        data,
168
        q);
169
 
170
        input     aclr;
171
        input     aset;
172
        input     clock;
173
        input     data;
174
        output    q;
175
 
176
        wire [0:0] sub_wire0;
177
        wire [0:0] sub_wire1 = sub_wire0[0:0];
178
        wire  q = sub_wire1;
179
        wire  sub_wire2 = data;
180
        wire  sub_wire3 = sub_wire2;
181
 
182
        lpm_ff  lpm_ff_component (
183
                                .aclr (aclr),
184
                                .clock (clock),
185
                                .data (sub_wire3),
186
                                .aset (aset),
187
                                .q (sub_wire0)
188
                                // synopsys translate_off
189
                                ,
190
                                .aload (),
191
                                .enable (),
192
                                .sclr (),
193
                                .sload (),
194
                                .sset ()
195
                                // synopsys translate_on
196
                                );
197
        defparam
198
                lpm_ff_component.lpm_fftype = "DFF",
199
                lpm_ff_component.lpm_type = "LPM_FF",
200
                lpm_ff_component.lpm_width = 1;
201
 
202
 
203
endmodule
204
 
205
// ============================================================
206
// CNX file retrieval info
207
// ============================================================
208
// Retrieval info: PRIVATE: ACLR NUMERIC "1"
209
// Retrieval info: PRIVATE: ALOAD NUMERIC "0"
210
// Retrieval info: PRIVATE: ASET NUMERIC "1"
211
// Retrieval info: PRIVATE: ASET_ALL1 NUMERIC "1"
212
// Retrieval info: PRIVATE: CLK_EN NUMERIC "0"
213
// Retrieval info: PRIVATE: DFF NUMERIC "1"
214
// Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone IV E"
215
// Retrieval info: PRIVATE: SCLR NUMERIC "0"
216
// Retrieval info: PRIVATE: SLOAD NUMERIC "0"
217
// Retrieval info: PRIVATE: SSET NUMERIC "0"
218
// Retrieval info: PRIVATE: SSET_ALL1 NUMERIC "1"
219
// Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0"
220
// Retrieval info: PRIVATE: UseTFFdataPort NUMERIC "0"
221
// Retrieval info: PRIVATE: nBit NUMERIC "1"
222
// Retrieval info: CONSTANT: LPM_FFTYPE STRING "DFF"
223
// Retrieval info: CONSTANT: LPM_TYPE STRING "LPM_FF"
224
// Retrieval info: CONSTANT: LPM_WIDTH NUMERIC "1"
225
// Retrieval info: USED_PORT: aclr 0 0 0 0 INPUT NODEFVAL aclr
226
// Retrieval info: USED_PORT: aset 0 0 0 0 INPUT NODEFVAL aset
227
// Retrieval info: USED_PORT: clock 0 0 0 0 INPUT NODEFVAL clock
228
// Retrieval info: USED_PORT: data 0 0 0 0 INPUT NODEFVAL data
229
// Retrieval info: USED_PORT: q 0 0 0 0 OUTPUT NODEFVAL q
230
// Retrieval info: CONNECT: @clock 0 0 0 0 clock 0 0 0 0
231
// Retrieval info: CONNECT: q 0 0 0 0 @q 0 0 1 0
232
// Retrieval info: CONNECT: @aclr 0 0 0 0 aclr 0 0 0 0
233
// Retrieval info: CONNECT: @aset 0 0 0 0 aset 0 0 0 0
234
// Retrieval info: CONNECT: @data 0 0 1 0 data 0 0 0 0
235
// Retrieval info: LIBRARY: lpm lpm.lpm_components.all
236
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr.v TRUE
237
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr.inc FALSE
238
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr.cmp FALSE
239
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr.bsf FALSE
240
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr_inst.v FALSE
241
// Retrieval info: GEN_FILE: TYPE_NORMAL dff_sr_bb.v FALSE
242
// Retrieval info: LIB_FILE: lpm
243
 
244
 
245
`else
246
 
247
 
248 18 unneback
module vl_dff_sr ( aclr, aset, clock, data, q);
249 3 unneback
 
250
    input         aclr;
251
    input         aset;
252
    input         clock;
253
    input         data;
254
    output reg    q;
255
 
256
   always @ (posedge clock or posedge aclr or posedge aset)
257
     if (aclr)
258
       q <= 1'b0;
259
     else if (aset)
260
       q <= 1'b1;
261
     else
262
       q <= data;
263
 
264
endmodule
265
 
266
`endif
267 5 unneback
 
268
// LATCH
269
// For targtes not supporting LATCH use dff_sr with clk=1 and data=1
270
`ifdef ALTERA
271 18 unneback
module vl_latch ( d, le, q, clk);
272 5 unneback
input d, le;
273
output q;
274
input clk;
275
dff_sr i0 (.aclr(), .aset(), .clock(1'b1), .data(1'b1), .q(q));
276
endmodule
277
`else
278
module latch ( d, le, q, clk);
279
input d, le;
280
output q;
281
input clk;/*
282
   always @ (posedge direction_set or posedge direction_clr)
283
     if (direction_clr)
284
       direction <= going_empty;
285
     else
286
       direction <= going_full;*/
287
endmodule
288 15 unneback
`endif
289
 
290 18 unneback
module vl_shreg ( d, q, clk, rst);
291 17 unneback
parameter depth = 10;
292
input d;
293
output q;
294
input clk, rst;
295
 
296
reg [1:depth] dffs;
297
 
298
always @ (posedge clk or posedge rst)
299
if (rst)
300
    dffs <= {depth{1'b0}};
301
else
302
    dffs <= {d,dffs[1:depth-1]};
303
assign q = dffs[depth];
304
endmodule
305
 
306 18 unneback
module vl_shreg_ce ( d, ce, q, clk, rst);
307 17 unneback
parameter depth = 10;
308
input d, ce;
309
output q;
310
input clk, rst;
311
 
312
reg [1:depth] dffs;
313
 
314
always @ (posedge clk or posedge rst)
315
if (rst)
316
    dffs <= {depth{1'b0}};
317
else
318
    if (ce)
319
        dffs <= {d,dffs[1:depth-1]};
320
assign q = dffs[depth];
321
endmodule
322
 
323 18 unneback
module vl_delay ( d, q, clk, rst);
324 15 unneback
parameter depth = 10;
325
input d;
326
output q;
327
input clk, rst;
328
 
329
reg [1:depth] dffs;
330
 
331
always @ (posedge clk or posedge rst)
332
if (rst)
333
    dffs <= {depth{1'b0}};
334
else
335
    dffs <= {d,dffs[1:depth-1]};
336
assign q = dffs[depth];
337 17 unneback
endmodule
338
 
339 18 unneback
module vl_delay_emptyflag ( d, q, emptyflag, clk, rst);
340 17 unneback
parameter depth = 10;
341
input d;
342
output q, emptyflag;
343
input clk, rst;
344
 
345
reg [1:depth] dffs;
346
 
347
always @ (posedge clk or posedge rst)
348
if (rst)
349
    dffs <= {depth{1'b0}};
350
else
351
    dffs <= {d,dffs[1:depth-1]};
352
assign q = dffs[depth];
353
assign emptyflag = !(|dffs);
354
endmodule

powered by: WebSVN 2.1.0

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