Tickers in VHDL
This example demonstrates how to create a periodic process in VHDL, similar to the concept of tickers in other languages. We’ll use a process with a wait statement to create a repeating event at regular intervals.
In this VHDL code:
We define an entity called
Ticker
with no ports.In the architecture, we declare a
done
signal to control when the ticker should stop.The
ticker_process
simulates a ticker:- It runs in a loop until
done
becomes true. - Each iteration, it waits for 500 ms and then reports a “tick” message.
- After the loop ends, it reports that the ticker has stopped.
- It runs in a loop until
The
control_process
simulates the main control flow:- It waits for 1600 ms (equivalent to the
time.Sleep
in the original code). - Then it sets
done
to true, which will stop the ticker process.
- It waits for 1600 ms (equivalent to the
When you simulate this VHDL code, you should see output similar to this:
The ticker “ticks” three times before it’s stopped, just like in the original example.
Note that VHDL is typically used for hardware description and simulation, so concepts like channels and goroutines don’t have direct equivalents. Instead, we use concurrent processes to simulate similar behavior. The wait
statements in VHDL provide a way to create time-based events in simulation.