VERILOG

Verilog

Article by:
Date Published:
Last Modified:

Child Pages

  • Verilog Operators
  • Counters

    A 4-bit Counter In Verilog

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    
    module Count4Bit_v1_00 (
        output reg [3:0] count,
        output reg tc,
        input clock,
        input en,
        input reset
    );
        parameter period = 0;
    
        always @ (posedge clock)
    begin
        if(reset)
        begin
            count <= 4'b0000;
            tc <= 1'b0;
        end
        else
        begin
            if(en)
            begin
                if(count == period)
                begin
                tc <= 1'b1;
                count <= 4'b0000;
                end
                else
                begin
                count <= count + 1;
                tc <= 1'b0;
                end
            end
            else
            begin
                count <= count;
                tc <= tc;
            end
        end
    end
    
    endmodule
    

    External Resources

    Embedded Micro has a great example showing how to create a UART transceiver using verilog.


    Authors

    Geoffrey Hunter

    Dude making stuff.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution 4.0 International License .

    Tags

      comments powered by Disqus