← ProblemsCS450
Timer
36%cpu-archcountersBuild a down-counting timer that signals when a programmed interval has elapsed.
On each rising clock edge:
- If
load = 1: copy the 10-bit valuedatainto an internal counter. Load has priority — it works even if the counter is currently mid-countdown or at zero. - Otherwise: if the counter is non-zero, decrement it by 1; if it has already reached zero, hold it at zero (do not wrap around).
The output tc ("terminal count") is asserted whenever the internal counter equals zero, and stays asserted until the next load of a non-zero value.
There is no reset. In this simulator all flip-flops power up at 0, so the timer starts out expired (tc = 1) until the first load.