Counter

5
 Aim:-Implementation of up counter, down counter and up- down counter. Brief Introduction:- In digital logic and computing,  a counter is a d evice which stores (and sometimes displays) the number of times a particular event or  process has occurred, often in relationship to a clock signal. We have a different types of counter like up counter ,down counter and up-down counter, which are used in the different applications according to the requirement.  1)Up Counter:- Programme Code:- module upc(q, clk,rst); output reg [3:0] q; input clk; input rst; always@(p osedge clk or rst) begin if(rst) q<=0; else begin if(clk) q<=q+1; end end endmodule Test Bench:-

description

up counter , down counter and up-down counter

Transcript of Counter

  • Aim:-Implementation of up counter, down counter and up-

    down counter.

    Brief Introduction:- In digital logic and computing, a counter is a device which stores (and sometimes displays) the number of times a particular event or process has occurred, often in

    relationship to a clock signal. We have a different types of counter like up counter ,down counter

    and up-down counter, which are used in the different applications according to the requirement.

    1)Up Counter:-

    Programme Code:-

    module upc(q, clk,rst);

    output reg [3:0] q;

    input clk;

    input rst;

    always@(posedge clk or rst)

    begin

    if(rst)

    q

  • Output Waveform:-

    2)Down Counter:-

    Programme Code:-

    module dwncntr(q, clk,rst);

    output reg [3:0] q;

    input clk;

    input rst;

    always@(posedge clk or rst)

    begin

  • if(rst)

    q

  • output reg [3:0] q;

    input clk;

    input rst;

    input c;

    always@(posedge clk or rst or c)

    begin

    if(rst)

    q

  • Learning Outcomes:- In this practical I have implemented the up, down and up-

    down counter. So I learnt that how to write the verilog code to count the

    particular pulses on the Xilinx software