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

Subversion Repositories versatile_library

[/] [versatile_library/] [trunk/] [rtl/] [verilog/] [counters.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 3 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Versatile library, counters                                 ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  counters                                                    ////
7
////                                                              ////
8
////                                                              ////
9
////  To Do:                                                      ////
10
////   - add more counters                                        ////
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 4 unneback
module cnt_shreg_ce ( cke, q, rst, clk);
44
 
45
   parameter length = 4;
46
   input cke;
47
   output reg [0:length-1] q;
48
   input rst;
49
   input clk;
50
 
51
    always @ (posedge clk or posedge rst)
52
    if (rst)
53
        q <= {1'b1,{length-1{1'b0}}};
54
    else
55
        if (cke)
56
            q <= q >> 1;
57
 
58
endmodule
59
 
60
module cnt_shreg_ce_clear ( cke, clear, q, rst, clk);
61
 
62
   parameter length = 4;
63
   input cke;
64
   input clear;
65
   output reg [0:length-1] q;
66
   input rst;
67
   input clk;
68
 
69
    always @ (posedge clk or posedge rst)
70
    if (rst)
71
        q <= {1'b1,{length-1{1'b0}}};
72
    else
73
        if (cke)
74
            if (clear)
75
                q <= {1'b1,{length-1{1'b0}}};
76
            else
77
                q <= q >> 1;
78
 
79
endmodule
80
 
81
 

powered by: WebSVN 2.1.0

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