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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [verilog/] [ocidec-1/] [ro_cnt.v] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 rherveille
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Run-Once counter                                           ////
4
////                                                             ////
5
////  Author: Richard Herveille                                  ////
6
////          richard@asics.ws                                   ////
7
////          www.asics.ws                                       ////
8
////                                                             ////
9
/////////////////////////////////////////////////////////////////////
10
////                                                             ////
11
//// Copyright (C) 2001, 2002 Richard Herveille                  ////
12
////                          richard@asics.ws                   ////
13
////                                                             ////
14
//// This source file may be used and distributed without        ////
15
//// restriction provided that this copyright statement is not   ////
16
//// removed from the file and that any derivative work contains ////
17
//// the original copyright notice and the associated disclaimer.////
18
////                                                             ////
19
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
20
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
21
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
22
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
23
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
24
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
25
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
26
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
27
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
28
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
29
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
30
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
31
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
32
////                                                             ////
33
/////////////////////////////////////////////////////////////////////
34
 
35
//  CVS Log
36 15 rherveille
//
37 22 rherveille
//  $Id: ro_cnt.v,v 1.2 2002-02-16 10:42:17 rherveille Exp $
38 15 rherveille
//
39 22 rherveille
//  $Date: 2002-02-16 10:42:17 $
40
//  $Revision: 1.2 $
41
//  $Author: rherveille $
42
//  $Locker:  $
43
//  $State: Exp $
44 15 rherveille
//
45 22 rherveille
// Change History:
46
//               $Log: not supported by cvs2svn $
47
//
48 15 rherveille
 
49 22 rherveille
 
50 15 rherveille
///////////////////////////
51
// run-once down-counter //
52
///////////////////////////
53
 
54
// counts D+1 cycles before generating 'DONE'
55
 
56
`include "timescale.v"
57
 
58 22 rherveille
module ro_cnt (clk, nReset, rst, cnt_en, go, done, d, q);
59
 
60 15 rherveille
        // parameter declaration
61
        parameter SIZE = 8;
62 22 rherveille
 
63
        parameter UD = 1'b0;         // default count down
64
        parameter ID = {SIZE{1'b0}}; // initial data after reset
65
 
66 15 rherveille
        // inputs & outputs
67
        input  clk;           // master clock
68
        input  nReset;        // asynchronous active low reset
69
        input  rst;           // synchronous active high reset
70
        input  cnt_en;        // count enable
71
        input  go;            // load counter and start sequence
72
        output done;          // done counting
73
        input  [SIZE-1:0] d;  // load counter value
74
        output [SIZE-1:0] q;  // current counter value
75
 
76
        // variable declarations
77
        reg rci;
78
        wire nld, rco;
79
 
80
        //
81
        // module body
82
        //
83
 
84
        always@(posedge clk or negedge nReset)
85
                if (~nReset)
86
                        rci <= #1 1'b0;
87
                else if (rst)
88
                        rci <= #1 1'b0;
89 22 rherveille
                else //if (cnt_en)
90
                        rci <= #1 go | (rci & !rco);
91 15 rherveille
 
92
        assign nld = !go;
93
 
94
        // hookup counter
95 22 rherveille
        ud_cnt #(SIZE, ID) cnt (.clk(clk), .nReset(nReset), .rst(rst), .cnt_en(cnt_en),
96
                .ud(UD), .nld(nld), .d(d), .q(q), .rci(rci), .rco(rco));
97 15 rherveille
 
98 22 rherveille
 
99 15 rherveille
        // assign outputs
100 22 rherveille
 
101 15 rherveille
        assign done = rco;
102 22 rherveille
 
103 15 rherveille
endmodule
104 22 rherveille
 
105
 
106
 

powered by: WebSVN 2.1.0

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