Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
18 years ago

Counter in VHDL

Hello Guys

I need a code of a COUNTER in VHDL that do this :

1. The counter had 2 inputs

a. Clk input

b. a number (x) <-- Random number that alwayes changed

2. the Default of the counter is to give us HIGH

3. the counter count the Clk pulses

if Clk pulses < number (x)

the counter still give us HIGH

if Clk pulses >= number (x)

the counter change to LOW {--When the Clk pulses = number (x) the counter changes to LOW and stay LOW till it become 2004 Clk pulses}

5. the counter continues count the Clk pulses till 2400 Clk pulses and then back to 0 and changed to HIGH

6. the counter must do this nonstop. every time it take another number(x) and check it with the Clk pulses. (the number (x) can not be more than 2400).

Thanks a lot for your help :D

very important : How can i count CLK Pulses

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There are plenty of counter examples in books out there, but I've attached another one more specific to your question. It also includes a basic test bench. (Assuming my attach works).

    -- Randall