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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [verilog/] [ocidec-1/] [ro_cnt.v] - Diff between revs 15 and 22

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 15 Rev 22
Line 1... Line 1...
 
/////////////////////////////////////////////////////////////////////
 
////                                                             ////
 
////  Run-Once counter                                           ////
 
////                                                             ////
 
////  Author: Richard Herveille                                  ////
 
////          richard@asics.ws                                   ////
 
////          www.asics.ws                                       ////
 
////                                                             ////
 
/////////////////////////////////////////////////////////////////////
 
////                                                             ////
 
//// Copyright (C) 2001, 2002 Richard Herveille                  ////
 
////                          richard@asics.ws                   ////
 
////                                                             ////
 
//// This source file may be used and distributed without        ////
 
//// restriction provided that this copyright statement is not   ////
 
//// removed from the file and that any derivative work contains ////
 
//// the original copyright notice and the associated disclaimer.////
 
////                                                             ////
 
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
 
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
 
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
 
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
 
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
 
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
 
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
 
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
 
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
 
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
 
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
 
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
 
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
 
////                                                             ////
 
/////////////////////////////////////////////////////////////////////
 
 
 
//  CVS Log
 
//
 
//  $Id: ro_cnt.v,v 1.2 2002-02-16 10:42:17 rherveille Exp $
//
//
// Counter.v, contains 1) run-once down-counter  2) general purpose up-down riple-carry counter
//  $Date: 2002-02-16 10:42:17 $
 
//  $Revision: 1.2 $
 
//  $Author: rherveille $
 
//  $Locker:  $
 
//  $State: Exp $
//
//
// Author: Richard Herveille
// Change History:
// Rev. 1.0 June 27th, 2001. Initial Verilog release
//               $Log: not supported by cvs2svn $
// Rev. 1.1 July  2nd, 2001. Fixed incomplete port list.
 
//
//
 
 
 
 
///////////////////////////
///////////////////////////
// run-once down-counter //
// run-once down-counter //
///////////////////////////
///////////////////////////
 
 
// counts D+1 cycles before generating 'DONE'
// counts D+1 cycles before generating 'DONE'
 
 
`include "timescale.v"
`include "timescale.v"
 
 
module ro_cnt (clk, nReset, rst, cnt_en, go, done, d, q, id);
module ro_cnt (clk, nReset, rst, cnt_en, go, done, d, q);
 
 
        // parameter declaration
        // parameter declaration
        parameter SIZE = 8;
        parameter SIZE = 8;
 
 
 
        parameter UD = 1'b0;         // default count down
 
        parameter ID = {SIZE{1'b0}}; // initial data after reset
 
 
        // inputs & outputs
        // inputs & outputs
        input  clk;           // master clock
        input  clk;           // master clock
        input  nReset;        // asynchronous active low reset
        input  nReset;        // asynchronous active low reset
        input  rst;           // synchronous active high reset
        input  rst;           // synchronous active high reset
        input  cnt_en;        // count enable
        input  cnt_en;        // count enable
        input  go;            // load counter and start sequence
        input  go;            // load counter and start sequence
        output done;          // done counting
        output done;          // done counting
        input  [SIZE-1:0] d;  // load counter value
        input  [SIZE-1:0] d;  // load counter value
        output [SIZE-1:0] q;  // current counter value
        output [SIZE-1:0] q;  // current counter value
        input  [SIZE-1:0] id; // initial data after reset
 
 
 
        // variable declarations
        // variable declarations
        reg rci;
        reg rci;
        wire nld, rco;
        wire nld, rco;
 
 
Line 39... Line 84...
        always@(posedge clk or negedge nReset)
        always@(posedge clk or negedge nReset)
                if (~nReset)
                if (~nReset)
                        rci <= #1 1'b0;
                        rci <= #1 1'b0;
                else if (rst)
                else if (rst)
                        rci <= #1 1'b0;
                        rci <= #1 1'b0;
                else if (cnt_en)
                else //if (cnt_en)
                        rci <= #1 (go | rci) & !rco;
                        rci <= #1 go | (rci & !rco);
 
 
        assign nld = !go;
        assign nld = !go;
 
 
        // hookup counter
        // hookup counter
        ud_cnt #(SIZE) cnt (.clk(clk), .nReset(nReset), .rst(rst), .cnt_en(cnt_en),
        ud_cnt #(SIZE, ID) cnt (.clk(clk), .nReset(nReset), .rst(rst), .cnt_en(cnt_en),
                .ud(1'b0), .nld(nld), .d(d), .q(q), .resd(id), .rci(rci), .rco(rco));
                .ud(UD), .nld(nld), .d(d), .q(q), .rci(rci), .rco(rco));
 
 
 
 
        // assign outputs
        // assign outputs
 
 
        assign done = rco;
        assign done = rco;
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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