I have written Timer/Counter 0, Mode 0 in VHDL for
the 8051. It is an 8-bit counter with a divide-by-32 prescaler.
In this mode the Timer register is configured as a 13-bit register.
As the count rolls over from all 1's to all 0's, it sets the Timer interrupt
flag TFI, located in the TCON register. Its inputs are the TMOD and
TCON register, T0 pin on the 8051 board, clock, reset and INT0 pin.
It outputs the updated TCON register.
There are five components to my design. The
first is the DivideBy12. This entity takes the clock and divides
it by 12. Timer also contains a component called Counting.
Counting checks and sees that TR1 is equal to 1, located in the TCON register
and either Gate is equal to 0, located in TMOD register, or INT0 pin is
equal to 1. This gives the timer permission to start timing/counting.
Register8bit is the next entity and this is just a normal 8 bit register
used to keep track of the counter/timer. Then there is the Control
entity. This checks the C/T bit to see if the timer is taking
user input or the clock and then checks to see if Counting says we can
start counting. Finally is the InterruptProcess component.
This takes in either the user input, pin T0, or the clock and updates the
13-bit register. When the register rolls over it sets the TF1 flag
in the TCON register.
VHDL Code For This Project