Counter

Discussion in 'VHDL' started by amirster, May 30, 2007.

  1. amirster

    amirster

    Joined:
    May 10, 2007
    Messages:
    2
    Hello
    I am new in writing VHDL code, and i need to write a code for a Counter thats work this way:
    1. the counter take as input a number (X) between 0 and 2400
    2. the counter has another clk input, and the counter count the Clk pulses
    3. the counter check
    if (clk pulses < number x)
    stay HIGH
    if (Clk pulses >= number x)
    change to LOW
    if (Clk Pulses = 2400)
    reset Clk Pulses and change to HIGH
    4. The counter should do this action nonstop
    one more question: how can i count Clk pulses?
    Thanks
    Amirster
     
    Last edited: May 30, 2007
    amirster, May 30, 2007
    #1
    1. Advertising

  2. amirster

    sreenivas

    Joined:
    Jun 7, 2007
    Messages:
    1
    this does what you want

    module counter(X, clk, reset, Q);
    input [11:0] X;
    input clk;
    input reset;
    output [11:0] Q;
    reg [11:0] Q;
    reg [11:0] q_int;
    integer count;

    always @(posedge clk) begin
    count = count + 1;
    if(reset) q_int <= 0;
    else q_int <= q_int + 1;
    end

    always @(q_int)
    begin
    if(q_int == X) level = LOW;
    end
    endmodule


    1. the counter take as input a number (X) between 0 and 2400
    2. the counter has another clk input, and the counter count the Clk pulses
    3. the counter check
    if (clk pulses < number x)
    stay HIGH
    if (Clk pulses >= number x)
    change to LOW
    if (Clk Pulses = 2400)
    reset Clk Pulses and change to HIGH
     
    sreenivas, Jun 7, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    10,385
    VhdlCohen
    Sep 14, 2003
  2. Jan Kindt
    Replies:
    1
    Views:
    1,559
    Jim Lewis
    Sep 17, 2003
  3. dong seok huh

    [Q] : async event counter

    dong seok huh, Oct 1, 2003, in forum: VHDL
    Replies:
    6
    Views:
    783
    Renaud Pacalet
    Oct 6, 2003
  4. The Eeediot
    Replies:
    3
    Views:
    2,305
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  5. George2
    Replies:
    1
    Views:
    852
    Alf P. Steinbach
    Jan 31, 2008
Loading...

Share This Page