Professional Documents
Culture Documents
VHDL allows user to model counters using a single PROCESS and arithmetic operators mainly
+ and -.
Example 1
Write the behavioral VHDL code to synthesize a Mod-16 UP counter
If (Clk’event and Clk =’1’) means at every positive edge of Clk, then increment state. When the
signal state reaches “1111”, it will automatically roll over to “0000”.
1
Example 2
Write the behavioral VHDL code to synthesize a Mod-16 UP counter. Provide a mean to reset
(clear) the counter at any instant of time.
2
Example 3 Truncated counter
Write the behavioral VHDL code to synthesize a Mod-10 UP counter. Provide a mean to reset
(clear) the counter at any instant of time.
3
Example 4 Truncated counter
Write the behavioral VHDL code to synthesize a Mod-10 DOWN counter. Provide a mean to
reset (clear) the counter at any instant of time.
4
Example 5 Truncated counter
Write the behavioral VHDL code to synthesize a Mod-6 UP/DOWN counter. Provide a mean to
reset (clear) the counter at any instant of time.
1. 0 .. 80 ns Clear
2. 80 ns .. 620 ns UP mode
3. 620 ns .. 980 ns DOWN mode
4. 980 ns .. 1.12 µs UP
5. 1.12 µs .. 1.38 µs DOWN
5
Exercises
1. Write a behavioral VHDL code to synthesize a Mod-10 UP/DN counter. The counter should
increment/decrement at the negative edge of the clock.
Provide a mean (active HIGH) to clear the counter at any instant of time.
Perform a functional simulation
2. Write a behavioral VHDL code to synthesize a counter that will cycle through the following
sequence 0, 2, 5, 9, 13, 15, 0, 2, … Changes should occur during the negative edge of the clock.
Provide a mean to preset your counter to 5 at any instant of time.
Perform a functional simulation
3. Write a behavioral VHDL code to synthesize a Mod-12 UP counter. The counter should
increment at the negative edge of the clock. Provide a mean to enable or disable your counter at
any instant of time
Perform a functional simulation