HierarchyFilesModulesSignalsTasksFunctionsHelp
/* -*-Verilog-*-
*******************************************************************************
*
* File:         count_to_x.v
* RCS:          $Header: $
* Description:  Count to X!
* Author:       Costas Calamvokis
* Language:     Verilog
* Package:      N/A
* Status:       Experimental (Do Not Distribute)
*
* Copyright (c) 1998 Costas Calamvokis, all rights reserved.
*
*******************************************************************************
*/

[Up: count_millennia m1]
module count_to_xIndex(
    clk,
    reset,
    enable,
    out);

parameter X=0;      // Note it doesn't actually get to X: it
                    //    counts 0,1,2...X-1,0,1..
parameter WIDTH=0;

input clk;
input reset;
input enable;
output [WIDTH-1:0] out;
reg    [WIDTH-1:0] out;


always @(posedge clk)
    begin
    if (reset) 
        begin
        out = 0;
        end
    else if (enable)
        begin
        if (out == (X-1))
            begin
            out = 0;
            end
        else
            begin
            out = out + 1;
            end
        end
    end

endmodule

/*
 *  Click on this link to go back to v2html home page: 
 *    http:../../../v2html.html
 */    

HierarchyFilesModulesSignalsTasksFunctionsHelp

This page: Maintained by: v2html730@burbleland.com
Created:Thu Jan 15 16:17:01 2009
From: ../verilog/count_to_x.v

Verilog converted to html by v2html 7.30.1.3 (written by Costas Calamvokis).Help