

It’s visible in the first waveform where the 60-second mark on the timeline is slightly before when the Seconds signal wraps to 0. The timer time is slightly offset from simulation time because of the reset of the module at the beginning of the simulation. When changing the time unit from ns to seconds, minute, and hours, we could see that the timer was indeed working in real-time. We right-clicked the timeline in the waveform and selected “Grid, Timeline & Cursor Control”. Such adaptations are sometimes necessary to allow us to simulate a design. If we had left it at 100 MHz, the simulation would have taken days. Fifty hours is a really long simulation, and therefore we had to lower the clock frequency in the testbench to 10 Hz. To run a 50 hour simulation we gave the command run 50 hr in the ModelSim console. The waveform zoomed in on the Hours signal: The waveform zoomed in on the Minutes signal: The waveform zoomed in on the Seconds signal: Generic map(ClockFrequencyHz => ClockFrequencyHz) We're slowing down the clock to speed up simulation timeĬonstant ClockFrequencyHz : integer := 10 - 10 HzĬonstant ClockPeriod : time := 1000 ms / ClockFrequencyHz
#Real time clock seconds how to
In this video tutorial we will learn how to create a timer module in VHDL: But it will also react slower because the chain of events becomes longer. We are limited by the available physical resources in the underlying technology as well as the length of the counter versus the clock frequency.Īs the length of the counters increase, obviously it consumes more resources. We can continue this approach for counting days, weeks, and months too. Similarly, we can create an Hours counter for counting hours, incrementing when 60 minutes have passed. To count minutes, we can implement another Minutes counter which increments when 60 seconds have passed. When this counter reaches the value of the clock frequency, 100 million for example, we know that a second has passed and it’s time to increment another counter. To count seconds in VHDL, we can implement a counter that counts the number of clock periods which passes. This blog post is part of the Basic VHDL Tutorials series. Therefore, if we know that the clock frequency is 100 MHz, we can measure one second by counting a hundred million clock cycles. Every digital design has access to a clock signal which oscillates at a fixed, known frequency. The answer is simply counting clock cycles.

So how can we keep track of time in a design module? That only works in simulation because we can’t just tell the electrons in a circuit to pause for a given time. But what about production modules? The wait for statement cannot be used for that. However, operating system delays may degrade the accuracy to some degree.In earlier tutorials we have used the wait for statement to delay time in simulation. In most cases, the displayed time is correct to within an uncertainty equal to the network delay. The network delay can be used to estimate the uncertainties in the displayed official time and the clock offset. The network delay is equal to one half the period of time it takes for a roundtrip exchange of messages between your device and NRC's atomic clocks. You can adjust your device's clock manually, or have it set automatically through the use of Network Time Protocol (NTP). thousands of seconds), check that your computer settings for the date, time zone, or daylight saving time are correct. The offset of the clock in your device from NRC official time is also shown ('Your local clock is _ seconds fast / slow'). For more information on Canadian time zones consult Time zones & daylight saving time. If you are outside North America, the display will show UTC (Coordinated Universal Time – the modern implementation of Zulu time or GMT). If you are in North America, the display will usually show time according to your time zone. The time displayed is corrected for measured network delays. Your computer or mobile device receives the official time through a periodic exchange of time-stamped messages between your device and NRC's time source. The time displayed on your screen is derived from Canada's official time source: NRC's atomic clocks. How is the official time displayed on my screen?
