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

Subversion Repositories rtf68ksys

[/] [rtf68ksys/] [trunk/] [rtl/] [verilog/] [down_counter.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 robfinch
// ============================================================================
2
//  down_counter.v
3
//  - counts down
4
//
5
//
6
//      2010  Robert Finch
7
//      pfingh>remove<@birdcomputer.ca
8
//
9
//
10
//  This source code is available for evaluation and validation purposes
11
//  only. This copyright statement and disclaimer must remain present in
12
//  the file.
13
//
14
//
15
//      NO WARRANTY.
16
//  THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER
17
//  EXPRESS OR IMPLIED. The user must assume the entire risk of using the
18
//  Work.
19
//
20
//  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
21
//  INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO
22
//  THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR.
23
//
24
//  IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK
25
//  IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN
26
//  REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN
27
//  LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU
28
//  AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR
29
//  LOSSES RELATING TO SUCH UNAUTHORIZED USE.
30
//
31
//
32
//      Verilog 1995
33
// ============================================================================
34
 
35
module down_counter(rst, clk, ce, ld, d, q, z);
36
parameter WID=8;
37
input rst;
38
input clk;
39
input ce;
40
input ld;
41
input [WID:1] d;
42
output [WID:1] q;
43
reg [WID:1] q;
44
output z;
45
 
46
always @(posedge clk)
47
        if (rst)
48
                q <= 0;
49
        else if (ce) begin
50
                if (ld)
51
                        q <= d;
52
                else
53
                        q <= q + {WID{1'b1}};
54
        end
55
 
56
assign z = q == 0;
57
 
58
endmodule

powered by: WebSVN 2.1.0

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